From: Niklas Laxström Date: Sat, 23 Jan 2010 20:11:42 +0000 (+0000) Subject: Part 2 at solving conflict with vector and js edit X-Git-Tag: 1.31.0-rc.0~38135 X-Git-Url: http://git.cyclocoop.org/%22.%28%24lien.?a=commitdiff_plain;h=b7022e9cd9baa9eefc0d072344e0f235dfe9c801;p=lhc%2Fweb%2Fwiklou.git Part 2 at solving conflict with vector and js edit 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. --- diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 2d1ea8c5de..eed71f2f93 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -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; + } + }