8d528678aca5bf0994acfa1dfc7993cf700240e5
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 wfSuppressWarnings();
120 // Preload base classes to work around APC/PHP5 bug
121 include_once( "{$wgStyleDirectory}/{$skinName}.deps.php" );
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 $nsname = @$wgCanonicalNamespaceNames[ $wgTitle->getNamespace() ];
304 if ( $nsname === NULL ) $nsname = $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=\"".urlencode(self
::makeUrl('-','action=raw&smaxage=0&gen=js'))."\"><!-- site js --></script>\n";
332 $r .= "<script type=\"$wgJsMimeType\" src=\"".urlencode(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 $action = $wgRequest->getText('action');
374 $s = "@import \"$wgStylePath/common/common.css?$wgStyleVersion\";\n";
375 $s .= "@import \"$wgStylePath/$sheet?$wgStyleVersion\";\n";
376 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css?$wgStyleVersion\";\n";
378 $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
379 $s .= '@import "' . self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n" .
380 '@import "' . self
::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
382 $s .= $this->doGetUserStyles();
387 * This returns MediaWiki:Common.js. For some bizarre reason, it does
388 * *not* return any custom user JS from user subpages. Huh?
392 function getUserJs() {
393 $fname = 'Skin::getUserJs';
394 wfProfileIn( $fname );
397 $s = "/* generated javascript */\n";
398 $s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';";
399 $s .= "\n\n/* MediaWiki:Common.js */\n";
400 $commonJs = wfMsgForContent('Common.js');
401 if ( !wfEmptyMsg ( 'Common.js', $commonJs ) ) {
405 wfProfileOut( $fname );
410 * Return html code that include User stylesheets
412 function getUserStyles() {
413 $s = "<style type='text/css'>\n";
414 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
415 $s .= $this->getUserStylesheet();
416 $s .= "/*]]>*/ /* */\n";
422 * Some styles that are set by user through the user settings interface.
424 function doGetUserStyles() {
425 global $wgUser, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
429 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
430 if($wgTitle->isCssSubpage() && $this->userCanPreview( $wgRequest->getText( 'action' ) ) ) {
431 $s .= $wgRequest->getText('wpTextbox1');
433 $userpage = $wgUser->getUserPage();
434 $s.= '@import "'.self
::makeUrl(
435 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
436 'action=raw&ctype=text/css').'";'."\n";
440 return $s . $this->reallyDoGetUserStyles();
443 function reallyDoGetUserStyles() {
446 if (($undopt = $wgUser->getOption("underline")) != 2) {
447 $underline = $undopt ?
'underline' : 'none';
448 $s .= "a { text-decoration: $underline; }\n";
450 if( $wgUser->getOption( 'highlightbroken' ) ) {
451 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
454 a.new, #quickbar a.new,
455 a.stub, #quickbar a.stub {
457 text-decoration: inherit;
459 a.new:after, #quickbar a.new:after {
462 text-decoration: $underline;
464 a.stub:after, #quickbar a.stub:after {
467 text-decoration: $underline;
471 if( $wgUser->getOption( 'justify' ) ) {
472 $s .= "#article, #bodyContent { text-align: justify; }\n";
474 if( !$wgUser->getOption( 'showtoc' ) ) {
475 $s .= "#toc { display: none; }\n";
477 if( !$wgUser->getOption( 'editsection' ) ) {
478 $s .= ".editsection { display: none; }\n";
483 function getBodyOptions() {
484 global $wgUser, $wgTitle, $wgOut, $wgRequest, $wgContLang;
486 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
488 if ( 0 != $wgTitle->getNamespace() ) {
489 $a = array( 'bgcolor' => '#ffffec' );
491 else $a = array( 'bgcolor' => '#FFFFFF' );
492 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
493 $wgTitle->userCanEdit() ) {
494 $t = wfMsg( 'editthispage' );
495 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
496 $s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
497 $a +
= array ('ondblclick' => $s);
500 $a['onload'] = $wgOut->getOnloadHandler();
501 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
502 if( $a['onload'] != '' ) {
505 $a['onload'] .= 'setupRightClickEdit()';
507 $a['class'] = 'ns-'.$wgTitle->getNamespace().' '.($wgContLang->isRTL() ?
"rtl" : "ltr").
508 ' '.Sanitizer
::escapeId( 'page-'.$wgTitle->getPrefixedText() );
521 * This will be called immediately after the <body> tag. Split into
522 * two functions to make it easier to subclass.
524 function beforeContent() {
525 return $this->doBeforeContent();
528 function doBeforeContent() {
530 $fname = 'Skin::doBeforeContent';
531 wfProfileIn( $fname );
534 $qb = $this->qbSetting();
536 if( $langlinks = $this->otherLanguages() ) {
542 $borderhack = 'class="top"';
545 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
546 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
549 $left = ($qb == 1 ||
$qb == 3);
550 if($wgContLang->isRTL()) $left = !$left;
553 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
554 $this->logoText() . '</td>';
556 $s .= $this->getQuickbarCompensator( $rows );
558 $l = $wgContLang->isRTL() ?
'right' : 'left';
559 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
561 $s .= $this->topLinks() ;
562 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
564 $r = $wgContLang->isRTL() ?
"left" : "right";
565 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
566 $s .= $this->nameAndLogin();
567 $s .= "\n<br />" . $this->searchForm() . "</td>";
570 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
573 if ( $shove && !$left ) { # Right
574 $s .= $this->getQuickbarCompensator( $rows );
576 $s .= "</tr>\n</table>\n</div>\n";
577 $s .= "\n<div id='article'>\n";
579 $notice = wfGetSiteNotice();
581 $s .= "\n<div id='siteNotice'>$notice</div>\n";
583 $s .= $this->pageTitle();
584 $s .= $this->pageSubtitle() ;
585 $s .= $this->getCategories();
586 wfProfileOut( $fname );
591 function getCategoryLinks () {
592 global $wgOut, $wgTitle, $wgUseCategoryBrowser;
595 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
598 $sep = wfMsgHtml( 'catseparator' );
600 // Use Unicode bidi embedding override characters,
601 // to make sure links don't smash each other up in ugly ways.
602 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
603 $embed = "<span dir='$dir'>";
605 $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $wgOut->mCategoryLinks
) . $pop;
607 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escape' ), count( $wgOut->mCategoryLinks
) );
608 $s = $this->makeLinkObj( Title
::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
611 # optional 'dmoz-like' category browser. Will be shown under the list
612 # of categories an article belong to
613 if($wgUseCategoryBrowser) {
614 $s .= '<br /><hr />';
616 # get a big array of the parents tree
617 $parenttree = $wgTitle->getParentCategoryTree();
618 # Skin object passed by reference cause it can not be
619 # accessed under the method subfunction drawCategoryBrowser
620 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
621 # Clean out bogus first entry and sort them
624 # Output one per line
625 $s .= implode("<br />\n", $tempout);
631 /** Render the array as a serie of links.
632 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
633 * @param &skin Object: skin passed by reference
634 * @return String separated by >, terminate with "\n"
636 function drawCategoryBrowser($tree, &$skin) {
638 foreach ($tree as $element => $parent) {
639 if (empty($parent)) {
640 # element start a new list
643 # grab the others elements
644 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
646 # add our current element to the list
647 $eltitle = Title
::NewFromText($element);
648 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
653 function getCategories() {
654 $catlinks=$this->getCategoryLinks();
655 if(!empty($catlinks)) {
656 return "<p class='catlinks'>{$catlinks}</p>";
660 function getQuickbarCompensator( $rows = 1 ) {
661 return "<td width='152' rowspan='{$rows}'> </td>";
665 * This gets called shortly before the \</body\> tag.
666 * @return String HTML to be put before \</body\>
668 function afterContent() {
669 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
670 return $printfooter . $this->doAfterContent();
674 * This gets called shortly before the \</body\> tag.
675 * @return String HTML-wrapped JS code to be put before \</body\>
677 function bottomScripts() {
678 global $wgJsMimeType;
679 return "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
682 /** @return string Retrievied from HTML text */
683 function printSource() {
685 $url = htmlspecialchars( $wgTitle->getFullURL() );
686 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
689 function printFooter() {
690 return "<p>" . $this->printSource() .
691 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
694 /** overloaded by derived classes */
695 function doAfterContent() { }
697 function pageTitleLinks() {
698 global $wgOut, $wgTitle, $wgUser, $wgRequest;
700 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
701 $action = $wgRequest->getText( 'action' );
703 $s = $this->printableLink();
704 $disclaimer = $this->disclaimerLink(); # may be empty
706 $s .= ' | ' . $disclaimer;
708 $privacy = $this->privacyLink(); # may be empty too
710 $s .= ' | ' . $privacy;
713 if ( $wgOut->isArticleRelated() ) {
714 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
715 $name = $wgTitle->getDBkey();
716 $image = new Image( $wgTitle );
717 if( $image->exists() ) {
718 $link = htmlspecialchars( $image->getURL() );
719 $style = $this->getInternalLinkAttributes( $link, $name );
720 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
724 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
725 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
726 wfMsg( 'currentrev' ) );
729 if ( $wgUser->getNewtalk() ) {
730 # do not show "You have new messages" text when we are viewing our
732 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
733 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
734 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
735 $s.= ' | <strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
737 $wgOut->setSquidMaxage(0);
738 $wgOut->enableClientCache(false);
742 $undelete = $this->getUndeleteLink();
743 if( !empty( $undelete ) ) {
744 $s .= ' | '.$undelete;
749 function getUndeleteLink() {
750 global $wgUser, $wgTitle, $wgContLang, $action;
751 if( $wgUser->isAllowed( 'deletedhistory' ) &&
752 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
753 ($n = $wgTitle->isDeleted() ) )
755 if ( $wgUser->isAllowed( 'delete' ) ) {
756 $msg = 'thisisdeleted';
758 $msg = 'viewdeleted';
761 $this->makeKnownLink(
762 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
763 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $n ) ) );
768 function printableLink() {
769 global $wgOut, $wgFeedClasses, $wgRequest;
771 $baseurl = $_SERVER['REQUEST_URI'];
772 if( strpos( '?', $baseurl ) == false ) {
777 $baseurl = htmlspecialchars( $baseurl );
778 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
780 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
781 if( $wgOut->isSyndicated() ) {
782 foreach( $wgFeedClasses as $format => $class ) {
783 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
784 $s .= " | <a href=\"$feedurl\">{$format}</a>";
790 function pageTitle() {
792 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
796 function pageSubtitle() {
799 $sub = $wgOut->getSubtitle();
801 global $wgExtraSubtitle;
802 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
804 $subpages = $this->subPageSubtitle();
805 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
806 $s = "<p class='subtitle'>{$sub}</p>\n";
810 function subPageSubtitle() {
811 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
813 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
814 $ptext=$wgTitle->getPrefixedText();
815 if(preg_match('/\//',$ptext)) {
816 $links = explode('/',$ptext);
819 foreach($links as $link) {
821 if ($c<count($links)) {
822 $growinglink .= $link;
823 $getlink = $this->makeLink( $growinglink, htmlspecialchars( $link ) );
824 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
828 $subpages .= '< ';
830 $subpages .= $getlink;
839 function nameAndLogin() {
840 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader;
842 $li = $wgContLang->specialPage( 'Userlogin' );
843 $lo = $wgContLang->specialPage( 'Userlogout' );
846 if ( $wgUser->isAnon() ) {
847 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
850 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
851 $wgLang->getNsText( NS_TALK
) );
853 $s .= $n . ' ('.$tl.')';
855 $s .= wfMsg('notloggedin');
858 $rt = $wgTitle->getPrefixedURL();
859 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
861 } else { $q = "returnto={$rt}"; }
863 $s .= "\n<br />" . $this->makeKnownLinkObj(
864 SpecialPage
::getTitleFor( 'Userlogin' ),
865 wfMsg( 'login' ), $q );
867 $n = $wgUser->getName();
868 $rt = $wgTitle->getPrefixedURL();
869 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
870 $wgLang->getNsText( NS_TALK
) );
874 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
875 $n ) . "{$tl}<br />" .
876 $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
877 "returnto={$rt}" ) . ' | ' .
878 $this->specialLink( 'preferences' );
880 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
886 function getSearchLink() {
887 $searchPage =& SpecialPage
::getTitleFor( 'Search' );
888 return $searchPage->getLocalURL();
891 function escapeSearchLink() {
892 return htmlspecialchars( $this->getSearchLink() );
895 function searchForm() {
897 $search = $wgRequest->getText( 'search' );
899 $s = '<form name="search" class="inline" method="post" action="'
900 . $this->escapeSearchLink() . "\">\n"
901 . '<input type="text" name="search" size="19" value="'
902 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
903 . '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" /> '
904 . '<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n</form>";
909 function topLinks() {
913 $s = $this->mainPageLink() . $sep
914 . $this->specialLink( 'recentchanges' );
916 if ( $wgOut->isArticleRelated() ) {
917 $s .= $sep . $this->editThisPage()
918 . $sep . $this->historyLink();
920 # Many people don't like this dropdown box
921 #$s .= $sep . $this->specialPagesList();
923 $s .= $this->variantLinks();
925 $s .= $this->extensionTabLinks();
931 * Compatibility for extensions adding functionality through tabs.
932 * Eventually these old skins should be replaced with SkinTemplate-based
936 function extensionTabLinks() {
939 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
940 foreach( $tabs as $tab ) {
941 $s .= ' | ' . Xml
::element( 'a',
942 array( 'href' => $tab['href'] ),
949 * Language/charset variant links for classic-style skins
952 function variantLinks() {
954 /* show links to different language variants */
955 global $wgDisableLangConversion, $wgContLang, $wgTitle;
956 $variants = $wgContLang->getVariants();
957 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
958 foreach( $variants as $code ) {
959 $varname = $wgContLang->getVariantname( $code );
960 if( $varname == 'disable' )
962 $s .= ' | <a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>';
968 function bottomLinks() {
969 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
973 if ( $wgOut->isArticleRelated() ) {
974 $s .= '<strong>' . $this->editThisPage() . '</strong>';
975 if ( $wgUser->isLoggedIn() ) {
976 $s .= $sep . $this->watchThisPage();
978 $s .= $sep . $this->talkLink()
979 . $sep . $this->historyLink()
980 . $sep . $this->whatLinksHere()
981 . $sep . $this->watchPageLinksLink();
983 if ($wgUseTrackbacks)
984 $s .= $sep . $this->trackbackLink();
986 if ( $wgTitle->getNamespace() == NS_USER
987 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
990 $id=User
::idFromName($wgTitle->getText());
991 $ip=User
::isIP($wgTitle->getText());
993 if($id ||
$ip) { # both anons and non-anons have contri list
994 $s .= $sep . $this->userContribsLink();
996 if( $this->showEmailUser( $id ) ) {
997 $s .= $sep . $this->emailUserLink();
1000 if ( $wgTitle->getArticleId() ) {
1002 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
1003 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
1004 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
1006 $s .= "<br />\n" . $this->otherLanguages();
1011 function pageStats() {
1012 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1013 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
1015 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
1016 if ( ! $wgOut->isArticle() ) { return ''; }
1017 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1018 if ( 0 == $wgArticle->getID() ) { return ''; }
1021 if ( !$wgDisableCounters ) {
1022 $count = $wgLang->formatNum( $wgArticle->getCount() );
1024 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1028 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
1029 require_once('Credits.php');
1030 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
1032 $s .= $this->lastModified();
1035 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
1036 $dbr =& wfGetDB( DB_SLAVE
);
1037 extract( $dbr->tableNames( 'watchlist' ) );
1038 $sql = "SELECT COUNT(*) AS n FROM $watchlist
1039 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
1040 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
1041 $res = $dbr->query( $sql, 'Skin::pageStats');
1042 $x = $dbr->fetchObject( $res );
1043 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
1046 return $s . ' ' . $this->getCopyright();
1049 function getCopyright( $type = 'detect' ) {
1050 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
1052 if ( $type == 'detect' ) {
1053 $oldid = $wgRequest->getVal( 'oldid' );
1054 $diff = $wgRequest->getVal( 'diff' );
1056 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1063 if ( $type == 'history' ) {
1064 $msg = 'history_copyright';
1070 if( $wgRightsPage ) {
1071 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
1072 } elseif( $wgRightsUrl ) {
1073 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1078 $out .= wfMsgForContent( $msg, $link );
1082 function getCopyrightIcon() {
1083 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1085 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1086 $out = $wgCopyrightIcon;
1087 } else if ( $wgRightsIcon ) {
1088 $icon = htmlspecialchars( $wgRightsIcon );
1089 if ( $wgRightsUrl ) {
1090 $url = htmlspecialchars( $wgRightsUrl );
1091 $out .= '<a href="'.$url.'">';
1093 $text = htmlspecialchars( $wgRightsText );
1094 $out .= "<img src=\"$icon\" alt='$text' />";
1095 if ( $wgRightsUrl ) {
1102 function getPoweredBy() {
1103 global $wgStylePath;
1104 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1105 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
1109 function lastModified() {
1110 global $wgLang, $wgArticle, $wgLoadBalancer;
1112 $timestamp = $wgArticle->getTimestamp();
1114 $d = $wgLang->date( $timestamp, true );
1115 $t = $wgLang->time( $timestamp, true );
1116 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1120 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
1121 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1126 function logoText( $align = '' ) {
1127 if ( '' != $align ) { $a = " align='{$align}'"; }
1130 $mp = wfMsg( 'mainpage' );
1131 $titleObj = Title
::newFromText( $mp );
1132 if ( is_object( $titleObj ) ) {
1133 $url = $titleObj->escapeLocalURL();
1138 $logourl = $this->getLogo();
1139 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1144 * show a drop-down box of special pages
1146 function specialPagesList() {
1147 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1149 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1150 foreach ( $pages as $name => $page ) {
1151 $pages[$name] = $page->getDescription();
1154 $go = wfMsg( 'go' );
1155 $sp = wfMsg( 'specialpages' );
1156 $spp = $wgContLang->specialPage( 'Specialpages' );
1158 $s = '<form id="specialpages" method="get" class="inline" ' .
1159 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1160 $s .= "<select name=\"wpDropdown\">\n";
1161 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1164 foreach ( $pages as $name => $desc ) {
1165 $p = $wgContLang->specialPage( $name );
1166 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1168 $s .= "</select>\n";
1169 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1174 function mainPageLink() {
1175 $mp = wfMsgForContent( 'mainpage' );
1176 $mptxt = wfMsg( 'mainpage');
1177 $s = $this->makeKnownLink( $mp, $mptxt );
1181 function copyrightLink() {
1182 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1183 wfMsg( 'copyrightpagename' ) );
1187 function privacyLink() {
1188 $privacy = wfMsg( 'privacy' );
1189 if ($privacy == '-') {
1192 return $this->makeKnownLink( wfMsgForContent( 'privacypage' ), $privacy);
1196 function aboutLink() {
1197 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
1198 wfMsg( 'aboutsite' ) );
1202 function disclaimerLink() {
1203 $disclaimers = wfMsg( 'disclaimers' );
1204 if ($disclaimers == '-') {
1207 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
1212 function editThisPage() {
1213 global $wgOut, $wgTitle;
1215 if ( ! $wgOut->isArticleRelated() ) {
1216 $s = wfMsg( 'protectedpage' );
1218 if ( $wgTitle->userCanEdit() ) {
1219 $t = wfMsg( 'editthispage' );
1221 $t = wfMsg( 'viewsource' );
1224 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1230 * Return URL options for the 'edit page' link.
1231 * This may include an 'oldid' specifier, if the current page view is such.
1236 function editUrlOptions() {
1239 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1240 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1242 return "action=edit";
1246 function deleteThisPage() {
1247 global $wgUser, $wgTitle, $wgRequest;
1249 $diff = $wgRequest->getVal( 'diff' );
1250 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1251 $t = wfMsg( 'deletethispage' );
1253 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1260 function protectThisPage() {
1261 global $wgUser, $wgTitle, $wgRequest;
1263 $diff = $wgRequest->getVal( 'diff' );
1264 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1265 if ( $wgTitle->isProtected() ) {
1266 $t = wfMsg( 'unprotectthispage' );
1267 $q = 'action=unprotect';
1269 $t = wfMsg( 'protectthispage' );
1270 $q = 'action=protect';
1272 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1279 function watchThisPage() {
1280 global $wgOut, $wgTitle;
1282 if ( $wgOut->isArticleRelated() ) {
1283 if ( $wgTitle->userIsWatching() ) {
1284 $t = wfMsg( 'unwatchthispage' );
1285 $q = 'action=unwatch';
1287 $t = wfMsg( 'watchthispage' );
1288 $q = 'action=watch';
1290 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1292 $s = wfMsg( 'notanarticle' );
1297 function moveThisPage() {
1300 if ( $wgTitle->userCanMove() ) {
1301 return $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
1302 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1304 // no message if page is protected - would be redundant
1309 function historyLink() {
1312 return $this->makeKnownLinkObj( $wgTitle,
1313 wfMsg( 'history' ), 'action=history' );
1316 function whatLinksHere() {
1319 return $this->makeKnownLinkObj(
1320 SpecialPage
::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ),
1321 wfMsg( 'whatlinkshere' ) );
1324 function userContribsLink() {
1327 return $this->makeKnownLinkObj(
1328 SpecialPage
::getTitleFor( 'Contributions', $wgTitle->getDBkey() ),
1329 wfMsg( 'contributions' ) );
1332 function showEmailUser( $id ) {
1333 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1334 return $wgEnableEmail &&
1335 $wgEnableUserEmail &&
1336 $wgUser->isLoggedIn() && # show only to signed in users
1337 0 != $id; # we can only email to non-anons ..
1338 # '' != $id->getEmail() && # who must have an email address stored ..
1339 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1340 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1343 function emailUserLink() {
1346 return $this->makeKnownLinkObj(
1347 SpecialPage
::getTitleFor( 'Emailuser', $wgTitle->getDBkey() ),
1348 wfMsg( 'emailuser' ) );
1351 function watchPageLinksLink() {
1352 global $wgOut, $wgTitle;
1354 if ( ! $wgOut->isArticleRelated() ) {
1355 return '(' . wfMsg( 'notanarticle' ) . ')';
1357 return $this->makeKnownLinkObj(
1358 SpecialPage
::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ),
1359 wfMsg( 'recentchangeslinked' ) );
1363 function trackbackLink() {
1366 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1367 . wfMsg('trackbacklink') . "</a>";
1370 function otherLanguages() {
1371 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1373 if ( $wgHideInterlanguageLinks ) {
1377 $a = $wgOut->getLanguageLinks();
1378 if ( 0 == count( $a ) ) {
1382 $s = wfMsg( 'otherlanguages' ) . ': ';
1384 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1385 foreach( $a as $l ) {
1386 if ( ! $first ) { $s .= ' | '; }
1389 $nt = Title
::newFromText( $l );
1390 $url = $nt->escapeFullURL();
1391 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1393 if ( '' == $text ) { $text = $l; }
1394 $style = $this->getExternalLinkAttributes( $l, $text );
1395 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1397 if($wgContLang->isRTL()) $s .= '</span>';
1401 function bugReportsLink() {
1402 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1403 wfMsg( 'bugreports' ) );
1407 function dateLink() {
1408 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1409 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1411 $id = $t1->getArticleID();
1414 $s = $this->makeBrokenLink( $t1->getText() );
1416 $s = $this->makeKnownLink( $t1->getText() );
1420 $id = $t2->getArticleID();
1423 $s .= $this->makeBrokenLink( $t2->getText() );
1425 $s .= $this->makeKnownLink( $t2->getText() );
1430 function talkLink() {
1433 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1434 # No discussion links for special pages
1438 if( $wgTitle->isTalkPage() ) {
1439 $link = $wgTitle->getSubjectPage();
1440 switch( $link->getNamespace() ) {
1442 $text = wfMsg( 'articlepage' );
1445 $text = wfMsg( 'userpage' );
1448 $text = wfMsg( 'projectpage' );
1451 $text = wfMsg( 'imagepage' );
1454 $text = wfMsg( 'mediawikipage' );
1457 $text = wfMsg( 'templatepage' );
1460 $text = wfMsg( 'viewhelppage' );
1463 $text = wfMsg( 'categorypage' );
1466 $text = wfMsg( 'articlepage' );
1469 $link = $wgTitle->getTalkPage();
1470 $text = wfMsg( 'talkpage' );
1473 $s = $this->makeLinkObj( $link, $text );
1478 function commentLink() {
1479 global $wgTitle, $wgOut;
1481 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1485 # __NEWSECTIONLINK___ changes behaviour here
1486 # If it's present, the link points to this page, otherwise
1487 # it points to the talk page
1488 if( $wgTitle->isTalkPage() ) {
1490 } elseif( $wgOut->showNewSectionLink() ) {
1493 $title =& $wgTitle->getTalkPage();
1496 return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1499 /* these are used extensively in SkinTemplate, but also some other places */
1500 static function makeSpecialUrl( $name, $urlaction = '' ) {
1501 $title = SpecialPage
::getTitleFor( $name );
1502 return $title->getLocalURL( $urlaction );
1505 static function makeI18nUrl( $name, $urlaction = '' ) {
1506 $title = Title
::newFromText( wfMsgForContent( $name ) );
1507 self
::checkTitle( $title, $name );
1508 return $title->getLocalURL( $urlaction );
1511 static function makeUrl( $name, $urlaction = '' ) {
1512 $title = Title
::newFromText( $name );
1513 self
::checkTitle( $title, $name );
1514 return $title->getLocalURL( $urlaction );
1517 # If url string starts with http, consider as external URL, else
1519 static function makeInternalOrExternalUrl( $name ) {
1520 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1523 return self
::makeUrl( $name );
1527 # this can be passed the NS number as defined in Language.php
1528 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1529 $title = Title
::makeTitleSafe( $namespace, $name );
1530 self
::checkTitle( $title, $name );
1531 return $title->getLocalURL( $urlaction );
1534 /* these return an array with the 'href' and boolean 'exists' */
1535 static function makeUrlDetails( $name, $urlaction = '' ) {
1536 $title = Title
::newFromText( $name );
1537 self
::checkTitle( $title, $name );
1539 'href' => $title->getLocalURL( $urlaction ),
1540 'exists' => $title->getArticleID() != 0 ?
true : false
1545 * Make URL details where the article exists (or at least it's convenient to think so)
1547 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1548 $title = Title
::newFromText( $name );
1549 self
::checkTitle( $title, $name );
1551 'href' => $title->getLocalURL( $urlaction ),
1556 # make sure we have some title to operate on
1557 static function checkTitle( &$title, &$name ) {
1558 if( !is_object( $title ) ) {
1559 $title = Title
::newFromText( $name );
1560 if( !is_object( $title ) ) {
1561 $title = Title
::newFromText( '--error: link target missing--' );
1567 * Build an array that represents the sidebar(s), the navigation bar among them
1572 function buildSidebar() {
1573 global $parserMemc, $wgEnableSidebarCache;
1574 global $wgLang, $wgContLang;
1576 $fname = 'SkinTemplate::buildSidebar';
1578 wfProfileIn( $fname );
1580 $key = wfMemcKey( 'sidebar' );
1581 $cacheSidebar = $wgEnableSidebarCache &&
1582 ($wgLang->getCode() == $wgContLang->getCode());
1584 if ($cacheSidebar) {
1585 $cachedsidebar = $parserMemc->get( $key );
1586 if ($cachedsidebar!="") {
1587 wfProfileOut($fname);
1588 return $cachedsidebar;
1593 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1594 foreach ($lines as $line) {
1595 if (strpos($line, '*') !== 0)
1597 if (strpos($line, '**') !== 0) {
1598 $line = trim($line, '* ');
1601 if (strpos($line, '|') !== false) { // sanity check
1602 $line = explode( '|' , trim($line, '* '), 2 );
1603 $link = wfMsgForContent( $line[0] );
1606 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1608 if (wfEmptyMsg($line[0], $link))
1611 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1614 $title = Title
::newFromText( $link );
1616 $title = $title->fixSpecialName();
1617 $href = $title->getLocalURL();
1619 $href = 'INVALID-TITLE';
1623 $bar[$heading][] = array(
1626 'id' => 'n-' . strtr($line[1], ' ', '-'),
1629 } else { continue; }
1633 $cachednotice = $parserMemc->set( $key, $bar, 86400 );
1634 wfProfileOut( $fname );