MediaWiki  REL1_19
Init.php
Go to the documentation of this file.
00001 <?php
00002 
00006 class MWInit {
00007         static $compilerVersion;
00008 
00014         static function getCompilerVersion() {
00015                 if ( self::$compilerVersion === null ) {
00016                         if ( self::functionExists( 'wfHipHopCompilerVersion' ) ) {
00017                                 self::$compilerVersion = wfHipHopCompilerVersion();
00018                         } else {
00019                                 self::$compilerVersion = false;
00020                         }
00021                 }
00022                 return self::$compilerVersion;
00023         }
00024 
00031         static function isHipHop() {
00032                 return function_exists( 'hphp_thread_set_warmup_enabled' );
00033         }
00034 
00044         static function interpretedPath( $file ) {
00045                 global $IP;
00046                 return "$IP/$file";
00047         }
00048 
00060         static function compiledPath( $file ) {
00061                 global $IP;
00062 
00063                 if ( defined( 'MW_COMPILED' ) ) {
00064                         return "phase3/$file";
00065                 } else {
00066                         return "$IP/$file";
00067                 }
00068         }
00069 
00077         static function extInterpretedPath( $file ) {
00078                 return self::getExtensionsDirectory() . '/' . $file;
00079         }
00080 
00088         static function extCompiledPath( $file ) {
00089                 if ( defined( 'MW_COMPILED' ) ) {
00090                         return "extensions/$file";
00091                 } else {
00092                         return self::getExtensionsDirectory() . '/' . $file;
00093                 }
00094         }
00095 
00108         static function extSetupPath( $extRel ) {
00109                 $baseRel = "extensions/$extRel";
00110                 if ( defined( 'MW_COMPILED' ) ) {
00111                         return $baseRel;
00112                 } else {
00113                         global $wgCompiledFiles;
00114                         $wgCompiledFiles[] = $baseRel;
00115                         return self::getExtensionsDirectory() . '/' . $extRel;
00116                 }
00117         }
00118 
00122         static function getExtensionsDirectory() {
00123                 global $wgExtensionsDirectory, $IP;
00124                 if ( $wgExtensionsDirectory === false ) {
00125                         $wgExtensionsDirectory = "$IP/../extensions";
00126                 }
00127                 return $wgExtensionsDirectory;
00128         }
00129 
00146         static function classExists( $class ) {
00147                 try {
00148                         $r = new ReflectionClass( $class );
00149                 } catch( ReflectionException $r ) {
00150                         $r = false;
00151                 }
00152                 return $r !== false;
00153         }
00154 
00167         static function methodExists( $class, $method ) {
00168                 try {
00169                         $r = new ReflectionMethod( $class, $method );
00170                 } catch( ReflectionException $r ) {
00171                         $r = false;
00172                 }
00173                 return $r !== false;
00174         }
00175 
00184         static function functionExists( $function ) {
00185                 try {
00186                         $r = new ReflectionFunction( $function );
00187                 } catch( ReflectionException $r ) {
00188                         $r = false;
00189                 }
00190                 return $r !== false;
00191         }
00192 
00201         static function callStaticMethod( $className, $methodName, $args ) {
00202                 $r = new ReflectionMethod( $className, $methodName );
00203                 return $r->invokeArgs( null, $args );
00204         }
00205 }