MediaWiki  REL1_19
validate.php
Go to the documentation of this file.
00001 <?php
00024 if ( !isset( $argv[1] ) ) {
00025         print "Usage: php {$argv[0]} <filename>\n";
00026         exit( 1 );
00027 }
00028 array_shift( $argv );
00029 
00030 define( 'MEDIAWIKI', 1 );
00031 define( 'NOT_REALLY_MEDIAWIKI', 1 );
00032 
00033 $IP = dirname( __FILE__ ) . '/../..';
00034 
00035 require_once( "$IP/includes/Defines.php" );
00036 require_once( "$IP/languages/Language.php" );
00037 
00038 $files = array();
00039 foreach ( $argv as $arg ) {
00040         $files = array_merge( $files, glob( $arg ) );
00041 }
00042 
00043 foreach ( $files as $filename ) {
00044         print "$filename...";
00045         $vars = getVars( $filename );
00046         $keys = array_keys( $vars );
00047         $diff = array_diff( $keys, Language::$mLocalisationKeys );
00048         if ( $diff ) {
00049                 print "\nWarning: unrecognised variable(s): " . implode( ', ', $diff ) . "\n";
00050         } else {
00051                 print " ok\n";
00052         }
00053 }
00054 
00055 function getVars( $filename ) {
00056         require( $filename );
00057         $vars = get_defined_vars();
00058         unset( $vars['filename'] );
00059         return $vars;
00060 }
00061