From b7022e9cd9baa9eefc0d072344e0f235dfe9c801 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niklas=20Laxstr=C3=B6m?= Date: Sat, 23 Jan 2010 20:11:42 +0000 Subject: [PATCH] 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. --- includes/OutputPage.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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; + } + } -- 2.20.1