Index: branches/js2-work/phase3/js/mwEmbed/includes/jsClassLoader.php |
— | — | @@ -38,19 +38,20 @@ |
39 | 39 | } |
40 | 40 | self::$classesLoaded = true; |
41 | 41 | |
| 42 | + $mwEmbedAbsolutePath = ( $wgMwEmbedDirectory == '' )? $IP: $IP .'/' .$wgMwEmbedDirectory; |
| 43 | + |
42 | 44 | // Add the mwEmbed localizations |
43 | | - $wgExtensionMessagesFiles[ 'mwEmbed' ] = $IP . '/' . $wgMwEmbedDirectory . '/languages/mwEmbed.i18n.php'; |
| 45 | + $wgExtensionMessagesFiles[ 'mwEmbed' ] = $mwEmbedAbsolutePath . '/languages/mwEmbed.i18n.php'; |
44 | 46 | |
45 | | - |
46 | 47 | // Load javascript classes from mwEmbed.js |
47 | | - if ( !is_file( $wgMwEmbedDirectory . '/loader.js' ) ) { |
| 48 | + if ( !is_file( $mwEmbedAbsolutePath . '/loader.js' ) ) { |
48 | 49 | // throw error no mwEmbed found |
49 | 50 | throw new MWException( "mwEmbed loader.js missing check \$wgMwEmbedDirectory path\n" ); |
50 | 51 | return false; |
51 | 52 | } |
52 | 53 | |
53 | 54 | // Read the mwEmbed loader file: |
54 | | - $fileContent = file_get_contents( $wgMwEmbedDirectory . '/loader.js' ); |
| 55 | + $fileContent = file_get_contents( $mwEmbedAbsolutePath . '/loader.js' ); |
55 | 56 | |
56 | 57 | // Get class paths from mwEmbed.js |
57 | 58 | self::$directoryContext = $wgMwEmbedDirectory; |
— | — | @@ -60,19 +61,19 @@ |
61 | 62 | preg_replace_callback( |
62 | 63 | '/mwCoreComponentList\s*\=\s*\[(.*)\]/siU', |
63 | 64 | 'jsClassLoader::preg_buildComponentList', |
64 | | - $fileContent |
| 65 | + $fileContent |
65 | 66 | ); |
66 | 67 | |
67 | 68 | // Get the list of enabled modules into $moduleList |
68 | 69 | preg_replace_callback( |
69 | 70 | '/mwEnabledModuleList\s*\=\s*\[(.*)\]/siU', |
70 | 71 | 'jsClassLoader::preg_buildModuleList', |
71 | | - $fileContent |
| 72 | + $fileContent |
72 | 73 | ); |
73 | 74 | |
74 | 75 | // Get all the classes from the enabled mwEmbed modules folder |
75 | 76 | foreach( self::$moduleList as $na => $moduleName){ |
76 | | - self::proccessModulePath( $IP . '/' . $wgMwEmbedDirectory . '/modules/' . $moduleName ); |
| 77 | + self::proccessModulePath( $mwEmbedAbsolutePath . '/modules/' . $moduleName ); |
77 | 78 | } |
78 | 79 | |
79 | 80 | // Get all the extension loader paths registered mwEmbed modules |
— | — | @@ -201,23 +202,24 @@ |
202 | 203 | * @param String $jsvar Coma delimited list of modules |
203 | 204 | */ |
204 | 205 | private static function preg_buildModuleList( $jsvar ){ |
205 | | - global $wgMwEmbedDirectory; |
| 206 | + global $IP, $wgMwEmbedDirectory; |
206 | 207 | if(! isset( $jsvar[1] )){ |
207 | 208 | return false; |
208 | 209 | } |
209 | 210 | $moduleSet = explode(',', $jsvar[1] ); |
210 | 211 | |
| 212 | + $mwEmbedAbsolutePath = ( $wgMwEmbedDirectory == '' )? $IP: $IP .'/' .$wgMwEmbedDirectory; |
| 213 | + |
211 | 214 | foreach( $moduleSet as $na => $moduleName ){ |
212 | 215 | $moduleName = str_replace( array( '../', '\'', '"'), '', trim( $moduleName )); |
213 | 216 | // Check if there is there are module loader files |
214 | | - if( is_file( $wgMwEmbedDirectory . '/modules/' . $moduleName . '/loader.js' )){ |
| 217 | + if( is_file( $mwEmbedAbsolutePath . '/modules/' . $moduleName . '/loader.js' )){ |
215 | 218 | array_push( self::$moduleList, $moduleName ); |
216 | 219 | } else { |
217 | 220 | // Not valid module ( missing loader.js ) |
| 221 | + throw new MWException( "Missing module: $moduleName \n" ); |
218 | 222 | } |
219 | 223 | } |
220 | | - // Enabled modules is not reused. |
221 | | - return ''; |
222 | 224 | } |
223 | 225 | /** |
224 | 226 | * Adds javascript autoloader class names and paths |
— | — | @@ -232,10 +234,11 @@ |
233 | 235 | } |
234 | 236 | |
235 | 237 | $jClassSet = FormatJson::decode( '{' . $jsvar[1] . '}', true ); |
236 | | - foreach ( $jClassSet as $jClass => $jPath ) { |
| 238 | + foreach ( $jClassSet as $className => $classPath ) { |
237 | 239 | // Strip $ from class (as they are stripped on URL request parameter input) |
238 | | - $jClass = str_replace( '$', '', $jClass ); |
239 | | - $wgScriptLoaderNamedPaths[ $jClass ] = self::$directoryContext . '/' . $jPath; |
| 240 | + $className = str_replace( '$', '', $className ); |
| 241 | + $classPath = ( self::$directoryContext == '' )? $classPath : self::$directoryContext . '/' . $classPath; |
| 242 | + $wgScriptLoaderNamedPaths[ $className ] = $classPath; |
240 | 243 | } |
241 | 244 | } |
242 | 245 | } |
Index: branches/js2-work/phase3/js/mwEmbed/includes/maintenance/mergeJavascriptMsg.php |
— | — | @@ -11,6 +11,7 @@ |
12 | 12 | print "This script must be run from the command line\n"; |
13 | 13 | exit(); |
14 | 14 | } |
| 15 | +exit( 'This script has been depreciated' ); |
15 | 16 | define( 'MEDIAWIKI', true ); |
16 | 17 | // Get the scriptLoader globals: |
17 | 18 | require_once( '../../jsScriptLoader.php' ); |
Index: branches/js2-work/phase3/js/mwEmbed/includes/maintenance/clearMwEmbedVars.php |
— | — | @@ -3,6 +3,7 @@ |
4 | 4 | print "This script must be run from the command line\n"; |
5 | 5 | exit(); |
6 | 6 | } |
| 7 | +exit( 'This script has been depreciated' ); |
7 | 8 | $mwPath = dirname( __FILE__ ) . '/../../languages/mwEmbed.i18n.php' ; |
8 | 9 | |
9 | 10 | include( $mwPath ); |
Index: branches/js2-work/phase3/js/mwEmbed/includes/maintenance/moveMsgToModule.php |
— | — | @@ -3,6 +3,7 @@ |
4 | 4 | print "This script must be run from the command line\n"; |
5 | 5 | exit(); |
6 | 6 | } |
| 7 | +exit( 'This script has been depreciated' ); |
7 | 8 | // Merge all the modules msgs into |
8 | 9 | |
9 | 10 | // First get the big list of translations |
Index: branches/js2-work/phase3/js/mwEmbed/includes/noMediaWikiConfig.php |
— | — | @@ -145,10 +145,35 @@ |
146 | 146 | // MWException extends Exception (for noWiki we don't do anything fancy ) |
147 | 147 | class MWException extends Exception { |
148 | 148 | } |
149 | | -function wfSuppressWarnings(){ |
150 | | -}; |
151 | | -function wfRestoreWarnings(){ |
152 | | -}; |
| 149 | + |
| 150 | +/** |
| 151 | + * Reference-counted warning suppression |
| 152 | + */ |
| 153 | +function wfSuppressWarnings( $end = false ) { |
| 154 | + static $suppressCount = 0; |
| 155 | + static $originalLevel = false; |
| 156 | + |
| 157 | + if ( $end ) { |
| 158 | + if ( $suppressCount ) { |
| 159 | + --$suppressCount; |
| 160 | + if ( !$suppressCount ) { |
| 161 | + error_reporting( $originalLevel ); |
| 162 | + } |
| 163 | + } |
| 164 | + } else { |
| 165 | + if ( !$suppressCount ) { |
| 166 | + $originalLevel = error_reporting( E_ALL & ~( E_WARNING | E_NOTICE ) ); |
| 167 | + } |
| 168 | + ++$suppressCount; |
| 169 | + } |
| 170 | +} |
| 171 | + |
| 172 | +/** |
| 173 | + * Restore error level to previous value |
| 174 | + */ |
| 175 | +function wfRestoreWarnings() { |
| 176 | + wfSuppressWarnings( true ); |
| 177 | +} |
153 | 178 | class Xml { |
154 | 179 | public static function escapeJsString( $string ) { |
155 | 180 | // See ECMA 262 section 7.8.4 for string literal format |
Index: branches/js2-work/phase3/js/mwEmbed/jsScriptLoader.php |
— | — | @@ -100,9 +100,9 @@ |
101 | 101 | // Setup script loader header ( to easy identify file data ) |
102 | 102 | if( $this->outputFormat == 'js' ) { |
103 | 103 | $this->output .= 'var mwScriptLoaderDate = "' . |
104 | | - xml::escapeJsString( date( 'c' ) ) . '";' . "\n"; |
| 104 | + xml::escapeJsString( date( 'c' ) ) . '";' . "\n"; |
105 | 105 | $this->output .= 'var mwScriptLoaderRequestKey = "' . |
106 | | - xml::escapeJsString( $this->requestKey ) . '";' . "\n"; |
| 106 | + xml::escapeJsString( $this->requestKey ) . '";' . "\n"; |
107 | 107 | } |
108 | 108 | |
109 | 109 | // Build the output |
— | — | @@ -178,7 +178,7 @@ |
179 | 179 | */ |
180 | 180 | static private function getOnDoneCallback( ){ |
181 | 181 | return 'if(mw && mw.loadDone){mw.loadDone(\'' . |
182 | | - htmlspecialchars( self::$rawClassList ) . '\');};'; |
| 182 | + htmlspecialchars( self::$rawClassList ) . '\');};'; |
183 | 183 | } |
184 | 184 | /** |
185 | 185 | * Get Minified js |
— | — | @@ -234,7 +234,7 @@ |
235 | 235 | $cmd.= ' --js ' . $jsFileName; |
236 | 236 | |
237 | 237 | if( $wgClosureCompilerLevel ) |
238 | | - $cmd.= ' --compilation_level ' . wfEscapeShellArg( $wgClosureCompilerLevel ); |
| 238 | + $cmd.= ' --compilation_level ' . wfEscapeShellArg( $wgClosureCompilerLevel ); |
239 | 239 | |
240 | 240 | // only output js ( no warnings ) |
241 | 241 | $cmd.= ' --warning_level QUIET'; |
— | — | @@ -332,8 +332,8 @@ |
333 | 333 | } |
334 | 334 | $fileStr = $a->getContent() . "\n"; |
335 | 335 | $output.= ( $ext == 'css' ) ? |
336 | | - $this->transformCssOutput( $classKey, $fileStr ) : |
337 | | - $fileStr; |
| 336 | + $this->transformCssOutput( $classKey, $fileStr ) : |
| 337 | + $fileStr; |
338 | 338 | return $output; |
339 | 339 | } |
340 | 340 | } |
— | — | @@ -359,8 +359,8 @@ |
360 | 360 | $output .= "\n/**\n* File: " . xml::escapeJsString( $filePath ) . "\n*/\n"; |
361 | 361 | } |
362 | 362 | $output.= ( $ext == 'css' ) ? |
363 | | - $this->transformCssOutput( $classKey, $fileStr, $filePath ) : |
364 | | - $fileStr; |
| 363 | + $this->transformCssOutput( $classKey, $fileStr, $filePath ) : |
| 364 | + $fileStr; |
365 | 365 | |
366 | 366 | return $output; |
367 | 367 | }else{ |
— | — | @@ -390,10 +390,12 @@ |
391 | 391 | global $wgScriptPath; |
392 | 392 | $cssOptions[ 'prependRelativePath' ] = $wgScriptPath . '/' . dirname( $path ) . '/'; |
393 | 393 | } else if( strpos( $serverUri, 'jsScriptLoader.php') !== false ){ |
394 | | - // We should use an absolute url to jsScriptLoader.php |
| 394 | + // NOTE:: We HAVE to use an absolute url remote jsScriptLoader.php entry point. |
| 395 | + // this is because relative urls won't work when inserted into the DOM head |
| 396 | + // ( ie we package the css with javascript ) |
395 | 397 | $cssOptions[ 'prependRelativePath' ] = |
396 | | - str_replace('jsScriptLoader.php', '', $serverUri) |
397 | | - . dirname( $path ) . '/'; |
| 398 | + str_replace('jsScriptLoader.php', '', $serverUri) |
| 399 | + . dirname( $path ) . '/'; |
398 | 400 | } |
399 | 401 | |
400 | 402 | // We always run minify to update css urls |
— | — | @@ -408,7 +410,7 @@ |
409 | 411 | // CSS classes should be of form mw.style.{className} |
410 | 412 | $cssStyleName = str_replace('mw.style.', '', $classKey ); |
411 | 413 | return 'mw.addStyleString("' . Xml::escapeJsString( $cssStyleName ) |
412 | | - . '", "' . Xml::escapeJsString( $cssString ) . '");' . "\n"; |
| 414 | + . '", "' . Xml::escapeJsString( $cssString ) . '");' . "\n"; |
413 | 415 | } |
414 | 416 | |
415 | 417 | /** |
— | — | @@ -505,7 +507,7 @@ |
506 | 508 | |
507 | 509 | // Set debug flag |
508 | 510 | if ( ( isset( $_GET['debug'] ) && $_GET['debug'] == 'true' ) |
509 | | - || ( isset( $wgEnableScriptDebug ) && $wgEnableScriptDebug == true ) ) { |
| 511 | + || ( isset( $wgEnableScriptDebug ) && $wgEnableScriptDebug == true ) ) { |
510 | 512 | $this->debug = true; |
511 | 513 | } |
512 | 514 | |
— | — | @@ -672,7 +674,7 @@ |
673 | 675 | |
674 | 676 | /** |
675 | 677 | * Check for the commons language hack. |
676 | | - * ( someone had the bright idea to use language keys as message |
| 678 | + * ( someone had the bright idea to use language keys as message |
677 | 679 | * name-spaces for separate upload forms ) |
678 | 680 | * |
679 | 681 | * @param {String} $langKey The lang key for the form |
— | — | @@ -721,7 +723,7 @@ |
722 | 724 | } |
723 | 725 | |
724 | 726 | /** |
725 | | - * Retrieve the js file into a string, updates errorMsg if not retrivable. |
| 727 | + * Retrieve the js or css file into a string, updates errorMsg if not retrivable. |
726 | 728 | * |
727 | 729 | * @param {String} $filePath File to get |
728 | 730 | * @return {String} of the file contents |
— | — | @@ -740,7 +742,6 @@ |
741 | 743 | $this->errorMsg .= "\nError file name must not traverse paths: " . htmlspecialchars( $filePath ) . " \n "; |
742 | 744 | return false; |
743 | 745 | } |
744 | | - |
745 | 746 | // Load the file |
746 | 747 | wfSuppressWarnings(); |
747 | 748 | $str = file_get_contents( realpath( $filePath ) ); |
— | — | @@ -915,8 +916,8 @@ |
916 | 917 | } |
917 | 918 | |
918 | 919 | /* |
919 | | -* A simple version of HTMLFileCache so that the scriptLoader can operate stand alone |
920 | | -*/ |
| 920 | + * A simple version of HTMLFileCache so that the scriptLoader can operate stand alone |
| 921 | + */ |
921 | 922 | class simpleFileCache { |
922 | 923 | var $mFileCache; |
923 | 924 | var $filename = null; |
— | — | @@ -951,7 +952,7 @@ |
952 | 953 | |
953 | 954 | // Check for defined files:: |
954 | 955 | if( is_file( $this->filename ) ) |
955 | | - return $this->filename; |
| 956 | + return $this->filename; |
956 | 957 | |
957 | 958 | // Check for non-config based gzip version already there? |
958 | 959 | if( is_file( $this->filename . '.gz') ){ |
— | — | @@ -960,7 +961,7 @@ |
961 | 962 | } |
962 | 963 | //Update the name based on the $wgUseGzip config var |
963 | 964 | if ( isset($wgUseGzip) && $wgUseGzip ) |
964 | | - $this->filename.='.gz'; |
| 965 | + $this->filename.='.gz'; |
965 | 966 | |
966 | 967 | return $this->filename; |
967 | 968 | } |