* removed setupSkinUserJs (not called anywhere) same functionality in getHeadScripts
* moved Skin::getHeadScripts() to outputPage::getHeadScripts()
** ( part of an effort to clean up scripts insertion to OutputPage )
** Standard skin was the only skin that implemented the getHeadScripts method. Has been merged into a skin::OutputPage method.
/**
* Add the core scripts that are included on every page, for later output into the header
+ *
+ * this includes the conditional sitejs
*/
function addCoreScripts2Top(){
global $wgEnableScriptLoader, $wgJSAutoloadLocalClasses, $wgScriptPath, $wgEnableJS2system;
+ global $wgUseSiteJs, $wgUser, $wgJsMimeType;
// @todo We should deprecate wikibits in favor of mv_embed and jQuery
if( $wgEnableJS2system ){
$core_classes = array( 'wikibits' );
}
+ //make sure scripts are on top:
+ $postScripts = $this->mScripts;
+ $this->mScripts = '';
+
if( $wgEnableScriptLoader ){
- //add core to top of mScripts
- $this->mScripts = $this->getScriptLoaderJs( $core_classes ) . $this->mScripts;
+ //directly add script_loader call
+ //(separate from other scriptloader calls that may include extensions with conditional js)
+ $this->mScripts = $this->getScriptLoaderJs( $core_classes );
} else {
$so = '';
- //make sure scripts are on top:
- $postMscripts = $this->mScripts;
- $this->mScripts = '';
foreach( $core_classes as $js_class ){
$this->addScriptClass( $js_class );
}
- $this->mScripts .= $postMscripts;
}
+
+ $sk = $wgUser->getSkin();
+ //add site js:
+ if( $wgUseSiteJs ) {
+ $jsCache = $wgUser->isLoggedIn() ? '&smaxage=0' : '';
+ $this->addScriptFile( Skin::makeUrl( '-',
+ "action=raw$jsCache&gen=js&useskin=" .
+ urlencode( $sk->getSkinName() )
+ )
+ );
+ }
+ //now re-append any scripts that got added prior to the addCoreScripts2Top call
+ $this->mScripts = $this->mScripts . $postScripts;
}
/**
$ret .= implode( "\n", array(
$this->getHeadLinks(),
$this->buildCssLinks(),
- $sk->getHeadScripts( $this ),
+ $this->getHeadScripts(),
$this->getHeadItems(),
));
if( $sk->usercss ){
return $ret;
}
+ /*
+ * gets the global variables and mScripts
+ *
+ * also adds userjs to the end if enabled:
+ */
+ function getHeadScripts() {
+ global $wgUser;
+ $sk = $wgUser->getSkin();
+
+ $vars = Skin::makeGlobalVariablesScript( $sk->getSkinName() );
+
+ //add user js if enabled:
+ if( $this->isUserJsAllowed() && $wgUser->isLoggedIn() ) {
+ $userpage = $wgUser->getUserPage();
+ $userjs = Skin::makeUrl(
+ $userpage->getPrefixedText() . '/' . $sk->getSkinName() . '.js',
+ 'action=raw&ctype=' . $wgJsMimeType );
+ $this->addScriptFile( $userjs );
+ }
+
+ return $vars . "\n" . $this->mScripts;
+ }
+
protected function addDefaultMeta() {
global $wgVersion, $wgHtml5;
return self::makeVariablesScript( $vars );
}
- /**
- * Return a random selection of the scripts we want in the header,
- * according to no particular rhyme or reason. Various other scripts are
- * returned from a haphazard assortment of other functions scattered over
- * various files. This entire hackish system needs to be burned to the
- * ground and rebuilt.
- *
- * @param $out OutputPage object, should be $wgOut
- *
- * @return string Raw HTML to output to <head>
- */
- function getHeadScripts( OutputPage $out ) {
- global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion, $wgOut;
- global $wgUseSiteJs;
-
- $vars = self::makeGlobalVariablesScript( $this->getSkinName() );
-
- if( $wgUseSiteJs ) {
- $jsCache = $wgUser->isLoggedIn() ? '&smaxage=0' : '';
- $wgOut->addScriptFile( self::makeUrl( '-',
- "action=raw$jsCache&gen=js&useskin=" .
- urlencode( $this->getSkinName() )
- )
- );
- }
- if( $out->isUserJsAllowed() && $wgUser->isLoggedIn() ) {
- $userpage = $wgUser->getUserPage();
- $userjs = self::makeUrl(
- $userpage->getPrefixedText() . '/' . $this->getSkinName() . '.js',
- 'action=raw&ctype=' . $wgJsMimeType );
- $wgOut->addScriptFile( $userjs );
- }
- return $vars . "\n" . $out->mScripts;
- }
/**
* To make it harder for someone to slip a user a fake
$out->addStyle( 'common/commonPrint.css', 'print' );
}
- /**
- * Add specific JavaScript the base Skin class.
- * FIXME: not called from anywhere
- */
- function setupSkinUserJs( OutputPage $out ) {
- global $wgUseSiteJs;
- if( $wgUseSiteJs ) {
- $jsCache = $this->loggedin ? '&smaxage=0' : '';
- $siteGenScriptFile = self::makeUrl( '-',
- "action=raw$jsCache&gen=js&useskin=" . urlencode( $this->getSkinName() ) );
- $this->jsvarurl = $siteGenScriptFile;
- }
- }
-
/**
* Create the template engine object; we feed it a bunch of data
* and eventually it spits out some HTML. Should have interface
$out->addInlineStyle( $this->usercss );
}
-
- function setupSkinUserJs( OutputPage $out ) {
- parent::setupSkinUserJs( $out );
- $out->addScriptFile( 'wikibits.js' );
-
- // @todo We can move to parent once we update all the skins (to avoid including things twice)
- if( isset( $this->jsvarurl ) && $this->jsvarurl )
- $out->addScriptFile( $this->jsvarurl );
-
- if( isset( $this->userjs ) && $this->userjs )
- $out->addScriptFile( $this->userjs );
-
- if( isset( $this->userjsprev ) && $this->userjsprev )
- $out->addInlineScript( $this->userjsprev );
- }
}
/**
* @ingroup Skins
*/
class SkinStandard extends Skin {
-
- /**
- *
+ /*
+ * OutputPage
*/
- function getHeadScripts( OutputPage $out ) {
- global $wgStylePath, $wgJsMimeType, $wgStyleVersion;
-
- $s = parent::getHeadScripts( $out );
- if ( 3 == $this->qbSetting() ) { # Floating left
+ function outputPage( OutputPage $out ) {
+ global $wgStylePath;
+ if ( 3 == $this->qbSetting() ) { # Floating left
$out->addScriptFile ( "{$wgStylePath}/common/sticky.js" );
}
- return $s;
+ parent::outputPage( $out );
}
/**
- *
+ *
*/
function setupSkinUserCss( OutputPage $out ){
if ( 3 == $this->qbSetting() ) { # Floating left