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 $wgScript, $wgStylePath, $wgUser;
297 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
298 global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
299 global $wgBreakFrames, $wgRequest;
300 global $wgUseAjax, $wgAjaxWatch;
302 $ns = $wgTitle->getNamespace();
303 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
306 'skin' => $data['skinname'],
307 'stylepath' => $wgStylePath,
308 'wgArticlePath' => $wgArticlePath,
309 'wgScriptPath' => $wgScriptPath,
310 'wgScript' => $wgScript,
311 'wgServer' => $wgServer,
312 'wgCanonicalNamespace' => $nsname,
313 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBKey() ),
314 'wgNamespaceNumber' => $wgTitle->getNamespace(),
315 'wgPageName' => $wgTitle->getPrefixedDBKey(),
316 'wgTitle' => $wgTitle->getText(),
317 'wgAction' => $wgRequest->getText( 'action', 'view' ),
318 'wgRestrictionEdit' => $wgTitle->getRestrictions( 'edit' ),
319 'wgRestrictionMove' => $wgTitle->getRestrictions( 'move' ),
320 'wgArticleId' => $wgTitle->getArticleId(),
321 'wgIsArticle' => $wgOut->isArticle(),
322 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
323 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getEffectiveGroups(),
324 'wgUserLanguage' => $wgLang->getCode(),
325 'wgContentLanguage' => $wgContLang->getCode(),
326 'wgBreakFrames' => $wgBreakFrames,
327 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
330 global $wgLivePreview;
331 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
332 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
333 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
334 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
335 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
338 if($wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
339 $msgs = (object)array();
340 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
341 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
343 $vars['wgAjaxWatch'] = $msgs;
346 return self
::makeVariablesScript( $vars );
349 function getHeadScripts( $allowUserJs ) {
350 global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion;
352 $r = self
::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
354 $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n";
357 $jsCache = $wgUser->isLoggedIn() ?
'&smaxage=0' : '';
358 $r .= "<script type=\"$wgJsMimeType\" src=\"".
359 htmlspecialchars(self
::makeUrl('-',
360 "action=raw$jsCache&gen=js&useskin=" .
361 urlencode( $this->getSkinName() ) ) ) .
362 "\"><!-- site js --></script>\n";
364 if( $allowUserJs && $wgUser->isLoggedIn() ) {
365 $userpage = $wgUser->getUserPage();
366 $userjs = htmlspecialchars( self
::makeUrl(
367 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
368 'action=raw&ctype='.$wgJsMimeType));
369 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
375 * To make it harder for someone to slip a user a fake
376 * user-JavaScript or user-CSS preview, a random token
377 * is associated with the login session. If it's not
378 * passed back with the preview request, we won't render
381 * @param string $action
385 function userCanPreview( $action ) {
386 global $wgTitle, $wgRequest, $wgUser;
388 if( $action != 'submit' )
390 if( !$wgRequest->wasPosted() )
392 if( !$wgTitle->userCanEditCssJsSubpage() )
394 return $wgUser->matchEditToken(
395 $wgRequest->getVal( 'wpEditToken' ) );
398 # get the user/site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way)
399 function getUserStylesheet() {
400 global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage, $wgStyleVersion;
401 $sheet = $this->getStylesheet();
402 $s = "@import \"$wgStylePath/common/shared.css?$wgStyleVersion\";\n";
403 $s .= "@import \"$wgStylePath/common/oldshared.css?$wgStyleVersion\";\n";
404 $s .= "@import \"$wgStylePath/$sheet?$wgStyleVersion\";\n";
405 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css?$wgStyleVersion\";\n";
407 $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
408 $s .= '@import "' . self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n" .
409 '@import "' . self
::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
411 $s .= $this->doGetUserStyles();
416 * This returns MediaWiki:Common.js, and derived classes may add other JS.
417 * Despite its name, it does *not* return any custom user JS from user
418 * subpages. The returned script is sitewide and publicly cacheable and
419 * therefore must not include anything that varies according to user,
420 * interface language, etc. (although it may vary by skin). See
421 * makeGlobalVariablesScript for things that can vary per page view and are
424 * @return string Raw JavaScript to be returned
426 public function getUserJs() {
427 wfProfileIn( __METHOD__
);
430 $s = "/* generated javascript */\n";
431 $s .= "var skin = '" . Xml
::escapeJsString( $this->getSkinName() ) . "';\n";
432 $s .= "var stylepath = '" . Xml
::escapeJsString( $wgStylePath ) . "';";
433 $s .= "\n\n/* MediaWiki:Common.js */\n";
434 $commonJs = wfMsgForContent('common.js');
435 if ( !wfEmptyMsg ( 'common.js', $commonJs ) ) {
438 wfProfileOut( __METHOD__
);
443 * Return html code that include User stylesheets
445 function getUserStyles() {
446 $s = "<style type='text/css'>\n";
447 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
448 $s .= $this->getUserStylesheet();
449 $s .= "/*]]>*/ /* */\n";
455 * Some styles that are set by user through the user settings interface.
457 function doGetUserStyles() {
458 global $wgUser, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
462 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
463 if($wgTitle->isCssSubpage() && $this->userCanPreview( $wgRequest->getText( 'action' ) ) ) {
464 $s .= $wgRequest->getText('wpTextbox1');
466 $userpage = $wgUser->getUserPage();
467 $s.= '@import "'.self
::makeUrl(
468 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
469 'action=raw&ctype=text/css').'";'."\n";
473 return $s . $this->reallyDoGetUserStyles();
476 function reallyDoGetUserStyles() {
479 if (($undopt = $wgUser->getOption("underline")) != 2) {
480 $underline = $undopt ?
'underline' : 'none';
481 $s .= "a { text-decoration: $underline; }\n";
483 if( $wgUser->getOption( 'highlightbroken' ) ) {
484 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
487 a.new, #quickbar a.new,
488 a.stub, #quickbar a.stub {
490 text-decoration: inherit;
492 a.new:after, #quickbar a.new:after {
495 text-decoration: $underline;
497 a.stub:after, #quickbar a.stub:after {
500 text-decoration: $underline;
504 if( $wgUser->getOption( 'justify' ) ) {
505 $s .= "#article, #bodyContent { text-align: justify; }\n";
507 if( !$wgUser->getOption( 'showtoc' ) ) {
508 $s .= "#toc { display: none; }\n";
510 if( !$wgUser->getOption( 'editsection' ) ) {
511 $s .= ".editsection { display: none; }\n";
516 function getBodyOptions() {
517 global $wgUser, $wgTitle, $wgOut, $wgRequest, $wgContLang;
519 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
521 if ( 0 != $wgTitle->getNamespace() ) {
522 $a = array( 'bgcolor' => '#ffffec' );
524 else $a = array( 'bgcolor' => '#FFFFFF' );
525 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
526 $wgTitle->userCan( 'edit' ) ) {
527 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
528 $s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
529 $a +
= array ('ondblclick' => $s);
532 $a['onload'] = $wgOut->getOnloadHandler();
533 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
534 if( $a['onload'] != '' ) {
537 $a['onload'] .= 'setupRightClickEdit()';
539 $a['class'] = 'ns-'.$wgTitle->getNamespace().' '.($wgContLang->isRTL() ?
"rtl" : "ltr").
540 ' '.Sanitizer
::escapeClass( 'page-'.$wgTitle->getPrefixedText() );
553 * This will be called immediately after the <body> tag. Split into
554 * two functions to make it easier to subclass.
556 function beforeContent() {
557 return $this->doBeforeContent();
560 function doBeforeContent() {
562 $fname = 'Skin::doBeforeContent';
563 wfProfileIn( $fname );
566 $qb = $this->qbSetting();
568 if( $langlinks = $this->otherLanguages() ) {
574 $borderhack = 'class="top"';
577 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
578 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
581 $left = ($qb == 1 ||
$qb == 3);
582 if($wgContLang->isRTL()) $left = !$left;
585 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
586 $this->logoText() . '</td>';
588 $s .= $this->getQuickbarCompensator( $rows );
590 $l = $wgContLang->isRTL() ?
'right' : 'left';
591 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
593 $s .= $this->topLinks() ;
594 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
596 $r = $wgContLang->isRTL() ?
"left" : "right";
597 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
598 $s .= $this->nameAndLogin();
599 $s .= "\n<br />" . $this->searchForm() . "</td>";
602 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
605 if ( $shove && !$left ) { # Right
606 $s .= $this->getQuickbarCompensator( $rows );
608 $s .= "</tr>\n</table>\n</div>\n";
609 $s .= "\n<div id='article'>\n";
611 $notice = wfGetSiteNotice();
613 $s .= "\n<div id='siteNotice'>$notice</div>\n";
615 $s .= $this->pageTitle();
616 $s .= $this->pageSubtitle() ;
617 $s .= $this->getCategories();
618 wfProfileOut( $fname );
623 function getCategoryLinks () {
624 global $wgOut, $wgTitle, $wgUseCategoryBrowser;
627 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
630 $sep = wfMsgHtml( 'catseparator' );
632 // Use Unicode bidi embedding override characters,
633 // to make sure links don't smash each other up in ugly ways.
634 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
635 $embed = "<span dir='$dir'>";
637 $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $wgOut->mCategoryLinks
) . $pop;
639 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escape' ), count( $wgOut->mCategoryLinks
) );
640 $s = $this->makeLinkObj( Title
::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
643 # optional 'dmoz-like' category browser. Will be shown under the list
644 # of categories an article belong to
645 if($wgUseCategoryBrowser) {
646 $s .= '<br /><hr />';
648 # get a big array of the parents tree
649 $parenttree = $wgTitle->getParentCategoryTree();
650 # Skin object passed by reference cause it can not be
651 # accessed under the method subfunction drawCategoryBrowser
652 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
653 # Clean out bogus first entry and sort them
656 # Output one per line
657 $s .= implode("<br />\n", $tempout);
663 /** Render the array as a serie of links.
664 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
665 * @param &skin Object: skin passed by reference
666 * @return String separated by >, terminate with "\n"
668 function drawCategoryBrowser($tree, &$skin) {
670 foreach ($tree as $element => $parent) {
671 if (empty($parent)) {
672 # element start a new list
675 # grab the others elements
676 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
678 # add our current element to the list
679 $eltitle = Title
::NewFromText($element);
680 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
685 function getCategories() {
686 $catlinks=$this->getCategoryLinks();
687 if(!empty($catlinks)) {
688 return "<p class='catlinks'>{$catlinks}</p>";
692 function getQuickbarCompensator( $rows = 1 ) {
693 return "<td width='152' rowspan='{$rows}'> </td>";
697 * This gets called shortly before the \</body\> tag.
698 * @return String HTML to be put before \</body\>
700 function afterContent() {
701 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
702 return $printfooter . $this->doAfterContent();
706 * This gets called shortly before the \</body\> tag.
707 * @return String HTML-wrapped JS code to be put before \</body\>
709 function bottomScripts() {
710 global $wgJsMimeType;
711 $bottomScriptText = "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
712 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
713 return $bottomScriptText;
716 /** @return string Retrievied from HTML text */
717 function printSource() {
719 $url = htmlspecialchars( $wgTitle->getFullURL() );
720 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
723 function printFooter() {
724 return "<p>" . $this->printSource() .
725 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
728 /** overloaded by derived classes */
729 function doAfterContent() { }
731 function pageTitleLinks() {
732 global $wgOut, $wgTitle, $wgUser, $wgRequest;
734 $oldid = $wgRequest->getVal( 'oldid' );
735 $diff = $wgRequest->getVal( 'diff' );
736 $action = $wgRequest->getText( 'action' );
738 $s = $this->printableLink();
739 $disclaimer = $this->disclaimerLink(); # may be empty
741 $s .= ' | ' . $disclaimer;
743 $privacy = $this->privacyLink(); # may be empty too
745 $s .= ' | ' . $privacy;
748 if ( $wgOut->isArticleRelated() ) {
749 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
750 $name = $wgTitle->getDBkey();
751 $image = wfFindFile( $wgTitle );
753 $link = htmlspecialchars( $image->getURL() );
754 $style = $this->getInternalLinkAttributes( $link, $name );
755 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
759 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
760 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
761 wfMsg( 'currentrev' ) );
764 if ( $wgUser->getNewtalk() ) {
765 # do not show "You have new messages" text when we are viewing our
767 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
768 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
769 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
770 $s.= ' | <strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
772 $wgOut->setSquidMaxage(0);
773 $wgOut->enableClientCache(false);
777 $undelete = $this->getUndeleteLink();
778 if( !empty( $undelete ) ) {
779 $s .= ' | '.$undelete;
784 function getUndeleteLink() {
785 global $wgUser, $wgTitle, $wgContLang, $action;
786 if( $wgUser->isAllowed( 'deletedhistory' ) &&
787 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
788 ($n = $wgTitle->isDeleted() ) )
790 if ( $wgUser->isAllowed( 'delete' ) ) {
791 $msg = 'thisisdeleted';
793 $msg = 'viewdeleted';
796 $this->makeKnownLinkObj(
797 SpecialPage
::getTitleFor( 'Undelete', $wgTitle->getPrefixedDBkey() ),
798 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $n ) ) );
803 function printableLink() {
804 global $wgOut, $wgFeedClasses, $wgRequest;
806 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
808 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
809 if( $wgOut->isSyndicated() ) {
810 foreach( $wgFeedClasses as $format => $class ) {
811 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
812 $s .= " | <a href=\"$feedurl\">{$format}</a>";
818 function pageTitle() {
820 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
824 function pageSubtitle() {
827 $sub = $wgOut->getSubtitle();
829 global $wgExtraSubtitle;
830 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
832 $subpages = $this->subPageSubtitle();
833 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
834 $s = "<p class='subtitle'>{$sub}</p>\n";
838 function subPageSubtitle() {
839 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
841 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
842 $ptext=$wgTitle->getPrefixedText();
843 if(preg_match('/\//',$ptext)) {
844 $links = explode('/',$ptext);
847 foreach($links as $link) {
849 if ($c<count($links)) {
850 $growinglink .= $link;
851 $getlink = $this->makeLink( $growinglink, htmlspecialchars( $link ) );
852 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
856 $subpages .= '< ';
858 $subpages .= $getlink;
868 * Returns true if the IP should be shown in the header
870 function showIPinHeader() {
871 global $wgShowIPinHeader;
872 return $wgShowIPinHeader && session_id() != '';
875 function nameAndLogin() {
876 global $wgUser, $wgTitle, $wgLang, $wgContLang;
878 $lo = $wgContLang->specialPage( 'Userlogout' );
881 if ( $wgUser->isAnon() ) {
882 if( $this->showIPinHeader() ) {
885 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
886 $wgLang->getNsText( NS_TALK
) );
888 $s .= $n . ' ('.$tl.')';
890 $s .= wfMsg('notloggedin');
893 $rt = $wgTitle->getPrefixedURL();
894 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
896 } else { $q = "returnto={$rt}"; }
898 $s .= "\n<br />" . $this->makeKnownLinkObj(
899 SpecialPage
::getTitleFor( 'Userlogin' ),
900 wfMsg( 'login' ), $q );
902 $n = $wgUser->getName();
903 $rt = $wgTitle->getPrefixedURL();
904 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
905 $wgLang->getNsText( NS_TALK
) );
909 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
910 $n ) . "{$tl}<br />" .
911 $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
912 "returnto={$rt}" ) . ' | ' .
913 $this->specialLink( 'preferences' );
915 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
921 function getSearchLink() {
922 $searchPage = SpecialPage
::getTitleFor( 'Search' );
923 return $searchPage->getLocalURL();
926 function escapeSearchLink() {
927 return htmlspecialchars( $this->getSearchLink() );
930 function searchForm() {
932 $search = $wgRequest->getText( 'search' );
934 $s = '<form name="search" class="inline" method="post" action="'
935 . $this->escapeSearchLink() . "\">\n"
936 . '<input type="text" name="search" size="19" value="'
937 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
938 . '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" /> '
939 . '<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n</form>";
944 function topLinks() {
948 $s = $this->mainPageLink() . $sep
949 . $this->specialLink( 'recentchanges' );
951 if ( $wgOut->isArticleRelated() ) {
952 $s .= $sep . $this->editThisPage()
953 . $sep . $this->historyLink();
955 # Many people don't like this dropdown box
956 #$s .= $sep . $this->specialPagesList();
958 $s .= $this->variantLinks();
960 $s .= $this->extensionTabLinks();
966 * Compatibility for extensions adding functionality through tabs.
967 * Eventually these old skins should be replaced with SkinTemplate-based
971 function extensionTabLinks() {
974 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
975 foreach( $tabs as $tab ) {
976 $s .= ' | ' . Xml
::element( 'a',
977 array( 'href' => $tab['href'] ),
984 * Language/charset variant links for classic-style skins
987 function variantLinks() {
989 /* show links to different language variants */
990 global $wgDisableLangConversion, $wgContLang, $wgTitle;
991 $variants = $wgContLang->getVariants();
992 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
993 foreach( $variants as $code ) {
994 $varname = $wgContLang->getVariantname( $code );
995 if( $varname == 'disable' )
997 $s .= ' | <a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>';
1003 function bottomLinks() {
1004 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
1008 if ( $wgOut->isArticleRelated() ) {
1009 $s .= '<strong>' . $this->editThisPage() . '</strong>';
1010 if ( $wgUser->isLoggedIn() ) {
1011 $s .= $sep . $this->watchThisPage();
1013 $s .= $sep . $this->talkLink()
1014 . $sep . $this->historyLink()
1015 . $sep . $this->whatLinksHere()
1016 . $sep . $this->watchPageLinksLink();
1018 if ($wgUseTrackbacks)
1019 $s .= $sep . $this->trackbackLink();
1021 if ( $wgTitle->getNamespace() == NS_USER
1022 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
1025 $id=User
::idFromName($wgTitle->getText());
1026 $ip=User
::isIP($wgTitle->getText());
1028 if($id ||
$ip) { # both anons and non-anons have contri list
1029 $s .= $sep . $this->userContribsLink();
1031 if( $this->showEmailUser( $id ) ) {
1032 $s .= $sep . $this->emailUserLink();
1035 if ( $wgTitle->getArticleId() ) {
1037 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
1038 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
1039 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
1041 $s .= "<br />\n" . $this->otherLanguages();
1046 function pageStats() {
1047 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1048 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
1050 $oldid = $wgRequest->getVal( 'oldid' );
1051 $diff = $wgRequest->getVal( 'diff' );
1052 if ( ! $wgOut->isArticle() ) { return ''; }
1053 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1054 if ( 0 == $wgArticle->getID() ) { return ''; }
1057 if ( !$wgDisableCounters ) {
1058 $count = $wgLang->formatNum( $wgArticle->getCount() );
1060 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1064 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
1065 require_once('Credits.php');
1066 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
1068 $s .= $this->lastModified();
1071 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
1072 $dbr = wfGetDB( DB_SLAVE
);
1073 $watchlist = $dbr->tableName( 'watchlist' );
1074 $sql = "SELECT COUNT(*) AS n FROM $watchlist
1075 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
1076 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
1077 $res = $dbr->query( $sql, 'Skin::pageStats');
1078 $x = $dbr->fetchObject( $res );
1079 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
1082 return $s . ' ' . $this->getCopyright();
1085 function getCopyright( $type = 'detect' ) {
1086 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
1088 if ( $type == 'detect' ) {
1089 $oldid = $wgRequest->getVal( 'oldid' );
1090 $diff = $wgRequest->getVal( 'diff' );
1092 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1099 if ( $type == 'history' ) {
1100 $msg = 'history_copyright';
1106 if( $wgRightsPage ) {
1107 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
1108 } elseif( $wgRightsUrl ) {
1109 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1114 $out .= wfMsgForContent( $msg, $link );
1118 function getCopyrightIcon() {
1119 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1121 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1122 $out = $wgCopyrightIcon;
1123 } else if ( $wgRightsIcon ) {
1124 $icon = htmlspecialchars( $wgRightsIcon );
1125 if ( $wgRightsUrl ) {
1126 $url = htmlspecialchars( $wgRightsUrl );
1127 $out .= '<a href="'.$url.'">';
1129 $text = htmlspecialchars( $wgRightsText );
1130 $out .= "<img src=\"$icon\" alt='$text' />";
1131 if ( $wgRightsUrl ) {
1138 function getPoweredBy() {
1139 global $wgStylePath;
1140 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1141 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1145 function lastModified() {
1146 global $wgLang, $wgArticle, $wgLoadBalancer;
1148 $timestamp = $wgArticle->getTimestamp();
1150 $d = $wgLang->date( $timestamp, true );
1151 $t = $wgLang->time( $timestamp, true );
1152 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1156 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
1157 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1162 function logoText( $align = '' ) {
1163 if ( '' != $align ) { $a = " align='{$align}'"; }
1166 $mp = wfMsg( 'mainpage' );
1167 $mptitle = Title
::newMainPage();
1168 $url = ( is_object($mptitle) ?
$mptitle->escapeLocalURL() : '' );
1170 $logourl = $this->getLogo();
1171 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1176 * show a drop-down box of special pages
1178 function specialPagesList() {
1179 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1180 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1181 foreach ( $pages as $name => $page ) {
1182 $pages[$name] = $page->getDescription();
1185 $go = wfMsg( 'go' );
1186 $sp = wfMsg( 'specialpages' );
1187 $spp = $wgContLang->specialPage( 'Specialpages' );
1189 $s = '<form id="specialpages" method="get" class="inline" ' .
1190 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1191 $s .= "<select name=\"wpDropdown\">\n";
1192 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1195 foreach ( $pages as $name => $desc ) {
1196 $p = $wgContLang->specialPage( $name );
1197 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1199 $s .= "</select>\n";
1200 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1205 function mainPageLink() {
1206 $s = $this->makeKnownLinkObj( Title
::newMainPage(), wfMsg( 'mainpage' ) );
1210 function copyrightLink() {
1211 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1212 wfMsg( 'copyrightpagename' ) );
1216 private function footerLink ( $desc, $page ) {
1217 // if the link description has been set to "-" in the default language,
1218 if ( wfMsgForContent( $desc ) == '-') {
1219 // then it is disabled, for all languages.
1222 // Otherwise, we display the link for the user, described in their
1223 // language (which may or may not be the same as the default language),
1224 // but we make the link target be the one site-wide page.
1225 return $this->makeKnownLink( wfMsgForContent( $page ), wfMsg( $desc ) );
1229 function privacyLink() {
1230 return $this->footerLink( 'privacy', 'privacypage' );
1233 function aboutLink() {
1234 return $this->footerLink( 'aboutsite', 'aboutpage' );
1237 function disclaimerLink() {
1238 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1241 function editThisPage() {
1242 global $wgOut, $wgTitle;
1244 if ( ! $wgOut->isArticleRelated() ) {
1245 $s = wfMsg( 'protectedpage' );
1247 if ( $wgTitle->userCan( 'edit' ) ) {
1248 $t = wfMsg( 'editthispage' );
1250 $t = wfMsg( 'viewsource' );
1253 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1259 * Return URL options for the 'edit page' link.
1260 * This may include an 'oldid' specifier, if the current page view is such.
1265 function editUrlOptions() {
1268 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1269 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1271 return "action=edit";
1275 function deleteThisPage() {
1276 global $wgUser, $wgTitle, $wgRequest;
1278 $diff = $wgRequest->getVal( 'diff' );
1279 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1280 $t = wfMsg( 'deletethispage' );
1282 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1289 function protectThisPage() {
1290 global $wgUser, $wgTitle, $wgRequest;
1292 $diff = $wgRequest->getVal( 'diff' );
1293 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1294 if ( $wgTitle->isProtected() ) {
1295 $t = wfMsg( 'unprotectthispage' );
1296 $q = 'action=unprotect';
1298 $t = wfMsg( 'protectthispage' );
1299 $q = 'action=protect';
1301 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1308 function watchThisPage() {
1309 global $wgOut, $wgTitle;
1310 ++
$this->mWatchLinkNum
;
1312 if ( $wgOut->isArticleRelated() ) {
1313 if ( $wgTitle->userIsWatching() ) {
1314 $t = wfMsg( 'unwatchthispage' );
1315 $q = 'action=unwatch';
1316 $id = "mw-unwatch-link".$this->mWatchLinkNum
;
1318 $t = wfMsg( 'watchthispage' );
1319 $q = 'action=watch';
1320 $id = 'mw-watch-link'.$this->mWatchLinkNum
;
1322 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q, '', '', " id=\"$id\"" );
1324 $s = wfMsg( 'notanarticle' );
1329 function moveThisPage() {
1332 if ( $wgTitle->userCan( 'move' ) ) {
1333 return $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
1334 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1336 // no message if page is protected - would be redundant
1341 function historyLink() {
1344 return $this->makeKnownLinkObj( $wgTitle,
1345 wfMsg( 'history' ), 'action=history' );
1348 function whatLinksHere() {
1351 return $this->makeKnownLinkObj(
1352 SpecialPage
::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ),
1353 wfMsg( 'whatlinkshere' ) );
1356 function userContribsLink() {
1359 return $this->makeKnownLinkObj(
1360 SpecialPage
::getTitleFor( 'Contributions', $wgTitle->getDBkey() ),
1361 wfMsg( 'contributions' ) );
1364 function showEmailUser( $id ) {
1365 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1366 return $wgEnableEmail &&
1367 $wgEnableUserEmail &&
1368 $wgUser->isLoggedIn() && # show only to signed in users
1369 0 != $id; # we can only email to non-anons ..
1370 # '' != $id->getEmail() && # who must have an email address stored ..
1371 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1372 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1375 function emailUserLink() {
1378 return $this->makeKnownLinkObj(
1379 SpecialPage
::getTitleFor( 'Emailuser', $wgTitle->getDBkey() ),
1380 wfMsg( 'emailuser' ) );
1383 function watchPageLinksLink() {
1384 global $wgOut, $wgTitle;
1386 if ( ! $wgOut->isArticleRelated() ) {
1387 return '(' . wfMsg( 'notanarticle' ) . ')';
1389 return $this->makeKnownLinkObj(
1390 SpecialPage
::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ),
1391 wfMsg( 'recentchangeslinked' ) );
1395 function trackbackLink() {
1398 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1399 . wfMsg('trackbacklink') . "</a>";
1402 function otherLanguages() {
1403 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1405 if ( $wgHideInterlanguageLinks ) {
1409 $a = $wgOut->getLanguageLinks();
1410 if ( 0 == count( $a ) ) {
1414 $s = wfMsg( 'otherlanguages' ) . ': ';
1416 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1417 foreach( $a as $l ) {
1418 if ( ! $first ) { $s .= ' | '; }
1421 $nt = Title
::newFromText( $l );
1422 $url = $nt->escapeFullURL();
1423 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1425 if ( '' == $text ) { $text = $l; }
1426 $style = $this->getExternalLinkAttributes( $l, $text );
1427 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1429 if($wgContLang->isRTL()) $s .= '</span>';
1433 function bugReportsLink() {
1434 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1435 wfMsg( 'bugreports' ) );
1439 function talkLink() {
1442 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1443 # No discussion links for special pages
1447 if( $wgTitle->isTalkPage() ) {
1448 $link = $wgTitle->getSubjectPage();
1449 switch( $link->getNamespace() ) {
1451 $text = wfMsg( 'articlepage' );
1454 $text = wfMsg( 'userpage' );
1457 $text = wfMsg( 'projectpage' );
1460 $text = wfMsg( 'imagepage' );
1463 $text = wfMsg( 'mediawikipage' );
1466 $text = wfMsg( 'templatepage' );
1469 $text = wfMsg( 'viewhelppage' );
1472 $text = wfMsg( 'categorypage' );
1475 $text = wfMsg( 'articlepage' );
1478 $link = $wgTitle->getTalkPage();
1479 $text = wfMsg( 'talkpage' );
1482 $s = $this->makeLinkObj( $link, $text );
1487 function commentLink() {
1488 global $wgTitle, $wgOut;
1490 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1494 # __NEWSECTIONLINK___ changes behaviour here
1495 # If it's present, the link points to this page, otherwise
1496 # it points to the talk page
1497 if( $wgTitle->isTalkPage() ) {
1499 } elseif( $wgOut->showNewSectionLink() ) {
1502 $title =& $wgTitle->getTalkPage();
1505 return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1508 /* these are used extensively in SkinTemplate, but also some other places */
1509 static function makeMainPageUrl( $urlaction = '' ) {
1510 $title = Title
::newMainPage();
1511 self
::checkTitle( $title, '' );
1512 return $title->getLocalURL( $urlaction );
1515 static function makeSpecialUrl( $name, $urlaction = '' ) {
1516 $title = SpecialPage
::getTitleFor( $name );
1517 return $title->getLocalURL( $urlaction );
1520 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1521 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1522 return $title->getLocalURL( $urlaction );
1525 static function makeI18nUrl( $name, $urlaction = '' ) {
1526 $title = Title
::newFromText( wfMsgForContent( $name ) );
1527 self
::checkTitle( $title, $name );
1528 return $title->getLocalURL( $urlaction );
1531 static function makeUrl( $name, $urlaction = '' ) {
1532 $title = Title
::newFromText( $name );
1533 self
::checkTitle( $title, $name );
1534 return $title->getLocalURL( $urlaction );
1537 # If url string starts with http, consider as external URL, else
1539 static function makeInternalOrExternalUrl( $name ) {
1540 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1543 return self
::makeUrl( $name );
1547 # this can be passed the NS number as defined in Language.php
1548 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1549 $title = Title
::makeTitleSafe( $namespace, $name );
1550 self
::checkTitle( $title, $name );
1551 return $title->getLocalURL( $urlaction );
1554 /* these return an array with the 'href' and boolean 'exists' */
1555 static function makeUrlDetails( $name, $urlaction = '' ) {
1556 $title = Title
::newFromText( $name );
1557 self
::checkTitle( $title, $name );
1559 'href' => $title->getLocalURL( $urlaction ),
1560 'exists' => $title->getArticleID() != 0 ?
true : false
1565 * Make URL details where the article exists (or at least it's convenient to think so)
1567 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1568 $title = Title
::newFromText( $name );
1569 self
::checkTitle( $title, $name );
1571 'href' => $title->getLocalURL( $urlaction ),
1576 # make sure we have some title to operate on
1577 static function checkTitle( &$title, $name ) {
1578 if( !is_object( $title ) ) {
1579 $title = Title
::newFromText( $name );
1580 if( !is_object( $title ) ) {
1581 $title = Title
::newFromText( '--error: link target missing--' );
1587 * Build an array that represents the sidebar(s), the navigation bar among them
1592 function buildSidebar() {
1593 global $parserMemc, $wgEnableSidebarCache;
1594 global $wgLang, $wgContLang;
1596 $fname = 'SkinTemplate::buildSidebar';
1598 wfProfileIn( $fname );
1600 $key = wfMemcKey( 'sidebar' );
1601 $cacheSidebar = $wgEnableSidebarCache &&
1602 ($wgLang->getCode() == $wgContLang->getCode());
1604 if ($cacheSidebar) {
1605 $cachedsidebar = $parserMemc->get( $key );
1606 if ($cachedsidebar!="") {
1607 wfProfileOut($fname);
1608 return $cachedsidebar;
1613 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1614 foreach ($lines as $line) {
1615 if (strpos($line, '*') !== 0)
1617 if (strpos($line, '**') !== 0) {
1618 $line = trim($line, '* ');
1621 if (strpos($line, '|') !== false) { // sanity check
1622 $line = explode( '|' , trim($line, '* '), 2 );
1623 $link = wfMsgForContent( $line[0] );
1626 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1628 if (wfEmptyMsg($line[0], $link))
1631 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1634 $title = Title
::newFromText( $link );
1636 $title = $title->fixSpecialName();
1637 $href = $title->getLocalURL();
1639 $href = 'INVALID-TITLE';
1643 $bar[$heading][] = array(
1646 'id' => 'n-' . strtr($line[1], ' ', '-'),
1649 } else { continue; }
1653 $parserMemc->set( $key, $bar, 86400 );
1654 wfProfileOut( $fname );