3 * @defgroup Skins Skins
6 if ( ! defined( 'MEDIAWIKI' ) )
10 * The main skin class that provide methods and properties for all other skins.
11 * This base class is also the "Standard" skin.
13 * See docs/skin.txt for more information.
17 class Skin
extends Linker
{
21 var $mWatchLinkNum = 0; // Appended to end of watch link id's
22 // How many search boxes have we made? Avoid duplicate id's.
23 protected $searchboxes = '';
25 protected $mRevisionId; // The revision ID we're looking at, null if not applicable.
26 protected $skinname = 'standard' ;
28 /** Constructor, call parent constructor */
29 function Skin() { parent
::__construct(); }
32 * Fetch the set of available skins.
33 * @return array of strings
36 static function getSkinNames() {
37 global $wgValidSkinNames;
38 static $skinsInitialised = false;
39 if ( !$skinsInitialised ) {
40 # Get a list of available skins
41 # Build using the regular expression '^(.*).php$'
42 # Array keys are all lower case, array value keep the case used by filename
44 wfProfileIn( __METHOD__
. '-init' );
45 global $wgStyleDirectory;
46 $skinDir = dir( $wgStyleDirectory );
48 # while code from www.php.net
49 while (false !== ($file = $skinDir->read())) {
50 // Skip non-PHP files, hidden files, and '.dep' includes
52 if(preg_match('/^([^.]*)\.php$/',$file, $matches)) {
54 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
58 $skinsInitialised = true;
59 wfProfileOut( __METHOD__
. '-init' );
61 return $wgValidSkinNames;
65 * Normalize a skin preference value to a form that can be loaded.
66 * If a skin can't be found, it will fall back to the configured
67 * default (or the old 'Classic' skin if that's broken).
72 static function normalizeKey( $key ) {
73 global $wgDefaultSkin;
74 $skinNames = Skin
::getSkinNames();
77 // Don't return the default immediately;
78 // in a misconfiguration we need to fall back.
79 $key = $wgDefaultSkin;
82 if( isset( $skinNames[$key] ) ) {
86 // Older versions of the software used a numeric setting
87 // in the user preferences.
93 if( isset( $fallback[$key] ) ){
94 $key = $fallback[$key];
97 if( isset( $skinNames[$key] ) ) {
105 * Factory method for loading a skin of a given type
106 * @param string $key 'monobook', 'standard', etc
110 static function &newFromKey( $key ) {
111 global $wgStyleDirectory;
113 $key = Skin
::normalizeKey( $key );
115 $skinNames = Skin
::getSkinNames();
116 $skinName = $skinNames[$key];
117 $className = 'Skin'.ucfirst($key);
119 # Grab the skin class and initialise it.
120 if ( !class_exists( $className ) ) {
121 // Preload base classes to work around APC/PHP5 bug
122 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
123 if( file_exists( $deps ) ) include_once( $deps );
124 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
126 # Check if we got if not failback to default skin
127 if( !class_exists( $className ) ) {
128 # DO NOT die if the class isn't found. This breaks maintenance
129 # scripts and can cause a user account to be unrecoverable
130 # except by SQL manipulation if a previously valid skin name
131 # is no longer valid.
132 wfDebug( "Skin class does not exist: $className\n" );
133 $className = 'SkinMonobook';
134 require_once( "{$wgStyleDirectory}/MonoBook.php" );
137 $skin = new $className;
141 /** @return string path to the skin stylesheet */
142 function getStylesheet() {
143 return 'common/wikistandard.css';
146 /** @return string skin name */
147 public function getSkinName() {
148 return $this->skinname
;
151 function qbSetting() {
152 global $wgOut, $wgUser;
154 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
155 $q = $wgUser->getOption( 'quickbar', 0 );
159 function initPage( &$out ) {
160 global $wgFavicon, $wgAppleTouchIcon, $wgScriptPath, $wgScriptExtension;
162 wfProfileIn( __METHOD__
);
164 if( false !== $wgFavicon ) {
165 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
168 if( false !== $wgAppleTouchIcon ) {
169 $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
172 # OpenSearch description link
173 $out->addLink( array(
175 'type' => 'application/opensearchdescription+xml',
176 'href' => "$wgScriptPath/opensearch_desc{$wgScriptExtension}",
177 'title' => wfMsgForContent( 'opensearch-desc' ),
180 $this->addMetadataLinks($out);
182 $this->mRevisionId
= $out->mRevisionId
;
184 $this->preloadExistence();
186 wfProfileOut( __METHOD__
);
190 * Preload the existence of three commonly-requested pages in a single query
192 function preloadExistence() {
193 global $wgUser, $wgTitle;
196 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
199 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
201 } elseif ( $wgTitle->isTalkPage() ) {
202 $titles[] = $wgTitle->getSubjectPage();
204 $titles[] = $wgTitle->getTalkPage();
207 $lb = new LinkBatch( $titles );
211 function addMetadataLinks( &$out ) {
212 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
213 global $wgRightsPage, $wgRightsUrl;
215 if( $out->isArticleRelated() ) {
216 # note: buggy CC software only reads first "meta" link
217 if( $wgEnableCreativeCommonsRdf ) {
218 $out->addMetadataLink( array(
219 'title' => 'Creative Commons',
220 'type' => 'application/rdf+xml',
221 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
223 if( $wgEnableDublinCoreRdf ) {
224 $out->addMetadataLink( array(
225 'title' => 'Dublin Core',
226 'type' => 'application/rdf+xml',
227 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
231 if( $wgRightsPage ) {
232 $copy = Title
::newFromText( $wgRightsPage );
234 $copyright = $copy->getLocalURL();
237 if( !$copyright && $wgRightsUrl ) {
238 $copyright = $wgRightsUrl;
241 $out->addLink( array(
242 'rel' => 'copyright',
243 'href' => $copyright ) );
247 function outputPage( &$out ) {
248 global $wgDebugComments;
250 wfProfileIn( __METHOD__
);
251 $this->initPage( $out );
253 $out->out( $out->headElement() );
255 $out->out( "\n<body" );
256 $ops = $this->getBodyOptions();
257 foreach ( $ops as $name => $val ) {
258 $out->out( " $name='$val'" );
261 if ( $wgDebugComments ) {
262 $out->out( "<!-- Wiki debugging output:\n" .
263 $out->mDebugtext
. "-->\n" );
266 $out->out( $this->beforeContent() );
268 $out->out( $out->mBodytext
. "\n" );
270 $out->out( $this->afterContent() );
272 $out->out( $this->bottomScripts() );
274 $out->out( wfReportTime() );
276 $out->out( "\n</body></html>" );
277 wfProfileOut( __METHOD__
);
280 static function makeVariablesScript( $data ) {
281 global $wgJsMimeType;
283 $r = "<script type= \"$wgJsMimeType\">/*<![CDATA[*/\n";
284 foreach ( $data as $name => $value ) {
285 $encValue = Xml
::encodeJsVar( $value );
286 $r .= "var $name = $encValue;\n";
288 $r .= "/*]]>*/</script>\n";
294 * Make a <script> tag containing global variables
295 * @param array $data Associative array containing one element:
296 * skinname => the skin name
297 * The odd calling convention is for backwards compatibility
299 static function makeGlobalVariablesScript( $data ) {
300 global $wgScript, $wgStylePath, $wgUser;
301 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
302 global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
303 global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
304 global $wgUseAjax, $wgAjaxWatch;
305 global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
306 global $wgRestrictionTypes, $wgLivePreview;
307 global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
309 $ns = $wgTitle->getNamespace();
310 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
313 'skin' => $data['skinname'],
314 'stylepath' => $wgStylePath,
315 'wgArticlePath' => $wgArticlePath,
316 'wgScriptPath' => $wgScriptPath,
317 'wgScript' => $wgScript,
318 'wgVariantArticlePath' => $wgVariantArticlePath,
319 'wgActionPaths' => $wgActionPaths,
320 'wgServer' => $wgServer,
321 'wgCanonicalNamespace' => $nsname,
322 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBkey() ),
323 'wgNamespaceNumber' => $wgTitle->getNamespace(),
324 'wgPageName' => $wgTitle->getPrefixedDBKey(),
325 'wgTitle' => $wgTitle->getText(),
326 'wgAction' => $wgRequest->getText( 'action', 'view' ),
327 'wgArticleId' => $wgTitle->getArticleId(),
328 'wgIsArticle' => $wgOut->isArticle(),
329 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
330 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getEffectiveGroups(),
331 'wgUserLanguage' => $wgLang->getCode(),
332 'wgContentLanguage' => $wgContLang->getCode(),
333 'wgBreakFrames' => $wgBreakFrames,
334 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
335 'wgVersion' => $wgVersion,
336 'wgEnableAPI' => $wgEnableAPI,
337 'wgEnableWriteAPI' => $wgEnableWriteAPI,
340 if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false )){
341 $vars['wgMWSuggestTemplate'] = SearchEngine
::getMWSuggestTemplate();
342 $vars['wgDBname'] = $wgDBname;
343 $vars['wgSearchNamespaces'] = SearchEngine
::userNamespaces( $wgUser );
344 $vars['wgMWSuggestMessages'] = array( wfMsg('search-mwsuggest-enabled'), wfMsg('search-mwsuggest-disabled'));
347 foreach( $wgRestrictionTypes as $type )
348 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
350 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
351 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
352 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
353 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
354 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
357 if($wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
358 $msgs = (object)array();
359 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
360 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
362 $vars['wgAjaxWatch'] = $msgs;
365 wfRunHooks('SkinGlobalVariables', array(&$vars));
367 return self
::makeVariablesScript( $vars );
370 function getHeadScripts( $allowUserJs ) {
371 global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion;
373 $r = self
::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
375 $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n";
378 $jsCache = $wgUser->isLoggedIn() ?
'&smaxage=0' : '';
379 $r .= "<script type=\"$wgJsMimeType\" src=\"".
380 htmlspecialchars(self
::makeUrl('-',
381 "action=raw$jsCache&gen=js&useskin=" .
382 urlencode( $this->getSkinName() ) ) ) .
383 "\"><!-- site js --></script>\n";
385 if( $allowUserJs && $wgUser->isLoggedIn() ) {
386 $userpage = $wgUser->getUserPage();
387 $userjs = htmlspecialchars( self
::makeUrl(
388 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
389 'action=raw&ctype='.$wgJsMimeType));
390 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
396 * To make it harder for someone to slip a user a fake
397 * user-JavaScript or user-CSS preview, a random token
398 * is associated with the login session. If it's not
399 * passed back with the preview request, we won't render
402 * @param string $action
406 function userCanPreview( $action ) {
407 global $wgTitle, $wgRequest, $wgUser;
409 if( $action != 'submit' )
411 if( !$wgRequest->wasPosted() )
413 if( !$wgTitle->userCanEditCssJsSubpage() )
415 return $wgUser->matchEditToken(
416 $wgRequest->getVal( 'wpEditToken' ) );
419 # get the user/site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way)
420 function getUserStylesheet() {
421 global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage, $wgStyleVersion;
422 $sheet = $this->getStylesheet();
423 $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
425 $stylesheets = array();
426 $stylesheets['shared'] = "$wgStylePath/common/shared.css?$wgStyleVersion";
427 $stylesheets['oldshared'] = "$wgStylePath/common/oldshared.css?$wgStyleVersion";
428 $stylesheets['skin'] = "$wgStylePath/$sheet?$wgStyleVersion";
429 if($wgContLang->isRTL()) $stylesheets['rtl'] = "$wgStylePath/common/common_rtl.css?$wgStyleVersion";
430 $stylesheets['sitecommon'] = self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
);
431 $stylesheets['siteskin'] = self
::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
);
433 $rawcss = $this->doGetUserStyles();
435 wfRunHooks( 'SkinSetupSiteCss', array( &$stylesheets, &$rawcss, $query ) );
438 foreach( $stylesheets as $link ) {
439 $s .= "@import \"$link\";\n";
441 return "{$s}{$rawcss}\n";
445 * This returns MediaWiki:Common.js, and derived classes may add other JS.
446 * Despite its name, it does *not* return any custom user JS from user
447 * subpages. The returned script is sitewide and publicly cacheable and
448 * therefore must not include anything that varies according to user,
449 * interface language, etc. (although it may vary by skin). See
450 * makeGlobalVariablesScript for things that can vary per page view and are
453 * @return string Raw JavaScript to be returned
455 public function getUserJs() {
456 wfProfileIn( __METHOD__
);
459 $s = "/* generated javascript */\n";
460 $s .= "var skin = '" . Xml
::escapeJsString( $this->getSkinName() ) . "';\n";
461 $s .= "var stylepath = '" . Xml
::escapeJsString( $wgStylePath ) . "';";
462 $s .= "\n\n/* MediaWiki:Common.js */\n";
463 $commonJs = wfMsgForContent('common.js');
464 if ( !wfEmptyMsg ( 'common.js', $commonJs ) ) {
467 wfProfileOut( __METHOD__
);
472 * Return html code that include User stylesheets
474 function getUserStyles() {
475 $s = "<style type='text/css'>\n";
476 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
477 $s .= $this->getUserStylesheet();
478 $s .= "/*]]>*/ /* */\n";
484 * Some styles that are set by user through the user settings interface.
486 function doGetUserStyles() {
487 global $wgUser, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
491 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
492 if($wgTitle->isCssSubpage() && $this->userCanPreview( $wgRequest->getText( 'action' ) ) ) {
493 $s .= $wgRequest->getText('wpTextbox1');
495 $userpage = $wgUser->getUserPage();
496 $s.= '@import "'.self
::makeUrl(
497 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
498 'action=raw&ctype=text/css').'";'."\n";
502 return $s . $this->reallyDoGetUserStyles();
505 function reallyDoGetUserStyles() {
508 if (($undopt = $wgUser->getOption("underline")) < 2) {
509 $underline = $undopt ?
'underline' : 'none';
510 $s .= "a { text-decoration: $underline; }\n";
512 if( $wgUser->getOption( 'highlightbroken' ) ) {
513 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
516 a.new, #quickbar a.new,
517 a.stub, #quickbar a.stub {
520 a.new:after, #quickbar a.new:after {
524 a.stub:after, #quickbar a.stub:after {
530 if( $wgUser->getOption( 'justify' ) ) {
531 $s .= "#article, #bodyContent, #mw_content { text-align: justify; }\n";
533 if( !$wgUser->getOption( 'showtoc' ) ) {
534 $s .= "#toc { display: none; }\n";
536 if( !$wgUser->getOption( 'editsection' ) ) {
537 $s .= ".editsection { display: none; }\n";
542 function getBodyOptions() {
543 global $wgUser, $wgTitle, $wgOut, $wgRequest, $wgContLang;
545 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
547 if ( 0 != $wgTitle->getNamespace() ) {
548 $a = array( 'bgcolor' => '#ffffec' );
550 else $a = array( 'bgcolor' => '#FFFFFF' );
551 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
552 $wgTitle->userCan( 'edit' ) ) {
553 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
554 $s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
555 $a +
= array ('ondblclick' => $s);
558 $a['onload'] = $wgOut->getOnloadHandler();
560 'mediawiki ns-'.$wgTitle->getNamespace().
561 ' '.($wgContLang->isRTL() ?
"rtl" : "ltr").
562 ' '.Sanitizer
::escapeClass( 'page-'.$wgTitle->getPrefixedText() );
575 * This will be called immediately after the <body> tag. Split into
576 * two functions to make it easier to subclass.
578 function beforeContent() {
579 return $this->doBeforeContent();
582 function doBeforeContent() {
584 $fname = 'Skin::doBeforeContent';
585 wfProfileIn( $fname );
588 $qb = $this->qbSetting();
590 if( $langlinks = $this->otherLanguages() ) {
596 $borderhack = 'class="top"';
599 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
600 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
603 $left = ($qb == 1 ||
$qb == 3);
604 if($wgContLang->isRTL()) $left = !$left;
607 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
608 $this->logoText() . '</td>';
610 $s .= $this->getQuickbarCompensator( $rows );
612 $l = $wgContLang->isRTL() ?
'right' : 'left';
613 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
615 $s .= $this->topLinks() ;
616 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
618 $r = $wgContLang->isRTL() ?
"left" : "right";
619 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
620 $s .= $this->nameAndLogin();
621 $s .= "\n<br />" . $this->searchForm() . "</td>";
624 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
627 if ( $shove && !$left ) { # Right
628 $s .= $this->getQuickbarCompensator( $rows );
630 $s .= "</tr>\n</table>\n</div>\n";
631 $s .= "\n<div id='article'>\n";
633 $notice = wfGetSiteNotice();
635 $s .= "\n<div id='siteNotice'>$notice</div>\n";
637 $s .= $this->pageTitle();
638 $s .= $this->pageSubtitle() ;
639 $s .= $this->getCategories();
640 wfProfileOut( $fname );
645 function getCategoryLinks() {
646 global $wgOut, $wgTitle, $wgUseCategoryBrowser;
647 global $wgContLang, $wgUser;
649 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
652 $sep = wfMsgHtml( 'catseparator' );
654 // Use Unicode bidi embedding override characters,
655 // to make sure links don't smash each other up in ugly ways.
656 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
657 $embed = "<span dir='$dir'>";
660 $allCats = $wgOut->getCategoryLinks();
662 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
663 if ( !empty( $allCats['normal'] ) ) {
664 $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
666 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
667 $s .= '<div id="mw-normal-catlinks">' .
668 $this->makeLinkObj( Title
::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
669 . $colon . $t . '</div>';
673 if ( isset( $allCats['hidden'] ) ) {
674 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
675 $class ='mw-hidden-cats-user-shown';
676 } elseif ( $wgTitle->getNamespace() == NS_CATEGORY
) {
677 $class = 'mw-hidden-cats-ns-shown';
679 $class = 'mw-hidden-cats-hidden';
681 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
682 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
683 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
687 # optional 'dmoz-like' category browser. Will be shown under the list
688 # of categories an article belong to
689 if($wgUseCategoryBrowser) {
690 $s .= '<br /><hr />';
692 # get a big array of the parents tree
693 $parenttree = $wgTitle->getParentCategoryTree();
694 # Skin object passed by reference cause it can not be
695 # accessed under the method subfunction drawCategoryBrowser
696 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
697 # Clean out bogus first entry and sort them
700 # Output one per line
701 $s .= implode("<br />\n", $tempout);
707 /** Render the array as a serie of links.
708 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
709 * @param &skin Object: skin passed by reference
710 * @return String separated by >, terminate with "\n"
712 function drawCategoryBrowser($tree, &$skin) {
714 foreach ($tree as $element => $parent) {
715 if (empty($parent)) {
716 # element start a new list
719 # grab the others elements
720 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
722 # add our current element to the list
723 $eltitle = Title
::NewFromText($element);
724 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
729 function getCategories() {
730 $catlinks=$this->getCategoryLinks();
732 $classes = 'catlinks';
734 if( strpos( $catlinks, '<div id="mw-normal-catlinks">' ) === false &&
735 strpos( $catlinks, '<div id="mw-hidden-catlinks" class="mw-hidden-cats-hidden">' ) !== false ) {
736 $classes .= ' catlinks-allhidden';
739 if( !empty( $catlinks ) ){
740 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
744 function getQuickbarCompensator( $rows = 1 ) {
745 return "<td width='152' rowspan='{$rows}'> </td>";
749 * This gets called shortly before the \</body\> tag.
750 * @return String HTML to be put before \</body\>
752 function afterContent() {
753 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
754 return $printfooter . $this->doAfterContent();
758 * This gets called shortly before the \</body\> tag.
759 * @return String HTML-wrapped JS code to be put before \</body\>
761 function bottomScripts() {
762 global $wgJsMimeType;
763 $bottomScriptText = "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
764 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
765 return $bottomScriptText;
768 /** @return string Retrievied from HTML text */
769 function printSource() {
771 $url = htmlspecialchars( $wgTitle->getFullURL() );
772 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
775 function printFooter() {
776 return "<p>" . $this->printSource() .
777 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
780 /** overloaded by derived classes */
781 function doAfterContent() { }
783 function pageTitleLinks() {
784 global $wgOut, $wgTitle, $wgUser, $wgRequest;
786 $oldid = $wgRequest->getVal( 'oldid' );
787 $diff = $wgRequest->getVal( 'diff' );
788 $action = $wgRequest->getText( 'action' );
790 $s = $this->printableLink();
791 $disclaimer = $this->disclaimerLink(); # may be empty
793 $s .= ' | ' . $disclaimer;
795 $privacy = $this->privacyLink(); # may be empty too
797 $s .= ' | ' . $privacy;
800 if ( $wgOut->isArticleRelated() ) {
801 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
802 $name = $wgTitle->getDBkey();
803 $image = wfFindFile( $wgTitle );
805 $link = htmlspecialchars( $image->getURL() );
806 $style = $this->getInternalLinkAttributes( $link, $name );
807 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
811 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
812 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
813 wfMsg( 'currentrev' ) );
816 if ( $wgUser->getNewtalk() ) {
817 # do not show "You have new messages" text when we are viewing our
819 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
820 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
821 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
822 $s.= ' | <strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
824 $wgOut->setSquidMaxage(0);
825 $wgOut->enableClientCache(false);
829 $undelete = $this->getUndeleteLink();
830 if( !empty( $undelete ) ) {
831 $s .= ' | '.$undelete;
836 function getUndeleteLink() {
837 global $wgUser, $wgTitle, $wgContLang, $wgLang, $action;
838 if( $wgUser->isAllowed( 'deletedhistory' ) &&
839 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
840 ($n = $wgTitle->isDeleted() ) )
842 if ( $wgUser->isAllowed( 'undelete' ) ) {
843 $msg = 'thisisdeleted';
845 $msg = 'viewdeleted';
848 $this->makeKnownLinkObj(
849 SpecialPage
::getTitleFor( 'Undelete', $wgTitle->getPrefixedDBkey() ),
850 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ) ) );
855 function printableLink() {
856 global $wgOut, $wgFeedClasses, $wgRequest;
858 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
860 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
861 if( $wgOut->isSyndicated() ) {
862 foreach( $wgFeedClasses as $format => $class ) {
863 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
864 $s .= " | <a href=\"$feedurl\">{$format}</a>";
870 function pageTitle() {
872 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
876 function pageSubtitle() {
879 $sub = $wgOut->getSubtitle();
881 global $wgExtraSubtitle;
882 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
884 $subpages = $this->subPageSubtitle();
885 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
886 $s = "<p class='subtitle'>{$sub}</p>\n";
890 function subPageSubtitle() {
892 if(!wfRunHooks('SkinSubPageSubtitle', array(&$subpages)))
895 global $wgOut, $wgTitle;
896 if($wgOut->isArticle() && MWNamespace
::hasSubpages( $wgTitle->getNamespace() )) {
897 $ptext=$wgTitle->getPrefixedText();
898 if(preg_match('/\//',$ptext)) {
899 $links = explode('/',$ptext);
904 foreach($links as $link) {
905 $growinglink .= $link;
907 $linkObj = Title
::newFromText( $growinglink );
908 if( is_object( $linkObj ) && $linkObj->exists() ){
909 $getlink = $this->makeKnownLinkObj( $linkObj, htmlspecialchars( $display ) );
914 $subpages .= '< ';
916 $subpages .= $getlink;
929 * Returns true if the IP should be shown in the header
931 function showIPinHeader() {
932 global $wgShowIPinHeader;
933 return $wgShowIPinHeader && session_id() != '';
936 function nameAndLogin() {
937 global $wgUser, $wgTitle, $wgLang, $wgContLang;
939 $lo = $wgContLang->specialPage( 'Userlogout' );
942 if ( $wgUser->isAnon() ) {
943 if( $this->showIPinHeader() ) {
946 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
947 $wgLang->getNsText( NS_TALK
) );
949 $s .= $n . ' ('.$tl.')';
951 $s .= wfMsg('notloggedin');
954 $rt = $wgTitle->getPrefixedURL();
955 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
957 } else { $q = "returnto={$rt}"; }
959 $loginlink = $wgUser->isAllowed( 'createaccount' )
960 ?
'nav-login-createaccount'
962 $s .= "\n<br />" . $this->makeKnownLinkObj(
963 SpecialPage
::getTitleFor( 'Userlogin' ),
964 wfMsg( $loginlink ), $q );
966 $n = $wgUser->getName();
967 $rt = $wgTitle->getPrefixedURL();
968 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
969 $wgLang->getNsText( NS_TALK
) );
973 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
974 $n ) . "{$tl}<br />" .
975 $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
976 "returnto={$rt}" ) . ' | ' .
977 $this->specialLink( 'preferences' );
979 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
985 function getSearchLink() {
986 $searchPage = SpecialPage
::getTitleFor( 'Search' );
987 return $searchPage->getLocalURL();
990 function escapeSearchLink() {
991 return htmlspecialchars( $this->getSearchLink() );
994 function searchForm() {
996 $search = $wgRequest->getText( 'search' );
998 $s = '<form id="searchform'.$this->searchboxes
.'" name="search" class="inline" method="post" action="'
999 . $this->escapeSearchLink() . "\">\n"
1000 . '<input type="text" id="searchInput'.$this->searchboxes
.'" name="search" size="19" value="'
1001 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
1002 . '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" /> '
1003 . '<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n</form>";
1005 // Ensure unique id's for search boxes made after the first
1006 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
1011 function topLinks() {
1015 $s = $this->mainPageLink() . $sep
1016 . $this->specialLink( 'recentchanges' );
1018 if ( $wgOut->isArticleRelated() ) {
1019 $s .= $sep . $this->editThisPage()
1020 . $sep . $this->historyLink();
1022 # Many people don't like this dropdown box
1023 #$s .= $sep . $this->specialPagesList();
1025 $s .= $this->variantLinks();
1027 $s .= $this->extensionTabLinks();
1033 * Compatibility for extensions adding functionality through tabs.
1034 * Eventually these old skins should be replaced with SkinTemplate-based
1038 function extensionTabLinks() {
1041 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1042 foreach( $tabs as $tab ) {
1043 $s .= ' | ' . Xml
::element( 'a',
1044 array( 'href' => $tab['href'] ),
1051 * Language/charset variant links for classic-style skins
1054 function variantLinks() {
1056 /* show links to different language variants */
1057 global $wgDisableLangConversion, $wgContLang, $wgTitle;
1058 $variants = $wgContLang->getVariants();
1059 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1060 foreach( $variants as $code ) {
1061 $varname = $wgContLang->getVariantname( $code );
1062 if( $varname == 'disable' )
1064 $s .= ' | <a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>';
1070 function bottomLinks() {
1071 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
1075 if ( $wgOut->isArticleRelated() ) {
1076 $s .= '<strong>' . $this->editThisPage() . '</strong>';
1077 if ( $wgUser->isLoggedIn() ) {
1078 $s .= $sep . $this->watchThisPage();
1080 $s .= $sep . $this->talkLink()
1081 . $sep . $this->historyLink()
1082 . $sep . $this->whatLinksHere()
1083 . $sep . $this->watchPageLinksLink();
1085 if ($wgUseTrackbacks)
1086 $s .= $sep . $this->trackbackLink();
1088 if ( $wgTitle->getNamespace() == NS_USER
1089 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
1092 $id=User
::idFromName($wgTitle->getText());
1093 $ip=User
::isIP($wgTitle->getText());
1095 if($id ||
$ip) { # both anons and non-anons have contri list
1096 $s .= $sep . $this->userContribsLink();
1098 if( $this->showEmailUser( $id ) ) {
1099 $s .= $sep . $this->emailUserLink();
1102 if ( $wgTitle->getArticleId() ) {
1104 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
1105 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
1106 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
1108 $s .= "<br />\n" . $this->otherLanguages();
1113 function pageStats() {
1114 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1115 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
1117 $oldid = $wgRequest->getVal( 'oldid' );
1118 $diff = $wgRequest->getVal( 'diff' );
1119 if ( ! $wgOut->isArticle() ) { return ''; }
1120 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1121 if ( 0 == $wgArticle->getID() ) { return ''; }
1124 if ( !$wgDisableCounters ) {
1125 $count = $wgLang->formatNum( $wgArticle->getCount() );
1127 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1131 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
1132 require_once('Credits.php');
1133 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
1135 $s .= $this->lastModified();
1138 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
1139 $dbr = wfGetDB( DB_SLAVE
);
1140 $watchlist = $dbr->tableName( 'watchlist' );
1141 $sql = "SELECT COUNT(*) AS n FROM $watchlist
1142 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBkey()) .
1143 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
1144 $res = $dbr->query( $sql, 'Skin::pageStats');
1145 $x = $dbr->fetchObject( $res );
1147 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1148 array( 'parseinline' ), $wgLang->formatNum($x->n
)
1152 return $s . ' ' . $this->getCopyright();
1155 function getCopyright( $type = 'detect' ) {
1156 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
1158 if ( $type == 'detect' ) {
1159 $oldid = $wgRequest->getVal( 'oldid' );
1160 $diff = $wgRequest->getVal( 'diff' );
1162 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1169 if ( $type == 'history' ) {
1170 $msg = 'history_copyright';
1176 if( $wgRightsPage ) {
1177 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
1178 } elseif( $wgRightsUrl ) {
1179 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1184 $out .= wfMsgForContent( $msg, $link );
1188 function getCopyrightIcon() {
1189 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1191 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1192 $out = $wgCopyrightIcon;
1193 } else if ( $wgRightsIcon ) {
1194 $icon = htmlspecialchars( $wgRightsIcon );
1195 if ( $wgRightsUrl ) {
1196 $url = htmlspecialchars( $wgRightsUrl );
1197 $out .= '<a href="'.$url.'">';
1199 $text = htmlspecialchars( $wgRightsText );
1200 $out .= "<img src=\"$icon\" alt='$text' />";
1201 if ( $wgRightsUrl ) {
1208 function getPoweredBy() {
1209 global $wgStylePath;
1210 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1211 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1215 function lastModified() {
1216 global $wgLang, $wgArticle;
1217 if( $this->mRevisionId
) {
1218 $timestamp = Revision
::getTimestampFromId( $this->mRevisionId
, $wgArticle->getId() );
1220 $timestamp = $wgArticle->getTimestamp();
1223 $d = $wgLang->date( $timestamp, true );
1224 $t = $wgLang->time( $timestamp, true );
1225 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1229 if ( wfGetLB()->getLaggedSlaveMode() ) {
1230 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1235 function logoText( $align = '' ) {
1236 if ( '' != $align ) { $a = " align='{$align}'"; }
1239 $mp = wfMsg( 'mainpage' );
1240 $mptitle = Title
::newMainPage();
1241 $url = ( is_object($mptitle) ?
$mptitle->escapeLocalURL() : '' );
1243 $logourl = $this->getLogo();
1244 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1249 * show a drop-down box of special pages
1251 function specialPagesList() {
1252 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1253 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1254 foreach ( $pages as $name => $page ) {
1255 $pages[$name] = $page->getDescription();
1258 $go = wfMsg( 'go' );
1259 $sp = wfMsg( 'specialpages' );
1260 $spp = $wgContLang->specialPage( 'Specialpages' );
1262 $s = '<form id="specialpages" method="get" class="inline" ' .
1263 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1264 $s .= "<select name=\"wpDropdown\">\n";
1265 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1268 foreach ( $pages as $name => $desc ) {
1269 $p = $wgContLang->specialPage( $name );
1270 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1272 $s .= "</select>\n";
1273 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1278 function mainPageLink() {
1279 $s = $this->makeKnownLinkObj( Title
::newMainPage(), wfMsg( 'mainpage' ) );
1283 function copyrightLink() {
1284 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1285 wfMsg( 'copyrightpagename' ) );
1289 private function footerLink ( $desc, $page ) {
1290 // if the link description has been set to "-" in the default language,
1291 if ( wfMsgForContent( $desc ) == '-') {
1292 // then it is disabled, for all languages.
1295 // Otherwise, we display the link for the user, described in their
1296 // language (which may or may not be the same as the default language),
1297 // but we make the link target be the one site-wide page.
1298 return $this->makeKnownLink( wfMsgForContent( $page ),
1299 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) ) );
1303 function privacyLink() {
1304 return $this->footerLink( 'privacy', 'privacypage' );
1307 function aboutLink() {
1308 return $this->footerLink( 'aboutsite', 'aboutpage' );
1311 function disclaimerLink() {
1312 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1315 function editThisPage() {
1316 global $wgOut, $wgTitle;
1318 if ( !$wgOut->isArticleRelated() ) {
1319 $s = wfMsg( 'protectedpage' );
1321 if( $wgTitle->userCan( 'edit' ) && $wgTitle->exists() ) {
1322 $t = wfMsg( 'editthispage' );
1323 } elseif( $wgTitle->userCan( 'create' ) && !$wgTitle->exists() ) {
1324 $t = wfMsg( 'create-this-page' );
1326 $t = wfMsg( 'viewsource' );
1329 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1335 * Return URL options for the 'edit page' link.
1336 * This may include an 'oldid' specifier, if the current page view is such.
1341 function editUrlOptions() {
1344 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1345 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1347 return "action=edit";
1351 function deleteThisPage() {
1352 global $wgUser, $wgTitle, $wgRequest;
1354 $diff = $wgRequest->getVal( 'diff' );
1355 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1356 $t = wfMsg( 'deletethispage' );
1358 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1365 function protectThisPage() {
1366 global $wgUser, $wgTitle, $wgRequest;
1368 $diff = $wgRequest->getVal( 'diff' );
1369 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1370 if ( $wgTitle->isProtected() ) {
1371 $t = wfMsg( 'unprotectthispage' );
1372 $q = 'action=unprotect';
1374 $t = wfMsg( 'protectthispage' );
1375 $q = 'action=protect';
1377 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1384 function watchThisPage() {
1385 global $wgOut, $wgTitle;
1386 ++
$this->mWatchLinkNum
;
1388 if ( $wgOut->isArticleRelated() ) {
1389 if ( $wgTitle->userIsWatching() ) {
1390 $t = wfMsg( 'unwatchthispage' );
1391 $q = 'action=unwatch';
1392 $id = "mw-unwatch-link".$this->mWatchLinkNum
;
1394 $t = wfMsg( 'watchthispage' );
1395 $q = 'action=watch';
1396 $id = 'mw-watch-link'.$this->mWatchLinkNum
;
1398 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q, '', '', " id=\"$id\"" );
1400 $s = wfMsg( 'notanarticle' );
1405 function moveThisPage() {
1408 if ( $wgTitle->userCan( 'move' ) ) {
1409 return $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
1410 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1412 // no message if page is protected - would be redundant
1417 function historyLink() {
1420 return $this->makeKnownLinkObj( $wgTitle,
1421 wfMsg( 'history' ), 'action=history' );
1424 function whatLinksHere() {
1427 return $this->makeKnownLinkObj(
1428 SpecialPage
::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ),
1429 wfMsg( 'whatlinkshere' ) );
1432 function userContribsLink() {
1435 return $this->makeKnownLinkObj(
1436 SpecialPage
::getTitleFor( 'Contributions', $wgTitle->getDBkey() ),
1437 wfMsg( 'contributions' ) );
1440 function showEmailUser( $id ) {
1441 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1442 return $wgEnableEmail &&
1443 $wgEnableUserEmail &&
1444 $wgUser->isLoggedIn() && # show only to signed in users
1445 0 != $id; # we can only email to non-anons ..
1446 # '' != $id->getEmail() && # who must have an email address stored ..
1447 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1448 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1451 function emailUserLink() {
1454 return $this->makeKnownLinkObj(
1455 SpecialPage
::getTitleFor( 'Emailuser', $wgTitle->getDBkey() ),
1456 wfMsg( 'emailuser' ) );
1459 function watchPageLinksLink() {
1460 global $wgOut, $wgTitle;
1462 if ( ! $wgOut->isArticleRelated() ) {
1463 return '(' . wfMsg( 'notanarticle' ) . ')';
1465 return $this->makeKnownLinkObj(
1466 SpecialPage
::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ),
1467 wfMsg( 'recentchangeslinked' ) );
1471 function trackbackLink() {
1474 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1475 . wfMsg('trackbacklink') . "</a>";
1478 function otherLanguages() {
1479 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1481 if ( $wgHideInterlanguageLinks ) {
1485 $a = $wgOut->getLanguageLinks();
1486 if ( 0 == count( $a ) ) {
1490 $s = wfMsg( 'otherlanguages' ) . ': ';
1492 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1493 foreach( $a as $l ) {
1494 if ( ! $first ) { $s .= ' | '; }
1497 $nt = Title
::newFromText( $l );
1498 $url = $nt->escapeFullURL();
1499 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1501 if ( '' == $text ) { $text = $l; }
1502 $style = $this->getExternalLinkAttributes( $l, $text );
1503 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1505 if($wgContLang->isRTL()) $s .= '</span>';
1509 function bugReportsLink() {
1510 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1511 wfMsg( 'bugreports' ) );
1515 function talkLink() {
1518 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1519 # No discussion links for special pages
1523 if( $wgTitle->isTalkPage() ) {
1524 $link = $wgTitle->getSubjectPage();
1525 switch( $link->getNamespace() ) {
1527 $text = wfMsg( 'articlepage' );
1530 $text = wfMsg( 'userpage' );
1533 $text = wfMsg( 'projectpage' );
1536 $text = wfMsg( 'imagepage' );
1539 $text = wfMsg( 'mediawikipage' );
1542 $text = wfMsg( 'templatepage' );
1545 $text = wfMsg( 'viewhelppage' );
1548 $text = wfMsg( 'categorypage' );
1551 $text = wfMsg( 'articlepage' );
1554 $link = $wgTitle->getTalkPage();
1555 $text = wfMsg( 'talkpage' );
1558 $s = $this->makeLinkObj( $link, $text );
1563 function commentLink() {
1564 global $wgTitle, $wgOut;
1566 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1570 # __NEWSECTIONLINK___ changes behaviour here
1571 # If it's present, the link points to this page, otherwise
1572 # it points to the talk page
1573 if( $wgTitle->isTalkPage() ) {
1575 } elseif( $wgOut->showNewSectionLink() ) {
1578 $title = $wgTitle->getTalkPage();
1581 return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1584 /* these are used extensively in SkinTemplate, but also some other places */
1585 static function makeMainPageUrl( $urlaction = '' ) {
1586 $title = Title
::newMainPage();
1587 self
::checkTitle( $title, '' );
1588 return $title->getLocalURL( $urlaction );
1591 static function makeSpecialUrl( $name, $urlaction = '' ) {
1592 $title = SpecialPage
::getTitleFor( $name );
1593 return $title->getLocalURL( $urlaction );
1596 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1597 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1598 return $title->getLocalURL( $urlaction );
1601 static function makeI18nUrl( $name, $urlaction = '' ) {
1602 $title = Title
::newFromText( wfMsgForContent( $name ) );
1603 self
::checkTitle( $title, $name );
1604 return $title->getLocalURL( $urlaction );
1607 static function makeUrl( $name, $urlaction = '' ) {
1608 $title = Title
::newFromText( $name );
1609 self
::checkTitle( $title, $name );
1610 return $title->getLocalURL( $urlaction );
1613 # If url string starts with http, consider as external URL, else
1615 static function makeInternalOrExternalUrl( $name ) {
1616 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1619 return self
::makeUrl( $name );
1623 # this can be passed the NS number as defined in Language.php
1624 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1625 $title = Title
::makeTitleSafe( $namespace, $name );
1626 self
::checkTitle( $title, $name );
1627 return $title->getLocalURL( $urlaction );
1630 /* these return an array with the 'href' and boolean 'exists' */
1631 static function makeUrlDetails( $name, $urlaction = '' ) {
1632 $title = Title
::newFromText( $name );
1633 self
::checkTitle( $title, $name );
1635 'href' => $title->getLocalURL( $urlaction ),
1636 'exists' => $title->getArticleID() != 0 ?
true : false
1641 * Make URL details where the article exists (or at least it's convenient to think so)
1643 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1644 $title = Title
::newFromText( $name );
1645 self
::checkTitle( $title, $name );
1647 'href' => $title->getLocalURL( $urlaction ),
1652 # make sure we have some title to operate on
1653 static function checkTitle( &$title, $name ) {
1654 if( !is_object( $title ) ) {
1655 $title = Title
::newFromText( $name );
1656 if( !is_object( $title ) ) {
1657 $title = Title
::newFromText( '--error: link target missing--' );
1663 * Build an array that represents the sidebar(s), the navigation bar among them
1667 function buildSidebar() {
1668 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
1670 wfProfileIn( __METHOD__
);
1672 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
1674 if ( $wgEnableSidebarCache ) {
1675 $cachedsidebar = $parserMemc->get( $key );
1676 if ( $cachedsidebar ) {
1677 wfProfileOut( __METHOD__
);
1678 return $cachedsidebar;
1683 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1685 $specialBox = false;
1686 foreach ($lines as $line) {
1687 if (strpos($line, '*') !== 0)
1689 if (strpos($line, '**') !== 0) {
1690 $line = trim($line, '* ');
1692 if ( $line == 'SEARCH' ||
$line == 'TOOLBOX' ||
$line == 'LANGUAGES' ) {
1693 # Internal special box type
1694 $bar[$line] = array();
1698 # Allow extensions to start a special box
1699 if( !wfRunHooks( 'SkinSidebarSpecialBox', array( &$this, $line, &$cont ) ) ) {
1700 # Extension special box type
1701 $bar[$line] = $cont;
1705 $specialBox = false;
1711 # Inside a special box, we just append the lines into the $cont
1712 $bar[$heading][] = $line;
1713 } elseif (strpos($line, '|') !== false) { // sanity check
1714 $line = array_map('trim', explode( '|' , trim($line, '* '), 2 ) );
1715 $link = wfMsgForContent( $line[0] );
1718 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1720 if (wfEmptyMsg($line[0], $link))
1723 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1726 $title = Title
::newFromText( $link );
1728 $title = $title->fixSpecialName();
1729 $href = $title->getLocalURL();
1731 $href = 'INVALID-TITLE';
1735 $bar[$heading][] = array(
1738 'id' => 'n-' . strtr($line[1], ' ', '-'),
1741 } else { continue; }
1744 if ( $wgEnableSidebarCache ) $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
1745 wfProfileOut( __METHOD__
);