r65571 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65570‎ | r65571 | r65572 >
Date:15:17, 27 April 2010
Author:dale
Status:deferred
Tags:
Comment:
added wgScriptLoaderLocation
added stubs for mw.addMessageKeys support with debug mode javascript language file loading
Modified paths:
  • /branches/js2-work/phase3/includes/OutputPage.php (modified) (history)
  • /branches/js2-work/phase3/includes/Skin.php (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/includes/jsClassLoader.php (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/includes/noMediaWikiConfig.php (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/jsScriptLoader.php (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/languages/mw.Language.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/mw.EmbedPlayer.js (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/includes/OutputPage.php
@@ -2201,7 +2201,7 @@
22022202
22032203 $ret .= implode( "\n", array(
22042204 $this->getHeadLinks(),
2205 - $this->getCssLinks(),
 2205+ $this->buildCssLinks(),
22062206 $this->getHeadScripts( $sk ),
22072207 $this->getHeadItems(),
22082208 ) );
@@ -2532,7 +2532,7 @@
25332533 * Build a set of <link>s for the stylesheets specified in the $this->styles array.
25342534 * These will be applied to various media & IE conditionals.
25352535 */
2536 - public function getCssLinks() {
 2536+ public function buildCssLinks() {
25372537 global $wgEnableScriptLoader;
25382538
25392539 $scriptLoaderCss = '';
Index: branches/js2-work/phase3/includes/Skin.php
@@ -395,6 +395,7 @@
396396 'wgUrlProtocols' => wfUrlProtocols(),
397397 'wgArticlePath' => $wgArticlePath,
398398 'wgScriptPath' => $wgScriptPath,
 399+ 'wgScriptLoaderLocation' => $wgScriptPath . 'mwScriptLoader.php',
399400 'wgScriptExtension' => $wgScriptExtension,
400401 'wgScript' => $wgScript,
401402 'wgVariantArticlePath' => $wgVariantArticlePath,
Index: branches/js2-work/phase3/js/mwEmbed/includes/jsClassLoader.php
@@ -38,7 +38,7 @@
3939 }
4040 self::$classesLoaded = true;
4141
42 - $mwEmbedAbsolutePath = ( $wgMwEmbedDirectory == '' )? $IP: $IP .'/' .$wgMwEmbedDirectory;
 42+ $mwEmbedAbsolutePath = ( $wgMwEmbedDirectory == '' ) ? $IP : $IP .'/' .$wgMwEmbedDirectory;
4343 // Add the mwEmbed localizations
4444 $wgExtensionMessagesFiles[ 'mwEmbed' ] = $mwEmbedAbsolutePath . '/languages/mwEmbed.i18n.php';
4545
Index: branches/js2-work/phase3/js/mwEmbed/includes/noMediaWikiConfig.php
@@ -1,7 +1,9 @@
22 <?php
33 /**
4 - * No mediaWikiConfig sets variables for using the script-loader and mwEmbed modules
 4+ * NoMediaWikiConfig sets variables for using the script-loader and mwEmbed modules
55 * without a complete mediaWiki install.
 6+ *
 7+ * NoMediaWikiConfig also copies some utility functions from mediaWiki
68 */
79
810 // Google Closure Compiler ( for improved minification )
@@ -195,6 +197,28 @@
196198 function wfRestoreWarnings() {
197199 wfSuppressWarnings( true );
198200 }
 201+
 202+
 203+/**
 204+ * Simplifed MediaWiki wfShellExec Function
 205+ *
 206+ * Execute a shell command, with time and memory limits mirrored from the PHP
 207+ * configuration if supported.
 208+ * @param $cmd Command line, properly escaped for shell.
 209+ * @param &$retval optional, will receive the program's exit code.
 210+ * (non-zero is usually failure)
 211+ * @return collected stdout as a string (trailing newlines stripped)
 212+ */
 213+function wfShellExec( $cmd, &$retval=null ) {
 214+ $retval = 1; // error by default?
 215+ ob_start();
 216+ passthru( $cmd, $retval );
 217+ $output = ob_get_contents();
 218+ ob_end_clean();
 219+ return $output;
 220+}
 221+
 222+/* Stubs for mediawiki XML class */
199223 class Xml {
200224 public static function escapeJsString( $string ) {
201225 // See ECMA 262 section 7.8.4 for string literal format
Index: branches/js2-work/phase3/js/mwEmbed/languages/mw.Language.js
@@ -28,30 +28,35 @@
2929 messageCache[ i ] = msgSet[i];
3030 }
3131 }
32 -
33 - var messageKeyQueue = [];
 32+
 33+ mw.currentClassMissingMessages = true;
3434 /**
3535 * mw.addMessagesKey function
3636 * Adds a msgKey to be pulled in remotely.
3737 *
38 - * NOTE the script-loader should replace this with localized addMessages calls
 38+ * NOTE the script-loader should replace addMessageKeys with localized addMessages calls
3939 *
4040 * If addMessagesKey is called then we are running in raw file debug mode.
4141 * it populates the messegeKeyQueue and loads the values in a separate request callback
4242 *
4343 * @param {Array} msgSet The set of msgs to be loaded
4444 */
45 - mw.addMessageKeys = function( msgSet ) {
46 - messageKeyQueue.concat( msgSet );
 45+ mw.addMessageKeys = function( msgSet ) {
 46+ // Msg set is ignored ( we use class names to retrive msgs from script-loader )
 47+ mw.currentClassMissingMessages = true;
4748 }
4849
4950 /**
5051 * NOTE: this is somewhat of a hack. But its only used in debug mode since
5152 * normal msg loading happens via script-loader
5253 */
53 - mw.loadQueuedMessages = function( classSet, callback ){
54 - // Load the queued msgs ( requires access to the mediaWiki entry point )
55 -
 54+ mw.loadQueuedMessages = function( classSet, callback ) {
 55+ // Check if wgScriptLoaderPath is set ( else guess the path relative to mwEmbed)
 56+ if ( wgScriptLoaderLocation == 'undefined' || !wgScriptLoaderLocation ){
 57+ wgScriptLoaderLocation = mw.getMwEmbedPath() + 'jsScriptLoader.php';
 58+ }
 59+ // Run the addMessages script-loader call
 60+ $j.getScript( wgScriptLoaderLocation + '?class=' + classSet.join(',') + '&ctype=onlymsg', callback);
5661 }
5762
5863
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/mw.EmbedPlayer.js
@@ -8,65 +8,65 @@
99 *
1010 */
1111
12 -mw.addMessages( {
13 - "mwe-loading_plugin" : "loading plugin ...",
14 - "mwe-select_playback" : "Set playback preference",
15 - "mwe-link_back" : "Link back",
16 - "mwe-error_swap_vid" : "Error: mwEmbed was unable to swap the video tag for the mwEmbed interface",
17 - "mwe-add_to_end_of_sequence" : "Add to end of sequence",
18 - "mwe-missing_video_stream" : "The video file for this stream is missing",
19 - "mwe-play_clip" : "Play clip",
20 - "mwe-pause_clip" : "Pause clip",
21 - "mwe-volume_control" : "Volume control",
22 - "mwe-player_options" : "Player options",
23 - "mwe-timed_text" : "Timed text",
24 - "mwe-player_fullscreen" : "Fullscreen",
25 - "mwe-next_clip_msg" : "Play next clip",
26 - "mwe-prev_clip_msg" : "Play previous clip",
27 - "mwe-current_clip_msg" : "Continue playing this clip",
28 - "mwe-seek_to" : "Seek $1",
29 - "mwe-paused" : "paused",
30 - "mwe-download_segment" : "Download selection:",
31 - "mwe-download_full" : "Download full video file:",
32 - "mwe-download_right_click" : "To download, right click and select <i>Save link as...<\/i>",
33 - "mwe-download_clip" : "Download video",
34 - "mwe-download_text" : "Download text (<a style=\"color:white\" title=\"cmml\" href=\"http:\/\/wiki.xiph.org\/index.php\/CMML\">CMML<\/a> xml):",
35 - "mwe-download" : "Download",
36 - "mwe-share" : "Share",
37 - "mwe-credits" : "Credits",
38 - "mwe-clip_linkback" : "Clip source page",
39 - "mwe-chose_player" : "Chose video player",
40 - "mwe-no-player" : "No player available for $1",
41 - "mwe-share_this_video" : "Share this video",
42 - "mwe-video_credits" : "Video credits",
43 - "mwe-kaltura-platform-title" : "Kaltura open source video platform",
44 - "mwe-menu_btn" : "Menu",
45 - "mwe-close_btn" : "Close",
46 - "mwe-ogg-player-vlc-player" : "VLC player",
47 - "mwe-ogg-player-oggNative" : "HTML5 ogg player",
48 - "mwe-ogg-player-h264Native" : "HTML5 h.264 player",
49 - "mwe-ogg-player-oggPlugin" : "Generic Ogg plugin",
50 - "mwe-ogg-player-quicktime-mozilla" : "QuickTime plugin",
51 - "mwe-ogg-player-quicktime-activex" : "QuickTime ActiveX",
52 - "mwe-ogg-player-cortado" : "Java Cortado",
53 - "mwe-ogg-player-flowplayer" : "Flowplayer",
54 - "mwe-ogg-player-kplayer" : "Kaltura flash player",
55 - "mwe-ogg-player-selected" : "(selected)",
56 - "mwe-ogg-player-omtkplayer" : "OMTK Flash Vorbis",
57 - "mwe-generic_missing_plugin" : "You browser does not appear to support the following playback type: <b>$1<\/b><br \/>Visit the <a href=\"http:\/\/commons.wikimedia.org\/wiki\/Commons:Media_help\">Playback Methods<\/a> page to download a player.<br \/>",
58 - "mwe-for_best_experience" : "For a better video playback experience we recommend the <b><a href=\"http:\/\/www.mozilla.com\/en-US\/firefox\/upgrade.html?from=mwEmbed\">latest firefox<\/a>.<\/b>",
59 - "mwe-do_not_warn_again" : "Dismiss for now.",
60 - "mwe-playerSelect" : "Players",
61 - "mwe-read_before_embed" : "<a href=\"http:\/\/mediawiki.org\/wiki\/Security_Notes_on_Remote_Embedding\" target=\"_new\">Read this<\/a> before embedding.",
62 - "mwe-embed_site_or_blog" : "Embed on a page",
63 - "mwe-related_videos" : "Related videos",
64 - "mwe-seeking" : "seeking",
65 - "mwe-copy-code" : "Copy code",
66 - "mwe-video-h264" : "H.264 video",
67 - "mwe-video-flv" : "Flash video",
68 - "mwe-video-ogg" : "Ogg video",
69 - "mwe-video-audio" : "Ogg audio"
70 -} );
 12+mw.addMessageKeys( [
 13+ "mwe-loading_plugin",
 14+ "mwe-select_playback",
 15+ "mwe-link_back",
 16+ "mwe-error_swap_vid",
 17+ "mwe-add_to_end_of_sequence",
 18+ "mwe-missing_video_stream",
 19+ "mwe-play_clip",
 20+ "mwe-pause_clip",
 21+ "mwe-volume_control",
 22+ "mwe-player_options",
 23+ "mwe-timed_text",
 24+ "mwe-player_fullscreen",
 25+ "mwe-next_clip_msg",
 26+ "mwe-prev_clip_msg",
 27+ "mwe-current_clip_msg",
 28+ "mwe-seek_to",
 29+ "mwe-paused",
 30+ "mwe-download_segment",
 31+ "mwe-download_full",
 32+ "mwe-download_right_click",
 33+ "mwe-download_clip",
 34+ "mwe-download_text",
 35+ "mwe-download",
 36+ "mwe-share",
 37+ "mwe-credits",
 38+ "mwe-clip_linkback",
 39+ "mwe-chose_player",
 40+ "mwe-no-player",
 41+ "mwe-share_this_video",
 42+ "mwe-video_credits",
 43+ "mwe-kaltura-platform-title",
 44+ "mwe-menu_btn",
 45+ "mwe-close_btn",
 46+ "mwe-ogg-player-vlc-player",
 47+ "mwe-ogg-player-oggNative",
 48+ "mwe-ogg-player-h264Native",
 49+ "mwe-ogg-player-oggPlugin",
 50+ "mwe-ogg-player-quicktime-mozilla",
 51+ "mwe-ogg-player-quicktime-activex",
 52+ "mwe-ogg-player-cortado",
 53+ "mwe-ogg-player-flowplayer",
 54+ "mwe-ogg-player-kplayer",
 55+ "mwe-ogg-player-selected",
 56+ "mwe-ogg-player-omtkplayer",
 57+ "mwe-generic_missing_plugin",
 58+ "mwe-for_best_experience",
 59+ "mwe-do_not_warn_again",
 60+ "mwe-playerSelect",
 61+ "mwe-read_before_embed",
 62+ "mwe-embed_site_or_blog",
 63+ "mwe-related_videos",
 64+ "mwe-seeking",
 65+ "mwe-copy-code",
 66+ "mwe-video-h264",
 67+ "mwe-video-flv",
 68+ "mwe-video-ogg",
 69+ "mwe-video-audio"
 70+] );
7171
7272 /*
7373 * The default video attributes supported by embedPlayer
Index: branches/js2-work/phase3/js/mwEmbed/jsScriptLoader.php
@@ -194,7 +194,7 @@
195195
196196
197197 // Check if google closure compiler is enabled and we can get its output
198 - if( $wgJavaPath && $wgClosureCompilerPath && wfShellExecEnabled() ){
 198+ if( $wgJavaPath && $wgClosureCompilerPath ){
199199 $jsMinVal = self::getClosureMinifiedJs( $js_string, $requestKey );
200200 if( $jsMinVal ){
201201 return $jsMinVal;
@@ -239,13 +239,14 @@
240240 $cmd.= ' --compilation_level ' . wfEscapeShellArg( $wgClosureCompilerLevel );
241241
242242 // only output js ( no warnings )
243 - $cmd.= ' --warning_level QUIET';
244 - //print "run: $cmd";
 243+ $cmd.= ' --warning_level QUIET';
245244 // Run the command:
246245 $jsMinVal = wfShellExec($cmd , $retval);
247246
248247 // Clean up ( remove temporary file )
 248+ wfSuppressWarnings();
249249 unlink( $jsFileName );
 250+ wfRestoreWarnings();
250251
251252 if( strlen( $jsMinVal ) != 0 && $retval === 0){
252253 //die( "used closure" );
@@ -530,15 +531,8 @@
531532 //set English as default
532533 $this->langCode = 'en';
533534 }
534 - $this->langCode = self::checkForCommonsLanguageFormHack( $this->langCode );
 535+ $this->langCode = self::checkForCommonsLanguageFormHack( $this->langCode );
535536
536 - // Check if the outupt format is "css" or "js"
537 - if( isset( $_GET['ctype'] ) && $_GET['ctype'] == 'css' ){
538 - $this->outputFormat = 'css';
539 - } else {
540 - $this->outputFormat = 'js';
541 - }
542 -
543537 $reqClassList = false;
544538 if ( isset( $_GET['class'] ) && $_GET['class'] != '' ) {
545539 $reqClassList = explode( ',', $_GET['class'] );
@@ -657,9 +651,9 @@
658652 }
659653 // Check if the outupt format is "css" or "js"
660654 if( isset( $_GET['ctype'] ) && $_GET['ctype'] == 'css' ){
661 - $outputFormat = 'css';
 655+ $this->outputFormat = 'css';
662656 } else {
663 - $outputFormat = 'js';
 657+ $this->outputFormat = 'js';
664658 }
665659
666660 // Add the language code to the requestKey:

Status & tagging log