Loader.class.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003  * Loader it is the class resposanble to controls the load of the files
00004  * @package loader
00005  */
00006 
00016 class Loader
00017 {
00022     protected static $objInstance;
00023 
00028     protected $booExternal = false;
00029 
00035     protected $arrFiles = array();
00036 
00042     protected $strClassContent = '';
00043     
00049     public static function getInstance()
00050     {
00051         if( self::$objInstance == null )
00052         {
00053             self::$objInstance = new Loader();
00054         }
00055         return self::$objInstance;
00056     }
00057 
00065     public function setExternal( $booExternal )
00066     {
00067         $this->booExternal = $booExternal;
00068     }
00069 
00077     public function getExternal()
00078     {
00079         return $this->booExternal;
00080     }
00081 
00088     public static function requireOnce( $strFile , $booIsClass = false )
00089     {
00090 //        print $strFile . '<br/>' . "\n";
00091         $arrBackTrace = debug_backtrace();
00092         $arrCaller = $arrBackTrace[0];
00093         $strFileCaller = $arrCaller[ 'file' ];
00094         $strPathCaller = CorujaFileManipulation::getPathOfFile( $strFileCaller  );
00095 
00096         if( CorujaFileManipulation::isRelativePath( $strFile ) )
00097         {
00098             $strFullPathFile = $strPathCaller . $strFile;
00099         }
00100         else
00101         {
00102             $strFullPathFile = $strFile;
00103         }
00104 
00105         if( $booIsClass && self::getInstance()->getExternal() )
00106         {
00107              self::getInstance()->show( $strFullPathFile );
00108         }
00109         
00110         require_once( $strFullPathFile );
00111     }
00112 
00113     public function show( $strFullPathFile )
00114     {
00115         if( !in_array( $strFullPathFile , $this->arrFiles ) )
00116         {
00117             $this->arrFiles[] = $strFullPathFile;
00118             $this->strClassContent .= file_get_contents( $strFullPathFile );
00119         }
00120     }
00121 
00122     public function getClassContent()
00123     {
00124         return $this->strClassContent;
00125     }
00126 }
00127 ?>

Generated on Sat Apr 7 14:19:09 2012 for CodeToDiagram by  doxygen 1.5.9