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;
191 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
194 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
196 } elseif ( $wgTitle->isTalkPage() ) {
197 $titles[] = $wgTitle->getSubjectPage();
199 $titles[] = $wgTitle->getTalkPage();
202 $lb = new LinkBatch( $titles );
206 function addMetadataLinks( &$out ) {
207 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
208 global $wgRightsPage, $wgRightsUrl;
210 if( $out->isArticleRelated() ) {
211 # note: buggy CC software only reads first "meta" link
212 if( $wgEnableCreativeCommonsRdf ) {
213 $out->addMetadataLink( array(
214 'title' => 'Creative Commons',
215 'type' => 'application/rdf+xml',
216 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
218 if( $wgEnableDublinCoreRdf ) {
219 $out->addMetadataLink( array(
220 'title' => 'Dublin Core',
221 'type' => 'application/rdf+xml',
222 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
226 if( $wgRightsPage ) {
227 $copy = Title
::newFromText( $wgRightsPage );
229 $copyright = $copy->getLocalURL();
232 if( !$copyright && $wgRightsUrl ) {
233 $copyright = $wgRightsUrl;
236 $out->addLink( array(
237 'rel' => 'copyright',
238 'href' => $copyright ) );
242 function outputPage( &$out ) {
243 global $wgDebugComments;
245 wfProfileIn( 'Skin::outputPage' );
246 $this->initPage( $out );
248 $out->out( $out->headElement() );
250 $out->out( "\n<body" );
251 $ops = $this->getBodyOptions();
252 foreach ( $ops as $name => $val ) {
253 $out->out( " $name='$val'" );
256 if ( $wgDebugComments ) {
257 $out->out( "<!-- Wiki debugging output:\n" .
258 $out->mDebugtext
. "-->\n" );
261 $out->out( $this->beforeContent() );
263 $out->out( $out->mBodytext
. "\n" );
265 $out->out( $this->afterContent() );
267 $out->out( $this->bottomScripts() );
269 $out->out( $out->reportTime() );
271 $out->out( "\n</body></html>" );
274 static function makeVariablesScript( $data ) {
275 global $wgJsMimeType;
277 $r = "<script type= \"$wgJsMimeType\">/*<![CDATA[*/\n";
278 foreach ( $data as $name => $value ) {
279 $encValue = Xml
::encodeJsVar( $value );
280 $r .= "var $name = $encValue;\n";
282 $r .= "/*]]>*/</script>\n";
288 * Make a <script> tag containing global variables
289 * @param array $data Associative array containing one element:
290 * skinname => the skin name
291 * The odd calling convention is for backwards compatibility
293 static function makeGlobalVariablesScript( $data ) {
294 global $wgStylePath, $wgUser;
295 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
296 global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
297 global $wgBreakFrames;
299 $ns = $wgTitle->getNamespace();
300 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
303 'skin' => $data['skinname'],
304 'stylepath' => $wgStylePath,
305 'wgArticlePath' => $wgArticlePath,
306 'wgScriptPath' => $wgScriptPath,
307 'wgServer' => $wgServer,
308 'wgCanonicalNamespace' => $nsname,
309 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBKey() ),
310 'wgNamespaceNumber' => $wgTitle->getNamespace(),
311 'wgPageName' => $wgTitle->getPrefixedDBKey(),
312 'wgTitle' => $wgTitle->getText(),
313 'wgArticleId' => $wgTitle->getArticleId(),
314 'wgIsArticle' => $wgOut->isArticle(),
315 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
316 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getEffectiveGroups(),
317 'wgUserLanguage' => $wgLang->getCode(),
318 'wgContentLanguage' => $wgContLang->getCode(),
319 'wgBreakFrames' => $wgBreakFrames,
320 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
323 return self
::makeVariablesScript( $vars );
326 function getHeadScripts() {
327 global $wgStylePath, $wgUser, $wgAllowUserJs, $wgJsMimeType, $wgStyleVersion;
329 $r = self
::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
331 $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n";
334 if ($wgUser->isLoggedIn()) {
335 $r .= "<script type=\"$wgJsMimeType\" src=\"".htmlspecialchars(self
::makeUrl('-','action=raw&smaxage=0&gen=js'))."\"><!-- site js --></script>\n";
337 $r .= "<script type=\"$wgJsMimeType\" src=\"".htmlspecialchars(self
::makeUrl('-','action=raw&gen=js'))."\"><!-- site js --></script>\n";
340 if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
341 $userpage = $wgUser->getUserPage();
342 $userjs = htmlspecialchars( self
::makeUrl(
343 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
344 'action=raw&ctype='.$wgJsMimeType));
345 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
351 * To make it harder for someone to slip a user a fake
352 * user-JavaScript or user-CSS preview, a random token
353 * is associated with the login session. If it's not
354 * passed back with the preview request, we won't render
357 * @param string $action
361 function userCanPreview( $action ) {
362 global $wgTitle, $wgRequest, $wgUser;
364 if( $action != 'submit' )
366 if( !$wgRequest->wasPosted() )
368 if( !$wgTitle->userCanEditCssJsSubpage() )
370 return $wgUser->matchEditToken(
371 $wgRequest->getVal( 'wpEditToken' ) );
374 # get the user/site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way)
375 function getUserStylesheet() {
376 global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage, $wgStyleVersion;
377 $sheet = $this->getStylesheet();
378 $s = "@import \"$wgStylePath/common/common.css?$wgStyleVersion\";\n";
379 $s .= "@import \"$wgStylePath/$sheet?$wgStyleVersion\";\n";
380 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css?$wgStyleVersion\";\n";
382 $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
383 $s .= '@import "' . self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n" .
384 '@import "' . self
::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
386 $s .= $this->doGetUserStyles();
391 * This returns MediaWiki:Common.js. For some bizarre reason, it does
392 * *not* return any custom user JS from user subpages. Huh?
396 function getUserJs() {
397 wfProfileIn( __METHOD__
);
400 $s = "/* generated javascript */\n";
401 $s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';";
402 $s .= "\n\n/* MediaWiki:Common.js */\n";
403 $commonJs = wfMsgForContent('common.js');
404 if ( !wfEmptyMsg ( 'common.js', $commonJs ) ) {
408 global $wgUseAjax, $wgAjaxWatch;
409 if($wgUseAjax && $wgAjaxWatch) {
412 /* AJAX (un)watch (see /skins/common/ajaxwatch.js) */
414 watchMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'watch', array() ) )."',
415 unwatchMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'unwatch', array() ) )."',
416 watchingMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'watching', array() ) )."',
417 unwatchingMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'unwatching', array() ) )."'
421 wfProfileOut( __METHOD__
);
426 * Return html code that include User stylesheets
428 function getUserStyles() {
429 $s = "<style type='text/css'>\n";
430 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
431 $s .= $this->getUserStylesheet();
432 $s .= "/*]]>*/ /* */\n";
438 * Some styles that are set by user through the user settings interface.
440 function doGetUserStyles() {
441 global $wgUser, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
445 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
446 if($wgTitle->isCssSubpage() && $this->userCanPreview( $wgRequest->getText( 'action' ) ) ) {
447 $s .= $wgRequest->getText('wpTextbox1');
449 $userpage = $wgUser->getUserPage();
450 $s.= '@import "'.self
::makeUrl(
451 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
452 'action=raw&ctype=text/css').'";'."\n";
456 return $s . $this->reallyDoGetUserStyles();
459 function reallyDoGetUserStyles() {
462 if (($undopt = $wgUser->getOption("underline")) != 2) {
463 $underline = $undopt ?
'underline' : 'none';
464 $s .= "a { text-decoration: $underline; }\n";
466 if( $wgUser->getOption( 'highlightbroken' ) ) {
467 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
470 a.new, #quickbar a.new,
471 a.stub, #quickbar a.stub {
473 text-decoration: inherit;
475 a.new:after, #quickbar a.new:after {
478 text-decoration: $underline;
480 a.stub:after, #quickbar a.stub:after {
483 text-decoration: $underline;
487 if( $wgUser->getOption( 'justify' ) ) {
488 $s .= "#article, #bodyContent { text-align: justify; }\n";
490 if( !$wgUser->getOption( 'showtoc' ) ) {
491 $s .= "#toc { display: none; }\n";
493 if( !$wgUser->getOption( 'editsection' ) ) {
494 $s .= ".editsection { display: none; }\n";
499 function getBodyOptions() {
500 global $wgUser, $wgTitle, $wgOut, $wgRequest, $wgContLang;
502 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
504 if ( 0 != $wgTitle->getNamespace() ) {
505 $a = array( 'bgcolor' => '#ffffec' );
507 else $a = array( 'bgcolor' => '#FFFFFF' );
508 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
509 $wgTitle->userCan( 'edit' ) ) {
510 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
511 $s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
512 $a +
= array ('ondblclick' => $s);
515 $a['onload'] = $wgOut->getOnloadHandler();
516 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
517 if( $a['onload'] != '' ) {
520 $a['onload'] .= 'setupRightClickEdit()';
522 $a['class'] = 'ns-'.$wgTitle->getNamespace().' '.($wgContLang->isRTL() ?
"rtl" : "ltr").
523 ' '.Sanitizer
::escapeClass( 'page-'.$wgTitle->getPrefixedText() );
536 * This will be called immediately after the <body> tag. Split into
537 * two functions to make it easier to subclass.
539 function beforeContent() {
540 return $this->doBeforeContent();
543 function doBeforeContent() {
545 $fname = 'Skin::doBeforeContent';
546 wfProfileIn( $fname );
549 $qb = $this->qbSetting();
551 if( $langlinks = $this->otherLanguages() ) {
557 $borderhack = 'class="top"';
560 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
561 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
564 $left = ($qb == 1 ||
$qb == 3);
565 if($wgContLang->isRTL()) $left = !$left;
568 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
569 $this->logoText() . '</td>';
571 $s .= $this->getQuickbarCompensator( $rows );
573 $l = $wgContLang->isRTL() ?
'right' : 'left';
574 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
576 $s .= $this->topLinks() ;
577 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
579 $r = $wgContLang->isRTL() ?
"left" : "right";
580 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
581 $s .= $this->nameAndLogin();
582 $s .= "\n<br />" . $this->searchForm() . "</td>";
585 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
588 if ( $shove && !$left ) { # Right
589 $s .= $this->getQuickbarCompensator( $rows );
591 $s .= "</tr>\n</table>\n</div>\n";
592 $s .= "\n<div id='article'>\n";
594 $notice = wfGetSiteNotice();
596 $s .= "\n<div id='siteNotice'>$notice</div>\n";
598 $s .= $this->pageTitle();
599 $s .= $this->pageSubtitle() ;
600 $s .= $this->getCategories();
601 wfProfileOut( $fname );
606 function getCategoryLinks () {
607 global $wgOut, $wgTitle, $wgUseCategoryBrowser;
610 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
613 $sep = wfMsgHtml( 'catseparator' );
615 // Use Unicode bidi embedding override characters,
616 // to make sure links don't smash each other up in ugly ways.
617 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
618 $embed = "<span dir='$dir'>";
620 $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $wgOut->mCategoryLinks
) . $pop;
622 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escape' ), count( $wgOut->mCategoryLinks
) );
623 $s = $this->makeLinkObj( Title
::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
626 # optional 'dmoz-like' category browser. Will be shown under the list
627 # of categories an article belong to
628 if($wgUseCategoryBrowser) {
629 $s .= '<br /><hr />';
631 # get a big array of the parents tree
632 $parenttree = $wgTitle->getParentCategoryTree();
633 # Skin object passed by reference cause it can not be
634 # accessed under the method subfunction drawCategoryBrowser
635 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
636 # Clean out bogus first entry and sort them
639 # Output one per line
640 $s .= implode("<br />\n", $tempout);
646 /** Render the array as a serie of links.
647 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
648 * @param &skin Object: skin passed by reference
649 * @return String separated by >, terminate with "\n"
651 function drawCategoryBrowser($tree, &$skin) {
653 foreach ($tree as $element => $parent) {
654 if (empty($parent)) {
655 # element start a new list
658 # grab the others elements
659 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
661 # add our current element to the list
662 $eltitle = Title
::NewFromText($element);
663 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
668 function getCategories() {
669 $catlinks=$this->getCategoryLinks();
670 if(!empty($catlinks)) {
671 return "<p class='catlinks'>{$catlinks}</p>";
675 function getQuickbarCompensator( $rows = 1 ) {
676 return "<td width='152' rowspan='{$rows}'> </td>";
680 * This gets called shortly before the \</body\> tag.
681 * @return String HTML to be put before \</body\>
683 function afterContent() {
684 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
685 return $printfooter . $this->doAfterContent();
689 * This gets called shortly before the \</body\> tag.
690 * @return String HTML-wrapped JS code to be put before \</body\>
692 function bottomScripts() {
693 global $wgJsMimeType;
694 return "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
697 /** @return string Retrievied from HTML text */
698 function printSource() {
700 $url = htmlspecialchars( $wgTitle->getFullURL() );
701 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
704 function printFooter() {
705 return "<p>" . $this->printSource() .
706 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
709 /** overloaded by derived classes */
710 function doAfterContent() { }
712 function pageTitleLinks() {
713 global $wgOut, $wgTitle, $wgUser, $wgRequest;
715 $oldid = $wgRequest->getVal( 'oldid' );
716 $diff = $wgRequest->getVal( 'diff' );
717 $action = $wgRequest->getText( 'action' );
719 $s = $this->printableLink();
720 $disclaimer = $this->disclaimerLink(); # may be empty
722 $s .= ' | ' . $disclaimer;
724 $privacy = $this->privacyLink(); # may be empty too
726 $s .= ' | ' . $privacy;
729 if ( $wgOut->isArticleRelated() ) {
730 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
731 $name = $wgTitle->getDBkey();
732 $image = new Image( $wgTitle );
733 if( $image->exists() ) {
734 $link = htmlspecialchars( $image->getURL() );
735 $style = $this->getInternalLinkAttributes( $link, $name );
736 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
740 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
741 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
742 wfMsg( 'currentrev' ) );
745 if ( $wgUser->getNewtalk() ) {
746 # do not show "You have new messages" text when we are viewing our
748 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
749 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
750 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
751 $s.= ' | <strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
753 $wgOut->setSquidMaxage(0);
754 $wgOut->enableClientCache(false);
758 $undelete = $this->getUndeleteLink();
759 if( !empty( $undelete ) ) {
760 $s .= ' | '.$undelete;
765 function getUndeleteLink() {
766 global $wgUser, $wgTitle, $wgContLang, $action;
767 if( $wgUser->isAllowed( 'deletedhistory' ) &&
768 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
769 ($n = $wgTitle->isDeleted() ) )
771 if ( $wgUser->isAllowed( 'delete' ) ) {
772 $msg = 'thisisdeleted';
774 $msg = 'viewdeleted';
777 $this->makeKnownLinkObj(
778 SpecialPage
::getTitleFor( 'Undelete', $wgTitle->getPrefixedDBkey() ),
779 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $n ) ) );
784 function printableLink() {
785 global $wgOut, $wgFeedClasses, $wgRequest;
787 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
789 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
790 if( $wgOut->isSyndicated() ) {
791 foreach( $wgFeedClasses as $format => $class ) {
792 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
793 $s .= " | <a href=\"$feedurl\">{$format}</a>";
799 function pageTitle() {
801 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
805 function pageSubtitle() {
808 $sub = $wgOut->getSubtitle();
810 global $wgExtraSubtitle;
811 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
813 $subpages = $this->subPageSubtitle();
814 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
815 $s = "<p class='subtitle'>{$sub}</p>\n";
819 function subPageSubtitle() {
820 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
822 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
823 $ptext=$wgTitle->getPrefixedText();
824 if(preg_match('/\//',$ptext)) {
825 $links = explode('/',$ptext);
828 foreach($links as $link) {
830 if ($c<count($links)) {
831 $growinglink .= $link;
832 $getlink = $this->makeLink( $growinglink, htmlspecialchars( $link ) );
833 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
837 $subpages .= '< ';
839 $subpages .= $getlink;
849 * Returns true if the IP should be shown in the header
851 function showIPinHeader() {
852 global $wgShowIPinHeader;
853 return $wgShowIPinHeader && session_id() != '';
856 function nameAndLogin() {
857 global $wgUser, $wgTitle, $wgLang, $wgContLang;
859 $lo = $wgContLang->specialPage( 'Userlogout' );
862 if ( $wgUser->isAnon() ) {
863 if( $this->showIPinHeader() ) {
866 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
867 $wgLang->getNsText( NS_TALK
) );
869 $s .= $n . ' ('.$tl.')';
871 $s .= wfMsg('notloggedin');
874 $rt = $wgTitle->getPrefixedURL();
875 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
877 } else { $q = "returnto={$rt}"; }
879 $s .= "\n<br />" . $this->makeKnownLinkObj(
880 SpecialPage
::getTitleFor( 'Userlogin' ),
881 wfMsg( 'login' ), $q );
883 $n = $wgUser->getName();
884 $rt = $wgTitle->getPrefixedURL();
885 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
886 $wgLang->getNsText( NS_TALK
) );
890 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
891 $n ) . "{$tl}<br />" .
892 $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
893 "returnto={$rt}" ) . ' | ' .
894 $this->specialLink( 'preferences' );
896 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
902 function getSearchLink() {
903 $searchPage = SpecialPage
::getTitleFor( 'Search' );
904 return $searchPage->getLocalURL();
907 function escapeSearchLink() {
908 return htmlspecialchars( $this->getSearchLink() );
911 function searchForm() {
913 $search = $wgRequest->getText( 'search' );
915 $s = '<form name="search" class="inline" method="post" action="'
916 . $this->escapeSearchLink() . "\">\n"
917 . '<input type="text" name="search" size="19" value="'
918 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
919 . '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" /> '
920 . '<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n</form>";
925 function topLinks() {
929 $s = $this->mainPageLink() . $sep
930 . $this->specialLink( 'recentchanges' );
932 if ( $wgOut->isArticleRelated() ) {
933 $s .= $sep . $this->editThisPage()
934 . $sep . $this->historyLink();
936 # Many people don't like this dropdown box
937 #$s .= $sep . $this->specialPagesList();
939 $s .= $this->variantLinks();
941 $s .= $this->extensionTabLinks();
947 * Compatibility for extensions adding functionality through tabs.
948 * Eventually these old skins should be replaced with SkinTemplate-based
952 function extensionTabLinks() {
955 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
956 foreach( $tabs as $tab ) {
957 $s .= ' | ' . Xml
::element( 'a',
958 array( 'href' => $tab['href'] ),
965 * Language/charset variant links for classic-style skins
968 function variantLinks() {
970 /* show links to different language variants */
971 global $wgDisableLangConversion, $wgContLang, $wgTitle;
972 $variants = $wgContLang->getVariants();
973 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
974 foreach( $variants as $code ) {
975 $varname = $wgContLang->getVariantname( $code );
976 if( $varname == 'disable' )
978 $s .= ' | <a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>';
984 function bottomLinks() {
985 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
989 if ( $wgOut->isArticleRelated() ) {
990 $s .= '<strong>' . $this->editThisPage() . '</strong>';
991 if ( $wgUser->isLoggedIn() ) {
992 $s .= $sep . $this->watchThisPage();
994 $s .= $sep . $this->talkLink()
995 . $sep . $this->historyLink()
996 . $sep . $this->whatLinksHere()
997 . $sep . $this->watchPageLinksLink();
999 if ($wgUseTrackbacks)
1000 $s .= $sep . $this->trackbackLink();
1002 if ( $wgTitle->getNamespace() == NS_USER
1003 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
1006 $id=User
::idFromName($wgTitle->getText());
1007 $ip=User
::isIP($wgTitle->getText());
1009 if($id ||
$ip) { # both anons and non-anons have contri list
1010 $s .= $sep . $this->userContribsLink();
1012 if( $this->showEmailUser( $id ) ) {
1013 $s .= $sep . $this->emailUserLink();
1016 if ( $wgTitle->getArticleId() ) {
1018 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
1019 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
1020 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
1022 $s .= "<br />\n" . $this->otherLanguages();
1027 function pageStats() {
1028 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1029 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
1031 $oldid = $wgRequest->getVal( 'oldid' );
1032 $diff = $wgRequest->getVal( 'diff' );
1033 if ( ! $wgOut->isArticle() ) { return ''; }
1034 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1035 if ( 0 == $wgArticle->getID() ) { return ''; }
1038 if ( !$wgDisableCounters ) {
1039 $count = $wgLang->formatNum( $wgArticle->getCount() );
1041 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1045 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
1046 require_once('Credits.php');
1047 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
1049 $s .= $this->lastModified();
1052 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
1053 $dbr = wfGetDB( DB_SLAVE
);
1054 $watchlist = $dbr->tableName( 'watchlist' );
1055 $sql = "SELECT COUNT(*) AS n FROM $watchlist
1056 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
1057 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
1058 $res = $dbr->query( $sql, 'Skin::pageStats');
1059 $x = $dbr->fetchObject( $res );
1060 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
1063 return $s . ' ' . $this->getCopyright();
1066 function getCopyright( $type = 'detect' ) {
1067 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
1069 if ( $type == 'detect' ) {
1070 $oldid = $wgRequest->getVal( 'oldid' );
1071 $diff = $wgRequest->getVal( 'diff' );
1073 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1080 if ( $type == 'history' ) {
1081 $msg = 'history_copyright';
1087 if( $wgRightsPage ) {
1088 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
1089 } elseif( $wgRightsUrl ) {
1090 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1095 $out .= wfMsgForContent( $msg, $link );
1099 function getCopyrightIcon() {
1100 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1102 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1103 $out = $wgCopyrightIcon;
1104 } else if ( $wgRightsIcon ) {
1105 $icon = htmlspecialchars( $wgRightsIcon );
1106 if ( $wgRightsUrl ) {
1107 $url = htmlspecialchars( $wgRightsUrl );
1108 $out .= '<a href="'.$url.'">';
1110 $text = htmlspecialchars( $wgRightsText );
1111 $out .= "<img src=\"$icon\" alt='$text' />";
1112 if ( $wgRightsUrl ) {
1119 function getPoweredBy() {
1120 global $wgStylePath;
1121 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1122 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1126 function lastModified() {
1127 global $wgLang, $wgArticle, $wgLoadBalancer;
1129 $timestamp = $wgArticle->getTimestamp();
1131 $d = $wgLang->date( $timestamp, true );
1132 $t = $wgLang->time( $timestamp, true );
1133 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1137 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
1138 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1143 function logoText( $align = '' ) {
1144 if ( '' != $align ) { $a = " align='{$align}'"; }
1147 $mp = wfMsg( 'mainpage' );
1148 $mptitle = Title
::newMainPage();
1149 $url = ( is_object($mptitle) ?
$mptitle->escapeLocalURL() : '' );
1151 $logourl = $this->getLogo();
1152 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1157 * show a drop-down box of special pages
1159 function specialPagesList() {
1160 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1161 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1162 foreach ( $pages as $name => $page ) {
1163 $pages[$name] = $page->getDescription();
1166 $go = wfMsg( 'go' );
1167 $sp = wfMsg( 'specialpages' );
1168 $spp = $wgContLang->specialPage( 'Specialpages' );
1170 $s = '<form id="specialpages" method="get" class="inline" ' .
1171 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1172 $s .= "<select name=\"wpDropdown\">\n";
1173 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1176 foreach ( $pages as $name => $desc ) {
1177 $p = $wgContLang->specialPage( $name );
1178 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1180 $s .= "</select>\n";
1181 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1186 function mainPageLink() {
1187 $s = $this->makeKnownLinkObj( Title
::newMainPage(), wfMsg( 'mainpage' ) );
1191 function copyrightLink() {
1192 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1193 wfMsg( 'copyrightpagename' ) );
1197 function privacyLink() {
1198 $privacy = wfMsg( 'privacy' );
1199 if ($privacy == '-') {
1202 return $this->makeKnownLink( wfMsgForContent( 'privacypage' ), $privacy);
1206 function aboutLink() {
1207 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
1208 wfMsg( 'aboutsite' ) );
1212 function disclaimerLink() {
1213 $disclaimers = wfMsg( 'disclaimers' );
1214 if ($disclaimers == '-') {
1217 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
1222 function editThisPage() {
1223 global $wgOut, $wgTitle;
1225 if ( ! $wgOut->isArticleRelated() ) {
1226 $s = wfMsg( 'protectedpage' );
1228 if ( $wgTitle->userCan( 'edit' ) ) {
1229 $t = wfMsg( 'editthispage' );
1231 $t = wfMsg( 'viewsource' );
1234 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1240 * Return URL options for the 'edit page' link.
1241 * This may include an 'oldid' specifier, if the current page view is such.
1246 function editUrlOptions() {
1249 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1250 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1252 return "action=edit";
1256 function deleteThisPage() {
1257 global $wgUser, $wgTitle, $wgRequest;
1259 $diff = $wgRequest->getVal( 'diff' );
1260 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1261 $t = wfMsg( 'deletethispage' );
1263 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1270 function protectThisPage() {
1271 global $wgUser, $wgTitle, $wgRequest;
1273 $diff = $wgRequest->getVal( 'diff' );
1274 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1275 if ( $wgTitle->isProtected() ) {
1276 $t = wfMsg( 'unprotectthispage' );
1277 $q = 'action=unprotect';
1279 $t = wfMsg( 'protectthispage' );
1280 $q = 'action=protect';
1282 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1289 function watchThisPage() {
1290 global $wgOut, $wgTitle;
1291 ++
$this->mWatchLinkNum
;
1293 if ( $wgOut->isArticleRelated() ) {
1294 if ( $wgTitle->userIsWatching() ) {
1295 $t = wfMsg( 'unwatchthispage' );
1296 $q = 'action=unwatch';
1297 $id = "mw-unwatch-link".$this->mWatchLinkNum
;
1299 $t = wfMsg( 'watchthispage' );
1300 $q = 'action=watch';
1301 $id = 'mw-watch-link'.$this->mWatchLinkNum
;
1303 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q, '', '', " id=\"$id\"" );
1305 $s = wfMsg( 'notanarticle' );
1310 function moveThisPage() {
1313 if ( $wgTitle->userCan( 'move' ) ) {
1314 return $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
1315 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1317 // no message if page is protected - would be redundant
1322 function historyLink() {
1325 return $this->makeKnownLinkObj( $wgTitle,
1326 wfMsg( 'history' ), 'action=history' );
1329 function whatLinksHere() {
1332 return $this->makeKnownLinkObj(
1333 SpecialPage
::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ),
1334 wfMsg( 'whatlinkshere' ) );
1337 function userContribsLink() {
1340 return $this->makeKnownLinkObj(
1341 SpecialPage
::getTitleFor( 'Contributions', $wgTitle->getDBkey() ),
1342 wfMsg( 'contributions' ) );
1345 function showEmailUser( $id ) {
1346 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1347 return $wgEnableEmail &&
1348 $wgEnableUserEmail &&
1349 $wgUser->isLoggedIn() && # show only to signed in users
1350 0 != $id; # we can only email to non-anons ..
1351 # '' != $id->getEmail() && # who must have an email address stored ..
1352 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1353 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1356 function emailUserLink() {
1359 return $this->makeKnownLinkObj(
1360 SpecialPage
::getTitleFor( 'Emailuser', $wgTitle->getDBkey() ),
1361 wfMsg( 'emailuser' ) );
1364 function watchPageLinksLink() {
1365 global $wgOut, $wgTitle;
1367 if ( ! $wgOut->isArticleRelated() ) {
1368 return '(' . wfMsg( 'notanarticle' ) . ')';
1370 return $this->makeKnownLinkObj(
1371 SpecialPage
::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ),
1372 wfMsg( 'recentchangeslinked' ) );
1376 function trackbackLink() {
1379 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1380 . wfMsg('trackbacklink') . "</a>";
1383 function otherLanguages() {
1384 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1386 if ( $wgHideInterlanguageLinks ) {
1390 $a = $wgOut->getLanguageLinks();
1391 if ( 0 == count( $a ) ) {
1395 $s = wfMsg( 'otherlanguages' ) . ': ';
1397 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1398 foreach( $a as $l ) {
1399 if ( ! $first ) { $s .= ' | '; }
1402 $nt = Title
::newFromText( $l );
1403 $url = $nt->escapeFullURL();
1404 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1406 if ( '' == $text ) { $text = $l; }
1407 $style = $this->getExternalLinkAttributes( $l, $text );
1408 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1410 if($wgContLang->isRTL()) $s .= '</span>';
1414 function bugReportsLink() {
1415 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1416 wfMsg( 'bugreports' ) );
1420 function dateLink() {
1421 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1422 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1424 $id = $t1->getArticleID();
1427 $s = $this->makeBrokenLink( $t1->getText() );
1429 $s = $this->makeKnownLink( $t1->getText() );
1433 $id = $t2->getArticleID();
1436 $s .= $this->makeBrokenLink( $t2->getText() );
1438 $s .= $this->makeKnownLink( $t2->getText() );
1443 function talkLink() {
1446 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1447 # No discussion links for special pages
1451 if( $wgTitle->isTalkPage() ) {
1452 $link = $wgTitle->getSubjectPage();
1453 switch( $link->getNamespace() ) {
1455 $text = wfMsg( 'articlepage' );
1458 $text = wfMsg( 'userpage' );
1461 $text = wfMsg( 'projectpage' );
1464 $text = wfMsg( 'imagepage' );
1467 $text = wfMsg( 'mediawikipage' );
1470 $text = wfMsg( 'templatepage' );
1473 $text = wfMsg( 'viewhelppage' );
1476 $text = wfMsg( 'categorypage' );
1479 $text = wfMsg( 'articlepage' );
1482 $link = $wgTitle->getTalkPage();
1483 $text = wfMsg( 'talkpage' );
1486 $s = $this->makeLinkObj( $link, $text );
1491 function commentLink() {
1492 global $wgTitle, $wgOut;
1494 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1498 # __NEWSECTIONLINK___ changes behaviour here
1499 # If it's present, the link points to this page, otherwise
1500 # it points to the talk page
1501 if( $wgTitle->isTalkPage() ) {
1503 } elseif( $wgOut->showNewSectionLink() ) {
1506 $title =& $wgTitle->getTalkPage();
1509 return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1512 /* these are used extensively in SkinTemplate, but also some other places */
1513 static function makeMainPageUrl( $urlaction = '' ) {
1514 $title = Title
::newMainPage();
1515 self
::checkTitle( $title, '' );
1516 return $title->getLocalURL( $urlaction );
1519 static function makeSpecialUrl( $name, $urlaction = '' ) {
1520 $title = SpecialPage
::getTitleFor( $name );
1521 return $title->getLocalURL( $urlaction );
1524 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1525 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1526 return $title->getLocalURL( $urlaction );
1529 static function makeI18nUrl( $name, $urlaction = '' ) {
1530 $title = Title
::newFromText( wfMsgForContent( $name ) );
1531 self
::checkTitle( $title, $name );
1532 return $title->getLocalURL( $urlaction );
1535 static function makeUrl( $name, $urlaction = '' ) {
1536 $title = Title
::newFromText( $name );
1537 self
::checkTitle( $title, $name );
1538 return $title->getLocalURL( $urlaction );
1541 # If url string starts with http, consider as external URL, else
1543 static function makeInternalOrExternalUrl( $name ) {
1544 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1547 return self
::makeUrl( $name );
1551 # this can be passed the NS number as defined in Language.php
1552 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1553 $title = Title
::makeTitleSafe( $namespace, $name );
1554 self
::checkTitle( $title, $name );
1555 return $title->getLocalURL( $urlaction );
1558 /* these return an array with the 'href' and boolean 'exists' */
1559 static function makeUrlDetails( $name, $urlaction = '' ) {
1560 $title = Title
::newFromText( $name );
1561 self
::checkTitle( $title, $name );
1563 'href' => $title->getLocalURL( $urlaction ),
1564 'exists' => $title->getArticleID() != 0 ?
true : false
1569 * Make URL details where the article exists (or at least it's convenient to think so)
1571 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1572 $title = Title
::newFromText( $name );
1573 self
::checkTitle( $title, $name );
1575 'href' => $title->getLocalURL( $urlaction ),
1580 # make sure we have some title to operate on
1581 static function checkTitle( &$title, $name ) {
1582 if( !is_object( $title ) ) {
1583 $title = Title
::newFromText( $name );
1584 if( !is_object( $title ) ) {
1585 $title = Title
::newFromText( '--error: link target missing--' );
1591 * Build an array that represents the sidebar(s), the navigation bar among them
1596 function buildSidebar() {
1597 global $parserMemc, $wgEnableSidebarCache;
1598 global $wgLang, $wgContLang;
1600 $fname = 'SkinTemplate::buildSidebar';
1602 wfProfileIn( $fname );
1604 $key = wfMemcKey( 'sidebar' );
1605 $cacheSidebar = $wgEnableSidebarCache &&
1606 ($wgLang->getCode() == $wgContLang->getCode());
1608 if ($cacheSidebar) {
1609 $cachedsidebar = $parserMemc->get( $key );
1610 if ($cachedsidebar!="") {
1611 wfProfileOut($fname);
1612 return $cachedsidebar;
1617 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1618 foreach ($lines as $line) {
1619 if (strpos($line, '*') !== 0)
1621 if (strpos($line, '**') !== 0) {
1622 $line = trim($line, '* ');
1625 if (strpos($line, '|') !== false) { // sanity check
1626 $line = explode( '|' , trim($line, '* '), 2 );
1627 $link = wfMsgForContent( $line[0] );
1630 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1632 if (wfEmptyMsg($line[0], $link))
1635 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1638 $title = Title
::newFromText( $link );
1640 $title = $title->fixSpecialName();
1641 $href = $title->getLocalURL();
1643 $href = 'INVALID-TITLE';
1647 $bar[$heading][] = array(
1650 'id' => 'n-' . strtr($line[1], ' ', '-'),
1653 } else { continue; }
1657 $parserMemc->set( $key, $bar, 86400 );
1658 wfProfileOut( $fname );