2 if ( ! defined( 'MEDIAWIKI' ) )
8 * The main skin class that provide methods and properties for all other skins.
9 * This base class is also the "Standard" skin.
11 * See docs/skin.txt for more information.
15 class Skin
extends Linker
{
19 var $lastdate, $lastline;
20 var $rc_cache ; # Cache for Enhanced Recent Changes
21 var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle
23 var $mWatchLinkNum = 0; // Appended to end of watch link id's
25 protected $mRevisionId; // The revision ID we're looking at, null if not applicable.
26 protected $skinname = 'standard' ;
28 /** Constructor, call parent constructor */
29 function Skin() { parent
::__construct(); }
32 * Fetch the set of available skins.
33 * @return array of strings
36 static function getSkinNames() {
37 global $wgValidSkinNames;
38 static $skinsInitialised = false;
39 if ( !$skinsInitialised ) {
40 # Get a list of available skins
41 # Build using the regular expression '^(.*).php$'
42 # Array keys are all lower case, array value keep the case used by filename
44 wfProfileIn( __METHOD__
. '-init' );
45 global $wgStyleDirectory;
46 $skinDir = dir( $wgStyleDirectory );
48 # while code from www.php.net
49 while (false !== ($file = $skinDir->read())) {
50 // Skip non-PHP files, hidden files, and '.dep' includes
52 if(preg_match('/^([^.]*)\.php$/',$file, $matches)) {
54 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
58 $skinsInitialised = true;
59 wfProfileOut( __METHOD__
. '-init' );
61 return $wgValidSkinNames;
65 * Normalize a skin preference value to a form that can be loaded.
66 * If a skin can't be found, it will fall back to the configured
67 * default (or the old 'Classic' skin if that's broken).
72 static function normalizeKey( $key ) {
73 global $wgDefaultSkin;
74 $skinNames = Skin
::getSkinNames();
77 // Don't return the default immediately;
78 // in a misconfiguration we need to fall back.
79 $key = $wgDefaultSkin;
82 if( isset( $skinNames[$key] ) ) {
86 // Older versions of the software used a numeric setting
87 // in the user preferences.
93 if( isset( $fallback[$key] ) ){
94 $key = $fallback[$key];
97 if( isset( $skinNames[$key] ) ) {
100 // The old built-in skin
106 * Factory method for loading a skin of a given type
107 * @param string $key 'monobook', 'standard', etc
111 static function &newFromKey( $key ) {
112 global $wgStyleDirectory;
114 $key = Skin
::normalizeKey( $key );
116 $skinNames = Skin
::getSkinNames();
117 $skinName = $skinNames[$key];
119 # Grab the skin class and initialise it.
120 // Preload base classes to work around APC/PHP5 bug
121 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
122 if( file_exists( $deps ) ) include_once( $deps );
123 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
125 # Check if we got if not failback to default skin
126 $className = 'Skin'.$skinName;
127 if( !class_exists( $className ) ) {
128 # DO NOT die if the class isn't found. This breaks maintenance
129 # scripts and can cause a user account to be unrecoverable
130 # except by SQL manipulation if a previously valid skin name
131 # is no longer valid.
132 wfDebug( "Skin class does not exist: $className\n" );
133 $className = 'SkinStandard';
134 require_once( "{$wgStyleDirectory}/Standard.php" );
136 $skin = new $className;
140 /** @return string path to the skin stylesheet */
141 function getStylesheet() {
142 return 'common/wikistandard.css';
145 /** @return string skin name */
146 public function getSkinName() {
147 return $this->skinname
;
150 function qbSetting() {
151 global $wgOut, $wgUser;
153 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
154 $q = $wgUser->getOption( 'quickbar', 0 );
158 function initPage( &$out ) {
159 global $wgFavicon, $wgScriptPath, $wgSitename, $wgLanguageCode, $wgLanguageNames;
161 $fname = 'Skin::initPage';
162 wfProfileIn( $fname );
164 if( false !== $wgFavicon ) {
165 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
168 # OpenSearch description link
169 $out->addLink( array(
171 'type' => 'application/opensearchdescription+xml',
172 'href' => "$wgScriptPath/opensearch_desc.php",
173 'title' => "$wgSitename ({$wgLanguageNames[$wgLanguageCode]})",
176 $this->addMetadataLinks($out);
178 $this->mRevisionId
= $out->mRevisionId
;
180 $this->preloadExistence();
182 wfProfileOut( $fname );
186 * Preload the existence of three commonly-requested pages in a single query
188 function preloadExistence() {
189 global $wgUser, $wgTitle;
192 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
195 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
197 } elseif ( $wgTitle->isTalkPage() ) {
198 $titles[] = $wgTitle->getSubjectPage();
200 $titles[] = $wgTitle->getTalkPage();
203 $lb = new LinkBatch( $titles );
207 function addMetadataLinks( &$out ) {
208 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
209 global $wgRightsPage, $wgRightsUrl;
211 if( $out->isArticleRelated() ) {
212 # note: buggy CC software only reads first "meta" link
213 if( $wgEnableCreativeCommonsRdf ) {
214 $out->addMetadataLink( array(
215 'title' => 'Creative Commons',
216 'type' => 'application/rdf+xml',
217 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
219 if( $wgEnableDublinCoreRdf ) {
220 $out->addMetadataLink( array(
221 'title' => 'Dublin Core',
222 'type' => 'application/rdf+xml',
223 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
227 if( $wgRightsPage ) {
228 $copy = Title
::newFromText( $wgRightsPage );
230 $copyright = $copy->getLocalURL();
233 if( !$copyright && $wgRightsUrl ) {
234 $copyright = $wgRightsUrl;
237 $out->addLink( array(
238 'rel' => 'copyright',
239 'href' => $copyright ) );
243 function outputPage( &$out ) {
244 global $wgDebugComments;
246 wfProfileIn( __METHOD__
);
247 $this->initPage( $out );
249 $out->out( $out->headElement() );
251 $out->out( "\n<body" );
252 $ops = $this->getBodyOptions();
253 foreach ( $ops as $name => $val ) {
254 $out->out( " $name='$val'" );
257 if ( $wgDebugComments ) {
258 $out->out( "<!-- Wiki debugging output:\n" .
259 $out->mDebugtext
. "-->\n" );
262 $out->out( $this->beforeContent() );
264 $out->out( $out->mBodytext
. "\n" );
266 $out->out( $this->afterContent() );
268 $out->out( $this->bottomScripts() );
270 $out->out( $out->reportTime() );
272 $out->out( "\n</body></html>" );
273 wfProfileOut( __METHOD__
);
276 static function makeVariablesScript( $data ) {
277 global $wgJsMimeType;
279 $r = "<script type= \"$wgJsMimeType\">/*<![CDATA[*/\n";
280 foreach ( $data as $name => $value ) {
281 $encValue = Xml
::encodeJsVar( $value );
282 $r .= "var $name = $encValue;\n";
284 $r .= "/*]]>*/</script>\n";
290 * Make a <script> tag containing global variables
291 * @param array $data Associative array containing one element:
292 * skinname => the skin name
293 * The odd calling convention is for backwards compatibility
295 static function makeGlobalVariablesScript( $data ) {
296 global $wgStylePath, $wgUser;
297 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
298 global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
299 global $wgBreakFrames, $wgRequest;
301 $ns = $wgTitle->getNamespace();
302 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
305 'skin' => $data['skinname'],
306 'stylepath' => $wgStylePath,
307 'wgArticlePath' => $wgArticlePath,
308 'wgScriptPath' => $wgScriptPath,
309 'wgServer' => $wgServer,
310 'wgCanonicalNamespace' => $nsname,
311 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBKey() ),
312 'wgNamespaceNumber' => $wgTitle->getNamespace(),
313 'wgPageName' => $wgTitle->getPrefixedDBKey(),
314 'wgTitle' => $wgTitle->getText(),
315 'wgAction' => $wgRequest->getText( 'action', 'view' ),
316 'wgArticleId' => $wgTitle->getArticleId(),
317 'wgIsArticle' => $wgOut->isArticle(),
318 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
319 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getEffectiveGroups(),
320 'wgUserLanguage' => $wgLang->getCode(),
321 'wgContentLanguage' => $wgContLang->getCode(),
322 'wgBreakFrames' => $wgBreakFrames,
323 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
326 global $wgLivePreview;
327 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
328 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
329 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
330 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
331 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
334 return self
::makeVariablesScript( $vars );
337 function getHeadScripts( $allowUserJs ) {
338 global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion;
340 $r = self
::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
342 $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n";
345 if ($wgUser->isLoggedIn()) {
346 $r .= "<script type=\"$wgJsMimeType\" src=\"".htmlspecialchars(self
::makeUrl('-','action=raw&smaxage=0&gen=js'))."\"><!-- site js --></script>\n";
348 $r .= "<script type=\"$wgJsMimeType\" src=\"".htmlspecialchars(self
::makeUrl('-','action=raw&gen=js'))."\"><!-- site js --></script>\n";
351 if( $allowUserJs && $wgUser->isLoggedIn() ) {
352 $userpage = $wgUser->getUserPage();
353 $userjs = htmlspecialchars( self
::makeUrl(
354 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
355 'action=raw&ctype='.$wgJsMimeType));
356 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
362 * To make it harder for someone to slip a user a fake
363 * user-JavaScript or user-CSS preview, a random token
364 * is associated with the login session. If it's not
365 * passed back with the preview request, we won't render
368 * @param string $action
372 function userCanPreview( $action ) {
373 global $wgTitle, $wgRequest, $wgUser;
375 if( $action != 'submit' )
377 if( !$wgRequest->wasPosted() )
379 if( !$wgTitle->userCanEditCssJsSubpage() )
381 return $wgUser->matchEditToken(
382 $wgRequest->getVal( 'wpEditToken' ) );
385 # get the user/site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way)
386 function getUserStylesheet() {
387 global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage, $wgStyleVersion;
388 $sheet = $this->getStylesheet();
389 $s = "@import \"$wgStylePath/common/common.css?$wgStyleVersion\";\n";
390 $s .= "@import \"$wgStylePath/$sheet?$wgStyleVersion\";\n";
391 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css?$wgStyleVersion\";\n";
393 $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
394 $s .= '@import "' . self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n" .
395 '@import "' . self
::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
397 $s .= $this->doGetUserStyles();
402 * This returns MediaWiki:Common.js. For some bizarre reason, it does
403 * *not* return any custom user JS from user subpages. Huh?
407 function getUserJs() {
408 wfProfileIn( __METHOD__
);
411 $s = "/* generated javascript */\n";
412 $s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';";
413 $s .= "\n\n/* MediaWiki:Common.js */\n";
414 $commonJs = wfMsgForContent('common.js');
415 if ( !wfEmptyMsg ( 'common.js', $commonJs ) ) {
419 global $wgUseAjax, $wgAjaxWatch;
420 if($wgUseAjax && $wgAjaxWatch) {
423 /* AJAX (un)watch (see /skins/common/ajaxwatch.js) */
425 watchMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'watch', array() ) )."',
426 unwatchMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'unwatch', array() ) )."',
427 watchingMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'watching', array() ) )."',
428 unwatchingMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'unwatching', array() ) )."'
432 wfProfileOut( __METHOD__
);
437 * Return html code that include User stylesheets
439 function getUserStyles() {
440 $s = "<style type='text/css'>\n";
441 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
442 $s .= $this->getUserStylesheet();
443 $s .= "/*]]>*/ /* */\n";
449 * Some styles that are set by user through the user settings interface.
451 function doGetUserStyles() {
452 global $wgUser, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
456 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
457 if($wgTitle->isCssSubpage() && $this->userCanPreview( $wgRequest->getText( 'action' ) ) ) {
458 $s .= $wgRequest->getText('wpTextbox1');
460 $userpage = $wgUser->getUserPage();
461 $s.= '@import "'.self
::makeUrl(
462 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
463 'action=raw&ctype=text/css').'";'."\n";
467 return $s . $this->reallyDoGetUserStyles();
470 function reallyDoGetUserStyles() {
473 if (($undopt = $wgUser->getOption("underline")) != 2) {
474 $underline = $undopt ?
'underline' : 'none';
475 $s .= "a { text-decoration: $underline; }\n";
477 if( $wgUser->getOption( 'highlightbroken' ) ) {
478 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
481 a.new, #quickbar a.new,
482 a.stub, #quickbar a.stub {
484 text-decoration: inherit;
486 a.new:after, #quickbar a.new:after {
489 text-decoration: $underline;
491 a.stub:after, #quickbar a.stub:after {
494 text-decoration: $underline;
498 if( $wgUser->getOption( 'justify' ) ) {
499 $s .= "#article, #bodyContent { text-align: justify; }\n";
501 if( !$wgUser->getOption( 'showtoc' ) ) {
502 $s .= "#toc { display: none; }\n";
504 if( !$wgUser->getOption( 'editsection' ) ) {
505 $s .= ".editsection { display: none; }\n";
510 function getBodyOptions() {
511 global $wgUser, $wgTitle, $wgOut, $wgRequest, $wgContLang;
513 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
515 if ( 0 != $wgTitle->getNamespace() ) {
516 $a = array( 'bgcolor' => '#ffffec' );
518 else $a = array( 'bgcolor' => '#FFFFFF' );
519 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
520 $wgTitle->userCan( 'edit' ) ) {
521 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
522 $s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
523 $a +
= array ('ondblclick' => $s);
526 $a['onload'] = $wgOut->getOnloadHandler();
527 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
528 if( $a['onload'] != '' ) {
531 $a['onload'] .= 'setupRightClickEdit()';
533 $a['class'] = 'ns-'.$wgTitle->getNamespace().' '.($wgContLang->isRTL() ?
"rtl" : "ltr").
534 ' '.Sanitizer
::escapeClass( 'page-'.$wgTitle->getPrefixedText() );
547 * This will be called immediately after the <body> tag. Split into
548 * two functions to make it easier to subclass.
550 function beforeContent() {
551 return $this->doBeforeContent();
554 function doBeforeContent() {
556 $fname = 'Skin::doBeforeContent';
557 wfProfileIn( $fname );
560 $qb = $this->qbSetting();
562 if( $langlinks = $this->otherLanguages() ) {
568 $borderhack = 'class="top"';
571 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
572 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
575 $left = ($qb == 1 ||
$qb == 3);
576 if($wgContLang->isRTL()) $left = !$left;
579 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
580 $this->logoText() . '</td>';
582 $s .= $this->getQuickbarCompensator( $rows );
584 $l = $wgContLang->isRTL() ?
'right' : 'left';
585 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
587 $s .= $this->topLinks() ;
588 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
590 $r = $wgContLang->isRTL() ?
"left" : "right";
591 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
592 $s .= $this->nameAndLogin();
593 $s .= "\n<br />" . $this->searchForm() . "</td>";
596 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
599 if ( $shove && !$left ) { # Right
600 $s .= $this->getQuickbarCompensator( $rows );
602 $s .= "</tr>\n</table>\n</div>\n";
603 $s .= "\n<div id='article'>\n";
605 $notice = wfGetSiteNotice();
607 $s .= "\n<div id='siteNotice'>$notice</div>\n";
609 $s .= $this->pageTitle();
610 $s .= $this->pageSubtitle() ;
611 $s .= $this->getCategories();
612 wfProfileOut( $fname );
617 function getCategoryLinks () {
618 global $wgOut, $wgTitle, $wgUseCategoryBrowser;
621 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
624 $sep = wfMsgHtml( 'catseparator' );
626 // Use Unicode bidi embedding override characters,
627 // to make sure links don't smash each other up in ugly ways.
628 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
629 $embed = "<span dir='$dir'>";
631 $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $wgOut->mCategoryLinks
) . $pop;
633 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escape' ), count( $wgOut->mCategoryLinks
) );
634 $s = $this->makeLinkObj( Title
::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
637 # optional 'dmoz-like' category browser. Will be shown under the list
638 # of categories an article belong to
639 if($wgUseCategoryBrowser) {
640 $s .= '<br /><hr />';
642 # get a big array of the parents tree
643 $parenttree = $wgTitle->getParentCategoryTree();
644 # Skin object passed by reference cause it can not be
645 # accessed under the method subfunction drawCategoryBrowser
646 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
647 # Clean out bogus first entry and sort them
650 # Output one per line
651 $s .= implode("<br />\n", $tempout);
657 /** Render the array as a serie of links.
658 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
659 * @param &skin Object: skin passed by reference
660 * @return String separated by >, terminate with "\n"
662 function drawCategoryBrowser($tree, &$skin) {
664 foreach ($tree as $element => $parent) {
665 if (empty($parent)) {
666 # element start a new list
669 # grab the others elements
670 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
672 # add our current element to the list
673 $eltitle = Title
::NewFromText($element);
674 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
679 function getCategories() {
680 $catlinks=$this->getCategoryLinks();
681 if(!empty($catlinks)) {
682 return "<p class='catlinks'>{$catlinks}</p>";
686 function getQuickbarCompensator( $rows = 1 ) {
687 return "<td width='152' rowspan='{$rows}'> </td>";
691 * This gets called shortly before the \</body\> tag.
692 * @return String HTML to be put before \</body\>
694 function afterContent() {
695 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
696 return $printfooter . $this->doAfterContent();
700 * This gets called shortly before the \</body\> tag.
701 * @return String HTML-wrapped JS code to be put before \</body\>
703 function bottomScripts() {
704 global $wgJsMimeType;
705 return "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
708 /** @return string Retrievied from HTML text */
709 function printSource() {
711 $url = htmlspecialchars( $wgTitle->getFullURL() );
712 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
715 function printFooter() {
716 return "<p>" . $this->printSource() .
717 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
720 /** overloaded by derived classes */
721 function doAfterContent() { }
723 function pageTitleLinks() {
724 global $wgOut, $wgTitle, $wgUser, $wgRequest;
726 $oldid = $wgRequest->getVal( 'oldid' );
727 $diff = $wgRequest->getVal( 'diff' );
728 $action = $wgRequest->getText( 'action' );
730 $s = $this->printableLink();
731 $disclaimer = $this->disclaimerLink(); # may be empty
733 $s .= ' | ' . $disclaimer;
735 $privacy = $this->privacyLink(); # may be empty too
737 $s .= ' | ' . $privacy;
740 if ( $wgOut->isArticleRelated() ) {
741 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
742 $name = $wgTitle->getDBkey();
743 $image = new Image( $wgTitle );
744 if( $image->exists() ) {
745 $link = htmlspecialchars( $image->getURL() );
746 $style = $this->getInternalLinkAttributes( $link, $name );
747 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
751 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
752 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
753 wfMsg( 'currentrev' ) );
756 if ( $wgUser->getNewtalk() ) {
757 # do not show "You have new messages" text when we are viewing our
759 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
760 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
761 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
762 $s.= ' | <strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
764 $wgOut->setSquidMaxage(0);
765 $wgOut->enableClientCache(false);
769 $undelete = $this->getUndeleteLink();
770 if( !empty( $undelete ) ) {
771 $s .= ' | '.$undelete;
776 function getUndeleteLink() {
777 global $wgUser, $wgTitle, $wgContLang, $action;
778 if( $wgUser->isAllowed( 'deletedhistory' ) &&
779 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
780 ($n = $wgTitle->isDeleted() ) )
782 if ( $wgUser->isAllowed( 'delete' ) ) {
783 $msg = 'thisisdeleted';
785 $msg = 'viewdeleted';
788 $this->makeKnownLinkObj(
789 SpecialPage
::getTitleFor( 'Undelete', $wgTitle->getPrefixedDBkey() ),
790 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $n ) ) );
795 function printableLink() {
796 global $wgOut, $wgFeedClasses, $wgRequest;
798 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
800 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
801 if( $wgOut->isSyndicated() ) {
802 foreach( $wgFeedClasses as $format => $class ) {
803 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
804 $s .= " | <a href=\"$feedurl\">{$format}</a>";
810 function pageTitle() {
812 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
816 function pageSubtitle() {
819 $sub = $wgOut->getSubtitle();
821 global $wgExtraSubtitle;
822 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
824 $subpages = $this->subPageSubtitle();
825 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
826 $s = "<p class='subtitle'>{$sub}</p>\n";
830 function subPageSubtitle() {
831 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
833 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
834 $ptext=$wgTitle->getPrefixedText();
835 if(preg_match('/\//',$ptext)) {
836 $links = explode('/',$ptext);
839 foreach($links as $link) {
841 if ($c<count($links)) {
842 $growinglink .= $link;
843 $getlink = $this->makeLink( $growinglink, htmlspecialchars( $link ) );
844 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
848 $subpages .= '< ';
850 $subpages .= $getlink;
860 * Returns true if the IP should be shown in the header
862 function showIPinHeader() {
863 global $wgShowIPinHeader;
864 return $wgShowIPinHeader && session_id() != '';
867 function nameAndLogin() {
868 global $wgUser, $wgTitle, $wgLang, $wgContLang;
870 $lo = $wgContLang->specialPage( 'Userlogout' );
873 if ( $wgUser->isAnon() ) {
874 if( $this->showIPinHeader() ) {
877 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
878 $wgLang->getNsText( NS_TALK
) );
880 $s .= $n . ' ('.$tl.')';
882 $s .= wfMsg('notloggedin');
885 $rt = $wgTitle->getPrefixedURL();
886 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
888 } else { $q = "returnto={$rt}"; }
890 $s .= "\n<br />" . $this->makeKnownLinkObj(
891 SpecialPage
::getTitleFor( 'Userlogin' ),
892 wfMsg( 'login' ), $q );
894 $n = $wgUser->getName();
895 $rt = $wgTitle->getPrefixedURL();
896 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
897 $wgLang->getNsText( NS_TALK
) );
901 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
902 $n ) . "{$tl}<br />" .
903 $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
904 "returnto={$rt}" ) . ' | ' .
905 $this->specialLink( 'preferences' );
907 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
913 function getSearchLink() {
914 $searchPage = SpecialPage
::getTitleFor( 'Search' );
915 return $searchPage->getLocalURL();
918 function escapeSearchLink() {
919 return htmlspecialchars( $this->getSearchLink() );
922 function searchForm() {
924 $search = $wgRequest->getText( 'search' );
926 $s = '<form name="search" class="inline" method="post" action="'
927 . $this->escapeSearchLink() . "\">\n"
928 . '<input type="text" name="search" size="19" value="'
929 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
930 . '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" /> '
931 . '<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n</form>";
936 function topLinks() {
940 $s = $this->mainPageLink() . $sep
941 . $this->specialLink( 'recentchanges' );
943 if ( $wgOut->isArticleRelated() ) {
944 $s .= $sep . $this->editThisPage()
945 . $sep . $this->historyLink();
947 # Many people don't like this dropdown box
948 #$s .= $sep . $this->specialPagesList();
950 $s .= $this->variantLinks();
952 $s .= $this->extensionTabLinks();
958 * Compatibility for extensions adding functionality through tabs.
959 * Eventually these old skins should be replaced with SkinTemplate-based
963 function extensionTabLinks() {
966 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
967 foreach( $tabs as $tab ) {
968 $s .= ' | ' . Xml
::element( 'a',
969 array( 'href' => $tab['href'] ),
976 * Language/charset variant links for classic-style skins
979 function variantLinks() {
981 /* show links to different language variants */
982 global $wgDisableLangConversion, $wgContLang, $wgTitle;
983 $variants = $wgContLang->getVariants();
984 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
985 foreach( $variants as $code ) {
986 $varname = $wgContLang->getVariantname( $code );
987 if( $varname == 'disable' )
989 $s .= ' | <a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>';
995 function bottomLinks() {
996 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
1000 if ( $wgOut->isArticleRelated() ) {
1001 $s .= '<strong>' . $this->editThisPage() . '</strong>';
1002 if ( $wgUser->isLoggedIn() ) {
1003 $s .= $sep . $this->watchThisPage();
1005 $s .= $sep . $this->talkLink()
1006 . $sep . $this->historyLink()
1007 . $sep . $this->whatLinksHere()
1008 . $sep . $this->watchPageLinksLink();
1010 if ($wgUseTrackbacks)
1011 $s .= $sep . $this->trackbackLink();
1013 if ( $wgTitle->getNamespace() == NS_USER
1014 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
1017 $id=User
::idFromName($wgTitle->getText());
1018 $ip=User
::isIP($wgTitle->getText());
1020 if($id ||
$ip) { # both anons and non-anons have contri list
1021 $s .= $sep . $this->userContribsLink();
1023 if( $this->showEmailUser( $id ) ) {
1024 $s .= $sep . $this->emailUserLink();
1027 if ( $wgTitle->getArticleId() ) {
1029 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
1030 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
1031 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
1033 $s .= "<br />\n" . $this->otherLanguages();
1038 function pageStats() {
1039 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1040 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
1042 $oldid = $wgRequest->getVal( 'oldid' );
1043 $diff = $wgRequest->getVal( 'diff' );
1044 if ( ! $wgOut->isArticle() ) { return ''; }
1045 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1046 if ( 0 == $wgArticle->getID() ) { return ''; }
1049 if ( !$wgDisableCounters ) {
1050 $count = $wgLang->formatNum( $wgArticle->getCount() );
1052 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1056 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
1057 require_once('Credits.php');
1058 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
1060 $s .= $this->lastModified();
1063 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
1064 $dbr = wfGetDB( DB_SLAVE
);
1065 $watchlist = $dbr->tableName( 'watchlist' );
1066 $sql = "SELECT COUNT(*) AS n FROM $watchlist
1067 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
1068 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
1069 $res = $dbr->query( $sql, 'Skin::pageStats');
1070 $x = $dbr->fetchObject( $res );
1071 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
1074 return $s . ' ' . $this->getCopyright();
1077 function getCopyright( $type = 'detect' ) {
1078 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
1080 if ( $type == 'detect' ) {
1081 $oldid = $wgRequest->getVal( 'oldid' );
1082 $diff = $wgRequest->getVal( 'diff' );
1084 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1091 if ( $type == 'history' ) {
1092 $msg = 'history_copyright';
1098 if( $wgRightsPage ) {
1099 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
1100 } elseif( $wgRightsUrl ) {
1101 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1106 $out .= wfMsgForContent( $msg, $link );
1110 function getCopyrightIcon() {
1111 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1113 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1114 $out = $wgCopyrightIcon;
1115 } else if ( $wgRightsIcon ) {
1116 $icon = htmlspecialchars( $wgRightsIcon );
1117 if ( $wgRightsUrl ) {
1118 $url = htmlspecialchars( $wgRightsUrl );
1119 $out .= '<a href="'.$url.'">';
1121 $text = htmlspecialchars( $wgRightsText );
1122 $out .= "<img src=\"$icon\" alt='$text' />";
1123 if ( $wgRightsUrl ) {
1130 function getPoweredBy() {
1131 global $wgStylePath;
1132 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1133 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1137 function lastModified() {
1138 global $wgLang, $wgArticle, $wgLoadBalancer;
1140 $timestamp = $wgArticle->getTimestamp();
1142 $d = $wgLang->date( $timestamp, true );
1143 $t = $wgLang->time( $timestamp, true );
1144 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1148 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
1149 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1154 function logoText( $align = '' ) {
1155 if ( '' != $align ) { $a = " align='{$align}'"; }
1158 $mp = wfMsg( 'mainpage' );
1159 $mptitle = Title
::newMainPage();
1160 $url = ( is_object($mptitle) ?
$mptitle->escapeLocalURL() : '' );
1162 $logourl = $this->getLogo();
1163 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1168 * show a drop-down box of special pages
1170 function specialPagesList() {
1171 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1172 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1173 foreach ( $pages as $name => $page ) {
1174 $pages[$name] = $page->getDescription();
1177 $go = wfMsg( 'go' );
1178 $sp = wfMsg( 'specialpages' );
1179 $spp = $wgContLang->specialPage( 'Specialpages' );
1181 $s = '<form id="specialpages" method="get" class="inline" ' .
1182 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1183 $s .= "<select name=\"wpDropdown\">\n";
1184 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1187 foreach ( $pages as $name => $desc ) {
1188 $p = $wgContLang->specialPage( $name );
1189 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1191 $s .= "</select>\n";
1192 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1197 function mainPageLink() {
1198 $s = $this->makeKnownLinkObj( Title
::newMainPage(), wfMsg( 'mainpage' ) );
1202 function copyrightLink() {
1203 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1204 wfMsg( 'copyrightpagename' ) );
1208 private function footerLink ( $desc, $page ) {
1209 // if the link description has been set to "-" in the default language,
1210 if ( wfMsgForContent( $desc ) == '-') {
1211 // then it is disabled, for all languages.
1214 // Otherwise, we display the link for the user, described in their
1215 // language (which may or may not be the same as the default language),
1216 // but we make the link target be the one site-wide page.
1217 return $this->makeKnownLink( wfMsgForContent( $page ), wfMsg( $desc ) );
1221 function privacyLink() {
1222 return $this->footerLink( 'privacy', 'privacypage' );
1225 function aboutLink() {
1226 return $this->footerLink( 'aboutsite', 'aboutpage' );
1229 function disclaimerLink() {
1230 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1233 function editThisPage() {
1234 global $wgOut, $wgTitle;
1236 if ( ! $wgOut->isArticleRelated() ) {
1237 $s = wfMsg( 'protectedpage' );
1239 if ( $wgTitle->userCan( 'edit' ) ) {
1240 $t = wfMsg( 'editthispage' );
1242 $t = wfMsg( 'viewsource' );
1245 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1251 * Return URL options for the 'edit page' link.
1252 * This may include an 'oldid' specifier, if the current page view is such.
1257 function editUrlOptions() {
1260 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1261 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1263 return "action=edit";
1267 function deleteThisPage() {
1268 global $wgUser, $wgTitle, $wgRequest;
1270 $diff = $wgRequest->getVal( 'diff' );
1271 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1272 $t = wfMsg( 'deletethispage' );
1274 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1281 function protectThisPage() {
1282 global $wgUser, $wgTitle, $wgRequest;
1284 $diff = $wgRequest->getVal( 'diff' );
1285 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1286 if ( $wgTitle->isProtected() ) {
1287 $t = wfMsg( 'unprotectthispage' );
1288 $q = 'action=unprotect';
1290 $t = wfMsg( 'protectthispage' );
1291 $q = 'action=protect';
1293 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1300 function watchThisPage() {
1301 global $wgOut, $wgTitle;
1302 ++
$this->mWatchLinkNum
;
1304 if ( $wgOut->isArticleRelated() ) {
1305 if ( $wgTitle->userIsWatching() ) {
1306 $t = wfMsg( 'unwatchthispage' );
1307 $q = 'action=unwatch';
1308 $id = "mw-unwatch-link".$this->mWatchLinkNum
;
1310 $t = wfMsg( 'watchthispage' );
1311 $q = 'action=watch';
1312 $id = 'mw-watch-link'.$this->mWatchLinkNum
;
1314 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q, '', '', " id=\"$id\"" );
1316 $s = wfMsg( 'notanarticle' );
1321 function moveThisPage() {
1324 if ( $wgTitle->userCan( 'move' ) ) {
1325 return $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
1326 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1328 // no message if page is protected - would be redundant
1333 function historyLink() {
1336 return $this->makeKnownLinkObj( $wgTitle,
1337 wfMsg( 'history' ), 'action=history' );
1340 function whatLinksHere() {
1343 return $this->makeKnownLinkObj(
1344 SpecialPage
::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ),
1345 wfMsg( 'whatlinkshere' ) );
1348 function userContribsLink() {
1351 return $this->makeKnownLinkObj(
1352 SpecialPage
::getTitleFor( 'Contributions', $wgTitle->getDBkey() ),
1353 wfMsg( 'contributions' ) );
1356 function showEmailUser( $id ) {
1357 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1358 return $wgEnableEmail &&
1359 $wgEnableUserEmail &&
1360 $wgUser->isLoggedIn() && # show only to signed in users
1361 0 != $id; # we can only email to non-anons ..
1362 # '' != $id->getEmail() && # who must have an email address stored ..
1363 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1364 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1367 function emailUserLink() {
1370 return $this->makeKnownLinkObj(
1371 SpecialPage
::getTitleFor( 'Emailuser', $wgTitle->getDBkey() ),
1372 wfMsg( 'emailuser' ) );
1375 function watchPageLinksLink() {
1376 global $wgOut, $wgTitle;
1378 if ( ! $wgOut->isArticleRelated() ) {
1379 return '(' . wfMsg( 'notanarticle' ) . ')';
1381 return $this->makeKnownLinkObj(
1382 SpecialPage
::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ),
1383 wfMsg( 'recentchangeslinked' ) );
1387 function trackbackLink() {
1390 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1391 . wfMsg('trackbacklink') . "</a>";
1394 function otherLanguages() {
1395 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1397 if ( $wgHideInterlanguageLinks ) {
1401 $a = $wgOut->getLanguageLinks();
1402 if ( 0 == count( $a ) ) {
1406 $s = wfMsg( 'otherlanguages' ) . ': ';
1408 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1409 foreach( $a as $l ) {
1410 if ( ! $first ) { $s .= ' | '; }
1413 $nt = Title
::newFromText( $l );
1414 $url = $nt->escapeFullURL();
1415 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1417 if ( '' == $text ) { $text = $l; }
1418 $style = $this->getExternalLinkAttributes( $l, $text );
1419 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1421 if($wgContLang->isRTL()) $s .= '</span>';
1425 function bugReportsLink() {
1426 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1427 wfMsg( 'bugreports' ) );
1431 function talkLink() {
1434 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1435 # No discussion links for special pages
1439 if( $wgTitle->isTalkPage() ) {
1440 $link = $wgTitle->getSubjectPage();
1441 switch( $link->getNamespace() ) {
1443 $text = wfMsg( 'articlepage' );
1446 $text = wfMsg( 'userpage' );
1449 $text = wfMsg( 'projectpage' );
1452 $text = wfMsg( 'imagepage' );
1455 $text = wfMsg( 'mediawikipage' );
1458 $text = wfMsg( 'templatepage' );
1461 $text = wfMsg( 'viewhelppage' );
1464 $text = wfMsg( 'categorypage' );
1467 $text = wfMsg( 'articlepage' );
1470 $link = $wgTitle->getTalkPage();
1471 $text = wfMsg( 'talkpage' );
1474 $s = $this->makeLinkObj( $link, $text );
1479 function commentLink() {
1480 global $wgTitle, $wgOut;
1482 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1486 # __NEWSECTIONLINK___ changes behaviour here
1487 # If it's present, the link points to this page, otherwise
1488 # it points to the talk page
1489 if( $wgTitle->isTalkPage() ) {
1491 } elseif( $wgOut->showNewSectionLink() ) {
1494 $title =& $wgTitle->getTalkPage();
1497 return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1500 /* these are used extensively in SkinTemplate, but also some other places */
1501 static function makeMainPageUrl( $urlaction = '' ) {
1502 $title = Title
::newMainPage();
1503 self
::checkTitle( $title, '' );
1504 return $title->getLocalURL( $urlaction );
1507 static function makeSpecialUrl( $name, $urlaction = '' ) {
1508 $title = SpecialPage
::getTitleFor( $name );
1509 return $title->getLocalURL( $urlaction );
1512 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1513 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1514 return $title->getLocalURL( $urlaction );
1517 static function makeI18nUrl( $name, $urlaction = '' ) {
1518 $title = Title
::newFromText( wfMsgForContent( $name ) );
1519 self
::checkTitle( $title, $name );
1520 return $title->getLocalURL( $urlaction );
1523 static function makeUrl( $name, $urlaction = '' ) {
1524 $title = Title
::newFromText( $name );
1525 self
::checkTitle( $title, $name );
1526 return $title->getLocalURL( $urlaction );
1529 # If url string starts with http, consider as external URL, else
1531 static function makeInternalOrExternalUrl( $name ) {
1532 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1535 return self
::makeUrl( $name );
1539 # this can be passed the NS number as defined in Language.php
1540 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1541 $title = Title
::makeTitleSafe( $namespace, $name );
1542 self
::checkTitle( $title, $name );
1543 return $title->getLocalURL( $urlaction );
1546 /* these return an array with the 'href' and boolean 'exists' */
1547 static function makeUrlDetails( $name, $urlaction = '' ) {
1548 $title = Title
::newFromText( $name );
1549 self
::checkTitle( $title, $name );
1551 'href' => $title->getLocalURL( $urlaction ),
1552 'exists' => $title->getArticleID() != 0 ?
true : false
1557 * Make URL details where the article exists (or at least it's convenient to think so)
1559 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1560 $title = Title
::newFromText( $name );
1561 self
::checkTitle( $title, $name );
1563 'href' => $title->getLocalURL( $urlaction ),
1568 # make sure we have some title to operate on
1569 static function checkTitle( &$title, $name ) {
1570 if( !is_object( $title ) ) {
1571 $title = Title
::newFromText( $name );
1572 if( !is_object( $title ) ) {
1573 $title = Title
::newFromText( '--error: link target missing--' );
1579 * Build an array that represents the sidebar(s), the navigation bar among them
1584 function buildSidebar() {
1585 global $parserMemc, $wgEnableSidebarCache;
1586 global $wgLang, $wgContLang;
1588 $fname = 'SkinTemplate::buildSidebar';
1590 wfProfileIn( $fname );
1592 $key = wfMemcKey( 'sidebar' );
1593 $cacheSidebar = $wgEnableSidebarCache &&
1594 ($wgLang->getCode() == $wgContLang->getCode());
1596 if ($cacheSidebar) {
1597 $cachedsidebar = $parserMemc->get( $key );
1598 if ($cachedsidebar!="") {
1599 wfProfileOut($fname);
1600 return $cachedsidebar;
1605 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1606 foreach ($lines as $line) {
1607 if (strpos($line, '*') !== 0)
1609 if (strpos($line, '**') !== 0) {
1610 $line = trim($line, '* ');
1613 if (strpos($line, '|') !== false) { // sanity check
1614 $line = explode( '|' , trim($line, '* '), 2 );
1615 $link = wfMsgForContent( $line[0] );
1618 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1620 if (wfEmptyMsg($line[0], $link))
1623 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1626 $title = Title
::newFromText( $link );
1628 $title = $title->fixSpecialName();
1629 $href = $title->getLocalURL();
1631 $href = 'INVALID-TITLE';
1635 $bar[$heading][] = array(
1638 'id' => 'n-' . strtr($line[1], ' ', '-'),
1641 } else { continue; }
1645 $parserMemc->set( $key, $bar, 86400 );
1646 wfProfileOut( $fname );