wfProfileIn( __METHOD__ );
- # Add favicons and Apple touch icons, if they're not the defaults
- #
# Generally the order of the favicon and apple-touch-icon links
# should not matter, but Konqueror (3.5.9 at least) incorrectly
# uses whichever one appears later in the HTML source. Make sure
# apple-touch-icon is specified first to avoid this.
- if( false !== $wgAppleTouchIcon && wfExpandUrl('/apple-touch-icon.png') != wfExpandUrl($wgAppleTouchIcon) ) {
+ if( false !== $wgAppleTouchIcon ) {
$out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
}
- if( false !== $wgFavicon && wfExpandUrl('/favicon.ico') != wfExpandUrl($wgFavicon) ) {
+ if( false !== $wgFavicon ) {
$out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
}
}
static function makeVariablesScript( $data ) {
- $r = array();
- foreach ( $data as $name => $value ) {
- $encValue = Xml::encodeJsVar( $value );
- $r[] = "var $name = $encValue;";
+ if( $data ) {
+ $r = array();
+ foreach ( $data as $name => $value ) {
+ $encValue = Xml::encodeJsVar( $value );
+ $r[] = "$name=$encValue";
+ }
+ $js = 'var ' . implode( ",\n", $r ) . ';';
+ return Html::inlineScript( "\n$js\n" );
+ } else {
+ return '';
}
- return Html::inlineScript( "\n\t\t" . implode( "\n\t\t", $r ) .
- "\n\t\t" );
}
/**
$skinName = $skinName['skinname'];
}
global $wgScript, $wgTitle, $wgStylePath, $wgUser;
- global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang, $wgVariant;
+ global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
global $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
global $wgUseAjax, $wgAjaxWatch;
'wgIsArticle' => $wgOut->isArticle(),
'wgUserName' => $wgUser->isAnon() ? NULL : $wgUser->getName(),
'wgUserGroups' => $wgUser->isAnon() ? NULL : $wgUser->getEffectiveGroups(),
- 'wgUserVariant' => $wgVariant->getCode(),
'wgUserLanguage' => $wgLang->getCode(),
'wgContentLanguage' => $wgContLang->getCode(),
'wgBreakFrames' => $wgBreakFrames,
'wgSeparatorTransformTable' => $compactSeparatorTransTable,
'wgDigitTransformTable' => $compactDigitTransTable,
'wgMainPageTitle' => $mainPage ? $mainPage->getPrefixedText() : null,
+ 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(),
+ 'wgNamespaceIds' => $wgContLang->getNamespaceIds(),
);
- if ( !( $wgContLang->hasVariants() ) ) {
- unset( $vars['wgUserVariant'] );
+ if ( $wgContLang->hasVariants() ) {
+ $vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
}
//if on upload page output the extension list & js_upload
- if( SpecialPage::resolveAlias( $wgTitle->getDBkey() ) == "Upload" ){
+ if( SpecialPage::resolveAlias( $wgTitle->getDBkey() ) == "Upload" ) {
global $wgFileExtensions, $wgAjaxUploadInterface;
- $vars['wgFileExtensions'] = $wgFileExtensions;
+ $vars['wgFileExtensions'] = $wgFileExtensions;
$vars['wgAjaxUploadInterface'] = $wgAjaxUploadInterface;
}
$vars = self::makeGlobalVariablesScript( $this->getSkinName() );
- //moved wikibits to be called earlier on
- //$out->addScriptFile( "{$wgStylePath}/common/wikibits.js" );
if( $wgUseSiteJs ) {
$jsCache = $wgUser->isLoggedIn() ? '&smaxage=0' : '';
$wgOut->addScriptFile( self::makeUrl( '-',
}
if( $out->isUserJsAllowed() && $wgUser->isLoggedIn() ) {
$userpage = $wgUser->getUserPage();
- $userjs = self::makeUrl(
- $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
- 'action=raw&ctype='.$wgJsMimeType );
+ $userjs = self::makeUrl(
+ $userpage->getPrefixedText() . '/' . $this->getSkinName() . '.js',
+ 'action=raw&ctype=' . $wgJsMimeType );
$wgOut->addScriptFile( $userjs );
}
- return "\t" . $vars . "\t" . $out->mScripts;
+ return $vars . "\n" . $out->mScripts;
}
/**
* top. For now Monobook.js will be maintained, but it should be consi-
* dered deprecated.
*
- * @param force_skin lets you override the skin name
+ * @param $force_skin string If set, overrides the skin name
*
* @return string
*/
- public function generateUserJs( $skinName = null) {
+ public function generateUserJs( $skinName = null ) {
global $wgStylePath;
wfProfileIn( __METHOD__ );
- if(!$skinName){
+ if( !$skinName ) {
$skinName = $this->getSkinName();
}
$s .= "\n\n/* MediaWiki:".ucfirst( $skinName ).".js */\n";
// avoid inclusion of non defined user JavaScript (with custom skins only)
// by checking for default message content
- $msgKey = ucfirst( $skinName ).'.js';
+ $msgKey = ucfirst( $skinName ) . '.js';
$userJS = wfMsgForContent( $msgKey );
if ( !wfEmptyMsg( $msgKey, $userJS ) ) {
$s .= $userJS;
$classes = 'catlinks';
- if( strpos( $catlinks, '<div id="mw-normal-catlinks">' ) === false &&
- strpos( $catlinks, '<div id="mw-hidden-catlinks" class="mw-hidden-cats-hidden">' ) !== false ) {
+ if( strpos( $catlinks, '<div id="mw-normal-catlinks">' ) === false ) {
$classes .= ' catlinks-allhidden';
}
- if( !empty( $catlinks ) ){
- return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
- }
+ return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
}
function getQuickbarCompensator( $rows = 1 ) {
* @return String HTML-wrapped JS code to be put before </body>
*/
function bottomScripts() {
- $bottomScriptText = "\n\t\t" . Html::inlineScript( 'if (window.runOnloadHook) runOnloadHook();' ) . "\n";
+ $bottomScriptText = "\n" . Html::inlineScript( 'if (window.runOnloadHook) runOnloadHook();' ) . "\n";
wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
return $bottomScriptText;
}
$s = array();
- if ( !$wgRequest->getBool( 'printable' ) ) {
+ if ( !$wgOut->isPrintable() ) {
$printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
$s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
}
function lastModified() {
global $wgLang, $wgArticle;
- if( $this->mRevisionId ) {
+ if( $this->mRevisionId && $this->mRevisionId != $wgArticle->getLatest()) {
$timestamp = Revision::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId );
} else {
$timestamp = $wgArticle->getTimestamp();