2 if ( ! defined( 'MEDIAWIKI' ) )
13 * The main skin class that provide methods and properties for all other skins.
14 * This base class is also the "Standard" skin.
16 class Skin
extends Linker
{
20 var $lastdate, $lastline;
21 var $rc_cache ; # Cache for Enhanced Recent Changes
22 var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle
24 var $mWatchLinkNum = 0; // Appended to end of watch link id's
27 /** Constructor, call parent constructor */
28 function Skin() { parent
::__construct(); }
31 * Fetch the set of available skins.
32 * @return array of strings
35 static function &getSkinNames() {
36 global $wgValidSkinNames;
37 static $skinsInitialised = false;
38 if ( !$skinsInitialised ) {
39 # Get a list of available skins
40 # Build using the regular expression '^(.*).php$'
41 # Array keys are all lower case, array value keep the case used by filename
43 wfProfileIn( __METHOD__
. '-init' );
44 global $wgStyleDirectory;
45 $skinDir = dir( $wgStyleDirectory );
47 # while code from www.php.net
48 while (false !== ($file = $skinDir->read())) {
49 // 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', 0 );
157 function initPage( &$out ) {
158 global $wgFavicon, $wgScriptPath, $wgSitename, $wgLanguageCode, $wgLanguageNames;
160 $fname = 'Skin::initPage';
161 wfProfileIn( $fname );
163 if( false !== $wgFavicon ) {
164 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
167 # OpenSearch description link
168 $out->addLink( array(
170 'type' => 'application/opensearchdescription+xml',
171 'href' => "$wgScriptPath/opensearch_desc.php",
172 'title' => "$wgSitename ({$wgLanguageNames[$wgLanguageCode]})",
175 $this->addMetadataLinks($out);
177 $this->mRevisionId
= $out->mRevisionId
;
179 $this->preloadExistence();
181 wfProfileOut( $fname );
185 * Preload the existence of three commonly-requested pages in a single query
187 function preloadExistence() {
188 global $wgUser, $wgTitle;
190 if ( $wgTitle->isTalkPage() ) {
191 $otherTab = $wgTitle->getSubjectPage();
193 $otherTab = $wgTitle->getTalkPage();
195 $lb = new LinkBatch( array(
196 $wgUser->getUserPage(),
197 $wgUser->getTalkPage(),
203 function addMetadataLinks( &$out ) {
204 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
205 global $wgRightsPage, $wgRightsUrl;
207 if( $out->isArticleRelated() ) {
208 # note: buggy CC software only reads first "meta" link
209 if( $wgEnableCreativeCommonsRdf ) {
210 $out->addMetadataLink( array(
211 'title' => 'Creative Commons',
212 'type' => 'application/rdf+xml',
213 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
215 if( $wgEnableDublinCoreRdf ) {
216 $out->addMetadataLink( array(
217 'title' => 'Dublin Core',
218 'type' => 'application/rdf+xml',
219 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
223 if( $wgRightsPage ) {
224 $copy = Title
::newFromText( $wgRightsPage );
226 $copyright = $copy->getLocalURL();
229 if( !$copyright && $wgRightsUrl ) {
230 $copyright = $wgRightsUrl;
233 $out->addLink( array(
234 'rel' => 'copyright',
235 'href' => $copyright ) );
239 function outputPage( &$out ) {
240 global $wgDebugComments;
242 wfProfileIn( 'Skin::outputPage' );
243 $this->initPage( $out );
245 $out->out( $out->headElement() );
247 $out->out( "\n<body" );
248 $ops = $this->getBodyOptions();
249 foreach ( $ops as $name => $val ) {
250 $out->out( " $name='$val'" );
253 if ( $wgDebugComments ) {
254 $out->out( "<!-- Wiki debugging output:\n" .
255 $out->mDebugtext
. "-->\n" );
258 $out->out( $this->beforeContent() );
260 $out->out( $out->mBodytext
. "\n" );
262 $out->out( $this->afterContent() );
264 $out->out( $this->bottomScripts() );
266 $out->out( $out->reportTime() );
268 $out->out( "\n</body></html>" );
271 static function makeVariablesScript( $data ) {
272 global $wgJsMimeType;
274 $r = "<script type= \"$wgJsMimeType\">/*<![CDATA[*/\n";
275 foreach ( $data as $name => $value ) {
276 $encValue = Xml
::encodeJsVar( $value );
277 $r .= "var $name = $encValue;\n";
279 $r .= "/*]]>*/</script>\n";
285 * Make a <script> tag containing global variables
286 * @param array $data Associative array containing one element:
287 * skinname => the skin name
288 * The odd calling convention is for backwards compatibility
290 static function makeGlobalVariablesScript( $data ) {
291 global $wgStylePath, $wgUser;
292 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
293 global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
294 global $wgBreakFrames;
296 $ns = $wgTitle->getNamespace();
297 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
300 'skin' => $data['skinname'],
301 'stylepath' => $wgStylePath,
302 'wgArticlePath' => $wgArticlePath,
303 'wgScriptPath' => $wgScriptPath,
304 'wgServer' => $wgServer,
305 'wgCanonicalNamespace' => $nsname,
306 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBKey() ),
307 'wgNamespaceNumber' => $wgTitle->getNamespace(),
308 'wgPageName' => $wgTitle->getPrefixedDBKey(),
309 'wgTitle' => $wgTitle->getText(),
310 'wgArticleId' => $wgTitle->getArticleId(),
311 'wgIsArticle' => $wgOut->isArticle(),
312 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
313 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getGroups(),
314 'wgUserLanguage' => $wgLang->getCode(),
315 'wgContentLanguage' => $wgContLang->getCode(),
316 'wgBreakFrames' => $wgBreakFrames,
317 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
320 return self
::makeVariablesScript( $vars );
323 function getHeadScripts() {
324 global $wgStylePath, $wgUser, $wgAllowUserJs, $wgJsMimeType, $wgStyleVersion;
326 $r = self
::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
328 $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n";
331 if ($wgUser->isLoggedIn()) {
332 $r .= "<script type=\"$wgJsMimeType\" src=\"".htmlspecialchars(self
::makeUrl('-','action=raw&smaxage=0&gen=js'))."\"><!-- site js --></script>\n";
334 $r .= "<script type=\"$wgJsMimeType\" src=\"".htmlspecialchars(self
::makeUrl('-','action=raw&gen=js'))."\"><!-- site js --></script>\n";
337 if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
338 $userpage = $wgUser->getUserPage();
339 $userjs = htmlspecialchars( self
::makeUrl(
340 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
341 'action=raw&ctype='.$wgJsMimeType));
342 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
348 * To make it harder for someone to slip a user a fake
349 * user-JavaScript or user-CSS preview, a random token
350 * is associated with the login session. If it's not
351 * passed back with the preview request, we won't render
354 * @param string $action
358 function userCanPreview( $action ) {
359 global $wgTitle, $wgRequest, $wgUser;
361 if( $action != 'submit' )
363 if( !$wgRequest->wasPosted() )
365 if( !$wgTitle->userCanEditCssJsSubpage() )
367 return $wgUser->matchEditToken(
368 $wgRequest->getVal( 'wpEditToken' ) );
371 # get the user/site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way)
372 function getUserStylesheet() {
373 global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage, $wgStyleVersion;
374 $sheet = $this->getStylesheet();
375 $s = "@import \"$wgStylePath/common/common.css?$wgStyleVersion\";\n";
376 $s .= "@import \"$wgStylePath/$sheet?$wgStyleVersion\";\n";
377 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css?$wgStyleVersion\";\n";
379 $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
380 $s .= '@import "' . self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n" .
381 '@import "' . self
::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
383 $s .= $this->doGetUserStyles();
388 * This returns MediaWiki:Common.js. For some bizarre reason, it does
389 * *not* return any custom user JS from user subpages. Huh?
393 function getUserJs() {
394 wfProfileIn( __METHOD__
);
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 global $wgUseAjax, $wgAjaxWatch;
406 if($wgUseAjax && $wgAjaxWatch) {
409 /* AJAX (un)watch (see /skins/common/ajaxwatch.js) */
411 watchMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'watch', array() ) )."',
412 unwatchMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'unwatch', array() ) )."',
413 watchingMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'watching', array() ) )."',
414 unwatchingMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'unwatching', array() ) )."'
418 wfProfileOut( __METHOD__
);
423 * Return html code that include User stylesheets
425 function getUserStyles() {
426 $s = "<style type='text/css'>\n";
427 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
428 $s .= $this->getUserStylesheet();
429 $s .= "/*]]>*/ /* */\n";
435 * Some styles that are set by user through the user settings interface.
437 function doGetUserStyles() {
438 global $wgUser, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
442 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
443 if($wgTitle->isCssSubpage() && $this->userCanPreview( $wgRequest->getText( 'action' ) ) ) {
444 $s .= $wgRequest->getText('wpTextbox1');
446 $userpage = $wgUser->getUserPage();
447 $s.= '@import "'.self
::makeUrl(
448 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
449 'action=raw&ctype=text/css').'";'."\n";
453 return $s . $this->reallyDoGetUserStyles();
456 function reallyDoGetUserStyles() {
459 if (($undopt = $wgUser->getOption("underline")) != 2) {
460 $underline = $undopt ?
'underline' : 'none';
461 $s .= "a { text-decoration: $underline; }\n";
463 if( $wgUser->getOption( 'highlightbroken' ) ) {
464 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
467 a.new, #quickbar a.new,
468 a.stub, #quickbar a.stub {
470 text-decoration: inherit;
472 a.new:after, #quickbar a.new:after {
475 text-decoration: $underline;
477 a.stub:after, #quickbar a.stub:after {
480 text-decoration: $underline;
484 if( $wgUser->getOption( 'justify' ) ) {
485 $s .= "#article, #bodyContent { text-align: justify; }\n";
487 if( !$wgUser->getOption( 'showtoc' ) ) {
488 $s .= "#toc { display: none; }\n";
490 if( !$wgUser->getOption( 'editsection' ) ) {
491 $s .= ".editsection { display: none; }\n";
496 function getBodyOptions() {
497 global $wgUser, $wgTitle, $wgOut, $wgRequest, $wgContLang;
499 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
501 if ( 0 != $wgTitle->getNamespace() ) {
502 $a = array( 'bgcolor' => '#ffffec' );
504 else $a = array( 'bgcolor' => '#FFFFFF' );
505 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
506 $wgTitle->userCan( 'edit' ) ) {
507 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
508 $s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
509 $a +
= array ('ondblclick' => $s);
512 $a['onload'] = $wgOut->getOnloadHandler();
513 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
514 if( $a['onload'] != '' ) {
517 $a['onload'] .= 'setupRightClickEdit()';
519 $a['class'] = 'ns-'.$wgTitle->getNamespace().' '.($wgContLang->isRTL() ?
"rtl" : "ltr").
520 ' '.Sanitizer
::escapeClass( 'page-'.$wgTitle->getPrefixedText() );
533 * This will be called immediately after the <body> tag. Split into
534 * two functions to make it easier to subclass.
536 function beforeContent() {
537 return $this->doBeforeContent();
540 function doBeforeContent() {
542 $fname = 'Skin::doBeforeContent';
543 wfProfileIn( $fname );
546 $qb = $this->qbSetting();
548 if( $langlinks = $this->otherLanguages() ) {
554 $borderhack = 'class="top"';
557 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
558 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
561 $left = ($qb == 1 ||
$qb == 3);
562 if($wgContLang->isRTL()) $left = !$left;
565 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
566 $this->logoText() . '</td>';
568 $s .= $this->getQuickbarCompensator( $rows );
570 $l = $wgContLang->isRTL() ?
'right' : 'left';
571 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
573 $s .= $this->topLinks() ;
574 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
576 $r = $wgContLang->isRTL() ?
"left" : "right";
577 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
578 $s .= $this->nameAndLogin();
579 $s .= "\n<br />" . $this->searchForm() . "</td>";
582 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
585 if ( $shove && !$left ) { # Right
586 $s .= $this->getQuickbarCompensator( $rows );
588 $s .= "</tr>\n</table>\n</div>\n";
589 $s .= "\n<div id='article'>\n";
591 $notice = wfGetSiteNotice();
593 $s .= "\n<div id='siteNotice'>$notice</div>\n";
595 $s .= $this->pageTitle();
596 $s .= $this->pageSubtitle() ;
597 $s .= $this->getCategories();
598 wfProfileOut( $fname );
603 function getCategoryLinks () {
604 global $wgOut, $wgTitle, $wgUseCategoryBrowser;
607 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
610 $sep = wfMsgHtml( 'catseparator' );
612 // Use Unicode bidi embedding override characters,
613 // to make sure links don't smash each other up in ugly ways.
614 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
615 $embed = "<span dir='$dir'>";
617 $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $wgOut->mCategoryLinks
) . $pop;
619 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escape' ), count( $wgOut->mCategoryLinks
) );
620 $s = $this->makeLinkObj( Title
::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
623 # optional 'dmoz-like' category browser. Will be shown under the list
624 # of categories an article belong to
625 if($wgUseCategoryBrowser) {
626 $s .= '<br /><hr />';
628 # get a big array of the parents tree
629 $parenttree = $wgTitle->getParentCategoryTree();
630 # Skin object passed by reference cause it can not be
631 # accessed under the method subfunction drawCategoryBrowser
632 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
633 # Clean out bogus first entry and sort them
636 # Output one per line
637 $s .= implode("<br />\n", $tempout);
643 /** Render the array as a serie of links.
644 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
645 * @param &skin Object: skin passed by reference
646 * @return String separated by >, terminate with "\n"
648 function drawCategoryBrowser($tree, &$skin) {
650 foreach ($tree as $element => $parent) {
651 if (empty($parent)) {
652 # element start a new list
655 # grab the others elements
656 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
658 # add our current element to the list
659 $eltitle = Title
::NewFromText($element);
660 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
665 function getCategories() {
666 $catlinks=$this->getCategoryLinks();
667 if(!empty($catlinks)) {
668 return "<p class='catlinks'>{$catlinks}</p>";
672 function getQuickbarCompensator( $rows = 1 ) {
673 return "<td width='152' rowspan='{$rows}'> </td>";
677 * This gets called shortly before the \</body\> tag.
678 * @return String HTML to be put before \</body\>
680 function afterContent() {
681 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
682 return $printfooter . $this->doAfterContent();
686 * This gets called shortly before the \</body\> tag.
687 * @return String HTML-wrapped JS code to be put before \</body\>
689 function bottomScripts() {
690 global $wgJsMimeType;
691 return "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
694 /** @return string Retrievied from HTML text */
695 function printSource() {
697 $url = htmlspecialchars( $wgTitle->getFullURL() );
698 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
701 function printFooter() {
702 return "<p>" . $this->printSource() .
703 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
706 /** overloaded by derived classes */
707 function doAfterContent() { }
709 function pageTitleLinks() {
710 global $wgOut, $wgTitle, $wgUser, $wgRequest;
712 $oldid = $wgRequest->getVal( 'oldid' );
713 $diff = $wgRequest->getVal( 'diff' );
714 $action = $wgRequest->getText( 'action' );
716 $s = $this->printableLink();
717 $disclaimer = $this->disclaimerLink(); # may be empty
719 $s .= ' | ' . $disclaimer;
721 $privacy = $this->privacyLink(); # may be empty too
723 $s .= ' | ' . $privacy;
726 if ( $wgOut->isArticleRelated() ) {
727 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
728 $name = $wgTitle->getDBkey();
729 $image = new Image( $wgTitle );
730 if( $image->exists() ) {
731 $link = htmlspecialchars( $image->getURL() );
732 $style = $this->getInternalLinkAttributes( $link, $name );
733 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
737 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
738 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
739 wfMsg( 'currentrev' ) );
742 if ( $wgUser->getNewtalk() ) {
743 # do not show "You have new messages" text when we are viewing our
745 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
746 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
747 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
748 $s.= ' | <strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
750 $wgOut->setSquidMaxage(0);
751 $wgOut->enableClientCache(false);
755 $undelete = $this->getUndeleteLink();
756 if( !empty( $undelete ) ) {
757 $s .= ' | '.$undelete;
762 function getUndeleteLink() {
763 global $wgUser, $wgTitle, $wgContLang, $action;
764 if( $wgUser->isAllowed( 'deletedhistory' ) &&
765 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
766 ($n = $wgTitle->isDeleted() ) )
768 if ( $wgUser->isAllowed( 'delete' ) ) {
769 $msg = 'thisisdeleted';
771 $msg = 'viewdeleted';
774 $this->makeKnownLinkObj(
775 SpecialPage
::getTitleFor( 'Undelete', $wgTitle->getPrefixedDBkey() ),
776 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $n ) ) );
781 function printableLink() {
782 global $wgOut, $wgFeedClasses, $wgRequest;
784 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
786 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
787 if( $wgOut->isSyndicated() ) {
788 foreach( $wgFeedClasses as $format => $class ) {
789 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
790 $s .= " | <a href=\"$feedurl\">{$format}</a>";
796 function pageTitle() {
798 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
802 function pageSubtitle() {
805 $sub = $wgOut->getSubtitle();
807 global $wgExtraSubtitle;
808 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
810 $subpages = $this->subPageSubtitle();
811 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
812 $s = "<p class='subtitle'>{$sub}</p>\n";
816 function subPageSubtitle() {
817 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
819 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
820 $ptext=$wgTitle->getPrefixedText();
821 if(preg_match('/\//',$ptext)) {
822 $links = explode('/',$ptext);
825 foreach($links as $link) {
827 if ($c<count($links)) {
828 $growinglink .= $link;
829 $getlink = $this->makeLink( $growinglink, htmlspecialchars( $link ) );
830 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
834 $subpages .= '< ';
836 $subpages .= $getlink;
845 function nameAndLogin() {
846 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader;
848 $lo = $wgContLang->specialPage( 'Userlogout' );
851 if ( $wgUser->isAnon() ) {
852 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
855 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
856 $wgLang->getNsText( NS_TALK
) );
858 $s .= $n . ' ('.$tl.')';
860 $s .= wfMsg('notloggedin');
863 $rt = $wgTitle->getPrefixedURL();
864 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
866 } else { $q = "returnto={$rt}"; }
868 $s .= "\n<br />" . $this->makeKnownLinkObj(
869 SpecialPage
::getTitleFor( 'Userlogin' ),
870 wfMsg( 'login' ), $q );
872 $n = $wgUser->getName();
873 $rt = $wgTitle->getPrefixedURL();
874 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
875 $wgLang->getNsText( NS_TALK
) );
879 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
880 $n ) . "{$tl}<br />" .
881 $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
882 "returnto={$rt}" ) . ' | ' .
883 $this->specialLink( 'preferences' );
885 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
891 function getSearchLink() {
892 $searchPage = SpecialPage
::getTitleFor( 'Search' );
893 return $searchPage->getLocalURL();
896 function escapeSearchLink() {
897 return htmlspecialchars( $this->getSearchLink() );
900 function searchForm() {
902 $search = $wgRequest->getText( 'search' );
904 $s = '<form name="search" class="inline" method="post" action="'
905 . $this->escapeSearchLink() . "\">\n"
906 . '<input type="text" name="search" size="19" value="'
907 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
908 . '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" /> '
909 . '<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n</form>";
914 function topLinks() {
918 $s = $this->mainPageLink() . $sep
919 . $this->specialLink( 'recentchanges' );
921 if ( $wgOut->isArticleRelated() ) {
922 $s .= $sep . $this->editThisPage()
923 . $sep . $this->historyLink();
925 # Many people don't like this dropdown box
926 #$s .= $sep . $this->specialPagesList();
928 $s .= $this->variantLinks();
930 $s .= $this->extensionTabLinks();
936 * Compatibility for extensions adding functionality through tabs.
937 * Eventually these old skins should be replaced with SkinTemplate-based
941 function extensionTabLinks() {
944 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
945 foreach( $tabs as $tab ) {
946 $s .= ' | ' . Xml
::element( 'a',
947 array( 'href' => $tab['href'] ),
954 * Language/charset variant links for classic-style skins
957 function variantLinks() {
959 /* show links to different language variants */
960 global $wgDisableLangConversion, $wgContLang, $wgTitle;
961 $variants = $wgContLang->getVariants();
962 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
963 foreach( $variants as $code ) {
964 $varname = $wgContLang->getVariantname( $code );
965 if( $varname == 'disable' )
967 $s .= ' | <a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>';
973 function bottomLinks() {
974 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
978 if ( $wgOut->isArticleRelated() ) {
979 $s .= '<strong>' . $this->editThisPage() . '</strong>';
980 if ( $wgUser->isLoggedIn() ) {
981 $s .= $sep . $this->watchThisPage();
983 $s .= $sep . $this->talkLink()
984 . $sep . $this->historyLink()
985 . $sep . $this->whatLinksHere()
986 . $sep . $this->watchPageLinksLink();
988 if ($wgUseTrackbacks)
989 $s .= $sep . $this->trackbackLink();
991 if ( $wgTitle->getNamespace() == NS_USER
992 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
995 $id=User
::idFromName($wgTitle->getText());
996 $ip=User
::isIP($wgTitle->getText());
998 if($id ||
$ip) { # both anons and non-anons have contri list
999 $s .= $sep . $this->userContribsLink();
1001 if( $this->showEmailUser( $id ) ) {
1002 $s .= $sep . $this->emailUserLink();
1005 if ( $wgTitle->getArticleId() ) {
1007 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
1008 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
1009 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
1011 $s .= "<br />\n" . $this->otherLanguages();
1016 function pageStats() {
1017 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1018 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
1020 $oldid = $wgRequest->getVal( 'oldid' );
1021 $diff = $wgRequest->getVal( 'diff' );
1022 if ( ! $wgOut->isArticle() ) { return ''; }
1023 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1024 if ( 0 == $wgArticle->getID() ) { return ''; }
1027 if ( !$wgDisableCounters ) {
1028 $count = $wgLang->formatNum( $wgArticle->getCount() );
1030 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1034 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
1035 require_once('Credits.php');
1036 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
1038 $s .= $this->lastModified();
1041 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
1042 $dbr =& wfGetDB( DB_SLAVE
);
1043 $watchlist = $dbr->tableName( 'watchlist' );
1044 $sql = "SELECT COUNT(*) AS n FROM $watchlist
1045 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
1046 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
1047 $res = $dbr->query( $sql, 'Skin::pageStats');
1048 $x = $dbr->fetchObject( $res );
1049 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
1052 return $s . ' ' . $this->getCopyright();
1055 function getCopyright( $type = 'detect' ) {
1056 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
1058 if ( $type == 'detect' ) {
1059 $oldid = $wgRequest->getVal( 'oldid' );
1060 $diff = $wgRequest->getVal( 'diff' );
1062 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1069 if ( $type == 'history' ) {
1070 $msg = 'history_copyright';
1076 if( $wgRightsPage ) {
1077 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
1078 } elseif( $wgRightsUrl ) {
1079 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1084 $out .= wfMsgForContent( $msg, $link );
1088 function getCopyrightIcon() {
1089 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1091 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1092 $out = $wgCopyrightIcon;
1093 } else if ( $wgRightsIcon ) {
1094 $icon = htmlspecialchars( $wgRightsIcon );
1095 if ( $wgRightsUrl ) {
1096 $url = htmlspecialchars( $wgRightsUrl );
1097 $out .= '<a href="'.$url.'">';
1099 $text = htmlspecialchars( $wgRightsText );
1100 $out .= "<img src=\"$icon\" alt='$text' />";
1101 if ( $wgRightsUrl ) {
1108 function getPoweredBy() {
1109 global $wgStylePath;
1110 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1111 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1115 function lastModified() {
1116 global $wgLang, $wgArticle, $wgLoadBalancer;
1118 $timestamp = $wgArticle->getTimestamp();
1120 $d = $wgLang->date( $timestamp, true );
1121 $t = $wgLang->time( $timestamp, true );
1122 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1126 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
1127 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1132 function logoText( $align = '' ) {
1133 if ( '' != $align ) { $a = " align='{$align}'"; }
1136 $mp = wfMsg( 'mainpage' );
1137 $mptitle = Title
::newMainPage();
1138 $url = ( is_object($mptitle) ?
$mptitle->escapeLocalURL() : '' );
1140 $logourl = $this->getLogo();
1141 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1146 * show a drop-down box of special pages
1148 function specialPagesList() {
1149 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1150 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1151 foreach ( $pages as $name => $page ) {
1152 $pages[$name] = $page->getDescription();
1155 $go = wfMsg( 'go' );
1156 $sp = wfMsg( 'specialpages' );
1157 $spp = $wgContLang->specialPage( 'Specialpages' );
1159 $s = '<form id="specialpages" method="get" class="inline" ' .
1160 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1161 $s .= "<select name=\"wpDropdown\">\n";
1162 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1165 foreach ( $pages as $name => $desc ) {
1166 $p = $wgContLang->specialPage( $name );
1167 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1169 $s .= "</select>\n";
1170 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1175 function mainPageLink() {
1176 $s = $this->makeKnownLinkObj( Title
::newMainPage(), wfMsg( 'mainpage' ) );
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->userCan( 'edit' ) ) {
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;
1280 ++
$this->mWatchLinkNum
;
1282 if ( $wgOut->isArticleRelated() ) {
1283 if ( $wgTitle->userIsWatching() ) {
1284 $t = wfMsg( 'unwatchthispage' );
1285 $q = 'action=unwatch';
1286 $id = "mw-unwatch-link".$this->mWatchLinkNum
;
1288 $t = wfMsg( 'watchthispage' );
1289 $q = 'action=watch';
1290 $id = 'mw-watch-link'.$this->mWatchLinkNum
;
1292 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q, '', '', " id=\"$id\"" );
1294 $s = wfMsg( 'notanarticle' );
1299 function moveThisPage() {
1302 if ( $wgTitle->userCan( 'move' ) ) {
1303 return $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
1304 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1306 // no message if page is protected - would be redundant
1311 function historyLink() {
1314 return $this->makeKnownLinkObj( $wgTitle,
1315 wfMsg( 'history' ), 'action=history' );
1318 function whatLinksHere() {
1321 return $this->makeKnownLinkObj(
1322 SpecialPage
::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ),
1323 wfMsg( 'whatlinkshere' ) );
1326 function userContribsLink() {
1329 return $this->makeKnownLinkObj(
1330 SpecialPage
::getTitleFor( 'Contributions', $wgTitle->getDBkey() ),
1331 wfMsg( 'contributions' ) );
1334 function showEmailUser( $id ) {
1335 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1336 return $wgEnableEmail &&
1337 $wgEnableUserEmail &&
1338 $wgUser->isLoggedIn() && # show only to signed in users
1339 0 != $id; # we can only email to non-anons ..
1340 # '' != $id->getEmail() && # who must have an email address stored ..
1341 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1342 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1345 function emailUserLink() {
1348 return $this->makeKnownLinkObj(
1349 SpecialPage
::getTitleFor( 'Emailuser', $wgTitle->getDBkey() ),
1350 wfMsg( 'emailuser' ) );
1353 function watchPageLinksLink() {
1354 global $wgOut, $wgTitle;
1356 if ( ! $wgOut->isArticleRelated() ) {
1357 return '(' . wfMsg( 'notanarticle' ) . ')';
1359 return $this->makeKnownLinkObj(
1360 SpecialPage
::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ),
1361 wfMsg( 'recentchangeslinked' ) );
1365 function trackbackLink() {
1368 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1369 . wfMsg('trackbacklink') . "</a>";
1372 function otherLanguages() {
1373 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1375 if ( $wgHideInterlanguageLinks ) {
1379 $a = $wgOut->getLanguageLinks();
1380 if ( 0 == count( $a ) ) {
1384 $s = wfMsg( 'otherlanguages' ) . ': ';
1386 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1387 foreach( $a as $l ) {
1388 if ( ! $first ) { $s .= ' | '; }
1391 $nt = Title
::newFromText( $l );
1392 $url = $nt->escapeFullURL();
1393 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1395 if ( '' == $text ) { $text = $l; }
1396 $style = $this->getExternalLinkAttributes( $l, $text );
1397 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1399 if($wgContLang->isRTL()) $s .= '</span>';
1403 function bugReportsLink() {
1404 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1405 wfMsg( 'bugreports' ) );
1409 function dateLink() {
1410 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1411 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1413 $id = $t1->getArticleID();
1416 $s = $this->makeBrokenLink( $t1->getText() );
1418 $s = $this->makeKnownLink( $t1->getText() );
1422 $id = $t2->getArticleID();
1425 $s .= $this->makeBrokenLink( $t2->getText() );
1427 $s .= $this->makeKnownLink( $t2->getText() );
1432 function talkLink() {
1435 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1436 # No discussion links for special pages
1440 if( $wgTitle->isTalkPage() ) {
1441 $link = $wgTitle->getSubjectPage();
1442 switch( $link->getNamespace() ) {
1444 $text = wfMsg( 'articlepage' );
1447 $text = wfMsg( 'userpage' );
1450 $text = wfMsg( 'projectpage' );
1453 $text = wfMsg( 'imagepage' );
1456 $text = wfMsg( 'mediawikipage' );
1459 $text = wfMsg( 'templatepage' );
1462 $text = wfMsg( 'viewhelppage' );
1465 $text = wfMsg( 'categorypage' );
1468 $text = wfMsg( 'articlepage' );
1471 $link = $wgTitle->getTalkPage();
1472 $text = wfMsg( 'talkpage' );
1475 $s = $this->makeLinkObj( $link, $text );
1480 function commentLink() {
1481 global $wgTitle, $wgOut;
1483 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1487 # __NEWSECTIONLINK___ changes behaviour here
1488 # If it's present, the link points to this page, otherwise
1489 # it points to the talk page
1490 if( $wgTitle->isTalkPage() ) {
1492 } elseif( $wgOut->showNewSectionLink() ) {
1495 $title =& $wgTitle->getTalkPage();
1498 return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1501 /* these are used extensively in SkinTemplate, but also some other places */
1502 static function makeMainPageUrl( $urlaction = '' ) {
1503 $title = Title
::newMainPage();
1504 self
::checkTitle( $title, '' );
1505 return $title->getLocalURL( $urlaction );
1508 static function makeSpecialUrl( $name, $urlaction = '' ) {
1509 $title = SpecialPage
::getTitleFor( $name );
1510 return $title->getLocalURL( $urlaction );
1513 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1514 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1515 return $title->getLocalURL( $urlaction );
1518 static function makeI18nUrl( $name, $urlaction = '' ) {
1519 $title = Title
::newFromText( wfMsgForContent( $name ) );
1520 self
::checkTitle( $title, $name );
1521 return $title->getLocalURL( $urlaction );
1524 static function makeUrl( $name, $urlaction = '' ) {
1525 $title = Title
::newFromText( $name );
1526 self
::checkTitle( $title, $name );
1527 return $title->getLocalURL( $urlaction );
1530 # If url string starts with http, consider as external URL, else
1532 static function makeInternalOrExternalUrl( $name ) {
1533 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1536 return self
::makeUrl( $name );
1540 # this can be passed the NS number as defined in Language.php
1541 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1542 $title = Title
::makeTitleSafe( $namespace, $name );
1543 self
::checkTitle( $title, $name );
1544 return $title->getLocalURL( $urlaction );
1547 /* these return an array with the 'href' and boolean 'exists' */
1548 static function makeUrlDetails( $name, $urlaction = '' ) {
1549 $title = Title
::newFromText( $name );
1550 self
::checkTitle( $title, $name );
1552 'href' => $title->getLocalURL( $urlaction ),
1553 'exists' => $title->getArticleID() != 0 ?
true : false
1558 * Make URL details where the article exists (or at least it's convenient to think so)
1560 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1561 $title = Title
::newFromText( $name );
1562 self
::checkTitle( $title, $name );
1564 'href' => $title->getLocalURL( $urlaction ),
1569 # make sure we have some title to operate on
1570 static function checkTitle( &$title, $name ) {
1571 if( !is_object( $title ) ) {
1572 $title = Title
::newFromText( $name );
1573 if( !is_object( $title ) ) {
1574 $title = Title
::newFromText( '--error: link target missing--' );
1580 * Build an array that represents the sidebar(s), the navigation bar among them
1585 function buildSidebar() {
1586 global $parserMemc, $wgEnableSidebarCache;
1587 global $wgLang, $wgContLang;
1589 $fname = 'SkinTemplate::buildSidebar';
1591 wfProfileIn( $fname );
1593 $key = wfMemcKey( 'sidebar' );
1594 $cacheSidebar = $wgEnableSidebarCache &&
1595 ($wgLang->getCode() == $wgContLang->getCode());
1597 if ($cacheSidebar) {
1598 $cachedsidebar = $parserMemc->get( $key );
1599 if ($cachedsidebar!="") {
1600 wfProfileOut($fname);
1601 return $cachedsidebar;
1606 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1607 foreach ($lines as $line) {
1608 if (strpos($line, '*') !== 0)
1610 if (strpos($line, '**') !== 0) {
1611 $line = trim($line, '* ');
1614 if (strpos($line, '|') !== false) { // sanity check
1615 $line = explode( '|' , trim($line, '* '), 2 );
1616 $link = wfMsgForContent( $line[0] );
1619 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1621 if (wfEmptyMsg($line[0], $link))
1624 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1627 $title = Title
::newFromText( $link );
1629 $title = $title->fixSpecialName();
1630 $href = $title->getLocalURL();
1632 $href = 'INVALID-TITLE';
1636 $bar[$heading][] = array(
1639 'id' => 'n-' . strtr($line[1], ' ', '-'),
1642 } else { continue; }
1646 $parserMemc->set( $key, $bar, 86400 );
1647 wfProfileOut( $fname );