r99983 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99982‎ | r99983 | r99984 >
Date:22:17, 16 October 2011
Author:demon
Status:ok
Tags:
Comment:
MFT r98374
Modified paths:
  • /branches/wmf/1.18wmf1/includes/OutputPage.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/includes/OutputPage.php
@@ -118,6 +118,7 @@
119119 // @todo FIXME: Next variables probably comes from the resource loader
120120 var $mModules = array(), $mModuleScripts = array(), $mModuleStyles = array(), $mModuleMessages = array();
121121 var $mResourceLoader;
 122+ var $mJsConfigVars = array();
122123
123124 /** @todo FIXME: Is this still used ?*/
124125 var $mInlineMsg = array();
@@ -1314,7 +1315,7 @@
13151316 }
13161317
13171318 /**
1318 - * Add wikitext with a custom Title object and
 1319+ * Add wikitext with a custom Title object and tidy enabled.
13191320 *
13201321 * @param $text String: wikitext
13211322 * @param $title Title object
@@ -2582,11 +2583,29 @@
25832584 }
25842585
25852586 /**
2586 - * Get an array containing global JS variables
 2587+ * Add one or more variables to be set in mw.config in JavaScript.
25872588 *
2588 - * Do not add things here which can be evaluated in
2589 - * ResourceLoaderStartupScript - in other words, without state.
2590 - * You will only be adding bloat to the page and causing page caches to
 2589+ * @param $key {String|Array} Key or array of key/value pars.
 2590+ * @param $value {Mixed} Value of the configuration variable.
 2591+ */
 2592+ public function addJsConfigVars( $keys, $value ) {
 2593+ if ( is_array( $keys ) ) {
 2594+ foreach ( $keys as $key => $value ) {
 2595+ $this->mJsConfigVars[$key] = $value;
 2596+ }
 2597+ return;
 2598+ }
 2599+
 2600+ $this->mJsConfigVars[$keys] = $value;
 2601+ }
 2602+
 2603+
 2604+ /**
 2605+ * Get an array containing the variables to be set in mw.config in JavaScript.
 2606+ *
 2607+ * Do not add things here which can be evaluated in ResourceLoaderStartupScript
 2608+ * - in other words, page-indendent/site-wide variables (without state).
 2609+ * You will only be adding bloat to the html page and causing page caches to
25912610 * have to be purged on configuration changes.
25922611 */
25932612 protected function getJSVars() {
@@ -2629,10 +2648,14 @@
26302649 $vars['wgIsMainPage'] = true;
26312650 }
26322651
2633 - // Allow extensions to add their custom variables to the global JS variables
 2652+ // Allow extensions to add their custom variables to the mw.config map.
 2653+ // Use the 'ResourceLoaderGetConfigVars' hook if the variable is not
 2654+ // page-dependant but site-wide (without state).
 2655+ // Alternatively, you may want to use OutputPage->addJsConfigVars() instead.
26342656 wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
26352657
2636 - return $vars;
 2658+ // Merge in variables from addJsConfigVars last
 2659+ return array_merge( $vars, $this->mJsConfigVars );
26372660 }
26382661
26392662 /**
Property changes on: branches/wmf/1.18wmf1/includes/OutputPage.php
___________________________________________________________________
Modified: svn:mergeinfo
26402663 Merged /trunk/phase3/includes/OutputPage.php:r98374

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r98374New OutputPage::addJsConfigVars() method (bug 31233)...krinkle22:08, 28 September 2011

Status & tagging log