/**#@+
* @private
*/
- var $lastdate, $lastline;
- var $rc_cache ; # Cache for Enhanced Recent Changes
- var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle
- var $rcMoveIndex;
var $mWatchLinkNum = 0; // Appended to end of watch link id's
/**#@-*/
protected $mRevisionId; // The revision ID we're looking at, null if not applicable.
if( isset( $skinNames[$key] ) ) {
return $key;
} else {
- // The old built-in skin
- return 'standard';
+ return 'monobook';
}
}
$skinNames = Skin::getSkinNames();
$skinName = $skinNames[$key];
+ $className = 'Skin'.ucfirst($key);
# Grab the skin class and initialise it.
- // Preload base classes to work around APC/PHP5 bug
- $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
- if( file_exists( $deps ) ) include_once( $deps );
- require_once( "{$wgStyleDirectory}/{$skinName}.php" );
-
- # Check if we got if not failback to default skin
- $className = 'Skin'.$skinName;
- if( !class_exists( $className ) ) {
- # DO NOT die if the class isn't found. This breaks maintenance
- # scripts and can cause a user account to be unrecoverable
- # except by SQL manipulation if a previously valid skin name
- # is no longer valid.
- wfDebug( "Skin class does not exist: $className\n" );
- $className = 'SkinStandard';
- require_once( "{$wgStyleDirectory}/Standard.php" );
+ if ( !class_exists( $className ) ) {
+ // Preload base classes to work around APC/PHP5 bug
+ $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
+ if( file_exists( $deps ) ) include_once( $deps );
+ require_once( "{$wgStyleDirectory}/{$skinName}.php" );
+
+ # Check if we got if not failback to default skin
+ if( !class_exists( $className ) ) {
+ # DO NOT die if the class isn't found. This breaks maintenance
+ # scripts and can cause a user account to be unrecoverable
+ # except by SQL manipulation if a previously valid skin name
+ # is no longer valid.
+ wfDebug( "Skin class does not exist: $className\n" );
+ $className = 'SkinMonobook';
+ require_once( "{$wgStyleDirectory}/MonoBook.php" );
+ }
}
$skin = new $className;
return $skin;
}
function initPage( &$out ) {
- global $wgFavicon, $wgScriptPath, $wgSitename, $wgLanguageCode, $wgLanguageNames;
+ global $wgFavicon, $wgAppleTouchIcon, $wgScriptPath, $wgSitename, $wgContLang;
- $fname = 'Skin::initPage';
- wfProfileIn( $fname );
+ wfProfileIn( __METHOD__ );
if( false !== $wgFavicon ) {
$out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
}
+
+ if( false !== $wgAppleTouchIcon ) {
+ $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
+ }
+
+ $code = $wgContLang->getCode();
+ $name = $wgContLang->getLanguageName( $code );
+ $langName = $name ? $name : $code;
# OpenSearch description link
$out->addLink( array(
'rel' => 'search',
'type' => 'application/opensearchdescription+xml',
'href' => "$wgScriptPath/opensearch_desc.php",
- 'title' => "$wgSitename ({$wgLanguageNames[$wgLanguageCode]})",
+ 'title' => "$wgSitename ($langName)",
));
$this->addMetadataLinks($out);
$this->preloadExistence();
- wfProfileOut( $fname );
+ wfProfileOut( __METHOD__ );
}
/**
* The odd calling convention is for backwards compatibility
*/
static function makeGlobalVariablesScript( $data ) {
- global $wgStylePath, $wgUser;
+ global $wgScript, $wgStylePath, $wgUser;
global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
global $wgBreakFrames, $wgRequest;
+ global $wgUseAjax, $wgAjaxWatch;
+ global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
$ns = $wgTitle->getNamespace();
$nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ? $wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
-
+
$vars = array(
'skin' => $data['skinname'],
'stylepath' => $wgStylePath,
'wgArticlePath' => $wgArticlePath,
'wgScriptPath' => $wgScriptPath,
+ 'wgScript' => $wgScript,
'wgServer' => $wgServer,
'wgCanonicalNamespace' => $nsname,
- 'wgCanonicalSpecialPageName' => SpecialPage::resolveAlias( $wgTitle->getDBKey() ),
+ 'wgCanonicalSpecialPageName' => SpecialPage::resolveAlias( $wgTitle->getDBkey() ),
'wgNamespaceNumber' => $wgTitle->getNamespace(),
'wgPageName' => $wgTitle->getPrefixedDBKey(),
'wgTitle' => $wgTitle->getText(),
'wgAction' => $wgRequest->getText( 'action', 'view' ),
+ 'wgRestrictionEdit' => $wgTitle->getRestrictions( 'edit' ),
+ 'wgRestrictionMove' => $wgTitle->getRestrictions( 'move' ),
'wgArticleId' => $wgTitle->getArticleId(),
'wgIsArticle' => $wgOut->isArticle(),
'wgUserName' => $wgUser->isAnon() ? NULL : $wgUser->getName(),
'wgContentLanguage' => $wgContLang->getCode(),
'wgBreakFrames' => $wgBreakFrames,
'wgCurRevisionId' => isset( $wgArticle ) ? $wgArticle->getLatest() : 0,
+ 'wgVersion' => $wgVersion,
+ 'wgEnableAPI' => $wgEnableAPI,
+ 'wgEnableWriteAPI' => $wgEnableWriteAPI,
);
global $wgLivePreview;
$vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
}
+ if($wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
+ $msgs = (object)array();
+ foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
+ $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
+ }
+ $vars['wgAjaxWatch'] = $msgs;
+ }
+
return self::makeVariablesScript( $vars );
}
$r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n";
global $wgUseSiteJs;
if ($wgUseSiteJs) {
- if ($wgUser->isLoggedIn()) {
- $r .= "<script type=\"$wgJsMimeType\" src=\"".htmlspecialchars(self::makeUrl('-','action=raw&smaxage=0&gen=js'))."\"><!-- site js --></script>\n";
- } else {
- $r .= "<script type=\"$wgJsMimeType\" src=\"".htmlspecialchars(self::makeUrl('-','action=raw&gen=js'))."\"><!-- site js --></script>\n";
- }
+ $jsCache = $wgUser->isLoggedIn() ? '&smaxage=0' : '';
+ $r .= "<script type=\"$wgJsMimeType\" src=\"".
+ htmlspecialchars(self::makeUrl('-',
+ "action=raw$jsCache&gen=js&useskin=" .
+ urlencode( $this->getSkinName() ) ) ) .
+ "\"><!-- site js --></script>\n";
}
if( $allowUserJs && $wgUser->isLoggedIn() ) {
$userpage = $wgUser->getUserPage();
function getUserStylesheet() {
global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage, $wgStyleVersion;
$sheet = $this->getStylesheet();
- $s = "@import \"$wgStylePath/common/common.css?$wgStyleVersion\";\n";
+ $s = "@import \"$wgStylePath/common/shared.css?$wgStyleVersion\";\n";
+ $s .= "@import \"$wgStylePath/common/oldshared.css?$wgStyleVersion\";\n";
$s .= "@import \"$wgStylePath/$sheet?$wgStyleVersion\";\n";
if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css?$wgStyleVersion\";\n";
}
/**
- * This returns MediaWiki:Common.js. For some bizarre reason, it does
- * *not* return any custom user JS from user subpages. Huh?
+ * This returns MediaWiki:Common.js, and derived classes may add other JS.
+ * Despite its name, it does *not* return any custom user JS from user
+ * subpages. The returned script is sitewide and publicly cacheable and
+ * therefore must not include anything that varies according to user,
+ * interface language, etc. (although it may vary by skin). See
+ * makeGlobalVariablesScript for things that can vary per page view and are
+ * not cacheable.
*
- * @return string
+ * @return string Raw JavaScript to be returned
*/
- function getUserJs() {
+ public function getUserJs() {
wfProfileIn( __METHOD__ );
global $wgStylePath;
$s = "/* generated javascript */\n";
- $s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';";
+ $s .= "var skin = '" . Xml::escapeJsString( $this->getSkinName() ) . "';\n";
+ $s .= "var stylepath = '" . Xml::escapeJsString( $wgStylePath ) . "';";
$s .= "\n\n/* MediaWiki:Common.js */\n";
$commonJs = wfMsgForContent('common.js');
if ( !wfEmptyMsg ( 'common.js', $commonJs ) ) {
$s .= $commonJs;
}
-
- global $wgUseAjax, $wgAjaxWatch;
- if($wgUseAjax && $wgAjaxWatch) {
- $s .= "
-
-/* AJAX (un)watch (see /skins/common/ajaxwatch.js) */
-var wgAjaxWatch = {
- watchMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'watch', array() ) )."',
- unwatchMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'unwatch', array() ) )."',
- watchingMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'watching', array() ) )."',
- unwatchingMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'unwatching', array() ) )."'
-};";
- }
-
wfProfileOut( __METHOD__ );
return $s;
}
function reallyDoGetUserStyles() {
global $wgUser;
$s = '';
- if (($undopt = $wgUser->getOption("underline")) != 2) {
+ if (($undopt = $wgUser->getOption("underline")) < 2) {
$underline = $undopt ? 'underline' : 'none';
$s .= "a { text-decoration: $underline; }\n";
}
a.new, #quickbar a.new,
a.stub, #quickbar a.stub {
color: inherit;
- text-decoration: inherit;
}
a.new:after, #quickbar a.new:after {
content: "?";
color: #CC2200;
- text-decoration: $underline;
}
a.stub:after, #quickbar a.stub:after {
content: "!";
color: #772233;
- text-decoration: $underline;
}
END;
}
*/
function bottomScripts() {
global $wgJsMimeType;
- return "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
+ $bottomScriptText = "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
+ wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
+ return $bottomScriptText;
}
/** @return string Retrievied from HTML text */
if ( $wgOut->isArticleRelated() ) {
if ( $wgTitle->getNamespace() == NS_IMAGE ) {
$name = $wgTitle->getDBkey();
- $image = new Image( $wgTitle );
- if( $image->exists() ) {
+ $image = wfFindFile( $wgTitle );
+ if( $image ) {
$link = htmlspecialchars( $image->getURL() );
$style = $this->getInternalLinkAttributes( $link, $name );
$s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
}
function getUndeleteLink() {
- global $wgUser, $wgTitle, $wgContLang, $action;
+ global $wgUser, $wgTitle, $wgContLang, $wgLang, $action;
if( $wgUser->isAllowed( 'deletedhistory' ) &&
(($wgTitle->getArticleId() == 0) || ($action == "history")) &&
($n = $wgTitle->isDeleted() ) )
{
- if ( $wgUser->isAllowed( 'delete' ) ) {
+ if ( $wgUser->isAllowed( 'undelete' ) ) {
$msg = 'thisisdeleted';
} else {
$msg = 'viewdeleted';
return wfMsg( $msg,
$this->makeKnownLinkObj(
SpecialPage::getTitleFor( 'Undelete', $wgTitle->getPrefixedDBkey() ),
- wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $n ) ) );
+ wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ) ) );
}
return '';
}
$dbr = wfGetDB( DB_SLAVE );
$watchlist = $dbr->tableName( 'watchlist' );
$sql = "SELECT COUNT(*) AS n FROM $watchlist
- WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
+ WHERE wl_title='" . $dbr->strencode($wgTitle->getDBkey()) .
"' AND wl_namespace=" . $wgTitle->getNamespace() ;
$res = $dbr->query( $sql, 'Skin::pageStats');
$x = $dbr->fetchObject( $res );
- $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n );
+
+ $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
+ array( 'parseinline' ), $wgLang->formatNum($x->n)
+ );
}
return $s . ' ' . $this->getCopyright();
// Otherwise, we display the link for the user, described in their
// language (which may or may not be the same as the default language),
// but we make the link target be the one site-wide page.
- return $this->makeKnownLink( wfMsgForContent( $page ), wfMsg( $desc ) );
+ return $this->makeKnownLink( wfMsgForContent( $page ),
+ wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) ) );
}
}
# If it's present, the link points to this page, otherwise
# it points to the talk page
if( $wgTitle->isTalkPage() ) {
- $title =& $wgTitle;
+ $title = $wgTitle;
} elseif( $wgOut->showNewSectionLink() ) {
- $title =& $wgTitle;
+ $title = $wgTitle;
} else {
- $title =& $wgTitle->getTalkPage();
+ $title = $wgTitle->getTalkPage();
}
return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
wfProfileOut( $fname );
return $bar;
}
+
}
-?>