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