MediaWiki  REL1_20
Init.php
Go to the documentation of this file.
00001 <?php
00026 class MWInit {
00027         static $compilerVersion;
00028 
00034         static function getCompilerVersion() {
00035                 if ( self::$compilerVersion === null ) {
00036                         if ( self::functionExists( 'wfHipHopCompilerVersion' ) ) {
00037                                 self::$compilerVersion = wfHipHopCompilerVersion();
00038                         } else {
00039                                 self::$compilerVersion = false;
00040                         }
00041                 }
00042                 return self::$compilerVersion;
00043         }
00044 
00051         static function isHipHop() {
00052                 return function_exists( 'hphp_thread_set_warmup_enabled' );
00053         }
00054 
00064         static function interpretedPath( $file ) {
00065                 global $IP;
00066                 return "$IP/$file";
00067         }
00068 
00080         static function compiledPath( $file ) {
00081                 global $IP;
00082 
00083                 if ( defined( 'MW_COMPILED' ) ) {
00084                         return "phase3/$file";
00085                 } else {
00086                         return "$IP/$file";
00087                 }
00088         }
00089 
00097         static function extInterpretedPath( $file ) {
00098                 return self::getExtensionsDirectory() . '/' . $file;
00099         }
00100 
00108         static function extCompiledPath( $file ) {
00109                 if ( defined( 'MW_COMPILED' ) ) {
00110                         return "extensions/$file";
00111                 } else {
00112                         return self::getExtensionsDirectory() . '/' . $file;
00113                 }
00114         }
00115 
00128         static function extSetupPath( $extRel ) {
00129                 $baseRel = "extensions/$extRel";
00130                 if ( defined( 'MW_COMPILED' ) ) {
00131                         return $baseRel;
00132                 } else {
00133                         global $wgCompiledFiles;
00134                         $wgCompiledFiles[] = $baseRel;
00135                         return self::getExtensionsDirectory() . '/' . $extRel;
00136                 }
00137         }
00138 
00142         static function getExtensionsDirectory() {
00143                 global $wgExtensionsDirectory, $IP;
00144                 if ( $wgExtensionsDirectory === false ) {
00145                         $wgExtensionsDirectory = "$IP/../extensions";
00146                 }
00147                 return $wgExtensionsDirectory;
00148         }
00149 
00166         static function classExists( $class ) {
00167                 try {
00168                         $r = new ReflectionClass( $class );
00169                 } catch( ReflectionException $r ) {
00170                         $r = false;
00171                 }
00172                 return $r !== false;
00173         }
00174 
00187         static function methodExists( $class, $method ) {
00188                 try {
00189                         $r = new ReflectionMethod( $class, $method );
00190                 } catch( ReflectionException $r ) {
00191                         $r = false;
00192                 }
00193                 return $r !== false;
00194         }
00195 
00204         static function functionExists( $function ) {
00205                 try {
00206                         $r = new ReflectionFunction( $function );
00207                 } catch( ReflectionException $r ) {
00208                         $r = false;
00209                 }
00210                 return $r !== false;
00211         }
00212 
00222         static function callStaticMethod( $className, $methodName, $args ) {
00223                 $r = new ReflectionMethod( $className, $methodName );
00224                 return $r->invokeArgs( null, $args );
00225         }
00226 }