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 $mWatchLinkNum = 0; // Appended to end of watch link id's
21 protected $mRevisionId; // The revision ID we're looking at, null if not applicable.
22 protected $skinname = 'standard' ;
24 /** Constructor, call parent constructor */
25 function Skin() { parent
::__construct(); }
28 * Fetch the set of available skins.
29 * @return array of strings
32 static function getSkinNames() {
33 global $wgValidSkinNames;
34 static $skinsInitialised = false;
35 if ( !$skinsInitialised ) {
36 # Get a list of available skins
37 # Build using the regular expression '^(.*).php$'
38 # Array keys are all lower case, array value keep the case used by filename
40 wfProfileIn( __METHOD__
. '-init' );
41 global $wgStyleDirectory;
42 $skinDir = dir( $wgStyleDirectory );
44 # while code from www.php.net
45 while (false !== ($file = $skinDir->read())) {
46 // Skip non-PHP files, hidden files, and '.dep' includes
48 if(preg_match('/^([^.]*)\.php$/',$file, $matches)) {
50 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
54 $skinsInitialised = true;
55 wfProfileOut( __METHOD__
. '-init' );
57 return $wgValidSkinNames;
61 * Normalize a skin preference value to a form that can be loaded.
62 * If a skin can't be found, it will fall back to the configured
63 * default (or the old 'Classic' skin if that's broken).
68 static function normalizeKey( $key ) {
69 global $wgDefaultSkin;
70 $skinNames = Skin
::getSkinNames();
73 // Don't return the default immediately;
74 // in a misconfiguration we need to fall back.
75 $key = $wgDefaultSkin;
78 if( isset( $skinNames[$key] ) ) {
82 // Older versions of the software used a numeric setting
83 // in the user preferences.
89 if( isset( $fallback[$key] ) ){
90 $key = $fallback[$key];
93 if( isset( $skinNames[$key] ) ) {
101 * Factory method for loading a skin of a given type
102 * @param string $key 'monobook', 'standard', etc
106 static function &newFromKey( $key ) {
107 global $wgStyleDirectory;
109 $key = Skin
::normalizeKey( $key );
111 $skinNames = Skin
::getSkinNames();
112 $skinName = $skinNames[$key];
113 $className = 'Skin'.ucfirst($key);
115 # Grab the skin class and initialise it.
116 if ( !class_exists( $className ) ) {
117 // Preload base classes to work around APC/PHP5 bug
118 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
119 if( file_exists( $deps ) ) include_once( $deps );
120 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
122 # Check if we got if not failback to default skin
123 if( !class_exists( $className ) ) {
124 # DO NOT die if the class isn't found. This breaks maintenance
125 # scripts and can cause a user account to be unrecoverable
126 # except by SQL manipulation if a previously valid skin name
127 # is no longer valid.
128 wfDebug( "Skin class does not exist: $className\n" );
129 $className = 'SkinMonobook';
130 require_once( "{$wgStyleDirectory}/MonoBook.php" );
133 $skin = new $className;
137 /** @return string path to the skin stylesheet */
138 function getStylesheet() {
139 return 'common/wikistandard.css';
142 /** @return string skin name */
143 public function getSkinName() {
144 return $this->skinname
;
147 function qbSetting() {
148 global $wgOut, $wgUser;
150 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
151 $q = $wgUser->getOption( 'quickbar', 0 );
155 function initPage( &$out ) {
156 global $wgFavicon, $wgAppleTouchIcon, $wgScriptPath, $wgScriptExtension;
158 wfProfileIn( __METHOD__
);
160 if( false !== $wgFavicon ) {
161 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
164 if( false !== $wgAppleTouchIcon ) {
165 $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
168 # OpenSearch description link
169 $out->addLink( array(
171 'type' => 'application/opensearchdescription+xml',
172 'href' => "$wgScriptPath/opensearch_desc{$wgScriptExtension}",
173 'title' => wfMsgForContent( 'opensearch-desc' ),
176 $this->addMetadataLinks($out);
178 $this->mRevisionId
= $out->mRevisionId
;
180 $this->preloadExistence();
182 wfProfileOut( __METHOD__
);
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, $wgVariantArticlePath, $wgActionPaths;
300 global $wgUseAjax, $wgAjaxWatch;
301 global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
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 'wgVariantArticlePath' => $wgVariantArticlePath,
313 'wgActionPaths' => $wgActionPaths,
314 'wgServer' => $wgServer,
315 'wgCanonicalNamespace' => $nsname,
316 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBkey() ),
317 'wgNamespaceNumber' => $wgTitle->getNamespace(),
318 'wgPageName' => $wgTitle->getPrefixedDBKey(),
319 'wgTitle' => $wgTitle->getText(),
320 'wgAction' => $wgRequest->getText( 'action', 'view' ),
321 'wgRestrictionEdit' => $wgTitle->getRestrictions( 'edit' ),
322 'wgRestrictionMove' => $wgTitle->getRestrictions( 'move' ),
323 'wgArticleId' => $wgTitle->getArticleId(),
324 'wgIsArticle' => $wgOut->isArticle(),
325 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
326 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getEffectiveGroups(),
327 'wgUserLanguage' => $wgLang->getCode(),
328 'wgContentLanguage' => $wgContLang->getCode(),
329 'wgBreakFrames' => $wgBreakFrames,
330 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
331 'wgVersion' => $wgVersion,
332 'wgEnableAPI' => $wgEnableAPI,
333 'wgEnableWriteAPI' => $wgEnableWriteAPI,
336 global $wgLivePreview;
337 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
338 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
339 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
340 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
341 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
344 if($wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
345 $msgs = (object)array();
346 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
347 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
349 $vars['wgAjaxWatch'] = $msgs;
352 return self
::makeVariablesScript( $vars );
355 function getHeadScripts( $allowUserJs ) {
356 global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion;
358 $r = self
::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
360 $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n";
363 $jsCache = $wgUser->isLoggedIn() ?
'&smaxage=0' : '';
364 $r .= "<script type=\"$wgJsMimeType\" src=\"".
365 htmlspecialchars(self
::makeUrl('-',
366 "action=raw$jsCache&gen=js&useskin=" .
367 urlencode( $this->getSkinName() ) ) ) .
368 "\"><!-- site js --></script>\n";
370 if( $allowUserJs && $wgUser->isLoggedIn() ) {
371 $userpage = $wgUser->getUserPage();
372 $userjs = htmlspecialchars( self
::makeUrl(
373 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
374 'action=raw&ctype='.$wgJsMimeType));
375 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
381 * To make it harder for someone to slip a user a fake
382 * user-JavaScript or user-CSS preview, a random token
383 * is associated with the login session. If it's not
384 * passed back with the preview request, we won't render
387 * @param string $action
391 function userCanPreview( $action ) {
392 global $wgTitle, $wgRequest, $wgUser;
394 if( $action != 'submit' )
396 if( !$wgRequest->wasPosted() )
398 if( !$wgTitle->userCanEditCssJsSubpage() )
400 return $wgUser->matchEditToken(
401 $wgRequest->getVal( 'wpEditToken' ) );
404 # get the user/site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way)
405 function getUserStylesheet() {
406 global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage, $wgStyleVersion;
407 $sheet = $this->getStylesheet();
408 $s = "@import \"$wgStylePath/common/shared.css?$wgStyleVersion\";\n";
409 $s .= "@import \"$wgStylePath/common/oldshared.css?$wgStyleVersion\";\n";
410 $s .= "@import \"$wgStylePath/$sheet?$wgStyleVersion\";\n";
411 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css?$wgStyleVersion\";\n";
413 $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
414 $s .= '@import "' . self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n" .
415 '@import "' . self
::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
417 $s .= $this->doGetUserStyles();
422 * This returns MediaWiki:Common.js, and derived classes may add other JS.
423 * Despite its name, it does *not* return any custom user JS from user
424 * subpages. The returned script is sitewide and publicly cacheable and
425 * therefore must not include anything that varies according to user,
426 * interface language, etc. (although it may vary by skin). See
427 * makeGlobalVariablesScript for things that can vary per page view and are
430 * @return string Raw JavaScript to be returned
432 public function getUserJs() {
433 wfProfileIn( __METHOD__
);
436 $s = "/* generated javascript */\n";
437 $s .= "var skin = '" . Xml
::escapeJsString( $this->getSkinName() ) . "';\n";
438 $s .= "var stylepath = '" . Xml
::escapeJsString( $wgStylePath ) . "';";
439 $s .= "\n\n/* MediaWiki:Common.js */\n";
440 $commonJs = wfMsgForContent('common.js');
441 if ( !wfEmptyMsg ( 'common.js', $commonJs ) ) {
444 wfProfileOut( __METHOD__
);
449 * Return html code that include User stylesheets
451 function getUserStyles() {
452 $s = "<style type='text/css'>\n";
453 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
454 $s .= $this->getUserStylesheet();
455 $s .= "/*]]>*/ /* */\n";
461 * Some styles that are set by user through the user settings interface.
463 function doGetUserStyles() {
464 global $wgUser, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
468 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
469 if($wgTitle->isCssSubpage() && $this->userCanPreview( $wgRequest->getText( 'action' ) ) ) {
470 $s .= $wgRequest->getText('wpTextbox1');
472 $userpage = $wgUser->getUserPage();
473 $s.= '@import "'.self
::makeUrl(
474 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
475 'action=raw&ctype=text/css').'";'."\n";
479 return $s . $this->reallyDoGetUserStyles();
482 function reallyDoGetUserStyles() {
485 if (($undopt = $wgUser->getOption("underline")) < 2) {
486 $underline = $undopt ?
'underline' : 'none';
487 $s .= "a { text-decoration: $underline; }\n";
489 if( $wgUser->getOption( 'highlightbroken' ) ) {
490 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
493 a.new, #quickbar a.new,
494 a.stub, #quickbar a.stub {
497 a.new:after, #quickbar a.new:after {
501 a.stub:after, #quickbar a.stub:after {
507 if( $wgUser->getOption( 'justify' ) ) {
508 $s .= "#article, #bodyContent { text-align: justify; }\n";
510 if( !$wgUser->getOption( 'showtoc' ) ) {
511 $s .= "#toc { display: none; }\n";
513 if( !$wgUser->getOption( 'editsection' ) ) {
514 $s .= ".editsection { display: none; }\n";
519 function getBodyOptions() {
520 global $wgUser, $wgTitle, $wgOut, $wgRequest, $wgContLang;
522 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
524 if ( 0 != $wgTitle->getNamespace() ) {
525 $a = array( 'bgcolor' => '#ffffec' );
527 else $a = array( 'bgcolor' => '#FFFFFF' );
528 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
529 $wgTitle->userCan( 'edit' ) ) {
530 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
531 $s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
532 $a +
= array ('ondblclick' => $s);
535 $a['onload'] = $wgOut->getOnloadHandler();
536 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
537 if( $a['onload'] != '' ) {
540 $a['onload'] .= 'setupRightClickEdit()';
543 'mediawiki ns-'.$wgTitle->getNamespace().
544 ' '.($wgContLang->isRTL() ?
"rtl" : "ltr").
545 ' '.Sanitizer
::escapeClass( 'page-'.$wgTitle->getPrefixedText() );
558 * This will be called immediately after the <body> tag. Split into
559 * two functions to make it easier to subclass.
561 function beforeContent() {
562 return $this->doBeforeContent();
565 function doBeforeContent() {
567 $fname = 'Skin::doBeforeContent';
568 wfProfileIn( $fname );
571 $qb = $this->qbSetting();
573 if( $langlinks = $this->otherLanguages() ) {
579 $borderhack = 'class="top"';
582 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
583 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
586 $left = ($qb == 1 ||
$qb == 3);
587 if($wgContLang->isRTL()) $left = !$left;
590 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
591 $this->logoText() . '</td>';
593 $s .= $this->getQuickbarCompensator( $rows );
595 $l = $wgContLang->isRTL() ?
'right' : 'left';
596 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
598 $s .= $this->topLinks() ;
599 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
601 $r = $wgContLang->isRTL() ?
"left" : "right";
602 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
603 $s .= $this->nameAndLogin();
604 $s .= "\n<br />" . $this->searchForm() . "</td>";
607 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
610 if ( $shove && !$left ) { # Right
611 $s .= $this->getQuickbarCompensator( $rows );
613 $s .= "</tr>\n</table>\n</div>\n";
614 $s .= "\n<div id='article'>\n";
616 $notice = wfGetSiteNotice();
618 $s .= "\n<div id='siteNotice'>$notice</div>\n";
620 $s .= $this->pageTitle();
621 $s .= $this->pageSubtitle() ;
622 $s .= $this->getCategories();
623 wfProfileOut( $fname );
628 function getCategoryLinks () {
629 global $wgOut, $wgTitle, $wgUseCategoryBrowser;
630 global $wgContLang, $wgUser;
632 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
635 $sep = wfMsgHtml( 'catseparator' );
637 // Use Unicode bidi embedding override characters,
638 // to make sure links don't smash each other up in ugly ways.
639 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
640 $embed = "<span dir='$dir'>";
643 $allCats = $wgOut->getCategoryLinks();
645 if ( !empty( $allCats['normal'] ) ) {
646 $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
648 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escape' ), count( $allCats['normal'] ) );
649 $s .= '<div id="mw-normal-catlinks">' .
650 $this->makeLinkObj( Title
::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
651 . ': ' . $t . '</div>';
655 if ( isset( $allCats['hidden'] ) ) {
656 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
657 $class ='mw-hidden-cats-user-shown';
658 } elseif ( $wgTitle->getNamespace() == NS_CATEGORY
) {
659 $class = 'mw-hidden-cats-ns-shown';
661 $class = 'mw-hidden-cats-hidden';
663 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
664 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escape' ), count( $allCats['hidden'] ) ) .
665 ': ' . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
669 # optional 'dmoz-like' category browser. Will be shown under the list
670 # of categories an article belong to
671 if($wgUseCategoryBrowser) {
672 $s .= '<br /><hr />';
674 # get a big array of the parents tree
675 $parenttree = $wgTitle->getParentCategoryTree();
676 # Skin object passed by reference cause it can not be
677 # accessed under the method subfunction drawCategoryBrowser
678 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
679 # Clean out bogus first entry and sort them
682 # Output one per line
683 $s .= implode("<br />\n", $tempout);
689 /** Render the array as a serie of links.
690 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
691 * @param &skin Object: skin passed by reference
692 * @return String separated by >, terminate with "\n"
694 function drawCategoryBrowser($tree, &$skin) {
696 foreach ($tree as $element => $parent) {
697 if (empty($parent)) {
698 # element start a new list
701 # grab the others elements
702 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
704 # add our current element to the list
705 $eltitle = Title
::NewFromText($element);
706 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
711 function getCategories() {
712 $catlinks=$this->getCategoryLinks();
713 if(!empty($catlinks)) {
714 return "<div class='catlinks'>{$catlinks}</div>";
718 function getQuickbarCompensator( $rows = 1 ) {
719 return "<td width='152' rowspan='{$rows}'> </td>";
723 * This gets called shortly before the \</body\> tag.
724 * @return String HTML to be put before \</body\>
726 function afterContent() {
727 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
728 return $printfooter . $this->doAfterContent();
732 * This gets called shortly before the \</body\> tag.
733 * @return String HTML-wrapped JS code to be put before \</body\>
735 function bottomScripts() {
736 global $wgJsMimeType;
737 $bottomScriptText = "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
738 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
739 return $bottomScriptText;
742 /** @return string Retrievied from HTML text */
743 function printSource() {
745 $url = htmlspecialchars( $wgTitle->getFullURL() );
746 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
749 function printFooter() {
750 return "<p>" . $this->printSource() .
751 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
754 /** overloaded by derived classes */
755 function doAfterContent() { }
757 function pageTitleLinks() {
758 global $wgOut, $wgTitle, $wgUser, $wgRequest;
760 $oldid = $wgRequest->getVal( 'oldid' );
761 $diff = $wgRequest->getVal( 'diff' );
762 $action = $wgRequest->getText( 'action' );
764 $s = $this->printableLink();
765 $disclaimer = $this->disclaimerLink(); # may be empty
767 $s .= ' | ' . $disclaimer;
769 $privacy = $this->privacyLink(); # may be empty too
771 $s .= ' | ' . $privacy;
774 if ( $wgOut->isArticleRelated() ) {
775 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
776 $name = $wgTitle->getDBkey();
777 $image = wfFindFile( $wgTitle );
779 $link = htmlspecialchars( $image->getURL() );
780 $style = $this->getInternalLinkAttributes( $link, $name );
781 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
785 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
786 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
787 wfMsg( 'currentrev' ) );
790 if ( $wgUser->getNewtalk() ) {
791 # do not show "You have new messages" text when we are viewing our
793 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
794 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
795 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
796 $s.= ' | <strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
798 $wgOut->setSquidMaxage(0);
799 $wgOut->enableClientCache(false);
803 $undelete = $this->getUndeleteLink();
804 if( !empty( $undelete ) ) {
805 $s .= ' | '.$undelete;
810 function getUndeleteLink() {
811 global $wgUser, $wgTitle, $wgContLang, $wgLang, $action;
812 if( $wgUser->isAllowed( 'deletedhistory' ) &&
813 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
814 ($n = $wgTitle->isDeleted() ) )
816 if ( $wgUser->isAllowed( 'undelete' ) ) {
817 $msg = 'thisisdeleted';
819 $msg = 'viewdeleted';
822 $this->makeKnownLinkObj(
823 SpecialPage
::getTitleFor( 'Undelete', $wgTitle->getPrefixedDBkey() ),
824 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ) ) );
829 function printableLink() {
830 global $wgOut, $wgFeedClasses, $wgRequest;
832 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
834 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
835 if( $wgOut->isSyndicated() ) {
836 foreach( $wgFeedClasses as $format => $class ) {
837 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
838 $s .= " | <a href=\"$feedurl\">{$format}</a>";
844 function pageTitle() {
846 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
850 function pageSubtitle() {
853 $sub = $wgOut->getSubtitle();
855 global $wgExtraSubtitle;
856 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
858 $subpages = $this->subPageSubtitle();
859 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
860 $s = "<p class='subtitle'>{$sub}</p>\n";
864 function subPageSubtitle() {
866 if(!wfRunHooks('SkinSubPageSubtitle', array(&$subpages)))
869 global $wgOut, $wgTitle, $wgNamespacesWithSubpages;
870 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
871 $ptext=$wgTitle->getPrefixedText();
872 if(preg_match('/\//',$ptext)) {
873 $links = explode('/',$ptext);
876 foreach($links as $link) {
878 if ($c<count($links)) {
879 $growinglink .= $link;
880 $getlink = $this->makeLink( $growinglink, htmlspecialchars( $link ) );
881 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
885 $subpages .= '< ';
887 $subpages .= $getlink;
897 * Returns true if the IP should be shown in the header
899 function showIPinHeader() {
900 global $wgShowIPinHeader;
901 return $wgShowIPinHeader && session_id() != '';
904 function nameAndLogin() {
905 global $wgUser, $wgTitle, $wgLang, $wgContLang;
907 $lo = $wgContLang->specialPage( 'Userlogout' );
910 if ( $wgUser->isAnon() ) {
911 if( $this->showIPinHeader() ) {
914 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
915 $wgLang->getNsText( NS_TALK
) );
917 $s .= $n . ' ('.$tl.')';
919 $s .= wfMsg('notloggedin');
922 $rt = $wgTitle->getPrefixedURL();
923 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
925 } else { $q = "returnto={$rt}"; }
927 $s .= "\n<br />" . $this->makeKnownLinkObj(
928 SpecialPage
::getTitleFor( 'Userlogin' ),
929 wfMsg( 'login' ), $q );
931 $n = $wgUser->getName();
932 $rt = $wgTitle->getPrefixedURL();
933 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
934 $wgLang->getNsText( NS_TALK
) );
938 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
939 $n ) . "{$tl}<br />" .
940 $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
941 "returnto={$rt}" ) . ' | ' .
942 $this->specialLink( 'preferences' );
944 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
950 function getSearchLink() {
951 $searchPage = SpecialPage
::getTitleFor( 'Search' );
952 return $searchPage->getLocalURL();
955 function escapeSearchLink() {
956 return htmlspecialchars( $this->getSearchLink() );
959 function searchForm() {
961 $search = $wgRequest->getText( 'search' );
963 $s = '<form name="search" class="inline" method="post" action="'
964 . $this->escapeSearchLink() . "\">\n"
965 . '<input type="text" name="search" size="19" value="'
966 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
967 . '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" /> '
968 . '<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n</form>";
973 function topLinks() {
977 $s = $this->mainPageLink() . $sep
978 . $this->specialLink( 'recentchanges' );
980 if ( $wgOut->isArticleRelated() ) {
981 $s .= $sep . $this->editThisPage()
982 . $sep . $this->historyLink();
984 # Many people don't like this dropdown box
985 #$s .= $sep . $this->specialPagesList();
987 $s .= $this->variantLinks();
989 $s .= $this->extensionTabLinks();
995 * Compatibility for extensions adding functionality through tabs.
996 * Eventually these old skins should be replaced with SkinTemplate-based
1000 function extensionTabLinks() {
1003 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1004 foreach( $tabs as $tab ) {
1005 $s .= ' | ' . Xml
::element( 'a',
1006 array( 'href' => $tab['href'] ),
1013 * Language/charset variant links for classic-style skins
1016 function variantLinks() {
1018 /* show links to different language variants */
1019 global $wgDisableLangConversion, $wgContLang, $wgTitle;
1020 $variants = $wgContLang->getVariants();
1021 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1022 foreach( $variants as $code ) {
1023 $varname = $wgContLang->getVariantname( $code );
1024 if( $varname == 'disable' )
1026 $s .= ' | <a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>';
1032 function bottomLinks() {
1033 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
1037 if ( $wgOut->isArticleRelated() ) {
1038 $s .= '<strong>' . $this->editThisPage() . '</strong>';
1039 if ( $wgUser->isLoggedIn() ) {
1040 $s .= $sep . $this->watchThisPage();
1042 $s .= $sep . $this->talkLink()
1043 . $sep . $this->historyLink()
1044 . $sep . $this->whatLinksHere()
1045 . $sep . $this->watchPageLinksLink();
1047 if ($wgUseTrackbacks)
1048 $s .= $sep . $this->trackbackLink();
1050 if ( $wgTitle->getNamespace() == NS_USER
1051 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
1054 $id=User
::idFromName($wgTitle->getText());
1055 $ip=User
::isIP($wgTitle->getText());
1057 if($id ||
$ip) { # both anons and non-anons have contri list
1058 $s .= $sep . $this->userContribsLink();
1060 if( $this->showEmailUser( $id ) ) {
1061 $s .= $sep . $this->emailUserLink();
1064 if ( $wgTitle->getArticleId() ) {
1066 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
1067 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
1068 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
1070 $s .= "<br />\n" . $this->otherLanguages();
1075 function pageStats() {
1076 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1077 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
1079 $oldid = $wgRequest->getVal( 'oldid' );
1080 $diff = $wgRequest->getVal( 'diff' );
1081 if ( ! $wgOut->isArticle() ) { return ''; }
1082 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1083 if ( 0 == $wgArticle->getID() ) { return ''; }
1086 if ( !$wgDisableCounters ) {
1087 $count = $wgLang->formatNum( $wgArticle->getCount() );
1089 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1093 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
1094 require_once('Credits.php');
1095 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
1097 $s .= $this->lastModified();
1100 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
1101 $dbr = wfGetDB( DB_SLAVE
);
1102 $watchlist = $dbr->tableName( 'watchlist' );
1103 $sql = "SELECT COUNT(*) AS n FROM $watchlist
1104 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBkey()) .
1105 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
1106 $res = $dbr->query( $sql, 'Skin::pageStats');
1107 $x = $dbr->fetchObject( $res );
1109 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1110 array( 'parseinline' ), $wgLang->formatNum($x->n
)
1114 return $s . ' ' . $this->getCopyright();
1117 function getCopyright( $type = 'detect' ) {
1118 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
1120 if ( $type == 'detect' ) {
1121 $oldid = $wgRequest->getVal( 'oldid' );
1122 $diff = $wgRequest->getVal( 'diff' );
1124 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1131 if ( $type == 'history' ) {
1132 $msg = 'history_copyright';
1138 if( $wgRightsPage ) {
1139 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
1140 } elseif( $wgRightsUrl ) {
1141 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1146 $out .= wfMsgForContent( $msg, $link );
1150 function getCopyrightIcon() {
1151 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1153 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1154 $out = $wgCopyrightIcon;
1155 } else if ( $wgRightsIcon ) {
1156 $icon = htmlspecialchars( $wgRightsIcon );
1157 if ( $wgRightsUrl ) {
1158 $url = htmlspecialchars( $wgRightsUrl );
1159 $out .= '<a href="'.$url.'">';
1161 $text = htmlspecialchars( $wgRightsText );
1162 $out .= "<img src=\"$icon\" alt='$text' />";
1163 if ( $wgRightsUrl ) {
1170 function getPoweredBy() {
1171 global $wgStylePath;
1172 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1173 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1177 function lastModified() {
1178 global $wgLang, $wgArticle, $wgLoadBalancer;
1180 $timestamp = $wgArticle->getTimestamp();
1182 $d = $wgLang->date( $timestamp, true );
1183 $t = $wgLang->time( $timestamp, true );
1184 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1188 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
1189 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1194 function logoText( $align = '' ) {
1195 if ( '' != $align ) { $a = " align='{$align}'"; }
1198 $mp = wfMsg( 'mainpage' );
1199 $mptitle = Title
::newMainPage();
1200 $url = ( is_object($mptitle) ?
$mptitle->escapeLocalURL() : '' );
1202 $logourl = $this->getLogo();
1203 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1208 * show a drop-down box of special pages
1210 function specialPagesList() {
1211 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1212 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1213 foreach ( $pages as $name => $page ) {
1214 $pages[$name] = $page->getDescription();
1217 $go = wfMsg( 'go' );
1218 $sp = wfMsg( 'specialpages' );
1219 $spp = $wgContLang->specialPage( 'Specialpages' );
1221 $s = '<form id="specialpages" method="get" class="inline" ' .
1222 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1223 $s .= "<select name=\"wpDropdown\">\n";
1224 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1227 foreach ( $pages as $name => $desc ) {
1228 $p = $wgContLang->specialPage( $name );
1229 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1231 $s .= "</select>\n";
1232 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1237 function mainPageLink() {
1238 $s = $this->makeKnownLinkObj( Title
::newMainPage(), wfMsg( 'mainpage' ) );
1242 function copyrightLink() {
1243 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1244 wfMsg( 'copyrightpagename' ) );
1248 private function footerLink ( $desc, $page ) {
1249 // if the link description has been set to "-" in the default language,
1250 if ( wfMsgForContent( $desc ) == '-') {
1251 // then it is disabled, for all languages.
1254 // Otherwise, we display the link for the user, described in their
1255 // language (which may or may not be the same as the default language),
1256 // but we make the link target be the one site-wide page.
1257 return $this->makeKnownLink( wfMsgForContent( $page ),
1258 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) ) );
1262 function privacyLink() {
1263 return $this->footerLink( 'privacy', 'privacypage' );
1266 function aboutLink() {
1267 return $this->footerLink( 'aboutsite', 'aboutpage' );
1270 function disclaimerLink() {
1271 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1274 function editThisPage() {
1275 global $wgOut, $wgTitle;
1277 if ( ! $wgOut->isArticleRelated() ) {
1278 $s = wfMsg( 'protectedpage' );
1280 if ( $wgTitle->userCan( 'edit' ) ) {
1281 $t = wfMsg( 'editthispage' );
1283 $t = wfMsg( 'viewsource' );
1286 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1292 * Return URL options for the 'edit page' link.
1293 * This may include an 'oldid' specifier, if the current page view is such.
1298 function editUrlOptions() {
1301 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1302 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1304 return "action=edit";
1308 function deleteThisPage() {
1309 global $wgUser, $wgTitle, $wgRequest;
1311 $diff = $wgRequest->getVal( 'diff' );
1312 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1313 $t = wfMsg( 'deletethispage' );
1315 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1322 function protectThisPage() {
1323 global $wgUser, $wgTitle, $wgRequest;
1325 $diff = $wgRequest->getVal( 'diff' );
1326 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1327 if ( $wgTitle->isProtected() ) {
1328 $t = wfMsg( 'unprotectthispage' );
1329 $q = 'action=unprotect';
1331 $t = wfMsg( 'protectthispage' );
1332 $q = 'action=protect';
1334 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1341 function watchThisPage() {
1342 global $wgOut, $wgTitle;
1343 ++
$this->mWatchLinkNum
;
1345 if ( $wgOut->isArticleRelated() ) {
1346 if ( $wgTitle->userIsWatching() ) {
1347 $t = wfMsg( 'unwatchthispage' );
1348 $q = 'action=unwatch';
1349 $id = "mw-unwatch-link".$this->mWatchLinkNum
;
1351 $t = wfMsg( 'watchthispage' );
1352 $q = 'action=watch';
1353 $id = 'mw-watch-link'.$this->mWatchLinkNum
;
1355 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q, '', '', " id=\"$id\"" );
1357 $s = wfMsg( 'notanarticle' );
1362 function moveThisPage() {
1365 if ( $wgTitle->userCan( 'move' ) ) {
1366 return $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
1367 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1369 // no message if page is protected - would be redundant
1374 function historyLink() {
1377 return $this->makeKnownLinkObj( $wgTitle,
1378 wfMsg( 'history' ), 'action=history' );
1381 function whatLinksHere() {
1384 return $this->makeKnownLinkObj(
1385 SpecialPage
::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ),
1386 wfMsg( 'whatlinkshere' ) );
1389 function userContribsLink() {
1392 return $this->makeKnownLinkObj(
1393 SpecialPage
::getTitleFor( 'Contributions', $wgTitle->getDBkey() ),
1394 wfMsg( 'contributions' ) );
1397 function showEmailUser( $id ) {
1398 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1399 return $wgEnableEmail &&
1400 $wgEnableUserEmail &&
1401 $wgUser->isLoggedIn() && # show only to signed in users
1402 0 != $id; # we can only email to non-anons ..
1403 # '' != $id->getEmail() && # who must have an email address stored ..
1404 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1405 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1408 function emailUserLink() {
1411 return $this->makeKnownLinkObj(
1412 SpecialPage
::getTitleFor( 'Emailuser', $wgTitle->getDBkey() ),
1413 wfMsg( 'emailuser' ) );
1416 function watchPageLinksLink() {
1417 global $wgOut, $wgTitle;
1419 if ( ! $wgOut->isArticleRelated() ) {
1420 return '(' . wfMsg( 'notanarticle' ) . ')';
1422 return $this->makeKnownLinkObj(
1423 SpecialPage
::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ),
1424 wfMsg( 'recentchangeslinked' ) );
1428 function trackbackLink() {
1431 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1432 . wfMsg('trackbacklink') . "</a>";
1435 function otherLanguages() {
1436 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1438 if ( $wgHideInterlanguageLinks ) {
1442 $a = $wgOut->getLanguageLinks();
1443 if ( 0 == count( $a ) ) {
1447 $s = wfMsg( 'otherlanguages' ) . ': ';
1449 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1450 foreach( $a as $l ) {
1451 if ( ! $first ) { $s .= ' | '; }
1454 $nt = Title
::newFromText( $l );
1455 $url = $nt->escapeFullURL();
1456 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1458 if ( '' == $text ) { $text = $l; }
1459 $style = $this->getExternalLinkAttributes( $l, $text );
1460 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1462 if($wgContLang->isRTL()) $s .= '</span>';
1466 function bugReportsLink() {
1467 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1468 wfMsg( 'bugreports' ) );
1472 function talkLink() {
1475 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1476 # No discussion links for special pages
1480 if( $wgTitle->isTalkPage() ) {
1481 $link = $wgTitle->getSubjectPage();
1482 switch( $link->getNamespace() ) {
1484 $text = wfMsg( 'articlepage' );
1487 $text = wfMsg( 'userpage' );
1490 $text = wfMsg( 'projectpage' );
1493 $text = wfMsg( 'imagepage' );
1496 $text = wfMsg( 'mediawikipage' );
1499 $text = wfMsg( 'templatepage' );
1502 $text = wfMsg( 'viewhelppage' );
1505 $text = wfMsg( 'categorypage' );
1508 $text = wfMsg( 'articlepage' );
1511 $link = $wgTitle->getTalkPage();
1512 $text = wfMsg( 'talkpage' );
1515 $s = $this->makeLinkObj( $link, $text );
1520 function commentLink() {
1521 global $wgTitle, $wgOut;
1523 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1527 # __NEWSECTIONLINK___ changes behaviour here
1528 # If it's present, the link points to this page, otherwise
1529 # it points to the talk page
1530 if( $wgTitle->isTalkPage() ) {
1532 } elseif( $wgOut->showNewSectionLink() ) {
1535 $title = $wgTitle->getTalkPage();
1538 return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1541 /* these are used extensively in SkinTemplate, but also some other places */
1542 static function makeMainPageUrl( $urlaction = '' ) {
1543 $title = Title
::newMainPage();
1544 self
::checkTitle( $title, '' );
1545 return $title->getLocalURL( $urlaction );
1548 static function makeSpecialUrl( $name, $urlaction = '' ) {
1549 $title = SpecialPage
::getTitleFor( $name );
1550 return $title->getLocalURL( $urlaction );
1553 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1554 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1555 return $title->getLocalURL( $urlaction );
1558 static function makeI18nUrl( $name, $urlaction = '' ) {
1559 $title = Title
::newFromText( wfMsgForContent( $name ) );
1560 self
::checkTitle( $title, $name );
1561 return $title->getLocalURL( $urlaction );
1564 static function makeUrl( $name, $urlaction = '' ) {
1565 $title = Title
::newFromText( $name );
1566 self
::checkTitle( $title, $name );
1567 return $title->getLocalURL( $urlaction );
1570 # If url string starts with http, consider as external URL, else
1572 static function makeInternalOrExternalUrl( $name ) {
1573 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1576 return self
::makeUrl( $name );
1580 # this can be passed the NS number as defined in Language.php
1581 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1582 $title = Title
::makeTitleSafe( $namespace, $name );
1583 self
::checkTitle( $title, $name );
1584 return $title->getLocalURL( $urlaction );
1587 /* these return an array with the 'href' and boolean 'exists' */
1588 static function makeUrlDetails( $name, $urlaction = '' ) {
1589 $title = Title
::newFromText( $name );
1590 self
::checkTitle( $title, $name );
1592 'href' => $title->getLocalURL( $urlaction ),
1593 'exists' => $title->getArticleID() != 0 ?
true : false
1598 * Make URL details where the article exists (or at least it's convenient to think so)
1600 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1601 $title = Title
::newFromText( $name );
1602 self
::checkTitle( $title, $name );
1604 'href' => $title->getLocalURL( $urlaction ),
1609 # make sure we have some title to operate on
1610 static function checkTitle( &$title, $name ) {
1611 if( !is_object( $title ) ) {
1612 $title = Title
::newFromText( $name );
1613 if( !is_object( $title ) ) {
1614 $title = Title
::newFromText( '--error: link target missing--' );
1620 * Build an array that represents the sidebar(s), the navigation bar among them
1625 function buildSidebar() {
1626 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
1627 global $wgLang, $wgContLang;
1629 $fname = 'SkinTemplate::buildSidebar';
1631 wfProfileIn( $fname );
1633 $key = wfMemcKey( 'sidebar' );
1634 $cacheSidebar = $wgEnableSidebarCache &&
1635 ($wgLang->getCode() == $wgContLang->getCode());
1637 if ($cacheSidebar) {
1638 $cachedsidebar = $parserMemc->get( $key );
1639 if ($cachedsidebar!="") {
1640 wfProfileOut($fname);
1641 return $cachedsidebar;
1646 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1648 foreach ($lines as $line) {
1649 if (strpos($line, '*') !== 0)
1651 if (strpos($line, '**') !== 0) {
1652 $line = trim($line, '* ');
1655 if (strpos($line, '|') !== false) { // sanity check
1656 $line = explode( '|' , trim($line, '* '), 2 );
1657 $link = wfMsgForContent( $line[0] );
1660 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1662 if (wfEmptyMsg($line[0], $link))
1665 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1668 $title = Title
::newFromText( $link );
1670 $title = $title->fixSpecialName();
1671 $href = $title->getLocalURL();
1673 $href = 'INVALID-TITLE';
1677 $bar[$heading][] = array(
1680 'id' => 'n-' . strtr($line[1], ' ', '-'),
1683 } else { continue; }
1687 $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
1688 wfProfileOut( $fname );