summaryrefslogtreecommitdiff
path: root/includes/Skin.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2008-08-15 01:29:47 +0200
committerPierre Schmitz <pierre@archlinux.de>2008-08-15 01:29:47 +0200
commit370e83bb0dfd0c70de268c93bf07ad5ee0897192 (patch)
tree491674f4c242e4d6ba0d04eafa305174c35a3391 /includes/Skin.php
parentf4debf0f12d0524d2b2427c55ea3f16b680fad97 (diff)
Update auf 1.13.0
Diffstat (limited to 'includes/Skin.php')
-rw-r--r--includes/Skin.php229
1 files changed, 140 insertions, 89 deletions
diff --git a/includes/Skin.php b/includes/Skin.php
index 30d2c2bc..a9e44ab4 100644
--- a/includes/Skin.php
+++ b/includes/Skin.php
@@ -1,22 +1,26 @@
<?php
+/**
+ * @defgroup Skins Skins
+ */
+
if ( ! defined( 'MEDIAWIKI' ) )
die( 1 );
-# See skin.txt
-
/**
* The main skin class that provide methods and properties for all other skins.
* This base class is also the "Standard" skin.
*
* See docs/skin.txt for more information.
*
- * @addtogroup Skins
+ * @ingroup Skins
*/
class Skin extends Linker {
/**#@+
* @private
*/
var $mWatchLinkNum = 0; // Appended to end of watch link id's
+ // How many search boxes have we made? Avoid duplicate id's.
+ protected $searchboxes = '';
/**#@-*/
protected $mRevisionId; // The revision ID we're looking at, null if not applicable.
protected $skinname = 'standard' ;
@@ -105,7 +109,7 @@ class Skin extends Linker {
*/
static function &newFromKey( $key ) {
global $wgStyleDirectory;
-
+
$key = Skin::normalizeKey( $key );
$skinNames = Skin::getSkinNames();
@@ -153,34 +157,30 @@ class Skin extends Linker {
}
function initPage( &$out ) {
- global $wgFavicon, $wgAppleTouchIcon, $wgScriptPath, $wgSitename, $wgContLang, $wgScriptExtension;
+ global $wgFavicon, $wgAppleTouchIcon, $wgScriptPath, $wgScriptExtension;
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',
+ $out->addLink( array(
+ 'rel' => 'search',
'type' => 'application/opensearchdescription+xml',
'href' => "$wgScriptPath/opensearch_desc{$wgScriptExtension}",
- 'title' => "$wgSitename ($langName)",
+ 'title' => wfMsgForContent( 'opensearch-desc' ),
));
$this->addMetadataLinks($out);
$this->mRevisionId = $out->mRevisionId;
-
+
$this->preloadExistence();
wfProfileOut( __METHOD__ );
@@ -207,7 +207,7 @@ class Skin extends Linker {
$lb = new LinkBatch( $titles );
$lb->execute();
}
-
+
function addMetadataLinks( &$out ) {
global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
global $wgRightsPage, $wgRightsUrl;
@@ -271,7 +271,7 @@ class Skin extends Linker {
$out->out( $this->bottomScripts() );
- $out->out( $out->reportTime() );
+ $out->out( wfReportTime() );
$out->out( "\n</body></html>" );
wfProfileOut( __METHOD__ );
@@ -300,19 +300,23 @@ class Skin extends Linker {
global $wgScript, $wgStylePath, $wgUser;
global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
- global $wgBreakFrames, $wgRequest;
+ global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
global $wgUseAjax, $wgAjaxWatch;
global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
+ global $wgRestrictionTypes, $wgLivePreview;
+ global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
$ns = $wgTitle->getNamespace();
$nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ? $wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
- $vars = array(
+ $vars = array(
'skin' => $data['skinname'],
'stylepath' => $wgStylePath,
'wgArticlePath' => $wgArticlePath,
'wgScriptPath' => $wgScriptPath,
'wgScript' => $wgScript,
+ 'wgVariantArticlePath' => $wgVariantArticlePath,
+ 'wgActionPaths' => $wgActionPaths,
'wgServer' => $wgServer,
'wgCanonicalNamespace' => $nsname,
'wgCanonicalSpecialPageName' => SpecialPage::resolveAlias( $wgTitle->getDBkey() ),
@@ -320,8 +324,6 @@ class Skin extends Linker {
'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(),
@@ -334,8 +336,17 @@ class Skin extends Linker {
'wgEnableAPI' => $wgEnableAPI,
'wgEnableWriteAPI' => $wgEnableWriteAPI,
);
+
+ if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false )){
+ $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
+ $vars['wgDBname'] = $wgDBname;
+ $vars['wgSearchNamespaces'] = SearchEngine::userNamespaces( $wgUser );
+ $vars['wgMWSuggestMessages'] = array( wfMsg('search-mwsuggest-enabled'), wfMsg('search-mwsuggest-disabled'));
+ }
+
+ foreach( $wgRestrictionTypes as $type )
+ $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
- global $wgLivePreview;
if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
$vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
$vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
@@ -507,7 +518,7 @@ a.stub:after, #quickbar a.stub:after {
END;
}
if( $wgUser->getOption( 'justify' ) ) {
- $s .= "#article, #bodyContent { text-align: justify; }\n";
+ $s .= "#article, #bodyContent, #mw_content { text-align: justify; }\n";
}
if( !$wgUser->getOption( 'showtoc' ) ) {
$s .= "#toc { display: none; }\n";
@@ -535,14 +546,10 @@ END;
}
$a['onload'] = $wgOut->getOnloadHandler();
- if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
- if( $a['onload'] != '' ) {
- $a['onload'] .= ';';
- }
- $a['onload'] .= 'setupRightClickEdit()';
- }
- $a['class'] = 'ns-'.$wgTitle->getNamespace().' '.($wgContLang->isRTL() ? "rtl" : "ltr").
- ' '.Sanitizer::escapeClass( 'page-'.$wgTitle->getPrefixedText() );
+ $a['class'] =
+ 'mediawiki ns-'.$wgTitle->getNamespace().
+ ' '.($wgContLang->isRTL() ? "rtl" : "ltr").
+ ' '.Sanitizer::escapeClass( 'page-'.$wgTitle->getPrefixedText() );
return $a;
}
@@ -625,9 +632,9 @@ END;
}
- function getCategoryLinks () {
+ function getCategoryLinks() {
global $wgOut, $wgTitle, $wgUseCategoryBrowser;
- global $wgContLang;
+ global $wgContLang, $wgUser;
if( count( $wgOut->mCategoryLinks ) == 0 ) return '';
@@ -639,11 +646,33 @@ END;
$dir = $wgContLang->isRTL() ? 'rtl' : 'ltr';
$embed = "<span dir='$dir'>";
$pop = '</span>';
- $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $wgOut->mCategoryLinks ) . $pop;
- $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escape' ), count( $wgOut->mCategoryLinks ) );
- $s = $this->makeLinkObj( Title::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
- . ': ' . $t;
+ $allCats = $wgOut->getCategoryLinks();
+ $s = '';
+ $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
+ if ( !empty( $allCats['normal'] ) ) {
+ $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
+
+ $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
+ $s .= '<div id="mw-normal-catlinks">' .
+ $this->makeLinkObj( Title::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
+ . $colon . $t . '</div>';
+ }
+
+ # Hidden categories
+ if ( isset( $allCats['hidden'] ) ) {
+ if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
+ $class ='mw-hidden-cats-user-shown';
+ } elseif ( $wgTitle->getNamespace() == NS_CATEGORY ) {
+ $class = 'mw-hidden-cats-ns-shown';
+ } else {
+ $class = 'mw-hidden-cats-hidden';
+ }
+ $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
+ wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
+ $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
+ "</div>";
+ }
# optional 'dmoz-like' category browser. Will be shown under the list
# of categories an article belong to
@@ -689,8 +718,16 @@ END;
function getCategories() {
$catlinks=$this->getCategoryLinks();
- if(!empty($catlinks)) {
- return "<p class='catlinks'>{$catlinks}</p>";
+
+ $classes = 'catlinks';
+
+ if( strpos( $catlinks, '<div id="mw-normal-catlinks">' ) === false &&
+ strpos( $catlinks, '<div id="mw-hidden-catlinks" class="mw-hidden-cats-hidden">' ) !== false ) {
+ $classes .= ' catlinks-allhidden';
+ }
+
+ if( !empty( $catlinks ) ){
+ return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
}
}
@@ -700,7 +737,7 @@ END;
/**
* This gets called shortly before the \</body\> tag.
- * @return String HTML to be put before \</body\>
+ * @return String HTML to be put before \</body\>
*/
function afterContent() {
$printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
@@ -709,7 +746,7 @@ END;
/**
* This gets called shortly before the \</body\> tag.
- * @return String HTML-wrapped JS code to be put before \</body\>
+ * @return String HTML-wrapped JS code to be put before \</body\>
*/
function bottomScripts() {
global $wgJsMimeType;
@@ -843,29 +880,35 @@ END;
function subPageSubtitle() {
$subpages = '';
if(!wfRunHooks('SkinSubPageSubtitle', array(&$subpages)))
- return $retval;
+ return $subpages;
- global $wgOut, $wgTitle, $wgNamespacesWithSubpages;
- if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
+ global $wgOut, $wgTitle;
+ if($wgOut->isArticle() && MWNamespace::hasSubpages( $wgTitle->getNamespace() )) {
$ptext=$wgTitle->getPrefixedText();
if(preg_match('/\//',$ptext)) {
$links = explode('/',$ptext);
+ array_pop( $links );
$c = 0;
$growinglink = '';
+ $display = '';
foreach($links as $link) {
- $c++;
- if ($c<count($links)) {
- $growinglink .= $link;
- $getlink = $this->makeLink( $growinglink, htmlspecialchars( $link ) );
- if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
+ $growinglink .= $link;
+ $display .= $link;
+ $linkObj = Title::newFromText( $growinglink );
+ if( is_object( $linkObj ) && $linkObj->exists() ){
+ $getlink = $this->makeKnownLinkObj( $linkObj, htmlspecialchars( $display ) );
+ $c++;
if ($c>1) {
$subpages .= ' | ';
} else {
$subpages .= '&lt; ';
}
$subpages .= $getlink;
- $growinglink .= '/';
+ $display = '';
+ } else {
+ $display .= '/';
}
+ $growinglink .= '/';
}
}
}
@@ -903,9 +946,12 @@ END;
$q = '';
} else { $q = "returnto={$rt}"; }
+ $loginlink = $wgUser->isAllowed( 'createaccount' )
+ ? 'nav-login-createaccount'
+ : 'login';
$s .= "\n<br />" . $this->makeKnownLinkObj(
SpecialPage::getTitleFor( 'Userlogin' ),
- wfMsg( 'login' ), $q );
+ wfMsg( $loginlink ), $q );
} else {
$n = $wgUser->getName();
$rt = $wgTitle->getPrefixedURL();
@@ -939,13 +985,16 @@ END;
global $wgRequest;
$search = $wgRequest->getText( 'search' );
- $s = '<form name="search" class="inline" method="post" action="'
+ $s = '<form id="searchform'.$this->searchboxes.'" name="search" class="inline" method="post" action="'
. $this->escapeSearchLink() . "\">\n"
- . '<input type="text" name="search" size="19" value="'
+ . '<input type="text" id="searchInput'.$this->searchboxes.'" name="search" size="19" value="'
. htmlspecialchars(substr($search,0,256)) . "\" />\n"
. '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" />&nbsp;'
. '<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n</form>";
+ // Ensure unique id's for search boxes made after the first
+ $this->searchboxes = $this->searchboxes == '' ? 2 : $this->searchboxes + 1;
+
return $s;
}
@@ -962,14 +1011,14 @@ END;
}
# Many people don't like this dropdown box
#$s .= $sep . $this->specialPagesList();
-
+
$s .= $this->variantLinks();
-
+
$s .= $this->extensionTabLinks();
return $s;
}
-
+
/**
* Compatibility for extensions adding functionality through tabs.
* Eventually these old skins should be replaced with SkinTemplate-based
@@ -987,7 +1036,7 @@ END;
}
return $s;
}
-
+
/**
* Language/charset variant links for classic-style skins
* @return string
@@ -1154,9 +1203,12 @@ END;
}
function lastModified() {
- global $wgLang, $wgArticle, $wgLoadBalancer;
-
- $timestamp = $wgArticle->getTimestamp();
+ global $wgLang, $wgArticle;
+ if( $this->mRevisionId ) {
+ $timestamp = Revision::getTimestampFromId( $this->mRevisionId, $wgArticle->getId() );
+ } else {
+ $timestamp = $wgArticle->getTimestamp();
+ }
if ( $timestamp ) {
$d = $wgLang->date( $timestamp, true );
$t = $wgLang->time( $timestamp, true );
@@ -1164,7 +1216,7 @@ END;
} else {
$s = '';
}
- if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
+ if ( wfGetLB()->getLaggedSlaveMode() ) {
$s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
}
return $s;
@@ -1253,11 +1305,13 @@ END;
function editThisPage() {
global $wgOut, $wgTitle;
- if ( ! $wgOut->isArticleRelated() ) {
+ if ( !$wgOut->isArticleRelated() ) {
$s = wfMsg( 'protectedpage' );
} else {
- if ( $wgTitle->userCan( 'edit' ) ) {
+ if( $wgTitle->userCan( 'edit' ) && $wgTitle->exists() ) {
$t = wfMsg( 'editthispage' );
+ } elseif( $wgTitle->userCan( 'create' ) && !$wgTitle->exists() ) {
+ $t = wfMsg( 'create-this-page' );
} else {
$t = wfMsg( 'viewsource' );
}
@@ -1360,15 +1414,15 @@ END;
function whatLinksHere() {
global $wgTitle;
- return $this->makeKnownLinkObj(
- SpecialPage::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ),
+ return $this->makeKnownLinkObj(
+ SpecialPage::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ),
wfMsg( 'whatlinkshere' ) );
}
function userContribsLink() {
global $wgTitle;
- return $this->makeKnownLinkObj(
+ return $this->makeKnownLinkObj(
SpecialPage::getTitleFor( 'Contributions', $wgTitle->getDBkey() ),
wfMsg( 'contributions' ) );
}
@@ -1387,7 +1441,7 @@ END;
function emailUserLink() {
global $wgTitle;
- return $this->makeKnownLinkObj(
+ return $this->makeKnownLinkObj(
SpecialPage::getTitleFor( 'Emailuser', $wgTitle->getDBkey() ),
wfMsg( 'emailuser' ) );
}
@@ -1398,8 +1452,8 @@ END;
if ( ! $wgOut->isArticleRelated() ) {
return '(' . wfMsg( 'notanarticle' ) . ')';
} else {
- return $this->makeKnownLinkObj(
- SpecialPage::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ),
+ return $this->makeKnownLinkObj(
+ SpecialPage::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ),
wfMsg( 'recentchangeslinked' ) );
}
}
@@ -1502,7 +1556,7 @@ END;
if ( $wgTitle->getNamespace() == NS_SPECIAL ) {
return '';
}
-
+
# __NEWSECTIONLINK___ changes behaviour here
# If it's present, the link points to this page, otherwise
# it points to the talk page
@@ -1513,7 +1567,7 @@ END;
} else {
$title = $wgTitle->getTalkPage();
}
-
+
return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit&section=new' );
}
@@ -1599,24 +1653,18 @@ END;
* Build an array that represents the sidebar(s), the navigation bar among them
*
* @return array
- * @private
*/
function buildSidebar() {
global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
- global $wgLang, $wgContLang;
-
- $fname = 'SkinTemplate::buildSidebar';
+ global $wgLang;
+ wfProfileIn( __METHOD__ );
- wfProfileIn( $fname );
+ $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
- $key = wfMemcKey( 'sidebar' );
- $cacheSidebar = $wgEnableSidebarCache &&
- ($wgLang->getCode() == $wgContLang->getCode());
-
- if ($cacheSidebar) {
+ if ( $wgEnableSidebarCache ) {
$cachedsidebar = $parserMemc->get( $key );
- if ($cachedsidebar!="") {
- wfProfileOut($fname);
+ if ( $cachedsidebar ) {
+ wfProfileOut( __METHOD__ );
return $cachedsidebar;
}
}
@@ -1629,10 +1677,15 @@ END;
continue;
if (strpos($line, '**') !== 0) {
$line = trim($line, '* ');
- $heading = $line;
+ if ( $line == 'SEARCH' || $line == 'TOOLBOX' || $line == 'LANGUAGES' ) {
+ # Special box type
+ $bar[$line] = array();
+ } else {
+ $heading = $line;
+ }
} else {
if (strpos($line, '|') !== false) { // sanity check
- $line = explode( '|' , trim($line, '* '), 2 );
+ $line = array_map('trim', explode( '|' , trim($line, '* '), 2 ) );
$link = wfMsgForContent( $line[0] );
if ($link == '-')
continue;
@@ -1662,10 +1715,8 @@ END;
} else { continue; }
}
}
- if ($cacheSidebar)
- $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
- wfProfileOut( $fname );
+ if ( $wgEnableSidebarCache ) $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
+ wfProfileOut( __METHOD__ );
return $bar;
}
-
}