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( __METHOD__
);
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>" );
272 wfProfileOut( __METHOD__
);
275 static function makeVariablesScript( $data ) {
276 global $wgJsMimeType;
278 $r = "<script type= \"$wgJsMimeType\">/*<![CDATA[*/\n";
279 foreach ( $data as $name => $value ) {
280 $encValue = Xml
::encodeJsVar( $value );
281 $r .= "var $name = $encValue;\n";
283 $r .= "/*]]>*/</script>\n";
289 * Make a <script> tag containing global variables
290 * @param array $data Associative array containing one element:
291 * skinname => the skin name
292 * The odd calling convention is for backwards compatibility
294 static function makeGlobalVariablesScript( $data ) {
295 global $wgStylePath, $wgUser;
296 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
297 global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
298 global $wgBreakFrames;
300 $ns = $wgTitle->getNamespace();
301 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
304 'skin' => $data['skinname'],
305 'stylepath' => $wgStylePath,
306 'wgArticlePath' => $wgArticlePath,
307 'wgScriptPath' => $wgScriptPath,
308 'wgServer' => $wgServer,
309 'wgCanonicalNamespace' => $nsname,
310 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBKey() ),
311 'wgNamespaceNumber' => $wgTitle->getNamespace(),
312 'wgPageName' => $wgTitle->getPrefixedDBKey(),
313 'wgTitle' => $wgTitle->getText(),
314 'wgArticleId' => $wgTitle->getArticleId(),
315 'wgIsArticle' => $wgOut->isArticle(),
316 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
317 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getEffectiveGroups(),
318 'wgUserLanguage' => $wgLang->getCode(),
319 'wgContentLanguage' => $wgContLang->getCode(),
320 'wgBreakFrames' => $wgBreakFrames,
321 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
324 global $wgLivePreview;
325 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
326 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
327 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
328 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
329 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
332 return self
::makeVariablesScript( $vars );
335 function getHeadScripts() {
336 global $wgStylePath, $wgUser, $wgAllowUserJs, $wgJsMimeType, $wgStyleVersion;
338 $r = self
::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
340 $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n";
343 if ($wgUser->isLoggedIn()) {
344 $r .= "<script type=\"$wgJsMimeType\" src=\"".htmlspecialchars(self
::makeUrl('-','action=raw&smaxage=0&gen=js'))."\"><!-- site js --></script>\n";
346 $r .= "<script type=\"$wgJsMimeType\" src=\"".htmlspecialchars(self
::makeUrl('-','action=raw&gen=js'))."\"><!-- site js --></script>\n";
349 if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
350 $userpage = $wgUser->getUserPage();
351 $userjs = htmlspecialchars( self
::makeUrl(
352 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
353 'action=raw&ctype='.$wgJsMimeType));
354 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
360 * To make it harder for someone to slip a user a fake
361 * user-JavaScript or user-CSS preview, a random token
362 * is associated with the login session. If it's not
363 * passed back with the preview request, we won't render
366 * @param string $action
370 function userCanPreview( $action ) {
371 global $wgTitle, $wgRequest, $wgUser;
373 if( $action != 'submit' )
375 if( !$wgRequest->wasPosted() )
377 if( !$wgTitle->userCanEditCssJsSubpage() )
379 return $wgUser->matchEditToken(
380 $wgRequest->getVal( 'wpEditToken' ) );
383 # get the user/site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way)
384 function getUserStylesheet() {
385 global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage, $wgStyleVersion;
386 $sheet = $this->getStylesheet();
387 $s = "@import \"$wgStylePath/common/common.css?$wgStyleVersion\";\n";
388 $s .= "@import \"$wgStylePath/$sheet?$wgStyleVersion\";\n";
389 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css?$wgStyleVersion\";\n";
391 $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
392 $s .= '@import "' . self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n" .
393 '@import "' . self
::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
395 $s .= $this->doGetUserStyles();
400 * This returns MediaWiki:Common.js. For some bizarre reason, it does
401 * *not* return any custom user JS from user subpages. Huh?
405 function getUserJs() {
406 wfProfileIn( __METHOD__
);
409 $s = "/* generated javascript */\n";
410 $s .= "var skin = '{$this->skinname}';\nvar stylepath = '{$wgStylePath}';";
411 $s .= "\n\n/* MediaWiki:Common.js */\n";
412 $commonJs = wfMsgForContent('common.js');
413 if ( !wfEmptyMsg ( 'common.js', $commonJs ) ) {
417 global $wgUseAjax, $wgAjaxWatch;
418 if($wgUseAjax && $wgAjaxWatch) {
421 /* AJAX (un)watch (see /skins/common/ajaxwatch.js) */
423 watchMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'watch', array() ) )."',
424 unwatchMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'unwatch', array() ) )."',
425 watchingMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'watching', array() ) )."',
426 unwatchingMsg: '". str_replace( array("'", "\n"), array("\\'", ' '), wfMsgExt( 'unwatching', array() ) )."'
430 wfProfileOut( __METHOD__
);
435 * Return html code that include User stylesheets
437 function getUserStyles() {
438 $s = "<style type='text/css'>\n";
439 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
440 $s .= $this->getUserStylesheet();
441 $s .= "/*]]>*/ /* */\n";
447 * Some styles that are set by user through the user settings interface.
449 function doGetUserStyles() {
450 global $wgUser, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
454 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
455 if($wgTitle->isCssSubpage() && $this->userCanPreview( $wgRequest->getText( 'action' ) ) ) {
456 $s .= $wgRequest->getText('wpTextbox1');
458 $userpage = $wgUser->getUserPage();
459 $s.= '@import "'.self
::makeUrl(
460 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
461 'action=raw&ctype=text/css').'";'."\n";
465 return $s . $this->reallyDoGetUserStyles();
468 function reallyDoGetUserStyles() {
471 if (($undopt = $wgUser->getOption("underline")) != 2) {
472 $underline = $undopt ?
'underline' : 'none';
473 $s .= "a { text-decoration: $underline; }\n";
475 if( $wgUser->getOption( 'highlightbroken' ) ) {
476 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
479 a.new, #quickbar a.new,
480 a.stub, #quickbar a.stub {
482 text-decoration: inherit;
484 a.new:after, #quickbar a.new:after {
487 text-decoration: $underline;
489 a.stub:after, #quickbar a.stub:after {
492 text-decoration: $underline;
496 if( $wgUser->getOption( 'justify' ) ) {
497 $s .= "#article, #bodyContent { text-align: justify; }\n";
499 if( !$wgUser->getOption( 'showtoc' ) ) {
500 $s .= "#toc { display: none; }\n";
502 if( !$wgUser->getOption( 'editsection' ) ) {
503 $s .= ".editsection { display: none; }\n";
508 function getBodyOptions() {
509 global $wgUser, $wgTitle, $wgOut, $wgRequest, $wgContLang;
511 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
513 if ( 0 != $wgTitle->getNamespace() ) {
514 $a = array( 'bgcolor' => '#ffffec' );
516 else $a = array( 'bgcolor' => '#FFFFFF' );
517 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
518 $wgTitle->userCan( 'edit' ) ) {
519 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
520 $s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
521 $a +
= array ('ondblclick' => $s);
524 $a['onload'] = $wgOut->getOnloadHandler();
525 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
526 if( $a['onload'] != '' ) {
529 $a['onload'] .= 'setupRightClickEdit()';
531 $a['class'] = 'ns-'.$wgTitle->getNamespace().' '.($wgContLang->isRTL() ?
"rtl" : "ltr").
532 ' '.Sanitizer
::escapeClass( 'page-'.$wgTitle->getPrefixedText() );
545 * This will be called immediately after the <body> tag. Split into
546 * two functions to make it easier to subclass.
548 function beforeContent() {
549 return $this->doBeforeContent();
552 function doBeforeContent() {
554 $fname = 'Skin::doBeforeContent';
555 wfProfileIn( $fname );
558 $qb = $this->qbSetting();
560 if( $langlinks = $this->otherLanguages() ) {
566 $borderhack = 'class="top"';
569 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
570 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
573 $left = ($qb == 1 ||
$qb == 3);
574 if($wgContLang->isRTL()) $left = !$left;
577 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
578 $this->logoText() . '</td>';
580 $s .= $this->getQuickbarCompensator( $rows );
582 $l = $wgContLang->isRTL() ?
'right' : 'left';
583 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
585 $s .= $this->topLinks() ;
586 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
588 $r = $wgContLang->isRTL() ?
"left" : "right";
589 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
590 $s .= $this->nameAndLogin();
591 $s .= "\n<br />" . $this->searchForm() . "</td>";
594 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
597 if ( $shove && !$left ) { # Right
598 $s .= $this->getQuickbarCompensator( $rows );
600 $s .= "</tr>\n</table>\n</div>\n";
601 $s .= "\n<div id='article'>\n";
603 $notice = wfGetSiteNotice();
605 $s .= "\n<div id='siteNotice'>$notice</div>\n";
607 $s .= $this->pageTitle();
608 $s .= $this->pageSubtitle() ;
609 $s .= $this->getCategories();
610 wfProfileOut( $fname );
615 function getCategoryLinks () {
616 global $wgOut, $wgTitle, $wgUseCategoryBrowser;
619 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
622 $sep = wfMsgHtml( 'catseparator' );
624 // Use Unicode bidi embedding override characters,
625 // to make sure links don't smash each other up in ugly ways.
626 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
627 $embed = "<span dir='$dir'>";
629 $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $wgOut->mCategoryLinks
) . $pop;
631 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escape' ), count( $wgOut->mCategoryLinks
) );
632 $s = $this->makeLinkObj( Title
::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
635 # optional 'dmoz-like' category browser. Will be shown under the list
636 # of categories an article belong to
637 if($wgUseCategoryBrowser) {
638 $s .= '<br /><hr />';
640 # get a big array of the parents tree
641 $parenttree = $wgTitle->getParentCategoryTree();
642 # Skin object passed by reference cause it can not be
643 # accessed under the method subfunction drawCategoryBrowser
644 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
645 # Clean out bogus first entry and sort them
648 # Output one per line
649 $s .= implode("<br />\n", $tempout);
655 /** Render the array as a serie of links.
656 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
657 * @param &skin Object: skin passed by reference
658 * @return String separated by >, terminate with "\n"
660 function drawCategoryBrowser($tree, &$skin) {
662 foreach ($tree as $element => $parent) {
663 if (empty($parent)) {
664 # element start a new list
667 # grab the others elements
668 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
670 # add our current element to the list
671 $eltitle = Title
::NewFromText($element);
672 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
677 function getCategories() {
678 $catlinks=$this->getCategoryLinks();
679 if(!empty($catlinks)) {
680 return "<p class='catlinks'>{$catlinks}</p>";
684 function getQuickbarCompensator( $rows = 1 ) {
685 return "<td width='152' rowspan='{$rows}'> </td>";
689 * This gets called shortly before the \</body\> tag.
690 * @return String HTML to be put before \</body\>
692 function afterContent() {
693 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
694 return $printfooter . $this->doAfterContent();
698 * This gets called shortly before the \</body\> tag.
699 * @return String HTML-wrapped JS code to be put before \</body\>
701 function bottomScripts() {
702 global $wgJsMimeType;
703 return "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
706 /** @return string Retrievied from HTML text */
707 function printSource() {
709 $url = htmlspecialchars( $wgTitle->getFullURL() );
710 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
713 function printFooter() {
714 return "<p>" . $this->printSource() .
715 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
718 /** overloaded by derived classes */
719 function doAfterContent() { }
721 function pageTitleLinks() {
722 global $wgOut, $wgTitle, $wgUser, $wgRequest;
724 $oldid = $wgRequest->getVal( 'oldid' );
725 $diff = $wgRequest->getVal( 'diff' );
726 $action = $wgRequest->getText( 'action' );
728 $s = $this->printableLink();
729 $disclaimer = $this->disclaimerLink(); # may be empty
731 $s .= ' | ' . $disclaimer;
733 $privacy = $this->privacyLink(); # may be empty too
735 $s .= ' | ' . $privacy;
738 if ( $wgOut->isArticleRelated() ) {
739 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
740 $name = $wgTitle->getDBkey();
741 $image = new Image( $wgTitle );
742 if( $image->exists() ) {
743 $link = htmlspecialchars( $image->getURL() );
744 $style = $this->getInternalLinkAttributes( $link, $name );
745 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
749 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
750 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
751 wfMsg( 'currentrev' ) );
754 if ( $wgUser->getNewtalk() ) {
755 # do not show "You have new messages" text when we are viewing our
757 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
758 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
759 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
760 $s.= ' | <strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
762 $wgOut->setSquidMaxage(0);
763 $wgOut->enableClientCache(false);
767 $undelete = $this->getUndeleteLink();
768 if( !empty( $undelete ) ) {
769 $s .= ' | '.$undelete;
774 function getUndeleteLink() {
775 global $wgUser, $wgTitle, $wgContLang, $action;
776 if( $wgUser->isAllowed( 'deletedhistory' ) &&
777 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
778 ($n = $wgTitle->isDeleted() ) )
780 if ( $wgUser->isAllowed( 'delete' ) ) {
781 $msg = 'thisisdeleted';
783 $msg = 'viewdeleted';
786 $this->makeKnownLinkObj(
787 SpecialPage
::getTitleFor( 'Undelete', $wgTitle->getPrefixedDBkey() ),
788 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $n ) ) );
793 function printableLink() {
794 global $wgOut, $wgFeedClasses, $wgRequest;
796 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
798 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
799 if( $wgOut->isSyndicated() ) {
800 foreach( $wgFeedClasses as $format => $class ) {
801 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
802 $s .= " | <a href=\"$feedurl\">{$format}</a>";
808 function pageTitle() {
810 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
814 function pageSubtitle() {
817 $sub = $wgOut->getSubtitle();
819 global $wgExtraSubtitle;
820 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
822 $subpages = $this->subPageSubtitle();
823 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
824 $s = "<p class='subtitle'>{$sub}</p>\n";
828 function subPageSubtitle() {
829 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
831 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
832 $ptext=$wgTitle->getPrefixedText();
833 if(preg_match('/\//',$ptext)) {
834 $links = explode('/',$ptext);
837 foreach($links as $link) {
839 if ($c<count($links)) {
840 $growinglink .= $link;
841 $getlink = $this->makeLink( $growinglink, htmlspecialchars( $link ) );
842 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
846 $subpages .= '< ';
848 $subpages .= $getlink;
858 * Returns true if the IP should be shown in the header
860 function showIPinHeader() {
861 global $wgShowIPinHeader;
862 return $wgShowIPinHeader && session_id() != '';
865 function nameAndLogin() {
866 global $wgUser, $wgTitle, $wgLang, $wgContLang;
868 $lo = $wgContLang->specialPage( 'Userlogout' );
871 if ( $wgUser->isAnon() ) {
872 if( $this->showIPinHeader() ) {
875 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
876 $wgLang->getNsText( NS_TALK
) );
878 $s .= $n . ' ('.$tl.')';
880 $s .= wfMsg('notloggedin');
883 $rt = $wgTitle->getPrefixedURL();
884 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
886 } else { $q = "returnto={$rt}"; }
888 $s .= "\n<br />" . $this->makeKnownLinkObj(
889 SpecialPage
::getTitleFor( 'Userlogin' ),
890 wfMsg( 'login' ), $q );
892 $n = $wgUser->getName();
893 $rt = $wgTitle->getPrefixedURL();
894 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
895 $wgLang->getNsText( NS_TALK
) );
899 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
900 $n ) . "{$tl}<br />" .
901 $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
902 "returnto={$rt}" ) . ' | ' .
903 $this->specialLink( 'preferences' );
905 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
911 function getSearchLink() {
912 $searchPage = SpecialPage
::getTitleFor( 'Search' );
913 return $searchPage->getLocalURL();
916 function escapeSearchLink() {
917 return htmlspecialchars( $this->getSearchLink() );
920 function searchForm() {
922 $search = $wgRequest->getText( 'search' );
924 $s = '<form name="search" class="inline" method="post" action="'
925 . $this->escapeSearchLink() . "\">\n"
926 . '<input type="text" name="search" size="19" value="'
927 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
928 . '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" /> '
929 . '<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n</form>";
934 function topLinks() {
938 $s = $this->mainPageLink() . $sep
939 . $this->specialLink( 'recentchanges' );
941 if ( $wgOut->isArticleRelated() ) {
942 $s .= $sep . $this->editThisPage()
943 . $sep . $this->historyLink();
945 # Many people don't like this dropdown box
946 #$s .= $sep . $this->specialPagesList();
948 $s .= $this->variantLinks();
950 $s .= $this->extensionTabLinks();
956 * Compatibility for extensions adding functionality through tabs.
957 * Eventually these old skins should be replaced with SkinTemplate-based
961 function extensionTabLinks() {
964 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
965 foreach( $tabs as $tab ) {
966 $s .= ' | ' . Xml
::element( 'a',
967 array( 'href' => $tab['href'] ),
974 * Language/charset variant links for classic-style skins
977 function variantLinks() {
979 /* show links to different language variants */
980 global $wgDisableLangConversion, $wgContLang, $wgTitle;
981 $variants = $wgContLang->getVariants();
982 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
983 foreach( $variants as $code ) {
984 $varname = $wgContLang->getVariantname( $code );
985 if( $varname == 'disable' )
987 $s .= ' | <a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>';
993 function bottomLinks() {
994 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
998 if ( $wgOut->isArticleRelated() ) {
999 $s .= '<strong>' . $this->editThisPage() . '</strong>';
1000 if ( $wgUser->isLoggedIn() ) {
1001 $s .= $sep . $this->watchThisPage();
1003 $s .= $sep . $this->talkLink()
1004 . $sep . $this->historyLink()
1005 . $sep . $this->whatLinksHere()
1006 . $sep . $this->watchPageLinksLink();
1008 if ($wgUseTrackbacks)
1009 $s .= $sep . $this->trackbackLink();
1011 if ( $wgTitle->getNamespace() == NS_USER
1012 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
1015 $id=User
::idFromName($wgTitle->getText());
1016 $ip=User
::isIP($wgTitle->getText());
1018 if($id ||
$ip) { # both anons and non-anons have contri list
1019 $s .= $sep . $this->userContribsLink();
1021 if( $this->showEmailUser( $id ) ) {
1022 $s .= $sep . $this->emailUserLink();
1025 if ( $wgTitle->getArticleId() ) {
1027 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
1028 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
1029 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
1031 $s .= "<br />\n" . $this->otherLanguages();
1036 function pageStats() {
1037 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1038 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
1040 $oldid = $wgRequest->getVal( 'oldid' );
1041 $diff = $wgRequest->getVal( 'diff' );
1042 if ( ! $wgOut->isArticle() ) { return ''; }
1043 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1044 if ( 0 == $wgArticle->getID() ) { return ''; }
1047 if ( !$wgDisableCounters ) {
1048 $count = $wgLang->formatNum( $wgArticle->getCount() );
1050 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1054 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
1055 require_once('Credits.php');
1056 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
1058 $s .= $this->lastModified();
1061 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
1062 $dbr = wfGetDB( DB_SLAVE
);
1063 $watchlist = $dbr->tableName( 'watchlist' );
1064 $sql = "SELECT COUNT(*) AS n FROM $watchlist
1065 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
1066 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
1067 $res = $dbr->query( $sql, 'Skin::pageStats');
1068 $x = $dbr->fetchObject( $res );
1069 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
1072 return $s . ' ' . $this->getCopyright();
1075 function getCopyright( $type = 'detect' ) {
1076 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
1078 if ( $type == 'detect' ) {
1079 $oldid = $wgRequest->getVal( 'oldid' );
1080 $diff = $wgRequest->getVal( 'diff' );
1082 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1089 if ( $type == 'history' ) {
1090 $msg = 'history_copyright';
1096 if( $wgRightsPage ) {
1097 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
1098 } elseif( $wgRightsUrl ) {
1099 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1104 $out .= wfMsgForContent( $msg, $link );
1108 function getCopyrightIcon() {
1109 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1111 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1112 $out = $wgCopyrightIcon;
1113 } else if ( $wgRightsIcon ) {
1114 $icon = htmlspecialchars( $wgRightsIcon );
1115 if ( $wgRightsUrl ) {
1116 $url = htmlspecialchars( $wgRightsUrl );
1117 $out .= '<a href="'.$url.'">';
1119 $text = htmlspecialchars( $wgRightsText );
1120 $out .= "<img src=\"$icon\" alt='$text' />";
1121 if ( $wgRightsUrl ) {
1128 function getPoweredBy() {
1129 global $wgStylePath;
1130 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1131 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1135 function lastModified() {
1136 global $wgLang, $wgArticle, $wgLoadBalancer;
1138 $timestamp = $wgArticle->getTimestamp();
1140 $d = $wgLang->date( $timestamp, true );
1141 $t = $wgLang->time( $timestamp, true );
1142 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1146 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
1147 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1152 function logoText( $align = '' ) {
1153 if ( '' != $align ) { $a = " align='{$align}'"; }
1156 $mp = wfMsg( 'mainpage' );
1157 $mptitle = Title
::newMainPage();
1158 $url = ( is_object($mptitle) ?
$mptitle->escapeLocalURL() : '' );
1160 $logourl = $this->getLogo();
1161 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1166 * show a drop-down box of special pages
1168 function specialPagesList() {
1169 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1170 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1171 foreach ( $pages as $name => $page ) {
1172 $pages[$name] = $page->getDescription();
1175 $go = wfMsg( 'go' );
1176 $sp = wfMsg( 'specialpages' );
1177 $spp = $wgContLang->specialPage( 'Specialpages' );
1179 $s = '<form id="specialpages" method="get" class="inline" ' .
1180 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1181 $s .= "<select name=\"wpDropdown\">\n";
1182 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1185 foreach ( $pages as $name => $desc ) {
1186 $p = $wgContLang->specialPage( $name );
1187 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1189 $s .= "</select>\n";
1190 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1195 function mainPageLink() {
1196 $s = $this->makeKnownLinkObj( Title
::newMainPage(), wfMsg( 'mainpage' ) );
1200 function copyrightLink() {
1201 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1202 wfMsg( 'copyrightpagename' ) );
1206 private function footerLink ( $desc, $page ) {
1207 // if the link description has been set to "-" in the default language,
1208 if ( wfMsgForContent( $desc ) == '-') {
1209 // then it is disabled, for all languages.
1212 // Otherwise, we display the link for the user, described in their
1213 // language (which may or may not be the same as the default language),
1214 // but we make the link target be the one site-wide page.
1215 return $this->makeKnownLink( wfMsgForContent( $page ), wfMsg( $desc ) );
1219 function privacyLink() {
1220 return $this->footerLink( 'privacy', 'privacypage' );
1223 function aboutLink() {
1224 return $this->footerLink( 'aboutsite', 'aboutpage' );
1227 function disclaimerLink() {
1228 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1231 function editThisPage() {
1232 global $wgOut, $wgTitle;
1234 if ( ! $wgOut->isArticleRelated() ) {
1235 $s = wfMsg( 'protectedpage' );
1237 if ( $wgTitle->userCan( 'edit' ) ) {
1238 $t = wfMsg( 'editthispage' );
1240 $t = wfMsg( 'viewsource' );
1243 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1249 * Return URL options for the 'edit page' link.
1250 * This may include an 'oldid' specifier, if the current page view is such.
1255 function editUrlOptions() {
1258 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1259 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1261 return "action=edit";
1265 function deleteThisPage() {
1266 global $wgUser, $wgTitle, $wgRequest;
1268 $diff = $wgRequest->getVal( 'diff' );
1269 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1270 $t = wfMsg( 'deletethispage' );
1272 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1279 function protectThisPage() {
1280 global $wgUser, $wgTitle, $wgRequest;
1282 $diff = $wgRequest->getVal( 'diff' );
1283 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1284 if ( $wgTitle->isProtected() ) {
1285 $t = wfMsg( 'unprotectthispage' );
1286 $q = 'action=unprotect';
1288 $t = wfMsg( 'protectthispage' );
1289 $q = 'action=protect';
1291 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1298 function watchThisPage() {
1299 global $wgOut, $wgTitle;
1300 ++
$this->mWatchLinkNum
;
1302 if ( $wgOut->isArticleRelated() ) {
1303 if ( $wgTitle->userIsWatching() ) {
1304 $t = wfMsg( 'unwatchthispage' );
1305 $q = 'action=unwatch';
1306 $id = "mw-unwatch-link".$this->mWatchLinkNum
;
1308 $t = wfMsg( 'watchthispage' );
1309 $q = 'action=watch';
1310 $id = 'mw-watch-link'.$this->mWatchLinkNum
;
1312 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q, '', '', " id=\"$id\"" );
1314 $s = wfMsg( 'notanarticle' );
1319 function moveThisPage() {
1322 if ( $wgTitle->userCan( 'move' ) ) {
1323 return $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
1324 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1326 // no message if page is protected - would be redundant
1331 function historyLink() {
1334 return $this->makeKnownLinkObj( $wgTitle,
1335 wfMsg( 'history' ), 'action=history' );
1338 function whatLinksHere() {
1341 return $this->makeKnownLinkObj(
1342 SpecialPage
::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ),
1343 wfMsg( 'whatlinkshere' ) );
1346 function userContribsLink() {
1349 return $this->makeKnownLinkObj(
1350 SpecialPage
::getTitleFor( 'Contributions', $wgTitle->getDBkey() ),
1351 wfMsg( 'contributions' ) );
1354 function showEmailUser( $id ) {
1355 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1356 return $wgEnableEmail &&
1357 $wgEnableUserEmail &&
1358 $wgUser->isLoggedIn() && # show only to signed in users
1359 0 != $id; # we can only email to non-anons ..
1360 # '' != $id->getEmail() && # who must have an email address stored ..
1361 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1362 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1365 function emailUserLink() {
1368 return $this->makeKnownLinkObj(
1369 SpecialPage
::getTitleFor( 'Emailuser', $wgTitle->getDBkey() ),
1370 wfMsg( 'emailuser' ) );
1373 function watchPageLinksLink() {
1374 global $wgOut, $wgTitle;
1376 if ( ! $wgOut->isArticleRelated() ) {
1377 return '(' . wfMsg( 'notanarticle' ) . ')';
1379 return $this->makeKnownLinkObj(
1380 SpecialPage
::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ),
1381 wfMsg( 'recentchangeslinked' ) );
1385 function trackbackLink() {
1388 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1389 . wfMsg('trackbacklink') . "</a>";
1392 function otherLanguages() {
1393 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1395 if ( $wgHideInterlanguageLinks ) {
1399 $a = $wgOut->getLanguageLinks();
1400 if ( 0 == count( $a ) ) {
1404 $s = wfMsg( 'otherlanguages' ) . ': ';
1406 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1407 foreach( $a as $l ) {
1408 if ( ! $first ) { $s .= ' | '; }
1411 $nt = Title
::newFromText( $l );
1412 $url = $nt->escapeFullURL();
1413 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1415 if ( '' == $text ) { $text = $l; }
1416 $style = $this->getExternalLinkAttributes( $l, $text );
1417 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1419 if($wgContLang->isRTL()) $s .= '</span>';
1423 function bugReportsLink() {
1424 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1425 wfMsg( 'bugreports' ) );
1429 function dateLink() {
1430 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1431 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1433 $id = $t1->getArticleID();
1436 $s = $this->makeBrokenLink( $t1->getText() );
1438 $s = $this->makeKnownLink( $t1->getText() );
1442 $id = $t2->getArticleID();
1445 $s .= $this->makeBrokenLink( $t2->getText() );
1447 $s .= $this->makeKnownLink( $t2->getText() );
1452 function talkLink() {
1455 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1456 # No discussion links for special pages
1460 if( $wgTitle->isTalkPage() ) {
1461 $link = $wgTitle->getSubjectPage();
1462 switch( $link->getNamespace() ) {
1464 $text = wfMsg( 'articlepage' );
1467 $text = wfMsg( 'userpage' );
1470 $text = wfMsg( 'projectpage' );
1473 $text = wfMsg( 'imagepage' );
1476 $text = wfMsg( 'mediawikipage' );
1479 $text = wfMsg( 'templatepage' );
1482 $text = wfMsg( 'viewhelppage' );
1485 $text = wfMsg( 'categorypage' );
1488 $text = wfMsg( 'articlepage' );
1491 $link = $wgTitle->getTalkPage();
1492 $text = wfMsg( 'talkpage' );
1495 $s = $this->makeLinkObj( $link, $text );
1500 function commentLink() {
1501 global $wgTitle, $wgOut;
1503 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1507 # __NEWSECTIONLINK___ changes behaviour here
1508 # If it's present, the link points to this page, otherwise
1509 # it points to the talk page
1510 if( $wgTitle->isTalkPage() ) {
1512 } elseif( $wgOut->showNewSectionLink() ) {
1515 $title =& $wgTitle->getTalkPage();
1518 return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1521 /* these are used extensively in SkinTemplate, but also some other places */
1522 static function makeMainPageUrl( $urlaction = '' ) {
1523 $title = Title
::newMainPage();
1524 self
::checkTitle( $title, '' );
1525 return $title->getLocalURL( $urlaction );
1528 static function makeSpecialUrl( $name, $urlaction = '' ) {
1529 $title = SpecialPage
::getTitleFor( $name );
1530 return $title->getLocalURL( $urlaction );
1533 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1534 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1535 return $title->getLocalURL( $urlaction );
1538 static function makeI18nUrl( $name, $urlaction = '' ) {
1539 $title = Title
::newFromText( wfMsgForContent( $name ) );
1540 self
::checkTitle( $title, $name );
1541 return $title->getLocalURL( $urlaction );
1544 static function makeUrl( $name, $urlaction = '' ) {
1545 $title = Title
::newFromText( $name );
1546 self
::checkTitle( $title, $name );
1547 return $title->getLocalURL( $urlaction );
1550 # If url string starts with http, consider as external URL, else
1552 static function makeInternalOrExternalUrl( $name ) {
1553 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1556 return self
::makeUrl( $name );
1560 # this can be passed the NS number as defined in Language.php
1561 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1562 $title = Title
::makeTitleSafe( $namespace, $name );
1563 self
::checkTitle( $title, $name );
1564 return $title->getLocalURL( $urlaction );
1567 /* these return an array with the 'href' and boolean 'exists' */
1568 static function makeUrlDetails( $name, $urlaction = '' ) {
1569 $title = Title
::newFromText( $name );
1570 self
::checkTitle( $title, $name );
1572 'href' => $title->getLocalURL( $urlaction ),
1573 'exists' => $title->getArticleID() != 0 ?
true : false
1578 * Make URL details where the article exists (or at least it's convenient to think so)
1580 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1581 $title = Title
::newFromText( $name );
1582 self
::checkTitle( $title, $name );
1584 'href' => $title->getLocalURL( $urlaction ),
1589 # make sure we have some title to operate on
1590 static function checkTitle( &$title, $name ) {
1591 if( !is_object( $title ) ) {
1592 $title = Title
::newFromText( $name );
1593 if( !is_object( $title ) ) {
1594 $title = Title
::newFromText( '--error: link target missing--' );
1600 * Build an array that represents the sidebar(s), the navigation bar among them
1605 function buildSidebar() {
1606 global $parserMemc, $wgEnableSidebarCache;
1607 global $wgLang, $wgContLang;
1609 $fname = 'SkinTemplate::buildSidebar';
1611 wfProfileIn( $fname );
1613 $key = wfMemcKey( 'sidebar' );
1614 $cacheSidebar = $wgEnableSidebarCache &&
1615 ($wgLang->getCode() == $wgContLang->getCode());
1617 if ($cacheSidebar) {
1618 $cachedsidebar = $parserMemc->get( $key );
1619 if ($cachedsidebar!="") {
1620 wfProfileOut($fname);
1621 return $cachedsidebar;
1626 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1627 foreach ($lines as $line) {
1628 if (strpos($line, '*') !== 0)
1630 if (strpos($line, '**') !== 0) {
1631 $line = trim($line, '* ');
1634 if (strpos($line, '|') !== false) { // sanity check
1635 $line = explode( '|' , trim($line, '* '), 2 );
1636 $link = wfMsgForContent( $line[0] );
1639 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1641 if (wfEmptyMsg($line[0], $link))
1644 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1647 $title = Title
::newFromText( $link );
1649 $title = $title->fixSpecialName();
1650 $href = $title->getLocalURL();
1652 $href = 'INVALID-TITLE';
1656 $bar[$heading][] = array(
1659 'id' => 'n-' . strtr($line[1], ' ', '-'),
1662 } else { continue; }
1666 $parserMemc->set( $key, $bar, 86400 );
1667 wfProfileOut( $fname );