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;
161 wfProfileIn( __METHOD__
);
163 if( false !== $wgFavicon ) {
164 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
167 $names = Language
::getLanguageNames();
169 # OpenSearch description link
170 $out->addLink( array(
172 'type' => 'application/opensearchdescription+xml',
173 'href' => "$wgScriptPath/opensearch_desc.php",
174 'title' => "$wgSitename ({$names[$wgLanguageCode]})",
177 $this->addMetadataLinks($out);
179 $this->mRevisionId
= $out->mRevisionId
;
181 $this->preloadExistence();
183 wfProfileOut( __METHOD__
);
187 * Preload the existence of three commonly-requested pages in a single query
189 function preloadExistence() {
190 global $wgUser, $wgTitle;
193 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
196 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
198 } elseif ( $wgTitle->isTalkPage() ) {
199 $titles[] = $wgTitle->getSubjectPage();
201 $titles[] = $wgTitle->getTalkPage();
204 $lb = new LinkBatch( $titles );
208 function addMetadataLinks( &$out ) {
209 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
210 global $wgRightsPage, $wgRightsUrl;
212 if( $out->isArticleRelated() ) {
213 # note: buggy CC software only reads first "meta" link
214 if( $wgEnableCreativeCommonsRdf ) {
215 $out->addMetadataLink( array(
216 'title' => 'Creative Commons',
217 'type' => 'application/rdf+xml',
218 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
220 if( $wgEnableDublinCoreRdf ) {
221 $out->addMetadataLink( array(
222 'title' => 'Dublin Core',
223 'type' => 'application/rdf+xml',
224 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
228 if( $wgRightsPage ) {
229 $copy = Title
::newFromText( $wgRightsPage );
231 $copyright = $copy->getLocalURL();
234 if( !$copyright && $wgRightsUrl ) {
235 $copyright = $wgRightsUrl;
238 $out->addLink( array(
239 'rel' => 'copyright',
240 'href' => $copyright ) );
244 function outputPage( &$out ) {
245 global $wgDebugComments;
247 wfProfileIn( __METHOD__
);
248 $this->initPage( $out );
250 $out->out( $out->headElement() );
252 $out->out( "\n<body" );
253 $ops = $this->getBodyOptions();
254 foreach ( $ops as $name => $val ) {
255 $out->out( " $name='$val'" );
258 if ( $wgDebugComments ) {
259 $out->out( "<!-- Wiki debugging output:\n" .
260 $out->mDebugtext
. "-->\n" );
263 $out->out( $this->beforeContent() );
265 $out->out( $out->mBodytext
. "\n" );
267 $out->out( $this->afterContent() );
269 $out->out( $this->bottomScripts() );
271 $out->out( $out->reportTime() );
273 $out->out( "\n</body></html>" );
274 wfProfileOut( __METHOD__
);
277 static function makeVariablesScript( $data ) {
278 global $wgJsMimeType;
280 $r = "<script type= \"$wgJsMimeType\">/*<![CDATA[*/\n";
281 foreach ( $data as $name => $value ) {
282 $encValue = Xml
::encodeJsVar( $value );
283 $r .= "var $name = $encValue;\n";
285 $r .= "/*]]>*/</script>\n";
291 * Make a <script> tag containing global variables
292 * @param array $data Associative array containing one element:
293 * skinname => the skin name
294 * The odd calling convention is for backwards compatibility
296 static function makeGlobalVariablesScript( $data ) {
297 global $wgScript, $wgStylePath, $wgUser;
298 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
299 global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
300 global $wgBreakFrames, $wgRequest;
301 global $wgUseAjax, $wgAjaxWatch;
303 $ns = $wgTitle->getNamespace();
304 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
307 'skin' => $data['skinname'],
308 'stylepath' => $wgStylePath,
309 'wgArticlePath' => $wgArticlePath,
310 'wgScriptPath' => $wgScriptPath,
311 'wgScript' => $wgScript,
312 'wgServer' => $wgServer,
313 'wgCanonicalNamespace' => $nsname,
314 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBKey() ),
315 'wgNamespaceNumber' => $wgTitle->getNamespace(),
316 'wgPageName' => $wgTitle->getPrefixedDBKey(),
317 'wgTitle' => $wgTitle->getText(),
318 'wgAction' => $wgRequest->getText( 'action', 'view' ),
319 'wgRestrictionEdit' => $wgTitle->getRestrictions( 'edit' ),
320 'wgRestrictionMove' => $wgTitle->getRestrictions( 'move' ),
321 'wgArticleId' => $wgTitle->getArticleId(),
322 'wgIsArticle' => $wgOut->isArticle(),
323 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
324 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getEffectiveGroups(),
325 'wgUserLanguage' => $wgLang->getCode(),
326 'wgContentLanguage' => $wgContLang->getCode(),
327 'wgBreakFrames' => $wgBreakFrames,
328 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
331 global $wgLivePreview;
332 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
333 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
334 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
335 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
336 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
339 if($wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
340 $msgs = (object)array();
341 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
342 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
344 $vars['wgAjaxWatch'] = $msgs;
347 return self
::makeVariablesScript( $vars );
350 function getHeadScripts( $allowUserJs ) {
351 global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion;
353 $r = self
::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
355 $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n";
358 $jsCache = $wgUser->isLoggedIn() ?
'&smaxage=0' : '';
359 $r .= "<script type=\"$wgJsMimeType\" src=\"".
360 htmlspecialchars(self
::makeUrl('-',
361 "action=raw$jsCache&gen=js&useskin=" .
362 urlencode( $this->getSkinName() ) ) ) .
363 "\"><!-- site js --></script>\n";
365 if( $allowUserJs && $wgUser->isLoggedIn() ) {
366 $userpage = $wgUser->getUserPage();
367 $userjs = htmlspecialchars( self
::makeUrl(
368 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
369 'action=raw&ctype='.$wgJsMimeType));
370 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
376 * To make it harder for someone to slip a user a fake
377 * user-JavaScript or user-CSS preview, a random token
378 * is associated with the login session. If it's not
379 * passed back with the preview request, we won't render
382 * @param string $action
386 function userCanPreview( $action ) {
387 global $wgTitle, $wgRequest, $wgUser;
389 if( $action != 'submit' )
391 if( !$wgRequest->wasPosted() )
393 if( !$wgTitle->userCanEditCssJsSubpage() )
395 return $wgUser->matchEditToken(
396 $wgRequest->getVal( 'wpEditToken' ) );
399 # get the user/site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way)
400 function getUserStylesheet() {
401 global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage, $wgStyleVersion;
402 $sheet = $this->getStylesheet();
403 $s = "@import \"$wgStylePath/common/shared.css?$wgStyleVersion\";\n";
404 $s .= "@import \"$wgStylePath/common/oldshared.css?$wgStyleVersion\";\n";
405 $s .= "@import \"$wgStylePath/$sheet?$wgStyleVersion\";\n";
406 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css?$wgStyleVersion\";\n";
408 $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
409 $s .= '@import "' . self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n" .
410 '@import "' . self
::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
412 $s .= $this->doGetUserStyles();
417 * This returns MediaWiki:Common.js, and derived classes may add other JS.
418 * Despite its name, it does *not* return any custom user JS from user
419 * subpages. The returned script is sitewide and publicly cacheable and
420 * therefore must not include anything that varies according to user,
421 * interface language, etc. (although it may vary by skin). See
422 * makeGlobalVariablesScript for things that can vary per page view and are
425 * @return string Raw JavaScript to be returned
427 public function getUserJs() {
428 wfProfileIn( __METHOD__
);
431 $s = "/* generated javascript */\n";
432 $s .= "var skin = '" . Xml
::escapeJsString( $this->getSkinName() ) . "';\n";
433 $s .= "var stylepath = '" . Xml
::escapeJsString( $wgStylePath ) . "';";
434 $s .= "\n\n/* MediaWiki:Common.js */\n";
435 $commonJs = wfMsgForContent('common.js');
436 if ( !wfEmptyMsg ( 'common.js', $commonJs ) ) {
439 wfProfileOut( __METHOD__
);
444 * Return html code that include User stylesheets
446 function getUserStyles() {
447 $s = "<style type='text/css'>\n";
448 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
449 $s .= $this->getUserStylesheet();
450 $s .= "/*]]>*/ /* */\n";
456 * Some styles that are set by user through the user settings interface.
458 function doGetUserStyles() {
459 global $wgUser, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
463 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
464 if($wgTitle->isCssSubpage() && $this->userCanPreview( $wgRequest->getText( 'action' ) ) ) {
465 $s .= $wgRequest->getText('wpTextbox1');
467 $userpage = $wgUser->getUserPage();
468 $s.= '@import "'.self
::makeUrl(
469 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
470 'action=raw&ctype=text/css').'";'."\n";
474 return $s . $this->reallyDoGetUserStyles();
477 function reallyDoGetUserStyles() {
480 if (($undopt = $wgUser->getOption("underline")) != 2) {
481 $underline = $undopt ?
'underline' : 'none';
482 $s .= "a { text-decoration: $underline; }\n";
484 if( $wgUser->getOption( 'highlightbroken' ) ) {
485 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
488 a.new, #quickbar a.new,
489 a.stub, #quickbar a.stub {
491 text-decoration: inherit;
493 a.new:after, #quickbar a.new:after {
496 text-decoration: $underline;
498 a.stub:after, #quickbar a.stub:after {
501 text-decoration: $underline;
505 if( $wgUser->getOption( 'justify' ) ) {
506 $s .= "#article, #bodyContent { text-align: justify; }\n";
508 if( !$wgUser->getOption( 'showtoc' ) ) {
509 $s .= "#toc { display: none; }\n";
511 if( !$wgUser->getOption( 'editsection' ) ) {
512 $s .= ".editsection { display: none; }\n";
517 function getBodyOptions() {
518 global $wgUser, $wgTitle, $wgOut, $wgRequest, $wgContLang;
520 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
522 if ( 0 != $wgTitle->getNamespace() ) {
523 $a = array( 'bgcolor' => '#ffffec' );
525 else $a = array( 'bgcolor' => '#FFFFFF' );
526 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
527 $wgTitle->userCan( 'edit' ) ) {
528 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
529 $s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
530 $a +
= array ('ondblclick' => $s);
533 $a['onload'] = $wgOut->getOnloadHandler();
534 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
535 if( $a['onload'] != '' ) {
538 $a['onload'] .= 'setupRightClickEdit()';
540 $a['class'] = 'ns-'.$wgTitle->getNamespace().' '.($wgContLang->isRTL() ?
"rtl" : "ltr").
541 ' '.Sanitizer
::escapeClass( 'page-'.$wgTitle->getPrefixedText() );
554 * This will be called immediately after the <body> tag. Split into
555 * two functions to make it easier to subclass.
557 function beforeContent() {
558 return $this->doBeforeContent();
561 function doBeforeContent() {
563 $fname = 'Skin::doBeforeContent';
564 wfProfileIn( $fname );
567 $qb = $this->qbSetting();
569 if( $langlinks = $this->otherLanguages() ) {
575 $borderhack = 'class="top"';
578 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
579 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
582 $left = ($qb == 1 ||
$qb == 3);
583 if($wgContLang->isRTL()) $left = !$left;
586 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
587 $this->logoText() . '</td>';
589 $s .= $this->getQuickbarCompensator( $rows );
591 $l = $wgContLang->isRTL() ?
'right' : 'left';
592 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
594 $s .= $this->topLinks() ;
595 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
597 $r = $wgContLang->isRTL() ?
"left" : "right";
598 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
599 $s .= $this->nameAndLogin();
600 $s .= "\n<br />" . $this->searchForm() . "</td>";
603 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
606 if ( $shove && !$left ) { # Right
607 $s .= $this->getQuickbarCompensator( $rows );
609 $s .= "</tr>\n</table>\n</div>\n";
610 $s .= "\n<div id='article'>\n";
612 $notice = wfGetSiteNotice();
614 $s .= "\n<div id='siteNotice'>$notice</div>\n";
616 $s .= $this->pageTitle();
617 $s .= $this->pageSubtitle() ;
618 $s .= $this->getCategories();
619 wfProfileOut( $fname );
624 function getCategoryLinks () {
625 global $wgOut, $wgTitle, $wgUseCategoryBrowser;
628 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
631 $sep = wfMsgHtml( 'catseparator' );
633 // Use Unicode bidi embedding override characters,
634 // to make sure links don't smash each other up in ugly ways.
635 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
636 $embed = "<span dir='$dir'>";
638 $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $wgOut->mCategoryLinks
) . $pop;
640 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escape' ), count( $wgOut->mCategoryLinks
) );
641 $s = $this->makeLinkObj( Title
::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
644 # optional 'dmoz-like' category browser. Will be shown under the list
645 # of categories an article belong to
646 if($wgUseCategoryBrowser) {
647 $s .= '<br /><hr />';
649 # get a big array of the parents tree
650 $parenttree = $wgTitle->getParentCategoryTree();
651 # Skin object passed by reference cause it can not be
652 # accessed under the method subfunction drawCategoryBrowser
653 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
654 # Clean out bogus first entry and sort them
657 # Output one per line
658 $s .= implode("<br />\n", $tempout);
664 /** Render the array as a serie of links.
665 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
666 * @param &skin Object: skin passed by reference
667 * @return String separated by >, terminate with "\n"
669 function drawCategoryBrowser($tree, &$skin) {
671 foreach ($tree as $element => $parent) {
672 if (empty($parent)) {
673 # element start a new list
676 # grab the others elements
677 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
679 # add our current element to the list
680 $eltitle = Title
::NewFromText($element);
681 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
686 function getCategories() {
687 $catlinks=$this->getCategoryLinks();
688 if(!empty($catlinks)) {
689 return "<p class='catlinks'>{$catlinks}</p>";
693 function getQuickbarCompensator( $rows = 1 ) {
694 return "<td width='152' rowspan='{$rows}'> </td>";
698 * This gets called shortly before the \</body\> tag.
699 * @return String HTML to be put before \</body\>
701 function afterContent() {
702 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
703 return $printfooter . $this->doAfterContent();
707 * This gets called shortly before the \</body\> tag.
708 * @return String HTML-wrapped JS code to be put before \</body\>
710 function bottomScripts() {
711 global $wgJsMimeType;
712 $bottomScriptText = "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
713 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
714 return $bottomScriptText;
717 /** @return string Retrievied from HTML text */
718 function printSource() {
720 $url = htmlspecialchars( $wgTitle->getFullURL() );
721 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
724 function printFooter() {
725 return "<p>" . $this->printSource() .
726 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
729 /** overloaded by derived classes */
730 function doAfterContent() { }
732 function pageTitleLinks() {
733 global $wgOut, $wgTitle, $wgUser, $wgRequest;
735 $oldid = $wgRequest->getVal( 'oldid' );
736 $diff = $wgRequest->getVal( 'diff' );
737 $action = $wgRequest->getText( 'action' );
739 $s = $this->printableLink();
740 $disclaimer = $this->disclaimerLink(); # may be empty
742 $s .= ' | ' . $disclaimer;
744 $privacy = $this->privacyLink(); # may be empty too
746 $s .= ' | ' . $privacy;
749 if ( $wgOut->isArticleRelated() ) {
750 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
751 $name = $wgTitle->getDBkey();
752 $image = wfFindFile( $wgTitle );
754 $link = htmlspecialchars( $image->getURL() );
755 $style = $this->getInternalLinkAttributes( $link, $name );
756 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
760 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
761 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
762 wfMsg( 'currentrev' ) );
765 if ( $wgUser->getNewtalk() ) {
766 # do not show "You have new messages" text when we are viewing our
768 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
769 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
770 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
771 $s.= ' | <strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
773 $wgOut->setSquidMaxage(0);
774 $wgOut->enableClientCache(false);
778 $undelete = $this->getUndeleteLink();
779 if( !empty( $undelete ) ) {
780 $s .= ' | '.$undelete;
785 function getUndeleteLink() {
786 global $wgUser, $wgTitle, $wgContLang, $action;
787 if( $wgUser->isAllowed( 'deletedhistory' ) &&
788 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
789 ($n = $wgTitle->isDeleted() ) )
791 if ( $wgUser->isAllowed( 'delete' ) ) {
792 $msg = 'thisisdeleted';
794 $msg = 'viewdeleted';
797 $this->makeKnownLinkObj(
798 SpecialPage
::getTitleFor( 'Undelete', $wgTitle->getPrefixedDBkey() ),
799 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $n ) ) );
804 function printableLink() {
805 global $wgOut, $wgFeedClasses, $wgRequest;
807 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
809 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
810 if( $wgOut->isSyndicated() ) {
811 foreach( $wgFeedClasses as $format => $class ) {
812 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
813 $s .= " | <a href=\"$feedurl\">{$format}</a>";
819 function pageTitle() {
821 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
825 function pageSubtitle() {
828 $sub = $wgOut->getSubtitle();
830 global $wgExtraSubtitle;
831 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
833 $subpages = $this->subPageSubtitle();
834 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
835 $s = "<p class='subtitle'>{$sub}</p>\n";
839 function subPageSubtitle() {
840 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
842 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
843 $ptext=$wgTitle->getPrefixedText();
844 if(preg_match('/\//',$ptext)) {
845 $links = explode('/',$ptext);
848 foreach($links as $link) {
850 if ($c<count($links)) {
851 $growinglink .= $link;
852 $getlink = $this->makeLink( $growinglink, htmlspecialchars( $link ) );
853 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
857 $subpages .= '< ';
859 $subpages .= $getlink;
869 * Returns true if the IP should be shown in the header
871 function showIPinHeader() {
872 global $wgShowIPinHeader;
873 return $wgShowIPinHeader && session_id() != '';
876 function nameAndLogin() {
877 global $wgUser, $wgTitle, $wgLang, $wgContLang;
879 $lo = $wgContLang->specialPage( 'Userlogout' );
882 if ( $wgUser->isAnon() ) {
883 if( $this->showIPinHeader() ) {
886 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
887 $wgLang->getNsText( NS_TALK
) );
889 $s .= $n . ' ('.$tl.')';
891 $s .= wfMsg('notloggedin');
894 $rt = $wgTitle->getPrefixedURL();
895 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
897 } else { $q = "returnto={$rt}"; }
899 $s .= "\n<br />" . $this->makeKnownLinkObj(
900 SpecialPage
::getTitleFor( 'Userlogin' ),
901 wfMsg( 'login' ), $q );
903 $n = $wgUser->getName();
904 $rt = $wgTitle->getPrefixedURL();
905 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
906 $wgLang->getNsText( NS_TALK
) );
910 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
911 $n ) . "{$tl}<br />" .
912 $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
913 "returnto={$rt}" ) . ' | ' .
914 $this->specialLink( 'preferences' );
916 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
922 function getSearchLink() {
923 $searchPage = SpecialPage
::getTitleFor( 'Search' );
924 return $searchPage->getLocalURL();
927 function escapeSearchLink() {
928 return htmlspecialchars( $this->getSearchLink() );
931 function searchForm() {
933 $search = $wgRequest->getText( 'search' );
935 $s = '<form name="search" class="inline" method="post" action="'
936 . $this->escapeSearchLink() . "\">\n"
937 . '<input type="text" name="search" size="19" value="'
938 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
939 . '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" /> '
940 . '<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n</form>";
945 function topLinks() {
949 $s = $this->mainPageLink() . $sep
950 . $this->specialLink( 'recentchanges' );
952 if ( $wgOut->isArticleRelated() ) {
953 $s .= $sep . $this->editThisPage()
954 . $sep . $this->historyLink();
956 # Many people don't like this dropdown box
957 #$s .= $sep . $this->specialPagesList();
959 $s .= $this->variantLinks();
961 $s .= $this->extensionTabLinks();
967 * Compatibility for extensions adding functionality through tabs.
968 * Eventually these old skins should be replaced with SkinTemplate-based
972 function extensionTabLinks() {
975 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
976 foreach( $tabs as $tab ) {
977 $s .= ' | ' . Xml
::element( 'a',
978 array( 'href' => $tab['href'] ),
985 * Language/charset variant links for classic-style skins
988 function variantLinks() {
990 /* show links to different language variants */
991 global $wgDisableLangConversion, $wgContLang, $wgTitle;
992 $variants = $wgContLang->getVariants();
993 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
994 foreach( $variants as $code ) {
995 $varname = $wgContLang->getVariantname( $code );
996 if( $varname == 'disable' )
998 $s .= ' | <a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>';
1004 function bottomLinks() {
1005 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
1009 if ( $wgOut->isArticleRelated() ) {
1010 $s .= '<strong>' . $this->editThisPage() . '</strong>';
1011 if ( $wgUser->isLoggedIn() ) {
1012 $s .= $sep . $this->watchThisPage();
1014 $s .= $sep . $this->talkLink()
1015 . $sep . $this->historyLink()
1016 . $sep . $this->whatLinksHere()
1017 . $sep . $this->watchPageLinksLink();
1019 if ($wgUseTrackbacks)
1020 $s .= $sep . $this->trackbackLink();
1022 if ( $wgTitle->getNamespace() == NS_USER
1023 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
1026 $id=User
::idFromName($wgTitle->getText());
1027 $ip=User
::isIP($wgTitle->getText());
1029 if($id ||
$ip) { # both anons and non-anons have contri list
1030 $s .= $sep . $this->userContribsLink();
1032 if( $this->showEmailUser( $id ) ) {
1033 $s .= $sep . $this->emailUserLink();
1036 if ( $wgTitle->getArticleId() ) {
1038 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
1039 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
1040 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
1042 $s .= "<br />\n" . $this->otherLanguages();
1047 function pageStats() {
1048 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1049 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
1051 $oldid = $wgRequest->getVal( 'oldid' );
1052 $diff = $wgRequest->getVal( 'diff' );
1053 if ( ! $wgOut->isArticle() ) { return ''; }
1054 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1055 if ( 0 == $wgArticle->getID() ) { return ''; }
1058 if ( !$wgDisableCounters ) {
1059 $count = $wgLang->formatNum( $wgArticle->getCount() );
1061 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1065 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
1066 require_once('Credits.php');
1067 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
1069 $s .= $this->lastModified();
1072 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
1073 $dbr = wfGetDB( DB_SLAVE
);
1074 $watchlist = $dbr->tableName( 'watchlist' );
1075 $sql = "SELECT COUNT(*) AS n FROM $watchlist
1076 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
1077 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
1078 $res = $dbr->query( $sql, 'Skin::pageStats');
1079 $x = $dbr->fetchObject( $res );
1080 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
1083 return $s . ' ' . $this->getCopyright();
1086 function getCopyright( $type = 'detect' ) {
1087 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
1089 if ( $type == 'detect' ) {
1090 $oldid = $wgRequest->getVal( 'oldid' );
1091 $diff = $wgRequest->getVal( 'diff' );
1093 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1100 if ( $type == 'history' ) {
1101 $msg = 'history_copyright';
1107 if( $wgRightsPage ) {
1108 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
1109 } elseif( $wgRightsUrl ) {
1110 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1115 $out .= wfMsgForContent( $msg, $link );
1119 function getCopyrightIcon() {
1120 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1122 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1123 $out = $wgCopyrightIcon;
1124 } else if ( $wgRightsIcon ) {
1125 $icon = htmlspecialchars( $wgRightsIcon );
1126 if ( $wgRightsUrl ) {
1127 $url = htmlspecialchars( $wgRightsUrl );
1128 $out .= '<a href="'.$url.'">';
1130 $text = htmlspecialchars( $wgRightsText );
1131 $out .= "<img src=\"$icon\" alt='$text' />";
1132 if ( $wgRightsUrl ) {
1139 function getPoweredBy() {
1140 global $wgStylePath;
1141 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1142 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1146 function lastModified() {
1147 global $wgLang, $wgArticle, $wgLoadBalancer;
1149 $timestamp = $wgArticle->getTimestamp();
1151 $d = $wgLang->date( $timestamp, true );
1152 $t = $wgLang->time( $timestamp, true );
1153 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1157 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
1158 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1163 function logoText( $align = '' ) {
1164 if ( '' != $align ) { $a = " align='{$align}'"; }
1167 $mp = wfMsg( 'mainpage' );
1168 $mptitle = Title
::newMainPage();
1169 $url = ( is_object($mptitle) ?
$mptitle->escapeLocalURL() : '' );
1171 $logourl = $this->getLogo();
1172 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1177 * show a drop-down box of special pages
1179 function specialPagesList() {
1180 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1181 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1182 foreach ( $pages as $name => $page ) {
1183 $pages[$name] = $page->getDescription();
1186 $go = wfMsg( 'go' );
1187 $sp = wfMsg( 'specialpages' );
1188 $spp = $wgContLang->specialPage( 'Specialpages' );
1190 $s = '<form id="specialpages" method="get" class="inline" ' .
1191 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1192 $s .= "<select name=\"wpDropdown\">\n";
1193 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1196 foreach ( $pages as $name => $desc ) {
1197 $p = $wgContLang->specialPage( $name );
1198 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1200 $s .= "</select>\n";
1201 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1206 function mainPageLink() {
1207 $s = $this->makeKnownLinkObj( Title
::newMainPage(), wfMsg( 'mainpage' ) );
1211 function copyrightLink() {
1212 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1213 wfMsg( 'copyrightpagename' ) );
1217 private function footerLink ( $desc, $page ) {
1218 // if the link description has been set to "-" in the default language,
1219 if ( wfMsgForContent( $desc ) == '-') {
1220 // then it is disabled, for all languages.
1223 // Otherwise, we display the link for the user, described in their
1224 // language (which may or may not be the same as the default language),
1225 // but we make the link target be the one site-wide page.
1226 return $this->makeKnownLink( wfMsgForContent( $page ), wfMsg( $desc ) );
1230 function privacyLink() {
1231 return $this->footerLink( 'privacy', 'privacypage' );
1234 function aboutLink() {
1235 return $this->footerLink( 'aboutsite', 'aboutpage' );
1238 function disclaimerLink() {
1239 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1242 function editThisPage() {
1243 global $wgOut, $wgTitle;
1245 if ( ! $wgOut->isArticleRelated() ) {
1246 $s = wfMsg( 'protectedpage' );
1248 if ( $wgTitle->userCan( 'edit' ) ) {
1249 $t = wfMsg( 'editthispage' );
1251 $t = wfMsg( 'viewsource' );
1254 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1260 * Return URL options for the 'edit page' link.
1261 * This may include an 'oldid' specifier, if the current page view is such.
1266 function editUrlOptions() {
1269 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1270 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1272 return "action=edit";
1276 function deleteThisPage() {
1277 global $wgUser, $wgTitle, $wgRequest;
1279 $diff = $wgRequest->getVal( 'diff' );
1280 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1281 $t = wfMsg( 'deletethispage' );
1283 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1290 function protectThisPage() {
1291 global $wgUser, $wgTitle, $wgRequest;
1293 $diff = $wgRequest->getVal( 'diff' );
1294 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1295 if ( $wgTitle->isProtected() ) {
1296 $t = wfMsg( 'unprotectthispage' );
1297 $q = 'action=unprotect';
1299 $t = wfMsg( 'protectthispage' );
1300 $q = 'action=protect';
1302 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1309 function watchThisPage() {
1310 global $wgOut, $wgTitle;
1311 ++
$this->mWatchLinkNum
;
1313 if ( $wgOut->isArticleRelated() ) {
1314 if ( $wgTitle->userIsWatching() ) {
1315 $t = wfMsg( 'unwatchthispage' );
1316 $q = 'action=unwatch';
1317 $id = "mw-unwatch-link".$this->mWatchLinkNum
;
1319 $t = wfMsg( 'watchthispage' );
1320 $q = 'action=watch';
1321 $id = 'mw-watch-link'.$this->mWatchLinkNum
;
1323 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q, '', '', " id=\"$id\"" );
1325 $s = wfMsg( 'notanarticle' );
1330 function moveThisPage() {
1333 if ( $wgTitle->userCan( 'move' ) ) {
1334 return $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
1335 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1337 // no message if page is protected - would be redundant
1342 function historyLink() {
1345 return $this->makeKnownLinkObj( $wgTitle,
1346 wfMsg( 'history' ), 'action=history' );
1349 function whatLinksHere() {
1352 return $this->makeKnownLinkObj(
1353 SpecialPage
::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ),
1354 wfMsg( 'whatlinkshere' ) );
1357 function userContribsLink() {
1360 return $this->makeKnownLinkObj(
1361 SpecialPage
::getTitleFor( 'Contributions', $wgTitle->getDBkey() ),
1362 wfMsg( 'contributions' ) );
1365 function showEmailUser( $id ) {
1366 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1367 return $wgEnableEmail &&
1368 $wgEnableUserEmail &&
1369 $wgUser->isLoggedIn() && # show only to signed in users
1370 0 != $id; # we can only email to non-anons ..
1371 # '' != $id->getEmail() && # who must have an email address stored ..
1372 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1373 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1376 function emailUserLink() {
1379 return $this->makeKnownLinkObj(
1380 SpecialPage
::getTitleFor( 'Emailuser', $wgTitle->getDBkey() ),
1381 wfMsg( 'emailuser' ) );
1384 function watchPageLinksLink() {
1385 global $wgOut, $wgTitle;
1387 if ( ! $wgOut->isArticleRelated() ) {
1388 return '(' . wfMsg( 'notanarticle' ) . ')';
1390 return $this->makeKnownLinkObj(
1391 SpecialPage
::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ),
1392 wfMsg( 'recentchangeslinked' ) );
1396 function trackbackLink() {
1399 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1400 . wfMsg('trackbacklink') . "</a>";
1403 function otherLanguages() {
1404 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1406 if ( $wgHideInterlanguageLinks ) {
1410 $a = $wgOut->getLanguageLinks();
1411 if ( 0 == count( $a ) ) {
1415 $s = wfMsg( 'otherlanguages' ) . ': ';
1417 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1418 foreach( $a as $l ) {
1419 if ( ! $first ) { $s .= ' | '; }
1422 $nt = Title
::newFromText( $l );
1423 $url = $nt->escapeFullURL();
1424 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1426 if ( '' == $text ) { $text = $l; }
1427 $style = $this->getExternalLinkAttributes( $l, $text );
1428 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1430 if($wgContLang->isRTL()) $s .= '</span>';
1434 function bugReportsLink() {
1435 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1436 wfMsg( 'bugreports' ) );
1440 function talkLink() {
1443 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1444 # No discussion links for special pages
1448 if( $wgTitle->isTalkPage() ) {
1449 $link = $wgTitle->getSubjectPage();
1450 switch( $link->getNamespace() ) {
1452 $text = wfMsg( 'articlepage' );
1455 $text = wfMsg( 'userpage' );
1458 $text = wfMsg( 'projectpage' );
1461 $text = wfMsg( 'imagepage' );
1464 $text = wfMsg( 'mediawikipage' );
1467 $text = wfMsg( 'templatepage' );
1470 $text = wfMsg( 'viewhelppage' );
1473 $text = wfMsg( 'categorypage' );
1476 $text = wfMsg( 'articlepage' );
1479 $link = $wgTitle->getTalkPage();
1480 $text = wfMsg( 'talkpage' );
1483 $s = $this->makeLinkObj( $link, $text );
1488 function commentLink() {
1489 global $wgTitle, $wgOut;
1491 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1495 # __NEWSECTIONLINK___ changes behaviour here
1496 # If it's present, the link points to this page, otherwise
1497 # it points to the talk page
1498 if( $wgTitle->isTalkPage() ) {
1500 } elseif( $wgOut->showNewSectionLink() ) {
1503 $title =& $wgTitle->getTalkPage();
1506 return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1509 /* these are used extensively in SkinTemplate, but also some other places */
1510 static function makeMainPageUrl( $urlaction = '' ) {
1511 $title = Title
::newMainPage();
1512 self
::checkTitle( $title, '' );
1513 return $title->getLocalURL( $urlaction );
1516 static function makeSpecialUrl( $name, $urlaction = '' ) {
1517 $title = SpecialPage
::getTitleFor( $name );
1518 return $title->getLocalURL( $urlaction );
1521 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1522 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1523 return $title->getLocalURL( $urlaction );
1526 static function makeI18nUrl( $name, $urlaction = '' ) {
1527 $title = Title
::newFromText( wfMsgForContent( $name ) );
1528 self
::checkTitle( $title, $name );
1529 return $title->getLocalURL( $urlaction );
1532 static function makeUrl( $name, $urlaction = '' ) {
1533 $title = Title
::newFromText( $name );
1534 self
::checkTitle( $title, $name );
1535 return $title->getLocalURL( $urlaction );
1538 # If url string starts with http, consider as external URL, else
1540 static function makeInternalOrExternalUrl( $name ) {
1541 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1544 return self
::makeUrl( $name );
1548 # this can be passed the NS number as defined in Language.php
1549 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1550 $title = Title
::makeTitleSafe( $namespace, $name );
1551 self
::checkTitle( $title, $name );
1552 return $title->getLocalURL( $urlaction );
1555 /* these return an array with the 'href' and boolean 'exists' */
1556 static function makeUrlDetails( $name, $urlaction = '' ) {
1557 $title = Title
::newFromText( $name );
1558 self
::checkTitle( $title, $name );
1560 'href' => $title->getLocalURL( $urlaction ),
1561 'exists' => $title->getArticleID() != 0 ?
true : false
1566 * Make URL details where the article exists (or at least it's convenient to think so)
1568 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1569 $title = Title
::newFromText( $name );
1570 self
::checkTitle( $title, $name );
1572 'href' => $title->getLocalURL( $urlaction ),
1577 # make sure we have some title to operate on
1578 static function checkTitle( &$title, $name ) {
1579 if( !is_object( $title ) ) {
1580 $title = Title
::newFromText( $name );
1581 if( !is_object( $title ) ) {
1582 $title = Title
::newFromText( '--error: link target missing--' );
1588 * Build an array that represents the sidebar(s), the navigation bar among them
1593 function buildSidebar() {
1594 global $parserMemc, $wgEnableSidebarCache;
1595 global $wgLang, $wgContLang;
1597 $fname = 'SkinTemplate::buildSidebar';
1599 wfProfileIn( $fname );
1601 $key = wfMemcKey( 'sidebar' );
1602 $cacheSidebar = $wgEnableSidebarCache &&
1603 ($wgLang->getCode() == $wgContLang->getCode());
1605 if ($cacheSidebar) {
1606 $cachedsidebar = $parserMemc->get( $key );
1607 if ($cachedsidebar!="") {
1608 wfProfileOut($fname);
1609 return $cachedsidebar;
1614 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1615 foreach ($lines as $line) {
1616 if (strpos($line, '*') !== 0)
1618 if (strpos($line, '**') !== 0) {
1619 $line = trim($line, '* ');
1622 if (strpos($line, '|') !== false) { // sanity check
1623 $line = explode( '|' , trim($line, '* '), 2 );
1624 $link = wfMsgForContent( $line[0] );
1627 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1629 if (wfEmptyMsg($line[0], $link))
1632 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1635 $title = Title
::newFromText( $link );
1637 $title = $title->fixSpecialName();
1638 $href = $title->getLocalURL();
1640 $href = 'INVALID-TITLE';
1644 $bar[$heading][] = array(
1647 'id' => 'n-' . strtr($line[1], ' ', '-'),
1650 } else { continue; }
1654 $parserMemc->set( $key, $bar, 86400 );
1655 wfProfileOut( $fname );