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
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] ) ) {
100 // The old built-in skin
106 * Factory method for loading a skin of a given type
107 * @param string $key 'monobook', 'standard', etc
111 static function &newFromKey( $key ) {
112 global $wgStyleDirectory;
114 $key = Skin
::normalizeKey( $key );
116 $skinNames = Skin
::getSkinNames();
117 $skinName = $skinNames[$key];
119 # Grab the skin class and initialise it.
120 // Preload base classes to work around APC/PHP5 bug
121 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
122 if( file_exists( $deps ) ) include_once( $deps );
123 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
125 # Check if we got if not failback to default skin
126 $className = 'Skin'.$skinName;
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 = 'SkinStandard';
134 require_once( "{$wgStyleDirectory}/Standard.php" );
136 $skin = new $className;
140 /** @return string path to the skin stylesheet */
141 function getStylesheet() {
142 return 'common/wikistandard.css';
145 /** @return string skin name */
146 function getSkinName() {
150 function qbSetting() {
151 global $wgOut, $wgUser;
153 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
154 $q = $wgUser->getOption( 'quickbar' );
155 if ( '' == $q ) { $q = 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 makeGlobalVariablesScript( $data ) {
274 $r = '<script type= "' . $data['jsmimetype'] . '">
275 var skin = "' . Xml
::escapeJsString( $data['skinname'] ) . '";
276 var stylepath = "' . Xml
::escapeJsString( $data['stylepath'] ) . '";
278 var wgArticlePath = "' . Xml
::escapeJsString( $data['articlepath'] ) . '";
279 var wgScriptPath = "' . Xml
::escapeJsString( $data['scriptpath'] ) . '";
280 var wgServer = "' . Xml
::escapeJsString( $data['serverurl'] ) . '";
282 var wgCanonicalNamespace = "' . Xml
::escapeJsString( $data['nscanonical'] ) . '";
283 var wgNamespaceNumber = ' . (int)$data['nsnumber'] . ';
284 var wgPageName = "' . Xml
::escapeJsString( $data['titleprefixeddbkey'] ) . '";
285 var wgTitle = "' . Xml
::escapeJsString( $data['titletext'] ) . '";
286 var wgArticleId = ' . (int)$data['articleid'] . ';
287 var wgIsArticle = ' . ( $data['isarticle'] ?
'true' : 'false' ) . ';
289 var wgUserName = ' . ( $data['username'] == NULL ?
'null' : ( '"' . Xml
::escapeJsString( $data['username'] ) . '"' ) ) . ';
290 var wgUserLanguage = "' . Xml
::escapeJsString( $data['userlang'] ) . '";
291 var wgContentLanguage = "' . Xml
::escapeJsString( $data['lang'] ) . '";
298 function getHeadScripts() {
299 global $wgStylePath, $wgUser, $wgAllowUserJs, $wgJsMimeType, $wgStyleVersion;
300 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
301 global $wgTitle, $wgCanonicalNamespaceNames, $wgOut;
303 $ns = $wgTitle->getNamespace();
304 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
307 'jsmimetype' => $wgJsMimeType,
308 'skinname' => $this->getSkinName(),
309 'stylepath' => $wgStylePath,
310 'articlepath' => $wgArticlePath,
311 'scriptpath' => $wgScriptPath,
312 'serverurl' => $wgServer,
313 'nscanonical' => $nsname,
314 'nsnumber' => $wgTitle->getNamespace(),
315 'titleprefixeddbkey' => $wgTitle->getPrefixedDBKey(),
316 'titletext' => $wgTitle->getText(),
317 'articleid' => $wgTitle->getArticleId(),
318 'isarticle' => $wgOut->isArticle(),
319 'username' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
320 'userlang' => $wgLang->getCode(),
321 'lang' => $wgContLang->getCode(),
324 $r = self
::makeGlobalVariablesScript( $vars );
326 $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n";
329 if ($wgUser->isLoggedIn()) {
330 $r .= "<script type=\"$wgJsMimeType\" src=\"".htmlspecialchars(self
::makeUrl('-','action=raw&smaxage=0&gen=js'))."\"><!-- site js --></script>\n";
332 $r .= "<script type=\"$wgJsMimeType\" src=\"".htmlspecialchars(self
::makeUrl('-','action=raw&gen=js'))."\"><!-- site js --></script>\n";
335 if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
336 $userpage = $wgUser->getUserPage();
337 $userjs = htmlspecialchars( self
::makeUrl(
338 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
339 'action=raw&ctype='.$wgJsMimeType));
340 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
346 * To make it harder for someone to slip a user a fake
347 * user-JavaScript or user-CSS preview, a random token
348 * is associated with the login session. If it's not
349 * passed back with the preview request, we won't render
352 * @param string $action
356 function userCanPreview( $action ) {
357 global $wgTitle, $wgRequest, $wgUser;
359 if( $action != 'submit' )
361 if( !$wgRequest->wasPosted() )
363 if( !$wgTitle->userCanEditCssJsSubpage() )
365 return $wgUser->matchEditToken(
366 $wgRequest->getVal( 'wpEditToken' ) );
369 # get the user/site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way)
370 function getUserStylesheet() {
371 global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage, $wgStyleVersion;
372 $sheet = $this->getStylesheet();
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 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
494 $s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
495 $a +
= array ('ondblclick' => $s);
498 $a['onload'] = $wgOut->getOnloadHandler();
499 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
500 if( $a['onload'] != '' ) {
503 $a['onload'] .= 'setupRightClickEdit()';
505 $a['class'] = 'ns-'.$wgTitle->getNamespace().' '.($wgContLang->isRTL() ?
"rtl" : "ltr").
506 ' '.Sanitizer
::escapeId( 'page-'.$wgTitle->getPrefixedText() );
519 * This will be called immediately after the <body> tag. Split into
520 * two functions to make it easier to subclass.
522 function beforeContent() {
523 return $this->doBeforeContent();
526 function doBeforeContent() {
528 $fname = 'Skin::doBeforeContent';
529 wfProfileIn( $fname );
532 $qb = $this->qbSetting();
534 if( $langlinks = $this->otherLanguages() ) {
540 $borderhack = 'class="top"';
543 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
544 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
547 $left = ($qb == 1 ||
$qb == 3);
548 if($wgContLang->isRTL()) $left = !$left;
551 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
552 $this->logoText() . '</td>';
554 $s .= $this->getQuickbarCompensator( $rows );
556 $l = $wgContLang->isRTL() ?
'right' : 'left';
557 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
559 $s .= $this->topLinks() ;
560 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
562 $r = $wgContLang->isRTL() ?
"left" : "right";
563 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
564 $s .= $this->nameAndLogin();
565 $s .= "\n<br />" . $this->searchForm() . "</td>";
568 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
571 if ( $shove && !$left ) { # Right
572 $s .= $this->getQuickbarCompensator( $rows );
574 $s .= "</tr>\n</table>\n</div>\n";
575 $s .= "\n<div id='article'>\n";
577 $notice = wfGetSiteNotice();
579 $s .= "\n<div id='siteNotice'>$notice</div>\n";
581 $s .= $this->pageTitle();
582 $s .= $this->pageSubtitle() ;
583 $s .= $this->getCategories();
584 wfProfileOut( $fname );
589 function getCategoryLinks () {
590 global $wgOut, $wgTitle, $wgUseCategoryBrowser;
593 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
596 $sep = wfMsgHtml( 'catseparator' );
598 // Use Unicode bidi embedding override characters,
599 // to make sure links don't smash each other up in ugly ways.
600 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
601 $embed = "<span dir='$dir'>";
603 $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $wgOut->mCategoryLinks
) . $pop;
605 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escape' ), count( $wgOut->mCategoryLinks
) );
606 $s = $this->makeLinkObj( Title
::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
609 # optional 'dmoz-like' category browser. Will be shown under the list
610 # of categories an article belong to
611 if($wgUseCategoryBrowser) {
612 $s .= '<br /><hr />';
614 # get a big array of the parents tree
615 $parenttree = $wgTitle->getParentCategoryTree();
616 # Skin object passed by reference cause it can not be
617 # accessed under the method subfunction drawCategoryBrowser
618 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
619 # Clean out bogus first entry and sort them
622 # Output one per line
623 $s .= implode("<br />\n", $tempout);
629 /** Render the array as a serie of links.
630 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
631 * @param &skin Object: skin passed by reference
632 * @return String separated by >, terminate with "\n"
634 function drawCategoryBrowser($tree, &$skin) {
636 foreach ($tree as $element => $parent) {
637 if (empty($parent)) {
638 # element start a new list
641 # grab the others elements
642 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
644 # add our current element to the list
645 $eltitle = Title
::NewFromText($element);
646 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
651 function getCategories() {
652 $catlinks=$this->getCategoryLinks();
653 if(!empty($catlinks)) {
654 return "<p class='catlinks'>{$catlinks}</p>";
658 function getQuickbarCompensator( $rows = 1 ) {
659 return "<td width='152' rowspan='{$rows}'> </td>";
663 * This gets called shortly before the \</body\> tag.
664 * @return String HTML to be put before \</body\>
666 function afterContent() {
667 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
668 return $printfooter . $this->doAfterContent();
672 * This gets called shortly before the \</body\> tag.
673 * @return String HTML-wrapped JS code to be put before \</body\>
675 function bottomScripts() {
676 global $wgJsMimeType;
677 return "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
680 /** @return string Retrievied from HTML text */
681 function printSource() {
683 $url = htmlspecialchars( $wgTitle->getFullURL() );
684 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
687 function printFooter() {
688 return "<p>" . $this->printSource() .
689 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
692 /** overloaded by derived classes */
693 function doAfterContent() { }
695 function pageTitleLinks() {
696 global $wgOut, $wgTitle, $wgUser, $wgRequest;
698 $oldid = $wgRequest->getVal( 'oldid' );
699 $diff = $wgRequest->getVal( '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 $lo = $wgContLang->specialPage( 'Userlogout' );
844 if ( $wgUser->isAnon() ) {
845 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
848 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
849 $wgLang->getNsText( NS_TALK
) );
851 $s .= $n . ' ('.$tl.')';
853 $s .= wfMsg('notloggedin');
856 $rt = $wgTitle->getPrefixedURL();
857 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
859 } else { $q = "returnto={$rt}"; }
861 $s .= "\n<br />" . $this->makeKnownLinkObj(
862 SpecialPage
::getTitleFor( 'Userlogin' ),
863 wfMsg( 'login' ), $q );
865 $n = $wgUser->getName();
866 $rt = $wgTitle->getPrefixedURL();
867 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
868 $wgLang->getNsText( NS_TALK
) );
872 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
873 $n ) . "{$tl}<br />" .
874 $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
875 "returnto={$rt}" ) . ' | ' .
876 $this->specialLink( 'preferences' );
878 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
884 function getSearchLink() {
885 $searchPage = SpecialPage
::getTitleFor( 'Search' );
886 return $searchPage->getLocalURL();
889 function escapeSearchLink() {
890 return htmlspecialchars( $this->getSearchLink() );
893 function searchForm() {
895 $search = $wgRequest->getText( 'search' );
897 $s = '<form name="search" class="inline" method="post" action="'
898 . $this->escapeSearchLink() . "\">\n"
899 . '<input type="text" name="search" size="19" value="'
900 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
901 . '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" /> '
902 . '<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n</form>";
907 function topLinks() {
911 $s = $this->mainPageLink() . $sep
912 . $this->specialLink( 'recentchanges' );
914 if ( $wgOut->isArticleRelated() ) {
915 $s .= $sep . $this->editThisPage()
916 . $sep . $this->historyLink();
918 # Many people don't like this dropdown box
919 #$s .= $sep . $this->specialPagesList();
921 $s .= $this->variantLinks();
923 $s .= $this->extensionTabLinks();
929 * Compatibility for extensions adding functionality through tabs.
930 * Eventually these old skins should be replaced with SkinTemplate-based
934 function extensionTabLinks() {
937 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
938 foreach( $tabs as $tab ) {
939 $s .= ' | ' . Xml
::element( 'a',
940 array( 'href' => $tab['href'] ),
947 * Language/charset variant links for classic-style skins
950 function variantLinks() {
952 /* show links to different language variants */
953 global $wgDisableLangConversion, $wgContLang, $wgTitle;
954 $variants = $wgContLang->getVariants();
955 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
956 foreach( $variants as $code ) {
957 $varname = $wgContLang->getVariantname( $code );
958 if( $varname == 'disable' )
960 $s .= ' | <a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>';
966 function bottomLinks() {
967 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
971 if ( $wgOut->isArticleRelated() ) {
972 $s .= '<strong>' . $this->editThisPage() . '</strong>';
973 if ( $wgUser->isLoggedIn() ) {
974 $s .= $sep . $this->watchThisPage();
976 $s .= $sep . $this->talkLink()
977 . $sep . $this->historyLink()
978 . $sep . $this->whatLinksHere()
979 . $sep . $this->watchPageLinksLink();
981 if ($wgUseTrackbacks)
982 $s .= $sep . $this->trackbackLink();
984 if ( $wgTitle->getNamespace() == NS_USER
985 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
988 $id=User
::idFromName($wgTitle->getText());
989 $ip=User
::isIP($wgTitle->getText());
991 if($id ||
$ip) { # both anons and non-anons have contri list
992 $s .= $sep . $this->userContribsLink();
994 if( $this->showEmailUser( $id ) ) {
995 $s .= $sep . $this->emailUserLink();
998 if ( $wgTitle->getArticleId() ) {
1000 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
1001 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
1002 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
1004 $s .= "<br />\n" . $this->otherLanguages();
1009 function pageStats() {
1010 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1011 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
1013 $oldid = $wgRequest->getVal( 'oldid' );
1014 $diff = $wgRequest->getVal( '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;
1147 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1148 foreach ( $pages as $name => $page ) {
1149 $pages[$name] = $page->getDescription();
1152 $go = wfMsg( 'go' );
1153 $sp = wfMsg( 'specialpages' );
1154 $spp = $wgContLang->specialPage( 'Specialpages' );
1156 $s = '<form id="specialpages" method="get" class="inline" ' .
1157 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1158 $s .= "<select name=\"wpDropdown\">\n";
1159 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1162 foreach ( $pages as $name => $desc ) {
1163 $p = $wgContLang->specialPage( $name );
1164 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1166 $s .= "</select>\n";
1167 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1172 function mainPageLink() {
1173 $mp = wfMsgForContent( 'mainpage' );
1174 $mptxt = wfMsg( 'mainpage');
1175 $s = $this->makeKnownLink( $mp, $mptxt );
1179 function copyrightLink() {
1180 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1181 wfMsg( 'copyrightpagename' ) );
1185 function privacyLink() {
1186 $privacy = wfMsg( 'privacy' );
1187 if ($privacy == '-') {
1190 return $this->makeKnownLink( wfMsgForContent( 'privacypage' ), $privacy);
1194 function aboutLink() {
1195 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
1196 wfMsg( 'aboutsite' ) );
1200 function disclaimerLink() {
1201 $disclaimers = wfMsg( 'disclaimers' );
1202 if ($disclaimers == '-') {
1205 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
1210 function editThisPage() {
1211 global $wgOut, $wgTitle;
1213 if ( ! $wgOut->isArticleRelated() ) {
1214 $s = wfMsg( 'protectedpage' );
1216 if ( $wgTitle->userCanEdit() ) {
1217 $t = wfMsg( 'editthispage' );
1219 $t = wfMsg( 'viewsource' );
1222 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1228 * Return URL options for the 'edit page' link.
1229 * This may include an 'oldid' specifier, if the current page view is such.
1234 function editUrlOptions() {
1237 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1238 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1240 return "action=edit";
1244 function deleteThisPage() {
1245 global $wgUser, $wgTitle, $wgRequest;
1247 $diff = $wgRequest->getVal( 'diff' );
1248 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1249 $t = wfMsg( 'deletethispage' );
1251 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1258 function protectThisPage() {
1259 global $wgUser, $wgTitle, $wgRequest;
1261 $diff = $wgRequest->getVal( 'diff' );
1262 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1263 if ( $wgTitle->isProtected() ) {
1264 $t = wfMsg( 'unprotectthispage' );
1265 $q = 'action=unprotect';
1267 $t = wfMsg( 'protectthispage' );
1268 $q = 'action=protect';
1270 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1277 function watchThisPage() {
1278 global $wgOut, $wgTitle;
1280 if ( $wgOut->isArticleRelated() ) {
1281 if ( $wgTitle->userIsWatching() ) {
1282 $t = wfMsg( 'unwatchthispage' );
1283 $q = 'action=unwatch';
1285 $t = wfMsg( 'watchthispage' );
1286 $q = 'action=watch';
1288 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1290 $s = wfMsg( 'notanarticle' );
1295 function moveThisPage() {
1298 if ( $wgTitle->userCanMove() ) {
1299 return $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
1300 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1302 // no message if page is protected - would be redundant
1307 function historyLink() {
1310 return $this->makeKnownLinkObj( $wgTitle,
1311 wfMsg( 'history' ), 'action=history' );
1314 function whatLinksHere() {
1317 return $this->makeKnownLinkObj(
1318 SpecialPage
::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ),
1319 wfMsg( 'whatlinkshere' ) );
1322 function userContribsLink() {
1325 return $this->makeKnownLinkObj(
1326 SpecialPage
::getTitleFor( 'Contributions', $wgTitle->getDBkey() ),
1327 wfMsg( 'contributions' ) );
1330 function showEmailUser( $id ) {
1331 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1332 return $wgEnableEmail &&
1333 $wgEnableUserEmail &&
1334 $wgUser->isLoggedIn() && # show only to signed in users
1335 0 != $id; # we can only email to non-anons ..
1336 # '' != $id->getEmail() && # who must have an email address stored ..
1337 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1338 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1341 function emailUserLink() {
1344 return $this->makeKnownLinkObj(
1345 SpecialPage
::getTitleFor( 'Emailuser', $wgTitle->getDBkey() ),
1346 wfMsg( 'emailuser' ) );
1349 function watchPageLinksLink() {
1350 global $wgOut, $wgTitle;
1352 if ( ! $wgOut->isArticleRelated() ) {
1353 return '(' . wfMsg( 'notanarticle' ) . ')';
1355 return $this->makeKnownLinkObj(
1356 SpecialPage
::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ),
1357 wfMsg( 'recentchangeslinked' ) );
1361 function trackbackLink() {
1364 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1365 . wfMsg('trackbacklink') . "</a>";
1368 function otherLanguages() {
1369 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1371 if ( $wgHideInterlanguageLinks ) {
1375 $a = $wgOut->getLanguageLinks();
1376 if ( 0 == count( $a ) ) {
1380 $s = wfMsg( 'otherlanguages' ) . ': ';
1382 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1383 foreach( $a as $l ) {
1384 if ( ! $first ) { $s .= ' | '; }
1387 $nt = Title
::newFromText( $l );
1388 $url = $nt->escapeFullURL();
1389 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1391 if ( '' == $text ) { $text = $l; }
1392 $style = $this->getExternalLinkAttributes( $l, $text );
1393 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1395 if($wgContLang->isRTL()) $s .= '</span>';
1399 function bugReportsLink() {
1400 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1401 wfMsg( 'bugreports' ) );
1405 function dateLink() {
1406 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1407 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1409 $id = $t1->getArticleID();
1412 $s = $this->makeBrokenLink( $t1->getText() );
1414 $s = $this->makeKnownLink( $t1->getText() );
1418 $id = $t2->getArticleID();
1421 $s .= $this->makeBrokenLink( $t2->getText() );
1423 $s .= $this->makeKnownLink( $t2->getText() );
1428 function talkLink() {
1431 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1432 # No discussion links for special pages
1436 if( $wgTitle->isTalkPage() ) {
1437 $link = $wgTitle->getSubjectPage();
1438 switch( $link->getNamespace() ) {
1440 $text = wfMsg( 'articlepage' );
1443 $text = wfMsg( 'userpage' );
1446 $text = wfMsg( 'projectpage' );
1449 $text = wfMsg( 'imagepage' );
1452 $text = wfMsg( 'mediawikipage' );
1455 $text = wfMsg( 'templatepage' );
1458 $text = wfMsg( 'viewhelppage' );
1461 $text = wfMsg( 'categorypage' );
1464 $text = wfMsg( 'articlepage' );
1467 $link = $wgTitle->getTalkPage();
1468 $text = wfMsg( 'talkpage' );
1471 $s = $this->makeLinkObj( $link, $text );
1476 function commentLink() {
1477 global $wgTitle, $wgOut;
1479 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1483 # __NEWSECTIONLINK___ changes behaviour here
1484 # If it's present, the link points to this page, otherwise
1485 # it points to the talk page
1486 if( $wgTitle->isTalkPage() ) {
1488 } elseif( $wgOut->showNewSectionLink() ) {
1491 $title =& $wgTitle->getTalkPage();
1494 return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1497 /* these are used extensively in SkinTemplate, but also some other places */
1498 static function makeSpecialUrl( $name, $urlaction = '' ) {
1499 $title = SpecialPage
::getTitleFor( $name );
1500 return $title->getLocalURL( $urlaction );
1503 static function makeI18nUrl( $name, $urlaction = '' ) {
1504 $title = Title
::newFromText( wfMsgForContent( $name ) );
1505 self
::checkTitle( $title, $name );
1506 return $title->getLocalURL( $urlaction );
1509 static function makeUrl( $name, $urlaction = '' ) {
1510 $title = Title
::newFromText( $name );
1511 self
::checkTitle( $title, $name );
1512 return $title->getLocalURL( $urlaction );
1515 # If url string starts with http, consider as external URL, else
1517 static function makeInternalOrExternalUrl( $name ) {
1518 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1521 return self
::makeUrl( $name );
1525 # this can be passed the NS number as defined in Language.php
1526 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1527 $title = Title
::makeTitleSafe( $namespace, $name );
1528 self
::checkTitle( $title, $name );
1529 return $title->getLocalURL( $urlaction );
1532 /* these return an array with the 'href' and boolean 'exists' */
1533 static function makeUrlDetails( $name, $urlaction = '' ) {
1534 $title = Title
::newFromText( $name );
1535 self
::checkTitle( $title, $name );
1537 'href' => $title->getLocalURL( $urlaction ),
1538 'exists' => $title->getArticleID() != 0 ?
true : false
1543 * Make URL details where the article exists (or at least it's convenient to think so)
1545 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1546 $title = Title
::newFromText( $name );
1547 self
::checkTitle( $title, $name );
1549 'href' => $title->getLocalURL( $urlaction ),
1554 # make sure we have some title to operate on
1555 static function checkTitle( &$title, &$name ) {
1556 if( !is_object( $title ) ) {
1557 $title = Title
::newFromText( $name );
1558 if( !is_object( $title ) ) {
1559 $title = Title
::newFromText( '--error: link target missing--' );
1565 * Build an array that represents the sidebar(s), the navigation bar among them
1570 function buildSidebar() {
1571 global $parserMemc, $wgEnableSidebarCache;
1572 global $wgLang, $wgContLang;
1574 $fname = 'SkinTemplate::buildSidebar';
1576 wfProfileIn( $fname );
1578 $key = wfMemcKey( 'sidebar' );
1579 $cacheSidebar = $wgEnableSidebarCache &&
1580 ($wgLang->getCode() == $wgContLang->getCode());
1582 if ($cacheSidebar) {
1583 $cachedsidebar = $parserMemc->get( $key );
1584 if ($cachedsidebar!="") {
1585 wfProfileOut($fname);
1586 return $cachedsidebar;
1591 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1592 foreach ($lines as $line) {
1593 if (strpos($line, '*') !== 0)
1595 if (strpos($line, '**') !== 0) {
1596 $line = trim($line, '* ');
1599 if (strpos($line, '|') !== false) { // sanity check
1600 $line = explode( '|' , trim($line, '* '), 2 );
1601 $link = wfMsgForContent( $line[0] );
1604 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1606 if (wfEmptyMsg($line[0], $link))
1609 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1612 $title = Title
::newFromText( $link );
1614 $title = $title->fixSpecialName();
1615 $href = $title->getLocalURL();
1617 $href = 'INVALID-TITLE';
1621 $bar[$heading][] = array(
1624 'id' => 'n-' . strtr($line[1], ' ', '-'),
1627 } else { continue; }
1631 $parserMemc->set( $key, $bar, 86400 );
1632 wfProfileOut( $fname );