2 if ( ! defined( 'MEDIAWIKI' ) )
14 * The main skin class that provide methods and properties for all other skins.
15 * This base class is also the "Standard" skin.
18 class Skin
extends Linker
{
22 var $lastdate, $lastline;
23 var $rc_cache ; # Cache for Enhanced Recent Changes
24 var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle
26 var $mWatchLinkNum = 0; // Appended to end of watch link id's
29 /** Constructor, call parent constructor */
30 function Skin() { parent
::Linker(); }
33 * Fetch the set of available skins.
34 * @return array of strings
37 static function &getSkinNames() {
38 global $wgValidSkinNames;
39 static $skinsInitialised = false;
40 if ( !$skinsInitialised ) {
41 # Get a list of available skins
42 # Build using the regular expression '^(.*).php$'
43 # Array keys are all lower case, array value keep the case used by filename
45 wfProfileIn( __METHOD__
. '-init' );
46 global $wgStyleDirectory;
47 $skinDir = dir( $wgStyleDirectory );
49 # while code from www.php.net
50 while (false !== ($file = $skinDir->read())) {
51 // Skip non-PHP files, hidden files, and '.dep' includes
53 if(preg_match('/^([^.]*)\.php$/',$file, $matches)) {
55 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
59 $skinsInitialised = true;
60 wfProfileOut( __METHOD__
. '-init' );
62 return $wgValidSkinNames;
66 * Normalize a skin preference value to a form that can be loaded.
67 * If a skin can't be found, it will fall back to the configured
68 * default (or the old 'Classic' skin if that's broken).
73 static function normalizeKey( $key ) {
74 global $wgDefaultSkin;
75 $skinNames = Skin
::getSkinNames();
78 // Don't return the default immediately;
79 // in a misconfiguration we need to fall back.
80 $key = $wgDefaultSkin;
83 if( isset( $skinNames[$key] ) ) {
87 // Older versions of the software used a numeric setting
88 // in the user preferences.
94 if( isset( $fallback[$key] ) ){
95 $key = $fallback[$key];
98 if( isset( $skinNames[$key] ) ) {
101 // The old built-in skin
107 * Factory method for loading a skin of a given type
108 * @param string $key 'monobook', 'standard', etc
112 static function &newFromKey( $key ) {
113 global $wgStyleDirectory;
115 $key = Skin
::normalizeKey( $key );
117 $skinNames = Skin
::getSkinNames();
118 $skinName = $skinNames[$key];
120 # Grab the skin class and initialise it.
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 $className = 'Skin'.$skinName;
128 if( !class_exists( $className ) ) {
129 # DO NOT die if the class isn't found. This breaks maintenance
130 # scripts and can cause a user account to be unrecoverable
131 # except by SQL manipulation if a previously valid skin name
132 # is no longer valid.
133 wfDebug( "Skin class does not exist: $className\n" );
134 $className = 'SkinStandard';
135 require_once( "{$wgStyleDirectory}/Standard.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 function getSkinName() {
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, $wgScriptPath, $wgSitename, $wgLanguageCode, $wgLanguageNames;
162 $fname = 'Skin::initPage';
163 wfProfileIn( $fname );
165 if( false !== $wgFavicon ) {
166 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
169 # OpenSearch description link
170 $out->addLink( array(
172 'type' => 'application/opensearchdescription+xml',
173 'href' => "$wgScriptPath/opensearch_desc.php",
174 'title' => "$wgSitename ({$wgLanguageNames[$wgLanguageCode]})",
177 $this->addMetadataLinks($out);
179 $this->mRevisionId
= $out->mRevisionId
;
181 $this->preloadExistence();
183 wfProfileOut( $fname );
187 * Preload the existence of three commonly-requested pages in a single query
189 function preloadExistence() {
190 global $wgUser, $wgTitle;
192 if ( $wgTitle->isTalkPage() ) {
193 $otherTab = $wgTitle->getSubjectPage();
195 $otherTab = $wgTitle->getTalkPage();
197 $lb = new LinkBatch( array(
198 $wgUser->getUserPage(),
199 $wgUser->getTalkPage(),
205 function addMetadataLinks( &$out ) {
206 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
207 global $wgRightsPage, $wgRightsUrl;
209 if( $out->isArticleRelated() ) {
210 # note: buggy CC software only reads first "meta" link
211 if( $wgEnableCreativeCommonsRdf ) {
212 $out->addMetadataLink( array(
213 'title' => 'Creative Commons',
214 'type' => 'application/rdf+xml',
215 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
217 if( $wgEnableDublinCoreRdf ) {
218 $out->addMetadataLink( array(
219 'title' => 'Dublin Core',
220 'type' => 'application/rdf+xml',
221 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
225 if( $wgRightsPage ) {
226 $copy = Title
::newFromText( $wgRightsPage );
228 $copyright = $copy->getLocalURL();
231 if( !$copyright && $wgRightsUrl ) {
232 $copyright = $wgRightsUrl;
235 $out->addLink( array(
236 'rel' => 'copyright',
237 'href' => $copyright ) );
241 function outputPage( &$out ) {
242 global $wgDebugComments;
244 wfProfileIn( 'Skin::outputPage' );
245 $this->initPage( $out );
247 $out->out( $out->headElement() );
249 $out->out( "\n<body" );
250 $ops = $this->getBodyOptions();
251 foreach ( $ops as $name => $val ) {
252 $out->out( " $name='$val'" );
255 if ( $wgDebugComments ) {
256 $out->out( "<!-- Wiki debugging output:\n" .
257 $out->mDebugtext
. "-->\n" );
260 $out->out( $this->beforeContent() );
262 $out->out( $out->mBodytext
. "\n" );
264 $out->out( $this->afterContent() );
266 $out->out( $this->bottomScripts() );
268 $out->out( $out->reportTime() );
270 $out->out( "\n</body></html>" );
273 static function makeVariablesScript( $data ) {
274 global $wgJsMimeType;
276 $r = "<script type= \"$wgJsMimeType\">/*<![CDATA[*/\n";
277 foreach ( $data as $name => $value ) {
278 $encValue = Xml
::encodeJsVar( $value );
279 $r .= "var $name = $encValue;\n";
281 $r .= "/*]]>*/</script>\n";
287 * Make a <script> tag containing global variables
288 * @param array $data Associative array containing one element:
289 * skinname => the skin name
290 * The odd calling convention is for backwards compatibility
292 static function makeGlobalVariablesScript( $data ) {
293 global $wgStylePath, $wgUser;
294 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
295 global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
296 global $wgBreakFrames;
298 $ns = $wgTitle->getNamespace();
299 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
302 'skin' => $data['skinname'],
303 'stylepath' => $wgStylePath,
304 'wgArticlePath' => $wgArticlePath,
305 'wgScriptPath' => $wgScriptPath,
306 'wgServer' => $wgServer,
307 'wgCanonicalNamespace' => $nsname,
308 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBKey() ),
309 'wgNamespaceNumber' => $wgTitle->getNamespace(),
310 'wgPageName' => $wgTitle->getPrefixedDBKey(),
311 'wgTitle' => $wgTitle->getText(),
312 'wgArticleId' => $wgTitle->getArticleId(),
313 'wgIsArticle' => $wgOut->isArticle(),
314 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
315 'wgUserLanguage' => $wgLang->getCode(),
316 'wgContentLanguage' => $wgContLang->getCode(),
317 'wgBreakFrames' => $wgBreakFrames,
318 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
321 return self
::makeVariablesScript( $vars );
324 function getHeadScripts() {
325 global $wgStylePath, $wgUser, $wgAllowUserJs, $wgJsMimeType, $wgStyleVersion;
327 $r = self
::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
329 $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n";
332 if ($wgUser->isLoggedIn()) {
333 $r .= "<script type=\"$wgJsMimeType\" src=\"".htmlspecialchars(self
::makeUrl('-','action=raw&smaxage=0&gen=js'))."\"><!-- site js --></script>\n";
335 $r .= "<script type=\"$wgJsMimeType\" src=\"".htmlspecialchars(self
::makeUrl('-','action=raw&gen=js'))."\"><!-- site js --></script>\n";
338 if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
339 $userpage = $wgUser->getUserPage();
340 $userjs = htmlspecialchars( self
::makeUrl(
341 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
342 'action=raw&ctype='.$wgJsMimeType));
343 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
349 * To make it harder for someone to slip a user a fake
350 * user-JavaScript or user-CSS preview, a random token
351 * is associated with the login session. If it's not
352 * passed back with the preview request, we won't render
355 * @param string $action
359 function userCanPreview( $action ) {
360 global $wgTitle, $wgRequest, $wgUser;
362 if( $action != 'submit' )
364 if( !$wgRequest->wasPosted() )
366 if( !$wgTitle->userCanEditCssJsSubpage() )
368 return $wgUser->matchEditToken(
369 $wgRequest->getVal( 'wpEditToken' ) );
372 # get the user/site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way)
373 function getUserStylesheet() {
374 global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage, $wgStyleVersion;
375 $sheet = $this->getStylesheet();
376 $s = "@import \"$wgStylePath/common/common.css?$wgStyleVersion\";\n";
377 $s .= "@import \"$wgStylePath/$sheet?$wgStyleVersion\";\n";
378 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css?$wgStyleVersion\";\n";
380 $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
381 $s .= '@import "' . self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n" .
382 '@import "' . self
::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
384 $s .= $this->doGetUserStyles();
389 * This returns MediaWiki:Common.js. For some bizarre reason, it does
390 * *not* return any custom user JS from user subpages. Huh?
394 function getUserJs() {
395 $fname = 'Skin::getUserJs';
396 wfProfileIn( __METHOD__
);
399 $s = "/* generated javascript */\n";
400 $s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';";
401 $s .= "\n\n/* MediaWiki:Common.js */\n";
402 $commonJs = wfMsgForContent('Common.js');
403 if ( !wfEmptyMsg ( 'Common.js', $commonJs ) ) {
407 global $wgUseAjax, $wgAjaxWatch;
408 if($wgUseAjax && $wgAjaxWatch) {
411 /* AJAX (un)watch (see /skins/common/ajaxwatch.js) */
413 watchMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'watch', array() ) )."',
414 unwatchMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'unwatch', array() ) )."',
415 watchingMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'watching', array() ) )."',
416 unwatchingMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'unwatching', array() ) )."'
420 wfProfileOut( __METHOD__
);
425 * Return html code that include User stylesheets
427 function getUserStyles() {
428 $s = "<style type='text/css'>\n";
429 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
430 $s .= $this->getUserStylesheet();
431 $s .= "/*]]>*/ /* */\n";
437 * Some styles that are set by user through the user settings interface.
439 function doGetUserStyles() {
440 global $wgUser, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
444 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
445 if($wgTitle->isCssSubpage() && $this->userCanPreview( $wgRequest->getText( 'action' ) ) ) {
446 $s .= $wgRequest->getText('wpTextbox1');
448 $userpage = $wgUser->getUserPage();
449 $s.= '@import "'.self
::makeUrl(
450 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
451 'action=raw&ctype=text/css').'";'."\n";
455 return $s . $this->reallyDoGetUserStyles();
458 function reallyDoGetUserStyles() {
461 if (($undopt = $wgUser->getOption("underline")) != 2) {
462 $underline = $undopt ?
'underline' : 'none';
463 $s .= "a { text-decoration: $underline; }\n";
465 if( $wgUser->getOption( 'highlightbroken' ) ) {
466 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
469 a.new, #quickbar a.new,
470 a.stub, #quickbar a.stub {
472 text-decoration: inherit;
474 a.new:after, #quickbar a.new:after {
477 text-decoration: $underline;
479 a.stub:after, #quickbar a.stub:after {
482 text-decoration: $underline;
486 if( $wgUser->getOption( 'justify' ) ) {
487 $s .= "#article, #bodyContent { text-align: justify; }\n";
489 if( !$wgUser->getOption( 'showtoc' ) ) {
490 $s .= "#toc { display: none; }\n";
492 if( !$wgUser->getOption( 'editsection' ) ) {
493 $s .= ".editsection { display: none; }\n";
498 function getBodyOptions() {
499 global $wgUser, $wgTitle, $wgOut, $wgRequest, $wgContLang;
501 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
503 if ( 0 != $wgTitle->getNamespace() ) {
504 $a = array( 'bgcolor' => '#ffffec' );
506 else $a = array( 'bgcolor' => '#FFFFFF' );
507 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
508 $wgTitle->userCanEdit() ) {
509 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
510 $s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
511 $a +
= array ('ondblclick' => $s);
514 $a['onload'] = $wgOut->getOnloadHandler();
515 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
516 if( $a['onload'] != '' ) {
519 $a['onload'] .= 'setupRightClickEdit()';
521 $a['class'] = 'ns-'.$wgTitle->getNamespace().' '.($wgContLang->isRTL() ?
"rtl" : "ltr").
522 ' '.Sanitizer
::escapeId( 'page-'.$wgTitle->getPrefixedText() );
535 * This will be called immediately after the <body> tag. Split into
536 * two functions to make it easier to subclass.
538 function beforeContent() {
539 return $this->doBeforeContent();
542 function doBeforeContent() {
544 $fname = 'Skin::doBeforeContent';
545 wfProfileIn( $fname );
548 $qb = $this->qbSetting();
550 if( $langlinks = $this->otherLanguages() ) {
556 $borderhack = 'class="top"';
559 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
560 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
563 $left = ($qb == 1 ||
$qb == 3);
564 if($wgContLang->isRTL()) $left = !$left;
567 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
568 $this->logoText() . '</td>';
570 $s .= $this->getQuickbarCompensator( $rows );
572 $l = $wgContLang->isRTL() ?
'right' : 'left';
573 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
575 $s .= $this->topLinks() ;
576 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
578 $r = $wgContLang->isRTL() ?
"left" : "right";
579 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
580 $s .= $this->nameAndLogin();
581 $s .= "\n<br />" . $this->searchForm() . "</td>";
584 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
587 if ( $shove && !$left ) { # Right
588 $s .= $this->getQuickbarCompensator( $rows );
590 $s .= "</tr>\n</table>\n</div>\n";
591 $s .= "\n<div id='article'>\n";
593 $notice = wfGetSiteNotice();
595 $s .= "\n<div id='siteNotice'>$notice</div>\n";
597 $s .= $this->pageTitle();
598 $s .= $this->pageSubtitle() ;
599 $s .= $this->getCategories();
600 wfProfileOut( $fname );
605 function getCategoryLinks () {
606 global $wgOut, $wgTitle, $wgUseCategoryBrowser;
609 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
612 $sep = wfMsgHtml( 'catseparator' );
614 // Use Unicode bidi embedding override characters,
615 // to make sure links don't smash each other up in ugly ways.
616 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
617 $embed = "<span dir='$dir'>";
619 $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $wgOut->mCategoryLinks
) . $pop;
621 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escape' ), count( $wgOut->mCategoryLinks
) );
622 $s = $this->makeLinkObj( Title
::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
625 # optional 'dmoz-like' category browser. Will be shown under the list
626 # of categories an article belong to
627 if($wgUseCategoryBrowser) {
628 $s .= '<br /><hr />';
630 # get a big array of the parents tree
631 $parenttree = $wgTitle->getParentCategoryTree();
632 # Skin object passed by reference cause it can not be
633 # accessed under the method subfunction drawCategoryBrowser
634 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
635 # Clean out bogus first entry and sort them
638 # Output one per line
639 $s .= implode("<br />\n", $tempout);
645 /** Render the array as a serie of links.
646 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
647 * @param &skin Object: skin passed by reference
648 * @return String separated by >, terminate with "\n"
650 function drawCategoryBrowser($tree, &$skin) {
652 foreach ($tree as $element => $parent) {
653 if (empty($parent)) {
654 # element start a new list
657 # grab the others elements
658 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
660 # add our current element to the list
661 $eltitle = Title
::NewFromText($element);
662 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
667 function getCategories() {
668 $catlinks=$this->getCategoryLinks();
669 if(!empty($catlinks)) {
670 return "<p class='catlinks'>{$catlinks}</p>";
674 function getQuickbarCompensator( $rows = 1 ) {
675 return "<td width='152' rowspan='{$rows}'> </td>";
679 * This gets called shortly before the \</body\> tag.
680 * @return String HTML to be put before \</body\>
682 function afterContent() {
683 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
684 return $printfooter . $this->doAfterContent();
688 * This gets called shortly before the \</body\> tag.
689 * @return String HTML-wrapped JS code to be put before \</body\>
691 function bottomScripts() {
692 global $wgJsMimeType;
693 return "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
696 /** @return string Retrievied from HTML text */
697 function printSource() {
699 $url = htmlspecialchars( $wgTitle->getFullURL() );
700 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
703 function printFooter() {
704 return "<p>" . $this->printSource() .
705 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
708 /** overloaded by derived classes */
709 function doAfterContent() { }
711 function pageTitleLinks() {
712 global $wgOut, $wgTitle, $wgUser, $wgRequest;
714 $oldid = $wgRequest->getVal( 'oldid' );
715 $diff = $wgRequest->getVal( 'diff' );
716 $action = $wgRequest->getText( 'action' );
718 $s = $this->printableLink();
719 $disclaimer = $this->disclaimerLink(); # may be empty
721 $s .= ' | ' . $disclaimer;
723 $privacy = $this->privacyLink(); # may be empty too
725 $s .= ' | ' . $privacy;
728 if ( $wgOut->isArticleRelated() ) {
729 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
730 $name = $wgTitle->getDBkey();
731 $image = new Image( $wgTitle );
732 if( $image->exists() ) {
733 $link = htmlspecialchars( $image->getURL() );
734 $style = $this->getInternalLinkAttributes( $link, $name );
735 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
739 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
740 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
741 wfMsg( 'currentrev' ) );
744 if ( $wgUser->getNewtalk() ) {
745 # do not show "You have new messages" text when we are viewing our
747 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
748 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
749 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
750 $s.= ' | <strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
752 $wgOut->setSquidMaxage(0);
753 $wgOut->enableClientCache(false);
757 $undelete = $this->getUndeleteLink();
758 if( !empty( $undelete ) ) {
759 $s .= ' | '.$undelete;
764 function getUndeleteLink() {
765 global $wgUser, $wgTitle, $wgContLang, $action;
766 if( $wgUser->isAllowed( 'deletedhistory' ) &&
767 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
768 ($n = $wgTitle->isDeleted() ) )
770 if ( $wgUser->isAllowed( 'delete' ) ) {
771 $msg = 'thisisdeleted';
773 $msg = 'viewdeleted';
776 $this->makeKnownLinkObj(
777 SpecialPage
::getTitleFor( 'Undelete', $wgTitle->getPrefixedDBkey() ),
778 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $n ) ) );
783 function printableLink() {
784 global $wgOut, $wgFeedClasses, $wgRequest;
786 $baseurl = $_SERVER['REQUEST_URI'];
787 if( strpos( '?', $baseurl ) == false ) {
792 $baseurl = htmlspecialchars( $baseurl );
793 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
795 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
796 if( $wgOut->isSyndicated() ) {
797 foreach( $wgFeedClasses as $format => $class ) {
798 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
799 $s .= " | <a href=\"$feedurl\">{$format}</a>";
805 function pageTitle() {
807 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
811 function pageSubtitle() {
814 $sub = $wgOut->getSubtitle();
816 global $wgExtraSubtitle;
817 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
819 $subpages = $this->subPageSubtitle();
820 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
821 $s = "<p class='subtitle'>{$sub}</p>\n";
825 function subPageSubtitle() {
826 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
828 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
829 $ptext=$wgTitle->getPrefixedText();
830 if(preg_match('/\//',$ptext)) {
831 $links = explode('/',$ptext);
834 foreach($links as $link) {
836 if ($c<count($links)) {
837 $growinglink .= $link;
838 $getlink = $this->makeLink( $growinglink, htmlspecialchars( $link ) );
839 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
843 $subpages .= '< ';
845 $subpages .= $getlink;
854 function nameAndLogin() {
855 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader;
857 $lo = $wgContLang->specialPage( 'Userlogout' );
860 if ( $wgUser->isAnon() ) {
861 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
864 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
865 $wgLang->getNsText( NS_TALK
) );
867 $s .= $n . ' ('.$tl.')';
869 $s .= wfMsg('notloggedin');
872 $rt = $wgTitle->getPrefixedURL();
873 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
875 } else { $q = "returnto={$rt}"; }
877 $s .= "\n<br />" . $this->makeKnownLinkObj(
878 SpecialPage
::getTitleFor( 'Userlogin' ),
879 wfMsg( 'login' ), $q );
881 $n = $wgUser->getName();
882 $rt = $wgTitle->getPrefixedURL();
883 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
884 $wgLang->getNsText( NS_TALK
) );
888 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
889 $n ) . "{$tl}<br />" .
890 $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
891 "returnto={$rt}" ) . ' | ' .
892 $this->specialLink( 'preferences' );
894 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
900 function getSearchLink() {
901 $searchPage = SpecialPage
::getTitleFor( 'Search' );
902 return $searchPage->getLocalURL();
905 function escapeSearchLink() {
906 return htmlspecialchars( $this->getSearchLink() );
909 function searchForm() {
911 $search = $wgRequest->getText( 'search' );
913 $s = '<form name="search" class="inline" method="post" action="'
914 . $this->escapeSearchLink() . "\">\n"
915 . '<input type="text" name="search" size="19" value="'
916 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
917 . '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" /> '
918 . '<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n</form>";
923 function topLinks() {
927 $s = $this->mainPageLink() . $sep
928 . $this->specialLink( 'recentchanges' );
930 if ( $wgOut->isArticleRelated() ) {
931 $s .= $sep . $this->editThisPage()
932 . $sep . $this->historyLink();
934 # Many people don't like this dropdown box
935 #$s .= $sep . $this->specialPagesList();
937 $s .= $this->variantLinks();
939 $s .= $this->extensionTabLinks();
945 * Compatibility for extensions adding functionality through tabs.
946 * Eventually these old skins should be replaced with SkinTemplate-based
950 function extensionTabLinks() {
953 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
954 foreach( $tabs as $tab ) {
955 $s .= ' | ' . Xml
::element( 'a',
956 array( 'href' => $tab['href'] ),
963 * Language/charset variant links for classic-style skins
966 function variantLinks() {
968 /* show links to different language variants */
969 global $wgDisableLangConversion, $wgContLang, $wgTitle;
970 $variants = $wgContLang->getVariants();
971 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
972 foreach( $variants as $code ) {
973 $varname = $wgContLang->getVariantname( $code );
974 if( $varname == 'disable' )
976 $s .= ' | <a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>';
982 function bottomLinks() {
983 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
987 if ( $wgOut->isArticleRelated() ) {
988 $s .= '<strong>' . $this->editThisPage() . '</strong>';
989 if ( $wgUser->isLoggedIn() ) {
990 $s .= $sep . $this->watchThisPage();
992 $s .= $sep . $this->talkLink()
993 . $sep . $this->historyLink()
994 . $sep . $this->whatLinksHere()
995 . $sep . $this->watchPageLinksLink();
997 if ($wgUseTrackbacks)
998 $s .= $sep . $this->trackbackLink();
1000 if ( $wgTitle->getNamespace() == NS_USER
1001 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
1004 $id=User
::idFromName($wgTitle->getText());
1005 $ip=User
::isIP($wgTitle->getText());
1007 if($id ||
$ip) { # both anons and non-anons have contri list
1008 $s .= $sep . $this->userContribsLink();
1010 if( $this->showEmailUser( $id ) ) {
1011 $s .= $sep . $this->emailUserLink();
1014 if ( $wgTitle->getArticleId() ) {
1016 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
1017 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
1018 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
1020 $s .= "<br />\n" . $this->otherLanguages();
1025 function pageStats() {
1026 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1027 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
1029 $oldid = $wgRequest->getVal( 'oldid' );
1030 $diff = $wgRequest->getVal( 'diff' );
1031 if ( ! $wgOut->isArticle() ) { return ''; }
1032 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1033 if ( 0 == $wgArticle->getID() ) { return ''; }
1036 if ( !$wgDisableCounters ) {
1037 $count = $wgLang->formatNum( $wgArticle->getCount() );
1039 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1043 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
1044 require_once('Credits.php');
1045 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
1047 $s .= $this->lastModified();
1050 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
1051 $dbr =& wfGetDB( DB_SLAVE
);
1052 $watchlist = $dbr->tableName( 'watchlist' );
1053 $sql = "SELECT COUNT(*) AS n FROM $watchlist
1054 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
1055 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
1056 $res = $dbr->query( $sql, 'Skin::pageStats');
1057 $x = $dbr->fetchObject( $res );
1058 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
1061 return $s . ' ' . $this->getCopyright();
1064 function getCopyright( $type = 'detect' ) {
1065 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
1067 if ( $type == 'detect' ) {
1068 $oldid = $wgRequest->getVal( 'oldid' );
1069 $diff = $wgRequest->getVal( 'diff' );
1071 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1078 if ( $type == 'history' ) {
1079 $msg = 'history_copyright';
1085 if( $wgRightsPage ) {
1086 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
1087 } elseif( $wgRightsUrl ) {
1088 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1093 $out .= wfMsgForContent( $msg, $link );
1097 function getCopyrightIcon() {
1098 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1100 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1101 $out = $wgCopyrightIcon;
1102 } else if ( $wgRightsIcon ) {
1103 $icon = htmlspecialchars( $wgRightsIcon );
1104 if ( $wgRightsUrl ) {
1105 $url = htmlspecialchars( $wgRightsUrl );
1106 $out .= '<a href="'.$url.'">';
1108 $text = htmlspecialchars( $wgRightsText );
1109 $out .= "<img src=\"$icon\" alt='$text' />";
1110 if ( $wgRightsUrl ) {
1117 function getPoweredBy() {
1118 global $wgStylePath;
1119 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1120 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1124 function lastModified() {
1125 global $wgLang, $wgArticle, $wgLoadBalancer;
1127 $timestamp = $wgArticle->getTimestamp();
1129 $d = $wgLang->date( $timestamp, true );
1130 $t = $wgLang->time( $timestamp, true );
1131 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1135 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
1136 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1141 function logoText( $align = '' ) {
1142 if ( '' != $align ) { $a = " align='{$align}'"; }
1145 $mp = wfMsg( 'mainpage' );
1146 $mptitle = Title
::newMainPage();
1147 $url = ( is_object($mptitle) ?
$mptitle->escapeLocalURL() : '' );
1149 $logourl = $this->getLogo();
1150 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1155 * show a drop-down box of special pages
1157 function specialPagesList() {
1158 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1159 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1160 foreach ( $pages as $name => $page ) {
1161 $pages[$name] = $page->getDescription();
1164 $go = wfMsg( 'go' );
1165 $sp = wfMsg( 'specialpages' );
1166 $spp = $wgContLang->specialPage( 'Specialpages' );
1168 $s = '<form id="specialpages" method="get" class="inline" ' .
1169 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1170 $s .= "<select name=\"wpDropdown\">\n";
1171 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1174 foreach ( $pages as $name => $desc ) {
1175 $p = $wgContLang->specialPage( $name );
1176 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1178 $s .= "</select>\n";
1179 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1184 function mainPageLink() {
1185 $s = $this->makeKnownLinkObj( Title
::newMainPage(), wfMsg( 'mainpage' ) );
1189 function copyrightLink() {
1190 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1191 wfMsg( 'copyrightpagename' ) );
1195 function privacyLink() {
1196 $privacy = wfMsg( 'privacy' );
1197 if ($privacy == '-') {
1200 return $this->makeKnownLink( wfMsgForContent( 'privacypage' ), $privacy);
1204 function aboutLink() {
1205 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
1206 wfMsg( 'aboutsite' ) );
1210 function disclaimerLink() {
1211 $disclaimers = wfMsg( 'disclaimers' );
1212 if ($disclaimers == '-') {
1215 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
1220 function editThisPage() {
1221 global $wgOut, $wgTitle;
1223 if ( ! $wgOut->isArticleRelated() ) {
1224 $s = wfMsg( 'protectedpage' );
1226 if ( $wgTitle->userCanEdit() ) {
1227 $t = wfMsg( 'editthispage' );
1229 $t = wfMsg( 'viewsource' );
1232 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1238 * Return URL options for the 'edit page' link.
1239 * This may include an 'oldid' specifier, if the current page view is such.
1244 function editUrlOptions() {
1247 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1248 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1250 return "action=edit";
1254 function deleteThisPage() {
1255 global $wgUser, $wgTitle, $wgRequest;
1257 $diff = $wgRequest->getVal( 'diff' );
1258 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1259 $t = wfMsg( 'deletethispage' );
1261 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1268 function protectThisPage() {
1269 global $wgUser, $wgTitle, $wgRequest;
1271 $diff = $wgRequest->getVal( 'diff' );
1272 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1273 if ( $wgTitle->isProtected() ) {
1274 $t = wfMsg( 'unprotectthispage' );
1275 $q = 'action=unprotect';
1277 $t = wfMsg( 'protectthispage' );
1278 $q = 'action=protect';
1280 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1287 function watchThisPage() {
1288 global $wgOut, $wgTitle;
1289 ++
$this->mWatchLinkNum
;
1291 if ( $wgOut->isArticleRelated() ) {
1292 if ( $wgTitle->userIsWatching() ) {
1293 $t = wfMsg( 'unwatchthispage' );
1294 $q = 'action=unwatch';
1295 $id = "mw-unwatch-link".$this->mWatchLinkNum
;
1297 $t = wfMsg( 'watchthispage' );
1298 $q = 'action=watch';
1299 $id = 'mw-watch-link'.$this->mWatchLinkNum
;
1301 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q, '', '', " id=\"$id\"" );
1303 $s = wfMsg( 'notanarticle' );
1308 function moveThisPage() {
1311 if ( $wgTitle->userCanMove() ) {
1312 return $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
1313 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1315 // no message if page is protected - would be redundant
1320 function historyLink() {
1323 return $this->makeKnownLinkObj( $wgTitle,
1324 wfMsg( 'history' ), 'action=history' );
1327 function whatLinksHere() {
1330 return $this->makeKnownLinkObj(
1331 SpecialPage
::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ),
1332 wfMsg( 'whatlinkshere' ) );
1335 function userContribsLink() {
1338 return $this->makeKnownLinkObj(
1339 SpecialPage
::getTitleFor( 'Contributions', $wgTitle->getDBkey() ),
1340 wfMsg( 'contributions' ) );
1343 function showEmailUser( $id ) {
1344 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1345 return $wgEnableEmail &&
1346 $wgEnableUserEmail &&
1347 $wgUser->isLoggedIn() && # show only to signed in users
1348 0 != $id; # we can only email to non-anons ..
1349 # '' != $id->getEmail() && # who must have an email address stored ..
1350 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1351 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1354 function emailUserLink() {
1357 return $this->makeKnownLinkObj(
1358 SpecialPage
::getTitleFor( 'Emailuser', $wgTitle->getDBkey() ),
1359 wfMsg( 'emailuser' ) );
1362 function watchPageLinksLink() {
1363 global $wgOut, $wgTitle;
1365 if ( ! $wgOut->isArticleRelated() ) {
1366 return '(' . wfMsg( 'notanarticle' ) . ')';
1368 return $this->makeKnownLinkObj(
1369 SpecialPage
::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ),
1370 wfMsg( 'recentchangeslinked' ) );
1374 function trackbackLink() {
1377 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1378 . wfMsg('trackbacklink') . "</a>";
1381 function otherLanguages() {
1382 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1384 if ( $wgHideInterlanguageLinks ) {
1388 $a = $wgOut->getLanguageLinks();
1389 if ( 0 == count( $a ) ) {
1393 $s = wfMsg( 'otherlanguages' ) . ': ';
1395 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1396 foreach( $a as $l ) {
1397 if ( ! $first ) { $s .= ' | '; }
1400 $nt = Title
::newFromText( $l );
1401 $url = $nt->escapeFullURL();
1402 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1404 if ( '' == $text ) { $text = $l; }
1405 $style = $this->getExternalLinkAttributes( $l, $text );
1406 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1408 if($wgContLang->isRTL()) $s .= '</span>';
1412 function bugReportsLink() {
1413 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1414 wfMsg( 'bugreports' ) );
1418 function dateLink() {
1419 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1420 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1422 $id = $t1->getArticleID();
1425 $s = $this->makeBrokenLink( $t1->getText() );
1427 $s = $this->makeKnownLink( $t1->getText() );
1431 $id = $t2->getArticleID();
1434 $s .= $this->makeBrokenLink( $t2->getText() );
1436 $s .= $this->makeKnownLink( $t2->getText() );
1441 function talkLink() {
1444 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1445 # No discussion links for special pages
1449 if( $wgTitle->isTalkPage() ) {
1450 $link = $wgTitle->getSubjectPage();
1451 switch( $link->getNamespace() ) {
1453 $text = wfMsg( 'articlepage' );
1456 $text = wfMsg( 'userpage' );
1459 $text = wfMsg( 'projectpage' );
1462 $text = wfMsg( 'imagepage' );
1465 $text = wfMsg( 'mediawikipage' );
1468 $text = wfMsg( 'templatepage' );
1471 $text = wfMsg( 'viewhelppage' );
1474 $text = wfMsg( 'categorypage' );
1477 $text = wfMsg( 'articlepage' );
1480 $link = $wgTitle->getTalkPage();
1481 $text = wfMsg( 'talkpage' );
1484 $s = $this->makeLinkObj( $link, $text );
1489 function commentLink() {
1490 global $wgTitle, $wgOut;
1492 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1496 # __NEWSECTIONLINK___ changes behaviour here
1497 # If it's present, the link points to this page, otherwise
1498 # it points to the talk page
1499 if( $wgTitle->isTalkPage() ) {
1501 } elseif( $wgOut->showNewSectionLink() ) {
1504 $title =& $wgTitle->getTalkPage();
1507 return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1510 /* these are used extensively in SkinTemplate, but also some other places */
1511 static function makeMainPageUrl( $urlaction = '' ) {
1512 $title = Title
::newMainPage();
1513 self
::checkTitle( $title, $name );
1514 return $title->getLocalURL( $urlaction );
1517 static function makeSpecialUrl( $name, $urlaction = '' ) {
1518 $title = SpecialPage
::getTitleFor( $name );
1519 return $title->getLocalURL( $urlaction );
1522 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1523 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1524 return $title->getLocalURL( $urlaction );
1527 static function makeI18nUrl( $name, $urlaction = '' ) {
1528 $title = Title
::newFromText( wfMsgForContent( $name ) );
1529 self
::checkTitle( $title, $name );
1530 return $title->getLocalURL( $urlaction );
1533 static function makeUrl( $name, $urlaction = '' ) {
1534 $title = Title
::newFromText( $name );
1535 self
::checkTitle( $title, $name );
1536 return $title->getLocalURL( $urlaction );
1539 # If url string starts with http, consider as external URL, else
1541 static function makeInternalOrExternalUrl( $name ) {
1542 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1545 return self
::makeUrl( $name );
1549 # this can be passed the NS number as defined in Language.php
1550 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1551 $title = Title
::makeTitleSafe( $namespace, $name );
1552 self
::checkTitle( $title, $name );
1553 return $title->getLocalURL( $urlaction );
1556 /* these return an array with the 'href' and boolean 'exists' */
1557 static function makeUrlDetails( $name, $urlaction = '' ) {
1558 $title = Title
::newFromText( $name );
1559 self
::checkTitle( $title, $name );
1561 'href' => $title->getLocalURL( $urlaction ),
1562 'exists' => $title->getArticleID() != 0 ?
true : false
1567 * Make URL details where the article exists (or at least it's convenient to think so)
1569 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1570 $title = Title
::newFromText( $name );
1571 self
::checkTitle( $title, $name );
1573 'href' => $title->getLocalURL( $urlaction ),
1578 # make sure we have some title to operate on
1579 static function checkTitle( &$title, &$name ) {
1580 if( !is_object( $title ) ) {
1581 $title = Title
::newFromText( $name );
1582 if( !is_object( $title ) ) {
1583 $title = Title
::newFromText( '--error: link target missing--' );
1589 * Build an array that represents the sidebar(s), the navigation bar among them
1594 function buildSidebar() {
1595 global $parserMemc, $wgEnableSidebarCache;
1596 global $wgLang, $wgContLang;
1598 $fname = 'SkinTemplate::buildSidebar';
1600 wfProfileIn( $fname );
1602 $key = wfMemcKey( 'sidebar' );
1603 $cacheSidebar = $wgEnableSidebarCache &&
1604 ($wgLang->getCode() == $wgContLang->getCode());
1606 if ($cacheSidebar) {
1607 $cachedsidebar = $parserMemc->get( $key );
1608 if ($cachedsidebar!="") {
1609 wfProfileOut($fname);
1610 return $cachedsidebar;
1615 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1616 foreach ($lines as $line) {
1617 if (strpos($line, '*') !== 0)
1619 if (strpos($line, '**') !== 0) {
1620 $line = trim($line, '* ');
1623 if (strpos($line, '|') !== false) { // sanity check
1624 $line = explode( '|' , trim($line, '* '), 2 );
1625 $link = wfMsgForContent( $line[0] );
1628 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1630 if (wfEmptyMsg($line[0], $link))
1633 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1636 $title = Title
::newFromText( $link );
1638 $title = $title->fixSpecialName();
1639 $href = $title->getLocalURL();
1641 $href = 'INVALID-TITLE';
1645 $bar[$heading][] = array(
1648 'id' => 'n-' . strtr($line[1], ' ', '-'),
1651 } else { continue; }
1655 $parserMemc->set( $key, $bar, 86400 );
1656 wfProfileOut( $fname );