Index: branches/js2-work/phase3/js/mwEmbed/loader.js |
— | — | @@ -16,7 +16,7 @@ |
17 | 17 | * Modules must define a loader.js file in the root |
18 | 18 | * of the module folder. |
19 | 19 | * |
20 | | -* The loader file should be short and only include: |
| 20 | +* A loader file should only include: |
21 | 21 | * Class paths of the module classes |
22 | 22 | * Sytle sheets of the module |
23 | 23 | * Loader function(s) that load module classes |
— | — | @@ -47,27 +47,30 @@ |
48 | 48 | // Set the loaderContext for the classFiles paths call: |
49 | 49 | mw.setConfig('loaderContext', '' ); |
50 | 50 | |
| 51 | +/** |
| 52 | + * Core set of mwEmbed classes: |
| 53 | + */ |
51 | 54 | mw.addClassFilePaths( { |
52 | | - "mwEmbed" : "mwEmbed.js", |
53 | | - "window.jQuery" : "jquery/jquery-1.3.2.js", |
| 55 | + "mwEmbed" : "mwEmbed.js", |
| 56 | + "window.jQuery" : "jquery/jquery-1.3.2.js", |
54 | 57 | |
55 | | - "ctrlBuilder" : "skins/ctrlBuilder.js", |
56 | | - "kskinConfig" : "skins/kskin/kskinConfig.js", |
57 | | - "mvpcfConfig" : "skins/mvpcf/mvpcfConfig.js", |
| 58 | + "ctrlBuilder" : "skins/ctrlBuilder.js", |
| 59 | + "kskinConfig" : "skins/kskin/kskinConfig.js", |
| 60 | + "mvpcfConfig" : "skins/mvpcf/mvpcfConfig.js", |
58 | 61 | |
59 | | - "$j.fn.pngFix" : "jquery/plugins/jquery.pngFix.js", |
60 | | - "$j.fn.autocomplete": "jquery/plugins/jquery.autocomplete.js", |
61 | | - "$j.fn.hoverIntent" : "jquery/plugins/jquery.hoverIntent.js", |
62 | | - "$j.fn.datePicker" : "jquery/plugins/jquery.datePicker.js", |
63 | | - "$j.ui" : "jquery/jquery.ui/ui/ui.core.js", |
| 62 | + "$j.fn.pngFix" : "jquery/plugins/jquery.pngFix.js", |
| 63 | + "$j.fn.autocomplete" : "jquery/plugins/jquery.autocomplete.js", |
| 64 | + "$j.fn.hoverIntent" : "jquery/plugins/jquery.hoverIntent.js", |
| 65 | + "$j.fn.datePicker" : "jquery/plugins/jquery.datePicker.js", |
| 66 | + "$j.ui" : "jquery/jquery.ui/ui/ui.core.js", |
64 | 67 | |
65 | | - "mw.testLang" : "tests/testLang.js", |
| 68 | + "mw.testLang" : "tests/testLang.js", |
66 | 69 | |
67 | | - "$j.cookie" : "jquery/plugins/jquery.cookie.js", |
68 | | - "$j.contextMenu" : "jquery/plugins/jquery.contextMenu.js", |
69 | | - "$j.fn.suggestions" : "jquery/plugins/jquery.suggestions.js", |
70 | | - "$j.fn.textSelection" : "jquery/plugins/jquery.textSelection.js", |
71 | | - "$j.browserTest" : "jquery/plugins/jquery.browserTest.js", |
| 70 | + "$j.cookie" : "jquery/plugins/jquery.cookie.js", |
| 71 | + "$j.contextMenu" : "jquery/plugins/jquery.contextMenu.js", |
| 72 | + "$j.fn.suggestions" : "jquery/plugins/jquery.suggestions.js", |
| 73 | + "$j.fn.textSelection" : "jquery/plugins/jquery.textSelection.js", |
| 74 | + "$j.browserTest" : "jquery/plugins/jquery.browserTest.js", |
72 | 75 | |
73 | 76 | "$j.effects.blind" : "jquery/jquery.ui/ui/effects.blind.js", |
74 | 77 | "$j.effects.drop" : "jquery/jquery.ui/ui/effects.drop.js", |
Index: branches/js2-work/phase3/js/mwEmbed/tests/Add_Media_Wizard.html |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | border:medium none; |
13 | 13 | } |
14 | 14 | </style> |
15 | | - <!-- |
| 15 | + <!-- |
16 | 16 | <script type="text/javascript" src="../mwEmbed.js?debug=true"></script> |
17 | 17 | --> |
18 | 18 | |
Index: branches/js2-work/phase3/js/mwEmbed/includes/jsClassLoader.php |
— | — | @@ -1,39 +1,50 @@ |
2 | 2 | <?php |
| 3 | +/** |
| 4 | + * The javascript class loader handles loading lists of available |
| 5 | + * javascript classes into php from their defined locations in javascript. |
| 6 | + */ |
3 | 7 | |
4 | 8 | if ( !defined( 'MEDIAWIKI' ) ) die( 1 ); |
5 | 9 | |
6 | 10 | class jsClassLoader { |
| 11 | + // The list of mwEmbed modules that are enabled |
7 | 12 | private static $moduleList = array(); |
| 13 | + |
| 14 | + // Stores the contents of the combined loader.js files |
8 | 15 | private static $combinedLoadersJs = ''; |
| 16 | + |
| 17 | + // Reg Exp that supports extracting classes from loaders |
9 | 18 | private static $classReplaceExp = '/mw\.addClassFilePaths\s*\(\s*{(.*)}\s*\)\s*\;/siU'; |
10 | 19 | |
11 | | - private static $loadClassFlag = false; |
| 20 | + // Flag to specify if the javascript class paths have been loaded. |
| 21 | + private static $classesLoaded = false; |
| 22 | + |
| 23 | + // The current directory context. Used in loading javascript modules outside of the mwEmbed folder |
12 | 24 | private static $directoryContext = ''; |
| 25 | + |
13 | 26 | /** |
14 | 27 | * Get the javascript class paths from javascript files |
15 | | - * |
16 | | - * Note:: if it is ~too costly~ to parse js we could cache in DB per file modified time |
17 | 28 | */ |
18 | 29 | public static function loadClassPaths(){ |
19 | 30 | global $wgMwEmbedDirectory, $wgExtensionJavascriptLoader, |
20 | 31 | $wgJSAutoloadClasses, $wgJSAutoloadLocalClasses, $IP; |
21 | 32 | |
22 | | - // Only run "once" |
23 | | - if( self::$loadClassFlag ) |
| 33 | + // Only run once |
| 34 | + if( self::$classesLoaded ) |
24 | 35 | return false; |
25 | | - self::$loadClassFlag = true; |
| 36 | + self::$classesLoaded = true; |
26 | 37 | |
27 | 38 | // Load classes from mediaWiki $wgJSAutoloadLocalClasses var: |
28 | 39 | $wgJSAutoloadClasses = array_merge( $wgJSAutoloadClasses, $wgJSAutoloadLocalClasses ); |
29 | 40 | |
30 | | - // Load classes from mwEmbed.js |
| 41 | + // Load javascript classes from mwEmbed.js |
31 | 42 | if ( !is_file( $wgMwEmbedDirectory . 'mwEmbed.js' ) ) { |
32 | 43 | // throw error no mwEmbed found |
33 | 44 | throw new MWException( "mwEmbed.js missing check \$wgMwEmbedDirectory path\n" ); |
34 | 45 | return false; |
35 | 46 | } |
| 47 | + |
36 | 48 | // Read the mwEmbed loader file: |
37 | | - |
38 | 49 | $fileContent = file_get_contents( $wgMwEmbedDirectory . 'loader.js' ); |
39 | 50 | |
40 | 51 | // Get class paths from mwEmbed.js |
— | — | @@ -63,6 +74,7 @@ |
64 | 75 | self::proccessLoaderPath( $IP . '/extensions/' . $loaderPath ); |
65 | 76 | } |
66 | 77 | } |
| 78 | + |
67 | 79 | /** |
68 | 80 | * Process a loader path, passes off to proccessLoaderContent |
69 | 81 | * |
— | — | @@ -73,6 +85,7 @@ |
74 | 86 | $fileContent = file_get_contents( $path ); |
75 | 87 | self::proccessLoaderContent( $fileContent ); |
76 | 88 | } |
| 89 | + |
77 | 90 | /** |
78 | 91 | * Process loader content |
79 | 92 | * |
— | — | @@ -90,6 +103,7 @@ |
91 | 104 | $fileContent |
92 | 105 | ); |
93 | 106 | } |
| 107 | + |
94 | 108 | /** |
95 | 109 | * Get the combined loader javascript |
96 | 110 | * |
— | — | @@ -99,6 +113,11 @@ |
100 | 114 | self::loadClassPaths(); |
101 | 115 | return self::$combinedLoadersJs; |
102 | 116 | } |
| 117 | + |
| 118 | + /** |
| 119 | + * Build the list of modules from the mwEnabledModuleList replace callback |
| 120 | + * @param String $jsvar Coma delimited list of modules |
| 121 | + */ |
103 | 122 | private static function preg_buildModuleList( $jsvar ){ |
104 | 123 | global $wgMwEmbedDirectory; |
105 | 124 | if(! isset( $jsvar[1] )){ |
— | — | @@ -113,8 +132,10 @@ |
114 | 133 | array_push( self::$moduleList, $moduleName ); |
115 | 134 | } |
116 | 135 | } |
| 136 | + // Enabled modules is not reused. |
117 | 137 | return ''; |
118 | 138 | } |
| 139 | + |
119 | 140 | /** |
120 | 141 | * Adds javascript autoloader class names and paths |
121 | 142 | * to $wgJSAutoloadClasses global |
Index: branches/js2-work/phase3/js/mwEmbed/includes/maintenance/mergeJavascriptMsg.php |
— | — | @@ -12,7 +12,7 @@ |
13 | 13 | exit(); |
14 | 14 | } |
15 | 15 | define( 'MEDIAWIKI', true ); |
16 | | -// get the scriptLoader globals: |
| 16 | +// Get the scriptLoader globals: |
17 | 17 | require_once( '../../jsScriptLoader.php' ); |
18 | 18 | |
19 | 19 | $mwSTART_MSG_KEY = '$messages[\'en\'] = array('; |
— | — | @@ -33,7 +33,7 @@ |
34 | 34 | die(); |
35 | 35 | } |
36 | 36 | |
37 | | -// get options (like override JS or override PHP) |
| 37 | +// Get options ( like override JS or override PHP ) |
38 | 38 | if ( in_array($argv[1], array('--help', '-help', '-h', '-?')) ) { |
39 | 39 | print_help(); |
40 | 40 | } |
— | — | @@ -96,14 +96,16 @@ |
97 | 97 | $jsFileText = file_get_contents( $fname ); |
98 | 98 | $mwPos = strpos( $fname, 'mwEmbed' ) + 7; |
99 | 99 | $curFileName = substr( $fname, $mwPos ); |
100 | | - if ( preg_match( '/mw\.addMessages\s*\(\s*{(.*)}\s*\)\s*/siU', // @@todo fix: will break down if someone does }) in their msg text |
101 | | - $jsFileText, |
102 | | - $matches ) ) { |
| 100 | + // @@todo fix: will break down if someone does }) in their msg text |
| 101 | + if ( preg_match( '/mw\.addMessages\s*\(\s*{(.*)}\s*\)\s*/siU', |
| 102 | + $jsFileText, |
| 103 | + $matches ) ) |
| 104 | + { |
103 | 105 | $msgSet .= doJsonMerge( $matches[1] ); |
104 | 106 | } |
105 | 107 | } |
106 | 108 | } |
107 | | -// rebuild and output to single php file if mergeToPHP is on |
| 109 | +// Rebuild and output to single php file if mergeToPHP is on |
108 | 110 | if ( $mergeToPhp ) { |
109 | 111 | if ( file_put_contents( $mwLangFilePath, trim( $preFile ) . "\n\t" . trim( $msgSet ) . "\n" . ltrim( $postFile ) ) ) { |
110 | 112 | if( $showInfo ) |
— | — | @@ -111,7 +113,10 @@ |
112 | 114 | exit(); |
113 | 115 | } |
114 | 116 | } |
115 | | - |
| 117 | +/** |
| 118 | + * Merges json messages into php file. |
| 119 | + * @param string $json_txt Json text to be merged |
| 120 | + */ |
116 | 121 | function doJsonMerge( $json_txt ) { |
117 | 122 | global $curFileName, $fname, $messages, $mergeToJS, $jsFileText, $showInfo; |
118 | 123 | |
— | — | @@ -126,7 +131,7 @@ |
127 | 132 | if ( count( $jmsg ) != 0 ) { |
128 | 133 | |
129 | 134 | foreach ( $jmsg as $k => $v ) { |
130 | | - // check if the existing value is changed and merge and merge ->right |
| 135 | + // Check if the existing value is changed and merge and merge ->right |
131 | 136 | if ( isset( $messages['en'][$k] ) ) { |
132 | 137 | if ( $messages['en'][$k] != $v ) { |
133 | 138 | $doReplaceFlag = true; |
— | — | @@ -140,7 +145,7 @@ |
141 | 146 | } ; |
142 | 147 | $outPhp .= "\t'{$k}' => '" . str_replace( '\'', '\\\'', $v ) . "',\n"; |
143 | 148 | } |
144 | | - // merge the jsLanguage array back in and wrap the output |
| 149 | + // Merge the jsLanguage array back in and wrap the output |
145 | 150 | if ( $mergeToJS && $doReplaceFlag ) { |
146 | 151 | $json = json_encode( $jsMsgAry ); |
147 | 152 | $json_txt = jsonReadable( $json ); |
— | — | @@ -151,8 +156,6 @@ |
152 | 157 | "mw.addMessages(" . $json_txt . ")", |
153 | 158 | $jsFileText ); |
154 | 159 | |
155 | | - // print substr($str, 0, 600); |
156 | | - |
157 | 160 | if ( file_put_contents( $fname, $str ) ) { |
158 | 161 | if( $showInfo ) |
159 | 162 | print "\nupdated $curFileName from php\n\n"; |
— | — | @@ -160,7 +163,7 @@ |
161 | 164 | die( "Could not write to: " . $fname ); |
162 | 165 | } |
163 | 166 | } |
164 | | - // return phpOut for building msgSet in outer function |
| 167 | + // Return phpOut for building msgSet in outer function |
165 | 168 | return $outPhp; |
166 | 169 | |
167 | 170 | } else { |
— | — | @@ -169,7 +172,11 @@ |
170 | 173 | return ''; |
171 | 174 | } |
172 | 175 | } |
173 | | - |
| 176 | +/** |
| 177 | + * Formats a json string |
| 178 | + * |
| 179 | + * @param string $json Json string to be formated |
| 180 | + */ |
174 | 181 | function jsonReadable( $json ) { |
175 | 182 | $tabcount = 0; |
176 | 183 | $result = ''; |
Index: branches/js2-work/phase3/js/mwEmbed/includes/noMediaWikiConfig.php |
— | — | @@ -1,6 +1,10 @@ |
2 | 2 | <?php |
| 3 | +/** |
| 4 | + * No mediaWikiConfig sets variables for using the script-loader and mwEmbed modules |
| 5 | + * without a complete mediaWiki install. |
| 6 | + */ |
3 | 7 | |
4 | | -//Optional set the path for google Closure Compiler ( for improved minification ) |
| 8 | +// Optional set the path for google Closure Compiler ( for improved minification ) |
5 | 9 | $wgClosureCompilerPath = false; |
6 | 10 | $wgJavaPath = false; |
7 | 11 | |
— | — | @@ -82,6 +86,19 @@ |
83 | 87 | |
84 | 88 | return @mkdir( $dir, $mode, true ); // PHP5 <3 |
85 | 89 | } |
| 90 | + |
| 91 | +/** |
| 92 | + * Copied from mediaWIki GlobalFunctions.php wfMsgGetKey |
| 93 | + * |
| 94 | + * Fetch a message string value, but don't replace any keys yet. |
| 95 | + * @param $key String |
| 96 | + * @param $useDB Bool |
| 97 | + * @param $langCode String: Code of the language to get the message for, or |
| 98 | + * behaves as a content language switch if it is a boolean. |
| 99 | + * @param $transform Boolean: whether to parse magic words, etc. |
| 100 | + * @return string |
| 101 | + * @private |
| 102 | + */ |
86 | 103 | function wfMsgGetKey( $msgKey, $na, $langKey=false ) { |
87 | 104 | global $messages, $mwLanguageCode; |
88 | 105 | if(!$langKey){ |
— | — | @@ -93,8 +110,11 @@ |
94 | 111 | return '<' . $msgKey . '>'; |
95 | 112 | } |
96 | 113 | } |
97 | | -/* mediaWiki abstracts the json functions with fallbacks |
98 | | -* here we just map directly to the call */ |
| 114 | + |
| 115 | +/** |
| 116 | + * mediaWiki abstracts the json functions with fallbacks |
| 117 | + * here we just map directly to the call |
| 118 | + */ |
99 | 119 | class FormatJson{ |
100 | 120 | public static function encode($value, $isHtml=false){ |
101 | 121 | return json_encode($value); |
Index: branches/js2-work/phase3/js/mwEmbed/skins/ctrlBuilder.js |
— | — | @@ -179,7 +179,7 @@ |
180 | 180 | if ( $j( '#gnp_' + embedPlayer.id ).length == 0 ) { |
181 | 181 | var toppos = ( embedPlayer.instanceOf == 'mvPlayList' ) ? 25 : 10; |
182 | 182 | $j( this ).append( '<div id="gnp_' + embedPlayer.id + '" class="ui-state-highlight ui-corner-all" ' + |
183 | | - 'style="position:absolute;display:none;background:#FFF;top:' + toppos + 'px;left:10px;right:10px;">' + |
| 183 | + 'style="position:absolute;display:none;background:#FFF;color:#111;top:' + toppos + 'px;left:10px;right:10px;">' + |
184 | 184 | gM( 'mwe-for_best_experience' ) + |
185 | 185 | '<br><input id="ffwarn_' + embedPlayer.id + '" type=\"checkbox\">' + |
186 | 186 | gM( 'mwe-do_not_warn_again' ) + |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js |
— | — | @@ -2421,12 +2421,15 @@ |
2422 | 2422 | mw.getJSON( this.local_wiki_api_url, request, function( data ) { |
2423 | 2423 | if ( data.query.pages ) { |
2424 | 2424 | for ( var i in data.query.pages ) { |
| 2425 | + if( i == '-1' ){ |
| 2426 | + callback( false ); |
| 2427 | + return ; |
| 2428 | + } |
2425 | 2429 | for ( var j in data.query.pages[i] ) { |
2426 | 2430 | if ( j == 'missing' |
2427 | 2431 | && data.query.pages[i].imagerepository != 'shared' |
2428 | 2432 | && data.query.pages[i].imagerepository != 'commons' ) |
2429 | | - { |
2430 | | - mw.log( fileName + " not found" ); |
| 2433 | + { |
2431 | 2434 | callback( false ); |
2432 | 2435 | return; |
2433 | 2436 | } |
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/genericEmbed.js |
— | — | @@ -11,8 +11,10 @@ |
12 | 12 | 'time_display':false, |
13 | 13 | 'volume_control':false |
14 | 14 | }, |
| 15 | + |
15 | 16 | // Instance name: |
16 | 17 | instanceOf:'genericEmbed', |
| 18 | + |
17 | 19 | /* |
18 | 20 | * Generic embed html |
19 | 21 | * |
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/nativeEmbed.js |
— | — | @@ -61,8 +61,7 @@ |
62 | 62 | var eb = '<video ' + |
63 | 63 | 'id="' + this.pid + '" ' + |
64 | 64 | 'style="width:' + this.width + 'px;height:' + this.height + 'px;" ' + |
65 | | - 'width="' + this.width + '" height="' + this.height + '" ' + |
66 | | - 'autobuffer="true" ' + |
| 65 | + 'width="' + this.width + '" height="' + this.height + '" ' + |
67 | 66 | 'autoplay="true" ' + |
68 | 67 | 'src="' + this.getSrc() + '" >' + |
69 | 68 | '</video>'; |
Index: branches/js2-work/phase3/js/mwEmbed/modules/ApiProxy/mw.proxy.js |
— | — | @@ -158,8 +158,8 @@ |
159 | 159 | } |
160 | 160 | var pUri = mw.parseUri( $.proxy.server_frame ); |
161 | 161 | |
162 | | - // FIXME we should have a Hosted iframe once we deploy mwEmbed on the servers. |
163 | | - // A hosted iframe would be much faster since than a normal page view |
| 162 | + // FIXME we should have a Hosted page once we deploy mwEmbed on the servers. |
| 163 | + // A hosted page would be much faster since than a normal page view rewrite |
164 | 164 | |
165 | 165 | var login_url = pUri.protocol + '://' + pUri.host; |
166 | 166 | login_url += pUri.path.replace( 'MediaWiki:ApiProxy', 'Special:UserLogin' ); |
— | — | @@ -326,17 +326,11 @@ |
327 | 327 | } |
328 | 328 | |
329 | 329 | // FIXME Add in user based approval :: |
330 | | - |
331 | | - // offer the user the ability to "approve" requested domain save to |
332 | | - // their user/ apiProxyDomainList.js page |
333 | 330 | |
334 | | - // FIXME grab the users whitelist for our current domain |
335 | | - /*var local_api = wgScriptPath + '/index' + wgScriptExtension + '?title=' + |
336 | | - 'User:' + wgUserName + '/apiProxyDomainList.js' + |
337 | | - '&action=raw&smaxage=0&gen=js'; |
338 | | - $j.get( local_api, function( data ){ |
339 | | - debugger; |
340 | | - });*/ |
| 331 | + // FIXME grab the users whitelist for our current domain |
| 332 | + |
| 333 | + // FIXME offer the user the ability to "approve" requested domain save to |
| 334 | + // their user/ apiProxyDomainList.js page ( or better some user-prefrence setup ) |
341 | 335 | |
342 | 336 | } |
343 | 337 | |
Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | * For details see: http://www.mediawiki.org/wiki/MwEmbed |
5 | 5 | * |
6 | 6 | * All MediaWiki code is released under the GPL2. |
7 | | - * For more information visit http://metavid.org/wiki/Code |
| 7 | + * also see: http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/COPYING?view=markup |
8 | 8 | * |
9 | 9 | * @author Michael Dale ( mdale at wikimedia.org ) |
10 | 10 | * @author and many others, see svn log for details |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | * mwEmbed uses the following libraries: |
13 | 13 | * |
14 | 14 | * jQuery: |
15 | | - * http://jquery.com/ |
| 15 | + * http://jquery.com/ & jquery.ui |
16 | 16 | * |
17 | 17 | * mw.parseUri: |
18 | 18 | * http://stevenlevithan.com/demo/parseuri/js/ |
— | — | @@ -1370,7 +1370,8 @@ |
1371 | 1371 | * callback parameter is not needed we setup the callback automatically |
1372 | 1372 | * url param 'action'=>'query' is assumed ( if not set to something else in the "data" param |
1373 | 1373 | * format is set to "json" automatically |
1374 | | - * automatically issues request over "POST" if action={postActions} |
| 1374 | + * automatically issues request over "POST" |
| 1375 | + * ( If the api specifices the action must be done over a post request ) |
1375 | 1376 | * automatically will setup apiProxy where needed. |
1376 | 1377 | * |
1377 | 1378 | * @param {Mixed} url or data request |
— | — | @@ -1453,10 +1454,10 @@ |
1454 | 1455 | } |
1455 | 1456 | |
1456 | 1457 | /** |
1457 | | - * Checks if a mw request data requires a proxy or not |
| 1458 | + * Checks if a mw request data requires a post request or not |
1458 | 1459 | * @param {Object} |
1459 | 1460 | * @return {Boolean} |
1460 | | - * true if the request requires a proxy |
| 1461 | + * true if the request requires a post request |
1461 | 1462 | * false if the request does not |
1462 | 1463 | */ |
1463 | 1464 | mw.checkRequestPost = function ( data ){ |
Index: branches/js2-work/phase3/js/mwEmbed/jsScriptLoader.php |
— | — | @@ -11,12 +11,16 @@ |
12 | 12 | |
13 | 13 | // Check if we are being invoked in a MediaWiki context or stand alone usage: |
14 | 14 | if ( !defined( 'MEDIAWIKI' ) && !defined( 'MW_CACHE_SCRIPT_CHECK' ) ){ |
| 15 | + |
15 | 16 | // Load noMediaWiki helper for quick cache result |
16 | 17 | $myScriptLoader = new jsScriptLoader(); |
| 18 | + |
17 | 19 | if( $myScriptLoader->outputFromCache() ) |
18 | 20 | exit(); |
| 21 | + |
19 | 22 | //Else load up all the config and do normal stand alone ScriptLoader process: |
20 | 23 | require_once( realpath( dirname( __FILE__ ) ) . '/includes/noMediaWikiConfig.php' ); |
| 24 | + |
21 | 25 | $myScriptLoader->doScriptLoader(); |
22 | 26 | } |
23 | 27 | |
— | — | @@ -156,8 +160,8 @@ |
157 | 161 | /** |
158 | 162 | * Get Minified js |
159 | 163 | * |
160 | | - * Takes the $js_string input |
161 | | - * and |
| 164 | + * @param {String} $js_string Javascript string to be minified |
| 165 | + * @param {String} $requestKey Unique key for minification |
162 | 166 | * @return minified javascript value |
163 | 167 | */ |
164 | 168 | static function getMinifiedJs( & $js_string, $requestKey='' ){ |
— | — | @@ -176,6 +180,11 @@ |
177 | 181 | // Do the minification using php JSMin |
178 | 182 | return JSMin::minify( $js_string ); |
179 | 183 | } |
| 184 | + /** |
| 185 | + * Optional function to use the google closer compiler to minify js |
| 186 | + * @param {String} $js_string Javascript string to be minified |
| 187 | + * @param {String} $requestKey request key used for temporary name in closure compile |
| 188 | + */ |
180 | 189 | static function getClosureMinifiedJs( & $js_string, $requestKey=''){ |
181 | 190 | if( !is_file( $wgJavaPath ) || ! is_file( $wgClosureCompilerPath ) ){ |
182 | 191 | return false; |
— | — | @@ -214,7 +223,7 @@ |
215 | 224 | return false; |
216 | 225 | } |
217 | 226 | /** |
218 | | - * Gets Script Text |
| 227 | + * Get the javascript text content from a given classKey |
219 | 228 | * |
220 | 229 | * @param {String} $classKey Class Key to grab text for |
221 | 230 | * @param {String} [$file_name] Optional file path to get js text |
— | — | @@ -268,21 +277,12 @@ |
269 | 278 | }else{ |
270 | 279 | // Dealing with files |
271 | 280 | |
272 | | - // Check that the filename ends with .js and does not include ../ traversing |
273 | | - if ( substr( $file_name, -3 ) != '.js' ) { |
274 | | - $this->errorMsg .= "\nError file name must end with .js: " . htmlspecialchars( $file_name ) . " \n "; |
275 | | - return false; |
276 | | - } |
277 | | - if ( strpos( $file_name, '../' ) !== false ) { |
278 | | - $this->errorMsg .= "\nError file name must not traverse paths: " . htmlspecialchars( $file_name ) . " \n "; |
279 | | - return false; |
280 | | - } |
281 | | - |
282 | 281 | if ( trim( $file_name ) != '' ) { |
283 | | - if ( $this->debug ) |
284 | | - $jsout .= "\n/**\n* File: " . htmlspecialchars( $file_name ) . "\n*/\n"; |
| 282 | + if ( $this->debug ){ |
| 283 | + $jsout .= "\n/**\n* File: " . htmlspecialchars( $file_name ) . "\n*/\n"; |
| 284 | + } |
285 | 285 | |
286 | | - $jsFileStr = $this->doGetJsFile( $file_name ) . "\n"; |
| 286 | + $jsFileStr = $this->getFileContents( $file_name ) . "\n"; |
287 | 287 | if( $jsFileStr ){ |
288 | 288 | return $jsout . $jsFileStr; |
289 | 289 | }else{ |
— | — | @@ -354,7 +354,8 @@ |
355 | 355 | } |
356 | 356 | |
357 | 357 | /** |
358 | | - * Post process request uses globals, configuration and mediaWiki to test wiki-titles and files exist etc. |
| 358 | + * Post process request uses globals, configuration to |
| 359 | + * validate classes and generate request key |
359 | 360 | */ |
360 | 361 | function postProcRequestVars(){ |
361 | 362 | global $wgContLanguageCode, $wgEnableScriptMinify, $wgJSAutoloadClasses, |
— | — | @@ -444,8 +445,10 @@ |
445 | 446 | } |
446 | 447 | } |
447 | 448 | /** |
448 | | - * Pre-process request variables ~without configuration~ or any utility functions |
449 | | - * This is to quickly get a requestKey that we can check against the cache |
| 449 | + * Pre-process request variables ~without configuration~ or any utility functions. |
| 450 | + * |
| 451 | + * This is to quickly get a requestKey that we can check against the cache, |
| 452 | + * request key validation is done in postProcRequestVars |
450 | 453 | */ |
451 | 454 | function preProcRequestVars() { |
452 | 455 | $requestKey = ''; |
— | — | @@ -553,9 +556,21 @@ |
554 | 557 | * @param {String} $filePath File to get |
555 | 558 | * @return {String} of the file contents |
556 | 559 | */ |
557 | | - function doGetJsFile( $filePath ) { |
| 560 | + function getFileContents( $filePath ) { |
558 | 561 | global $IP; |
559 | 562 | |
| 563 | + // Check that the filename ends with .js |
| 564 | + if ( substr( $filePath, -3 ) != '.js' ) { |
| 565 | + $this->errorMsg .= "\nError file name must end with .js: " . htmlspecialchars( $filePath ) . " \n "; |
| 566 | + return false; |
| 567 | + } |
| 568 | + |
| 569 | + // Check the file does not include ../ traversing |
| 570 | + if ( strpos( $filePath, '../' ) !== false ) { |
| 571 | + $this->errorMsg .= "\nError file name must not traverse paths: " . htmlspecialchars( $filePath ) . " \n "; |
| 572 | + return false; |
| 573 | + } |
| 574 | + |
560 | 575 | // Load the file |
561 | 576 | wfSuppressWarnings(); |
562 | 577 | $str = file_get_contents( "{$IP}/{$filePath}" ); |
— | — | @@ -580,9 +595,11 @@ |
581 | 596 | */ |
582 | 597 | function doProcessJs( $str ){ |
583 | 598 | global $wgEnableScriptLocalization; |
| 599 | + |
584 | 600 | // Strip out js_log debug lines (if not in debug mode) |
585 | | - if( !$this->debug ) |
| 601 | + if( !$this->debug ){ |
586 | 602 | $str = preg_replace('/\n\s*mw\.log\(([^\)]*\))*\s*[\;\n]/U', "\n", $str); |
| 603 | + } |
587 | 604 | |
588 | 605 | // Do language swap by index: |
589 | 606 | if ( $wgEnableScriptLocalization ){ |
— | — | @@ -593,7 +610,7 @@ |
594 | 611 | return substr($str, 0, $inx['s']-1) . $translated . substr($str, $inx['e']+1); |
595 | 612 | } |
596 | 613 | } |
597 | | - //return the js str unmodified if we did not transform with the localisation. |
| 614 | + // Return the js str unmodified if we did not transform with the localisation. |
598 | 615 | return $str; |
599 | 616 | } |
600 | 617 | |
— | — | @@ -641,6 +658,7 @@ |
642 | 659 | } |
643 | 660 | } |
644 | 661 | } |
| 662 | + |
645 | 663 | /** |
646 | 664 | * Generates an in-line addMessege call for page output. |
647 | 665 | * For use with OutputPage when the script-loader is disabled. |
— | — | @@ -658,6 +676,7 @@ |
659 | 677 | return ''; |
660 | 678 | } |
661 | 679 | } |
| 680 | + |
662 | 681 | /** |
663 | 682 | * Get the set of message associated with a given javascript class |
664 | 683 | * |
Index: branches/js2-work/phase3/js/mwEmbed/remotes/mediaWiki.js |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | */ |
6 | 6 | var urlparts = getRemoteEmbedPath(); |
7 | 7 | var mwEmbedHostPath = urlparts[0]; |
8 | | -var mwRemoteVersion = 'r89'; |
| 8 | +var mwRemoteVersion = 'r90'; |
9 | 9 | var mwUseScriptLoader = true; |
10 | 10 | |
11 | 11 | //Log the mwRemote version ( will determine what version of js we get ) |
Index: branches/js2-work/phase3/js/loader.js |
— | — | @@ -5,8 +5,8 @@ |
6 | 6 | mw.setConfig('loaderContext', wgScriptPath + '/js/'); |
7 | 7 | |
8 | 8 | mw.addClassFilePaths( { |
9 | | - 'uploadPage' => 'js/uploadPage.js', |
10 | | - 'editPage' => 'js/editPage.js', |
11 | | - 'ajaxCategories' => 'js/ajaxcategories.js', |
12 | | - 'apiProxyPage' => 'js/apiProxyPage.js' |
| 9 | + 'uploadPage' : 'js/uploadPage.js', |
| 10 | + 'editPage' : 'js/editPage.js', |
| 11 | + 'ajaxCategories': 'js/ajaxcategories.js', |
| 12 | + 'apiProxyPage' : 'js/apiProxyPage.js' |
13 | 13 | } ); |
\ No newline at end of file |
Index: branches/js2-work/phase3/js/editPage.js |
— | — | @@ -56,7 +56,7 @@ |
57 | 57 | setTimeout( function() { |
58 | 58 | if ( $j( '#btn-add-media-wiz' ).length == 0 && $j( '#toolbar' ).length != 0 ) { |
59 | 59 | mw.log( 'Do old toolbar bind:' ); |
60 | | - didWikiEditorBind = true; |
| 60 | + didWikiEditorBind = true; |
61 | 61 | $j( '#toolbar' ).append( '<img style="cursor:pointer" id="btn-add-media-wiz" src="' + |
62 | 62 | mw.getConfig( 'images_path' ) + 'Button_add_media.png">' ); |
63 | 63 | |