Part 2 at solving conflict with vector and js edit
authorNiklas Laxström <nikerabbit@users.mediawiki.org>
Sat, 23 Jan 2010 20:11:42 +0000 (20:11 +0000)
committerNiklas Laxström <nikerabbit@users.mediawiki.org>
Sat, 23 Jan 2010 20:11:42 +0000 (20:11 +0000)
Add OutputPage::includeJQuery() for loading the jQuery currently shipped
with core. Extension can use this function to avoid loading it multiple
times. No support for plugins etc.

Changes Translate extension to use that function, restored compatability
with 1.15 for at least this part of code.

includes/OutputPage.php

index 2d1ea8c..eed71f2 100644 (file)
@@ -47,6 +47,11 @@ class OutputPage {
         */
        var $styles = array();
 
+       /**
+        * Whether to load jQuery core.
+        */
+       protected $mIncludeJQuery = false;
+
        private $mIndexPolicy = 'index';
        private $mFollowPolicy = 'follow';
        private $mVaryHeader = array( 'Accept-Encoding' => array('list-contains=gzip'),
@@ -2103,4 +2108,22 @@ class OutputPage {
                }
                $this->addHTML( $this->parse( $s, /*linestart*/true, /*uilang*/true ) );
        }
+
+       /**
+        * Include jQuery core. Use this to avoid loading it multiple times
+        * before we get usable script loader.
+        */
+       public function includeJQuery() {
+               if ( $this->mIncludeJQuery ) return;
+               $this->mIncludeJQuery = true;
+
+               global $wgScriptPath, $wgStyleVersion, $wgJsMimeType;
+
+               $params = array(
+                       'type' => $wgJsMimeType,
+                       'src' => "$wgScriptPath/js2/js2stopgap.min.js?$wgStyleVersion",
+               );
+               $this->mScripts = Html::element( 'script', $params ) . "\n" . $this->mScripts;
+       }
+
 }