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
28 /** Constructor, call parent constructor */
29 function Skin() { parent
::Linker(); }
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
51 if(preg_match('/^([^.]*)\.php$/',$file, $matches)) {
53 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
57 $skinsInitialised = true;
58 wfProfileOut( __METHOD__
. '-init' );
60 return $wgValidSkinNames;
64 * Normalize a skin preference value to a form that can be loaded.
65 * If a skin can't be found, it will fall back to the configured
66 * default (or the old 'Classic' skin if that's broken).
71 static function normalizeKey( $key ) {
72 global $wgDefaultSkin;
73 $skinNames = Skin
::getSkinNames();
76 // Don't return the default immediately;
77 // in a misconfiguration we need to fall back.
78 $key = $wgDefaultSkin;
81 if( isset( $skinNames[$key] ) ) {
85 // Older versions of the software used a numeric setting
86 // in the user preferences.
92 if( isset( $fallback[$key] ) ){
93 $key = $fallback[$key];
96 if( isset( $skinNames[$key] ) ) {
99 // The old built-in skin
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];
118 # Grab the skin class and initialise it.
119 // Preload base classes to work around APC/PHP5 bug
120 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
121 if( file_exists( $deps ) ) include_once( $deps );
122 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
124 # Check if we got if not failback to default skin
125 $className = 'Skin'.$skinName;
126 if( !class_exists( $className ) ) {
127 # DO NOT die if the class isn't found. This breaks maintenance
128 # scripts and can cause a user account to be unrecoverable
129 # except by SQL manipulation if a previously valid skin name
130 # is no longer valid.
131 wfDebug( "Skin class does not exist: $className\n" );
132 $className = 'SkinStandard';
133 require_once( "{$wgStyleDirectory}/Standard.php" );
135 $skin = new $className;
139 /** @return string path to the skin stylesheet */
140 function getStylesheet() {
141 return 'common/wikistandard.css';
144 /** @return string skin name */
145 function getSkinName() {
149 function qbSetting() {
150 global $wgOut, $wgUser;
152 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
153 $q = $wgUser->getOption( 'quickbar' );
154 if ( '' == $q ) { $q = 0; }
158 function initPage( &$out ) {
159 global $wgFavicon, $wgScriptPath, $wgSitename, $wgLanguageCode, $wgLanguageNames;
161 $fname = 'Skin::initPage';
162 wfProfileIn( $fname );
164 if( false !== $wgFavicon ) {
165 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
168 # OpenSearch description link
169 $out->addLink( array(
171 'type' => 'application/opensearchdescription+xml',
172 'href' => "$wgScriptPath/opensearch_desc.php",
173 'title' => "$wgSitename ({$wgLanguageNames[$wgLanguageCode]})",
176 $this->addMetadataLinks($out);
178 $this->mRevisionId
= $out->mRevisionId
;
180 $this->preloadExistence();
182 wfProfileOut( $fname );
186 * Preload the existence of three commonly-requested pages in a single query
188 function preloadExistence() {
189 global $wgUser, $wgTitle;
191 if ( $wgTitle->isTalkPage() ) {
192 $otherTab = $wgTitle->getSubjectPage();
194 $otherTab = $wgTitle->getTalkPage();
196 $lb = new LinkBatch( array(
197 $wgUser->getUserPage(),
198 $wgUser->getTalkPage(),
204 function addMetadataLinks( &$out ) {
205 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
206 global $wgRightsPage, $wgRightsUrl;
208 if( $out->isArticleRelated() ) {
209 # note: buggy CC software only reads first "meta" link
210 if( $wgEnableCreativeCommonsRdf ) {
211 $out->addMetadataLink( array(
212 'title' => 'Creative Commons',
213 'type' => 'application/rdf+xml',
214 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
216 if( $wgEnableDublinCoreRdf ) {
217 $out->addMetadataLink( array(
218 'title' => 'Dublin Core',
219 'type' => 'application/rdf+xml',
220 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
224 if( $wgRightsPage ) {
225 $copy = Title
::newFromText( $wgRightsPage );
227 $copyright = $copy->getLocalURL();
230 if( !$copyright && $wgRightsUrl ) {
231 $copyright = $wgRightsUrl;
234 $out->addLink( array(
235 'rel' => 'copyright',
236 'href' => $copyright ) );
240 function outputPage( &$out ) {
241 global $wgDebugComments;
243 wfProfileIn( 'Skin::outputPage' );
244 $this->initPage( $out );
246 $out->out( $out->headElement() );
248 $out->out( "\n<body" );
249 $ops = $this->getBodyOptions();
250 foreach ( $ops as $name => $val ) {
251 $out->out( " $name='$val'" );
254 if ( $wgDebugComments ) {
255 $out->out( "<!-- Wiki debugging output:\n" .
256 $out->mDebugtext
. "-->\n" );
259 $out->out( $this->beforeContent() );
261 $out->out( $out->mBodytext
. "\n" );
263 $out->out( $this->afterContent() );
265 $out->out( $this->bottomScripts() );
267 $out->out( $out->reportTime() );
269 $out->out( "\n</body></html>" );
272 static function makeGlobalVariablesScript( $data ) {
273 $r = '<script type= "' . $data['jsmimetype'] . '">
274 var skin = "' . Xml
::escapeJsString( $data['skinname'] ) . '";
275 var stylepath = "' . Xml
::escapeJsString( $data['stylepath'] ) . '";
277 var wgArticlePath = "' . Xml
::escapeJsString( $data['articlepath'] ) . '";
278 var wgScriptPath = "' . Xml
::escapeJsString( $data['scriptpath'] ) . '";
279 var wgServer = "' . Xml
::escapeJsString( $data['serverurl'] ) . '";
281 var wgCanonicalNamespace = "' . Xml
::escapeJsString( $data['nscanonical'] ) . '";
282 var wgNamespaceNumber = ' . (int)$data['nsnumber'] . ';
283 var wgPageName = "' . Xml
::escapeJsString( $data['titleprefixeddbkey'] ) . '";
284 var wgTitle = "' . Xml
::escapeJsString( $data['titletext'] ) . '";
285 var wgArticleId = ' . (int)$data['articleid'] . ';
286 var wgIsArticle = ' . ( $data['isarticle'] ?
'true' : 'false' ) . ';
288 var wgUserName = ' . ( $data['username'] == NULL ?
'null' : ( '"' . Xml
::escapeJsString( $data['username'] ) . '"' ) ) . ';
289 var wgUserLanguage = "' . Xml
::escapeJsString( $data['userlang'] ) . '";
290 var wgContentLanguage = "' . Xml
::escapeJsString( $data['lang'] ) . '";
297 function getHeadScripts() {
298 global $wgStylePath, $wgUser, $wgAllowUserJs, $wgJsMimeType, $wgStyleVersion;
299 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
300 global $wgTitle, $wgCanonicalNamespaceNames, $wgOut;
302 $ns = $wgTitle->getNamespace();
303 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
306 'jsmimetype' => $wgJsMimeType,
307 'skinname' => $this->getSkinName(),
308 'stylepath' => $wgStylePath,
309 'articlepath' => $wgArticlePath,
310 'scriptpath' => $wgScriptPath,
311 'serverurl' => $wgServer,
312 'nscanonical' => $nsname,
313 'nsnumber' => $wgTitle->getNamespace(),
314 'titleprefixeddbkey' => $wgTitle->getPrefixedDBKey(),
315 'titletext' => $wgTitle->getText(),
316 'articleid' => $wgTitle->getArticleId(),
317 'isarticle' => $wgOut->isArticle(),
318 'username' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
319 'userlang' => $wgLang->getCode(),
320 'lang' => $wgContLang->getCode(),
323 $r = self
::makeGlobalVariablesScript( $vars );
325 $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n";
328 if ($wgUser->isLoggedIn()) {
329 $r .= "<script type=\"$wgJsMimeType\" src=\"".htmlspecialchars(self
::makeUrl('-','action=raw&smaxage=0&gen=js'))."\"><!-- site js --></script>\n";
331 $r .= "<script type=\"$wgJsMimeType\" src=\"".htmlspecialchars(self
::makeUrl('-','action=raw&gen=js'))."\"><!-- site js --></script>\n";
334 if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
335 $userpage = $wgUser->getUserPage();
336 $userjs = htmlspecialchars( self
::makeUrl(
337 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
338 'action=raw&ctype='.$wgJsMimeType));
339 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
345 * To make it harder for someone to slip a user a fake
346 * user-JavaScript or user-CSS preview, a random token
347 * is associated with the login session. If it's not
348 * passed back with the preview request, we won't render
351 * @param string $action
355 function userCanPreview( $action ) {
356 global $wgTitle, $wgRequest, $wgUser;
358 if( $action != 'submit' )
360 if( !$wgRequest->wasPosted() )
362 if( !$wgTitle->userCanEditCssJsSubpage() )
364 return $wgUser->matchEditToken(
365 $wgRequest->getVal( 'wpEditToken' ) );
368 # get the user/site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way)
369 function getUserStylesheet() {
370 global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage, $wgStyleVersion;
371 $sheet = $this->getStylesheet();
372 $action = $wgRequest->getText('action');
373 $s = "@import \"$wgStylePath/common/common.css?$wgStyleVersion\";\n";
374 $s .= "@import \"$wgStylePath/$sheet?$wgStyleVersion\";\n";
375 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css?$wgStyleVersion\";\n";
377 $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
378 $s .= '@import "' . self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n" .
379 '@import "' . self
::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
381 $s .= $this->doGetUserStyles();
386 * This returns MediaWiki:Common.js. For some bizarre reason, it does
387 * *not* return any custom user JS from user subpages. Huh?
391 function getUserJs() {
392 $fname = 'Skin::getUserJs';
393 wfProfileIn( $fname );
396 $s = "/* generated javascript */\n";
397 $s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';";
398 $s .= "\n\n/* MediaWiki:Common.js */\n";
399 $commonJs = wfMsgForContent('Common.js');
400 if ( !wfEmptyMsg ( 'Common.js', $commonJs ) ) {
404 wfProfileOut( $fname );
409 * Return html code that include User stylesheets
411 function getUserStyles() {
412 $s = "<style type='text/css'>\n";
413 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
414 $s .= $this->getUserStylesheet();
415 $s .= "/*]]>*/ /* */\n";
421 * Some styles that are set by user through the user settings interface.
423 function doGetUserStyles() {
424 global $wgUser, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
428 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
429 if($wgTitle->isCssSubpage() && $this->userCanPreview( $wgRequest->getText( 'action' ) ) ) {
430 $s .= $wgRequest->getText('wpTextbox1');
432 $userpage = $wgUser->getUserPage();
433 $s.= '@import "'.self
::makeUrl(
434 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
435 'action=raw&ctype=text/css').'";'."\n";
439 return $s . $this->reallyDoGetUserStyles();
442 function reallyDoGetUserStyles() {
445 if (($undopt = $wgUser->getOption("underline")) != 2) {
446 $underline = $undopt ?
'underline' : 'none';
447 $s .= "a { text-decoration: $underline; }\n";
449 if( $wgUser->getOption( 'highlightbroken' ) ) {
450 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
453 a.new, #quickbar a.new,
454 a.stub, #quickbar a.stub {
456 text-decoration: inherit;
458 a.new:after, #quickbar a.new:after {
461 text-decoration: $underline;
463 a.stub:after, #quickbar a.stub:after {
466 text-decoration: $underline;
470 if( $wgUser->getOption( 'justify' ) ) {
471 $s .= "#article, #bodyContent { text-align: justify; }\n";
473 if( !$wgUser->getOption( 'showtoc' ) ) {
474 $s .= "#toc { display: none; }\n";
476 if( !$wgUser->getOption( 'editsection' ) ) {
477 $s .= ".editsection { display: none; }\n";
482 function getBodyOptions() {
483 global $wgUser, $wgTitle, $wgOut, $wgRequest, $wgContLang;
485 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
487 if ( 0 != $wgTitle->getNamespace() ) {
488 $a = array( 'bgcolor' => '#ffffec' );
490 else $a = array( 'bgcolor' => '#FFFFFF' );
491 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
492 $wgTitle->userCanEdit() ) {
493 $t = wfMsg( 'editthispage' );
494 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
495 $s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
496 $a +
= array ('ondblclick' => $s);
499 $a['onload'] = $wgOut->getOnloadHandler();
500 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
501 if( $a['onload'] != '' ) {
504 $a['onload'] .= 'setupRightClickEdit()';
506 $a['class'] = 'ns-'.$wgTitle->getNamespace().' '.($wgContLang->isRTL() ?
"rtl" : "ltr").
507 ' '.Sanitizer
::escapeId( 'page-'.$wgTitle->getPrefixedText() );
520 * This will be called immediately after the <body> tag. Split into
521 * two functions to make it easier to subclass.
523 function beforeContent() {
524 return $this->doBeforeContent();
527 function doBeforeContent() {
529 $fname = 'Skin::doBeforeContent';
530 wfProfileIn( $fname );
533 $qb = $this->qbSetting();
535 if( $langlinks = $this->otherLanguages() ) {
541 $borderhack = 'class="top"';
544 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
545 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
548 $left = ($qb == 1 ||
$qb == 3);
549 if($wgContLang->isRTL()) $left = !$left;
552 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
553 $this->logoText() . '</td>';
555 $s .= $this->getQuickbarCompensator( $rows );
557 $l = $wgContLang->isRTL() ?
'right' : 'left';
558 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
560 $s .= $this->topLinks() ;
561 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
563 $r = $wgContLang->isRTL() ?
"left" : "right";
564 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
565 $s .= $this->nameAndLogin();
566 $s .= "\n<br />" . $this->searchForm() . "</td>";
569 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
572 if ( $shove && !$left ) { # Right
573 $s .= $this->getQuickbarCompensator( $rows );
575 $s .= "</tr>\n</table>\n</div>\n";
576 $s .= "\n<div id='article'>\n";
578 $notice = wfGetSiteNotice();
580 $s .= "\n<div id='siteNotice'>$notice</div>\n";
582 $s .= $this->pageTitle();
583 $s .= $this->pageSubtitle() ;
584 $s .= $this->getCategories();
585 wfProfileOut( $fname );
590 function getCategoryLinks () {
591 global $wgOut, $wgTitle, $wgUseCategoryBrowser;
594 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
597 $sep = wfMsgHtml( 'catseparator' );
599 // Use Unicode bidi embedding override characters,
600 // to make sure links don't smash each other up in ugly ways.
601 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
602 $embed = "<span dir='$dir'>";
604 $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $wgOut->mCategoryLinks
) . $pop;
606 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escape' ), count( $wgOut->mCategoryLinks
) );
607 $s = $this->makeLinkObj( Title
::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
610 # optional 'dmoz-like' category browser. Will be shown under the list
611 # of categories an article belong to
612 if($wgUseCategoryBrowser) {
613 $s .= '<br /><hr />';
615 # get a big array of the parents tree
616 $parenttree = $wgTitle->getParentCategoryTree();
617 # Skin object passed by reference cause it can not be
618 # accessed under the method subfunction drawCategoryBrowser
619 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
620 # Clean out bogus first entry and sort them
623 # Output one per line
624 $s .= implode("<br />\n", $tempout);
630 /** Render the array as a serie of links.
631 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
632 * @param &skin Object: skin passed by reference
633 * @return String separated by >, terminate with "\n"
635 function drawCategoryBrowser($tree, &$skin) {
637 foreach ($tree as $element => $parent) {
638 if (empty($parent)) {
639 # element start a new list
642 # grab the others elements
643 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
645 # add our current element to the list
646 $eltitle = Title
::NewFromText($element);
647 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
652 function getCategories() {
653 $catlinks=$this->getCategoryLinks();
654 if(!empty($catlinks)) {
655 return "<p class='catlinks'>{$catlinks}</p>";
659 function getQuickbarCompensator( $rows = 1 ) {
660 return "<td width='152' rowspan='{$rows}'> </td>";
664 * This gets called shortly before the \</body\> tag.
665 * @return String HTML to be put before \</body\>
667 function afterContent() {
668 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
669 return $printfooter . $this->doAfterContent();
673 * This gets called shortly before the \</body\> tag.
674 * @return String HTML-wrapped JS code to be put before \</body\>
676 function bottomScripts() {
677 global $wgJsMimeType;
678 return "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
681 /** @return string Retrievied from HTML text */
682 function printSource() {
684 $url = htmlspecialchars( $wgTitle->getFullURL() );
685 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
688 function printFooter() {
689 return "<p>" . $this->printSource() .
690 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
693 /** overloaded by derived classes */
694 function doAfterContent() { }
696 function pageTitleLinks() {
697 global $wgOut, $wgTitle, $wgUser, $wgRequest;
699 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
700 $action = $wgRequest->getText( 'action' );
702 $s = $this->printableLink();
703 $disclaimer = $this->disclaimerLink(); # may be empty
705 $s .= ' | ' . $disclaimer;
707 $privacy = $this->privacyLink(); # may be empty too
709 $s .= ' | ' . $privacy;
712 if ( $wgOut->isArticleRelated() ) {
713 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
714 $name = $wgTitle->getDBkey();
715 $image = new Image( $wgTitle );
716 if( $image->exists() ) {
717 $link = htmlspecialchars( $image->getURL() );
718 $style = $this->getInternalLinkAttributes( $link, $name );
719 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
723 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
724 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
725 wfMsg( 'currentrev' ) );
728 if ( $wgUser->getNewtalk() ) {
729 # do not show "You have new messages" text when we are viewing our
731 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
732 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
733 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
734 $s.= ' | <strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
736 $wgOut->setSquidMaxage(0);
737 $wgOut->enableClientCache(false);
741 $undelete = $this->getUndeleteLink();
742 if( !empty( $undelete ) ) {
743 $s .= ' | '.$undelete;
748 function getUndeleteLink() {
749 global $wgUser, $wgTitle, $wgContLang, $action;
750 if( $wgUser->isAllowed( 'deletedhistory' ) &&
751 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
752 ($n = $wgTitle->isDeleted() ) )
754 if ( $wgUser->isAllowed( 'delete' ) ) {
755 $msg = 'thisisdeleted';
757 $msg = 'viewdeleted';
760 $this->makeKnownLink(
761 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
762 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $n ) ) );
767 function printableLink() {
768 global $wgOut, $wgFeedClasses, $wgRequest;
770 $baseurl = $_SERVER['REQUEST_URI'];
771 if( strpos( '?', $baseurl ) == false ) {
776 $baseurl = htmlspecialchars( $baseurl );
777 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
779 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
780 if( $wgOut->isSyndicated() ) {
781 foreach( $wgFeedClasses as $format => $class ) {
782 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
783 $s .= " | <a href=\"$feedurl\">{$format}</a>";
789 function pageTitle() {
791 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
795 function pageSubtitle() {
798 $sub = $wgOut->getSubtitle();
800 global $wgExtraSubtitle;
801 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
803 $subpages = $this->subPageSubtitle();
804 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
805 $s = "<p class='subtitle'>{$sub}</p>\n";
809 function subPageSubtitle() {
810 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
812 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
813 $ptext=$wgTitle->getPrefixedText();
814 if(preg_match('/\//',$ptext)) {
815 $links = explode('/',$ptext);
818 foreach($links as $link) {
820 if ($c<count($links)) {
821 $growinglink .= $link;
822 $getlink = $this->makeLink( $growinglink, htmlspecialchars( $link ) );
823 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
827 $subpages .= '< ';
829 $subpages .= $getlink;
838 function nameAndLogin() {
839 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader;
841 $li = $wgContLang->specialPage( 'Userlogin' );
842 $lo = $wgContLang->specialPage( 'Userlogout' );
845 if ( $wgUser->isAnon() ) {
846 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
849 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
850 $wgLang->getNsText( NS_TALK
) );
852 $s .= $n . ' ('.$tl.')';
854 $s .= wfMsg('notloggedin');
857 $rt = $wgTitle->getPrefixedURL();
858 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
860 } else { $q = "returnto={$rt}"; }
862 $s .= "\n<br />" . $this->makeKnownLinkObj(
863 SpecialPage
::getTitleFor( 'Userlogin' ),
864 wfMsg( 'login' ), $q );
866 $n = $wgUser->getName();
867 $rt = $wgTitle->getPrefixedURL();
868 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
869 $wgLang->getNsText( NS_TALK
) );
873 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
874 $n ) . "{$tl}<br />" .
875 $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
876 "returnto={$rt}" ) . ' | ' .
877 $this->specialLink( 'preferences' );
879 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
885 function getSearchLink() {
886 $searchPage = SpecialPage
::getTitleFor( 'Search' );
887 return $searchPage->getLocalURL();
890 function escapeSearchLink() {
891 return htmlspecialchars( $this->getSearchLink() );
894 function searchForm() {
896 $search = $wgRequest->getText( 'search' );
898 $s = '<form name="search" class="inline" method="post" action="'
899 . $this->escapeSearchLink() . "\">\n"
900 . '<input type="text" name="search" size="19" value="'
901 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
902 . '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" /> '
903 . '<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n</form>";
908 function topLinks() {
912 $s = $this->mainPageLink() . $sep
913 . $this->specialLink( 'recentchanges' );
915 if ( $wgOut->isArticleRelated() ) {
916 $s .= $sep . $this->editThisPage()
917 . $sep . $this->historyLink();
919 # Many people don't like this dropdown box
920 #$s .= $sep . $this->specialPagesList();
922 $s .= $this->variantLinks();
924 $s .= $this->extensionTabLinks();
930 * Compatibility for extensions adding functionality through tabs.
931 * Eventually these old skins should be replaced with SkinTemplate-based
935 function extensionTabLinks() {
938 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
939 foreach( $tabs as $tab ) {
940 $s .= ' | ' . Xml
::element( 'a',
941 array( 'href' => $tab['href'] ),
948 * Language/charset variant links for classic-style skins
951 function variantLinks() {
953 /* show links to different language variants */
954 global $wgDisableLangConversion, $wgContLang, $wgTitle;
955 $variants = $wgContLang->getVariants();
956 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
957 foreach( $variants as $code ) {
958 $varname = $wgContLang->getVariantname( $code );
959 if( $varname == 'disable' )
961 $s .= ' | <a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>';
967 function bottomLinks() {
968 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
972 if ( $wgOut->isArticleRelated() ) {
973 $s .= '<strong>' . $this->editThisPage() . '</strong>';
974 if ( $wgUser->isLoggedIn() ) {
975 $s .= $sep . $this->watchThisPage();
977 $s .= $sep . $this->talkLink()
978 . $sep . $this->historyLink()
979 . $sep . $this->whatLinksHere()
980 . $sep . $this->watchPageLinksLink();
982 if ($wgUseTrackbacks)
983 $s .= $sep . $this->trackbackLink();
985 if ( $wgTitle->getNamespace() == NS_USER
986 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
989 $id=User
::idFromName($wgTitle->getText());
990 $ip=User
::isIP($wgTitle->getText());
992 if($id ||
$ip) { # both anons and non-anons have contri list
993 $s .= $sep . $this->userContribsLink();
995 if( $this->showEmailUser( $id ) ) {
996 $s .= $sep . $this->emailUserLink();
999 if ( $wgTitle->getArticleId() ) {
1001 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
1002 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
1003 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
1005 $s .= "<br />\n" . $this->otherLanguages();
1010 function pageStats() {
1011 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1012 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
1014 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
1015 if ( ! $wgOut->isArticle() ) { return ''; }
1016 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1017 if ( 0 == $wgArticle->getID() ) { return ''; }
1020 if ( !$wgDisableCounters ) {
1021 $count = $wgLang->formatNum( $wgArticle->getCount() );
1023 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1027 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
1028 require_once('Credits.php');
1029 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
1031 $s .= $this->lastModified();
1034 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
1035 $dbr =& wfGetDB( DB_SLAVE
);
1036 $watchlist = $dbr->tableName( 'watchlist' );
1037 $sql = "SELECT COUNT(*) AS n FROM $watchlist
1038 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
1039 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
1040 $res = $dbr->query( $sql, 'Skin::pageStats');
1041 $x = $dbr->fetchObject( $res );
1042 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
1045 return $s . ' ' . $this->getCopyright();
1048 function getCopyright( $type = 'detect' ) {
1049 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
1051 if ( $type == 'detect' ) {
1052 $oldid = $wgRequest->getVal( 'oldid' );
1053 $diff = $wgRequest->getVal( 'diff' );
1055 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1062 if ( $type == 'history' ) {
1063 $msg = 'history_copyright';
1069 if( $wgRightsPage ) {
1070 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
1071 } elseif( $wgRightsUrl ) {
1072 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1077 $out .= wfMsgForContent( $msg, $link );
1081 function getCopyrightIcon() {
1082 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1084 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1085 $out = $wgCopyrightIcon;
1086 } else if ( $wgRightsIcon ) {
1087 $icon = htmlspecialchars( $wgRightsIcon );
1088 if ( $wgRightsUrl ) {
1089 $url = htmlspecialchars( $wgRightsUrl );
1090 $out .= '<a href="'.$url.'">';
1092 $text = htmlspecialchars( $wgRightsText );
1093 $out .= "<img src=\"$icon\" alt='$text' />";
1094 if ( $wgRightsUrl ) {
1101 function getPoweredBy() {
1102 global $wgStylePath;
1103 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1104 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
1108 function lastModified() {
1109 global $wgLang, $wgArticle, $wgLoadBalancer;
1111 $timestamp = $wgArticle->getTimestamp();
1113 $d = $wgLang->date( $timestamp, true );
1114 $t = $wgLang->time( $timestamp, true );
1115 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1119 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
1120 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1125 function logoText( $align = '' ) {
1126 if ( '' != $align ) { $a = " align='{$align}'"; }
1129 $mp = wfMsg( 'mainpage' );
1130 $titleObj = Title
::newFromText( $mp );
1131 if ( is_object( $titleObj ) ) {
1132 $url = $titleObj->escapeLocalURL();
1137 $logourl = $this->getLogo();
1138 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1143 * show a drop-down box of special pages
1145 function specialPagesList() {
1146 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1148 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1149 foreach ( $pages as $name => $page ) {
1150 $pages[$name] = $page->getDescription();
1153 $go = wfMsg( 'go' );
1154 $sp = wfMsg( 'specialpages' );
1155 $spp = $wgContLang->specialPage( 'Specialpages' );
1157 $s = '<form id="specialpages" method="get" class="inline" ' .
1158 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1159 $s .= "<select name=\"wpDropdown\">\n";
1160 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1163 foreach ( $pages as $name => $desc ) {
1164 $p = $wgContLang->specialPage( $name );
1165 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1167 $s .= "</select>\n";
1168 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1173 function mainPageLink() {
1174 $mp = wfMsgForContent( 'mainpage' );
1175 $mptxt = wfMsg( 'mainpage');
1176 $s = $this->makeKnownLink( $mp, $mptxt );
1180 function copyrightLink() {
1181 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1182 wfMsg( 'copyrightpagename' ) );
1186 function privacyLink() {
1187 $privacy = wfMsg( 'privacy' );
1188 if ($privacy == '-') {
1191 return $this->makeKnownLink( wfMsgForContent( 'privacypage' ), $privacy);
1195 function aboutLink() {
1196 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
1197 wfMsg( 'aboutsite' ) );
1201 function disclaimerLink() {
1202 $disclaimers = wfMsg( 'disclaimers' );
1203 if ($disclaimers == '-') {
1206 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
1211 function editThisPage() {
1212 global $wgOut, $wgTitle;
1214 if ( ! $wgOut->isArticleRelated() ) {
1215 $s = wfMsg( 'protectedpage' );
1217 if ( $wgTitle->userCanEdit() ) {
1218 $t = wfMsg( 'editthispage' );
1220 $t = wfMsg( 'viewsource' );
1223 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1229 * Return URL options for the 'edit page' link.
1230 * This may include an 'oldid' specifier, if the current page view is such.
1235 function editUrlOptions() {
1238 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1239 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1241 return "action=edit";
1245 function deleteThisPage() {
1246 global $wgUser, $wgTitle, $wgRequest;
1248 $diff = $wgRequest->getVal( 'diff' );
1249 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1250 $t = wfMsg( 'deletethispage' );
1252 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1259 function protectThisPage() {
1260 global $wgUser, $wgTitle, $wgRequest;
1262 $diff = $wgRequest->getVal( 'diff' );
1263 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1264 if ( $wgTitle->isProtected() ) {
1265 $t = wfMsg( 'unprotectthispage' );
1266 $q = 'action=unprotect';
1268 $t = wfMsg( 'protectthispage' );
1269 $q = 'action=protect';
1271 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1278 function watchThisPage() {
1279 global $wgOut, $wgTitle;
1281 if ( $wgOut->isArticleRelated() ) {
1282 if ( $wgTitle->userIsWatching() ) {
1283 $t = wfMsg( 'unwatchthispage' );
1284 $q = 'action=unwatch';
1286 $t = wfMsg( 'watchthispage' );
1287 $q = 'action=watch';
1289 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1291 $s = wfMsg( 'notanarticle' );
1296 function moveThisPage() {
1299 if ( $wgTitle->userCanMove() ) {
1300 return $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
1301 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1303 // no message if page is protected - would be redundant
1308 function historyLink() {
1311 return $this->makeKnownLinkObj( $wgTitle,
1312 wfMsg( 'history' ), 'action=history' );
1315 function whatLinksHere() {
1318 return $this->makeKnownLinkObj(
1319 SpecialPage
::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ),
1320 wfMsg( 'whatlinkshere' ) );
1323 function userContribsLink() {
1326 return $this->makeKnownLinkObj(
1327 SpecialPage
::getTitleFor( 'Contributions', $wgTitle->getDBkey() ),
1328 wfMsg( 'contributions' ) );
1331 function showEmailUser( $id ) {
1332 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1333 return $wgEnableEmail &&
1334 $wgEnableUserEmail &&
1335 $wgUser->isLoggedIn() && # show only to signed in users
1336 0 != $id; # we can only email to non-anons ..
1337 # '' != $id->getEmail() && # who must have an email address stored ..
1338 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1339 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1342 function emailUserLink() {
1345 return $this->makeKnownLinkObj(
1346 SpecialPage
::getTitleFor( 'Emailuser', $wgTitle->getDBkey() ),
1347 wfMsg( 'emailuser' ) );
1350 function watchPageLinksLink() {
1351 global $wgOut, $wgTitle;
1353 if ( ! $wgOut->isArticleRelated() ) {
1354 return '(' . wfMsg( 'notanarticle' ) . ')';
1356 return $this->makeKnownLinkObj(
1357 SpecialPage
::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ),
1358 wfMsg( 'recentchangeslinked' ) );
1362 function trackbackLink() {
1365 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1366 . wfMsg('trackbacklink') . "</a>";
1369 function otherLanguages() {
1370 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1372 if ( $wgHideInterlanguageLinks ) {
1376 $a = $wgOut->getLanguageLinks();
1377 if ( 0 == count( $a ) ) {
1381 $s = wfMsg( 'otherlanguages' ) . ': ';
1383 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1384 foreach( $a as $l ) {
1385 if ( ! $first ) { $s .= ' | '; }
1388 $nt = Title
::newFromText( $l );
1389 $url = $nt->escapeFullURL();
1390 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1392 if ( '' == $text ) { $text = $l; }
1393 $style = $this->getExternalLinkAttributes( $l, $text );
1394 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1396 if($wgContLang->isRTL()) $s .= '</span>';
1400 function bugReportsLink() {
1401 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1402 wfMsg( 'bugreports' ) );
1406 function dateLink() {
1407 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1408 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1410 $id = $t1->getArticleID();
1413 $s = $this->makeBrokenLink( $t1->getText() );
1415 $s = $this->makeKnownLink( $t1->getText() );
1419 $id = $t2->getArticleID();
1422 $s .= $this->makeBrokenLink( $t2->getText() );
1424 $s .= $this->makeKnownLink( $t2->getText() );
1429 function talkLink() {
1432 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1433 # No discussion links for special pages
1437 if( $wgTitle->isTalkPage() ) {
1438 $link = $wgTitle->getSubjectPage();
1439 switch( $link->getNamespace() ) {
1441 $text = wfMsg( 'articlepage' );
1444 $text = wfMsg( 'userpage' );
1447 $text = wfMsg( 'projectpage' );
1450 $text = wfMsg( 'imagepage' );
1453 $text = wfMsg( 'mediawikipage' );
1456 $text = wfMsg( 'templatepage' );
1459 $text = wfMsg( 'viewhelppage' );
1462 $text = wfMsg( 'categorypage' );
1465 $text = wfMsg( 'articlepage' );
1468 $link = $wgTitle->getTalkPage();
1469 $text = wfMsg( 'talkpage' );
1472 $s = $this->makeLinkObj( $link, $text );
1477 function commentLink() {
1478 global $wgTitle, $wgOut;
1480 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1484 # __NEWSECTIONLINK___ changes behaviour here
1485 # If it's present, the link points to this page, otherwise
1486 # it points to the talk page
1487 if( $wgTitle->isTalkPage() ) {
1489 } elseif( $wgOut->showNewSectionLink() ) {
1492 $title =& $wgTitle->getTalkPage();
1495 return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1498 /* these are used extensively in SkinTemplate, but also some other places */
1499 static function makeSpecialUrl( $name, $urlaction = '' ) {
1500 $title = SpecialPage
::getTitleFor( $name );
1501 return $title->getLocalURL( $urlaction );
1504 static function makeI18nUrl( $name, $urlaction = '' ) {
1505 $title = Title
::newFromText( wfMsgForContent( $name ) );
1506 self
::checkTitle( $title, $name );
1507 return $title->getLocalURL( $urlaction );
1510 static function makeUrl( $name, $urlaction = '' ) {
1511 $title = Title
::newFromText( $name );
1512 self
::checkTitle( $title, $name );
1513 return $title->getLocalURL( $urlaction );
1516 # If url string starts with http, consider as external URL, else
1518 static function makeInternalOrExternalUrl( $name ) {
1519 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1522 return self
::makeUrl( $name );
1526 # this can be passed the NS number as defined in Language.php
1527 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1528 $title = Title
::makeTitleSafe( $namespace, $name );
1529 self
::checkTitle( $title, $name );
1530 return $title->getLocalURL( $urlaction );
1533 /* these return an array with the 'href' and boolean 'exists' */
1534 static function makeUrlDetails( $name, $urlaction = '' ) {
1535 $title = Title
::newFromText( $name );
1536 self
::checkTitle( $title, $name );
1538 'href' => $title->getLocalURL( $urlaction ),
1539 'exists' => $title->getArticleID() != 0 ?
true : false
1544 * Make URL details where the article exists (or at least it's convenient to think so)
1546 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1547 $title = Title
::newFromText( $name );
1548 self
::checkTitle( $title, $name );
1550 'href' => $title->getLocalURL( $urlaction ),
1555 # make sure we have some title to operate on
1556 static function checkTitle( &$title, &$name ) {
1557 if( !is_object( $title ) ) {
1558 $title = Title
::newFromText( $name );
1559 if( !is_object( $title ) ) {
1560 $title = Title
::newFromText( '--error: link target missing--' );
1566 * Build an array that represents the sidebar(s), the navigation bar among them
1571 function buildSidebar() {
1572 global $parserMemc, $wgEnableSidebarCache;
1573 global $wgLang, $wgContLang;
1575 $fname = 'SkinTemplate::buildSidebar';
1577 wfProfileIn( $fname );
1579 $key = wfMemcKey( 'sidebar' );
1580 $cacheSidebar = $wgEnableSidebarCache &&
1581 ($wgLang->getCode() == $wgContLang->getCode());
1583 if ($cacheSidebar) {
1584 $cachedsidebar = $parserMemc->get( $key );
1585 if ($cachedsidebar!="") {
1586 wfProfileOut($fname);
1587 return $cachedsidebar;
1592 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1593 foreach ($lines as $line) {
1594 if (strpos($line, '*') !== 0)
1596 if (strpos($line, '**') !== 0) {
1597 $line = trim($line, '* ');
1600 if (strpos($line, '|') !== false) { // sanity check
1601 $line = explode( '|' , trim($line, '* '), 2 );
1602 $link = wfMsgForContent( $line[0] );
1605 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1607 if (wfEmptyMsg($line[0], $link))
1610 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1613 $title = Title
::newFromText( $link );
1615 $title = $title->fixSpecialName();
1616 $href = $title->getLocalURL();
1618 $href = 'INVALID-TITLE';
1622 $bar[$heading][] = array(
1625 'id' => 'n-' . strtr($line[1], ' ', '-'),
1628 } else { continue; }
1632 $cachednotice = $parserMemc->set( $key, $bar, 86400 );
1633 wfProfileOut( $fname );