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( wfReportTime() );
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;
302 global $wgRestrictionTypes, $wgLivePreview;
303 global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
305 $ns = $wgTitle->getNamespace();
306 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
309 'skin' => $data['skinname'],
310 'stylepath' => $wgStylePath,
311 'wgArticlePath' => $wgArticlePath,
312 'wgScriptPath' => $wgScriptPath,
313 'wgScript' => $wgScript,
314 'wgVariantArticlePath' => $wgVariantArticlePath,
315 'wgActionPaths' => $wgActionPaths,
316 'wgServer' => $wgServer,
317 'wgCanonicalNamespace' => $nsname,
318 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBkey() ),
319 'wgNamespaceNumber' => $wgTitle->getNamespace(),
320 'wgPageName' => $wgTitle->getPrefixedDBKey(),
321 'wgTitle' => $wgTitle->getText(),
322 'wgAction' => $wgRequest->getText( 'action', 'view' ),
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 if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false )){
337 $vars['wgMWSuggestTemplate'] = SearchEngine
::getMWSuggestTemplate();
338 $vars['wgDBname'] = $wgDBname;
339 $vars['wgSearchNamespaces'] = SearchEngine
::userNamespaces( $wgUser );
340 $vars['wgMWSuggestMessages'] = array( wfMsg('search-mwsuggest-enabled'), wfMsg('search-mwsuggest-disabled'));
343 foreach( $wgRestrictionTypes as $type )
344 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
346 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
347 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
348 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
349 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
350 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
353 if($wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
354 $msgs = (object)array();
355 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
356 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
358 $vars['wgAjaxWatch'] = $msgs;
361 return self
::makeVariablesScript( $vars );
364 function getHeadScripts( $allowUserJs ) {
365 global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion;
367 $r = self
::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
369 $r .= "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>\n";
372 $jsCache = $wgUser->isLoggedIn() ?
'&smaxage=0' : '';
373 $r .= "<script type=\"$wgJsMimeType\" src=\"".
374 htmlspecialchars(self
::makeUrl('-',
375 "action=raw$jsCache&gen=js&useskin=" .
376 urlencode( $this->getSkinName() ) ) ) .
377 "\"><!-- site js --></script>\n";
379 if( $allowUserJs && $wgUser->isLoggedIn() ) {
380 $userpage = $wgUser->getUserPage();
381 $userjs = htmlspecialchars( self
::makeUrl(
382 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
383 'action=raw&ctype='.$wgJsMimeType));
384 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
390 * To make it harder for someone to slip a user a fake
391 * user-JavaScript or user-CSS preview, a random token
392 * is associated with the login session. If it's not
393 * passed back with the preview request, we won't render
396 * @param string $action
400 function userCanPreview( $action ) {
401 global $wgTitle, $wgRequest, $wgUser;
403 if( $action != 'submit' )
405 if( !$wgRequest->wasPosted() )
407 if( !$wgTitle->userCanEditCssJsSubpage() )
409 return $wgUser->matchEditToken(
410 $wgRequest->getVal( 'wpEditToken' ) );
413 # get the user/site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way)
414 function getUserStylesheet() {
415 global $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage, $wgStyleVersion;
416 $sheet = $this->getStylesheet();
417 $s = "@import \"$wgStylePath/common/shared.css?$wgStyleVersion\";\n";
418 $s .= "@import \"$wgStylePath/common/oldshared.css?$wgStyleVersion\";\n";
419 $s .= "@import \"$wgStylePath/$sheet?$wgStyleVersion\";\n";
420 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css?$wgStyleVersion\";\n";
422 $query = "usemsgcache=yes&action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
423 $s .= '@import "' . self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n" .
424 '@import "' . self
::makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
426 $s .= $this->doGetUserStyles();
431 * This returns MediaWiki:Common.js, and derived classes may add other JS.
432 * Despite its name, it does *not* return any custom user JS from user
433 * subpages. The returned script is sitewide and publicly cacheable and
434 * therefore must not include anything that varies according to user,
435 * interface language, etc. (although it may vary by skin). See
436 * makeGlobalVariablesScript for things that can vary per page view and are
439 * @return string Raw JavaScript to be returned
441 public function getUserJs() {
442 wfProfileIn( __METHOD__
);
445 $s = "/* generated javascript */\n";
446 $s .= "var skin = '" . Xml
::escapeJsString( $this->getSkinName() ) . "';\n";
447 $s .= "var stylepath = '" . Xml
::escapeJsString( $wgStylePath ) . "';";
448 $s .= "\n\n/* MediaWiki:Common.js */\n";
449 $commonJs = wfMsgForContent('common.js');
450 if ( !wfEmptyMsg ( 'common.js', $commonJs ) ) {
453 wfProfileOut( __METHOD__
);
458 * Return html code that include User stylesheets
460 function getUserStyles() {
461 $s = "<style type='text/css'>\n";
462 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
463 $s .= $this->getUserStylesheet();
464 $s .= "/*]]>*/ /* */\n";
470 * Some styles that are set by user through the user settings interface.
472 function doGetUserStyles() {
473 global $wgUser, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
477 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
478 if($wgTitle->isCssSubpage() && $this->userCanPreview( $wgRequest->getText( 'action' ) ) ) {
479 $s .= $wgRequest->getText('wpTextbox1');
481 $userpage = $wgUser->getUserPage();
482 $s.= '@import "'.self
::makeUrl(
483 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
484 'action=raw&ctype=text/css').'";'."\n";
488 return $s . $this->reallyDoGetUserStyles();
491 function reallyDoGetUserStyles() {
494 if (($undopt = $wgUser->getOption("underline")) < 2) {
495 $underline = $undopt ?
'underline' : 'none';
496 $s .= "a { text-decoration: $underline; }\n";
498 if( $wgUser->getOption( 'highlightbroken' ) ) {
499 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
502 a.new, #quickbar a.new,
503 a.stub, #quickbar a.stub {
506 a.new:after, #quickbar a.new:after {
510 a.stub:after, #quickbar a.stub:after {
516 if( $wgUser->getOption( 'justify' ) ) {
517 $s .= "#article, #bodyContent { text-align: justify; }\n";
519 if( !$wgUser->getOption( 'showtoc' ) ) {
520 $s .= "#toc { display: none; }\n";
522 if( !$wgUser->getOption( 'editsection' ) ) {
523 $s .= ".editsection { display: none; }\n";
528 function getBodyOptions() {
529 global $wgUser, $wgTitle, $wgOut, $wgRequest, $wgContLang;
531 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
533 if ( 0 != $wgTitle->getNamespace() ) {
534 $a = array( 'bgcolor' => '#ffffec' );
536 else $a = array( 'bgcolor' => '#FFFFFF' );
537 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
538 $wgTitle->userCan( 'edit' ) ) {
539 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
540 $s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
541 $a +
= array ('ondblclick' => $s);
544 $a['onload'] = $wgOut->getOnloadHandler();
545 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
546 if( $a['onload'] != '' ) {
549 $a['onload'] .= 'setupRightClickEdit()';
552 'mediawiki ns-'.$wgTitle->getNamespace().
553 ' '.($wgContLang->isRTL() ?
"rtl" : "ltr").
554 ' '.Sanitizer
::escapeClass( 'page-'.$wgTitle->getPrefixedText() );
567 * This will be called immediately after the <body> tag. Split into
568 * two functions to make it easier to subclass.
570 function beforeContent() {
571 return $this->doBeforeContent();
574 function doBeforeContent() {
576 $fname = 'Skin::doBeforeContent';
577 wfProfileIn( $fname );
580 $qb = $this->qbSetting();
582 if( $langlinks = $this->otherLanguages() ) {
588 $borderhack = 'class="top"';
591 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
592 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
595 $left = ($qb == 1 ||
$qb == 3);
596 if($wgContLang->isRTL()) $left = !$left;
599 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
600 $this->logoText() . '</td>';
602 $s .= $this->getQuickbarCompensator( $rows );
604 $l = $wgContLang->isRTL() ?
'right' : 'left';
605 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
607 $s .= $this->topLinks() ;
608 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
610 $r = $wgContLang->isRTL() ?
"left" : "right";
611 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
612 $s .= $this->nameAndLogin();
613 $s .= "\n<br />" . $this->searchForm() . "</td>";
616 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
619 if ( $shove && !$left ) { # Right
620 $s .= $this->getQuickbarCompensator( $rows );
622 $s .= "</tr>\n</table>\n</div>\n";
623 $s .= "\n<div id='article'>\n";
625 $notice = wfGetSiteNotice();
627 $s .= "\n<div id='siteNotice'>$notice</div>\n";
629 $s .= $this->pageTitle();
630 $s .= $this->pageSubtitle() ;
631 $s .= $this->getCategories();
632 wfProfileOut( $fname );
637 function getCategoryLinks() {
638 global $wgOut, $wgTitle, $wgUseCategoryBrowser;
639 global $wgContLang, $wgUser;
641 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
644 $sep = wfMsgHtml( 'catseparator' );
646 // Use Unicode bidi embedding override characters,
647 // to make sure links don't smash each other up in ugly ways.
648 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
649 $embed = "<span dir='$dir'>";
652 $allCats = $wgOut->getCategoryLinks();
654 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
655 if ( !empty( $allCats['normal'] ) ) {
656 $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
658 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
659 $s .= '<div id="mw-normal-catlinks">' .
660 $this->makeLinkObj( Title
::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
661 . $colon . $t . '</div>';
665 if ( isset( $allCats['hidden'] ) ) {
666 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
667 $class ='mw-hidden-cats-user-shown';
668 } elseif ( $wgTitle->getNamespace() == NS_CATEGORY
) {
669 $class = 'mw-hidden-cats-ns-shown';
671 $class = 'mw-hidden-cats-hidden';
673 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
674 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
675 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
679 # optional 'dmoz-like' category browser. Will be shown under the list
680 # of categories an article belong to
681 if($wgUseCategoryBrowser) {
682 $s .= '<br /><hr />';
684 # get a big array of the parents tree
685 $parenttree = $wgTitle->getParentCategoryTree();
686 # Skin object passed by reference cause it can not be
687 # accessed under the method subfunction drawCategoryBrowser
688 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
689 # Clean out bogus first entry and sort them
692 # Output one per line
693 $s .= implode("<br />\n", $tempout);
699 /** Render the array as a serie of links.
700 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
701 * @param &skin Object: skin passed by reference
702 * @return String separated by >, terminate with "\n"
704 function drawCategoryBrowser($tree, &$skin) {
706 foreach ($tree as $element => $parent) {
707 if (empty($parent)) {
708 # element start a new list
711 # grab the others elements
712 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
714 # add our current element to the list
715 $eltitle = Title
::NewFromText($element);
716 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
721 function getCategories() {
722 $catlinks=$this->getCategoryLinks();
724 $classes = 'catlinks';
726 if(FALSE === strpos($catlinks,'<div id="mw-normal-catlinks">')) {
727 $classes .= ' catlinks-allhidden';
730 if(!empty($catlinks)) {
731 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
735 function getQuickbarCompensator( $rows = 1 ) {
736 return "<td width='152' rowspan='{$rows}'> </td>";
740 * This gets called shortly before the \</body\> tag.
741 * @return String HTML to be put before \</body\>
743 function afterContent() {
744 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
745 return $printfooter . $this->doAfterContent();
749 * This gets called shortly before the \</body\> tag.
750 * @return String HTML-wrapped JS code to be put before \</body\>
752 function bottomScripts() {
753 global $wgJsMimeType;
754 $bottomScriptText = "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
755 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
756 return $bottomScriptText;
759 /** @return string Retrievied from HTML text */
760 function printSource() {
762 $url = htmlspecialchars( $wgTitle->getFullURL() );
763 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
766 function printFooter() {
767 return "<p>" . $this->printSource() .
768 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
771 /** overloaded by derived classes */
772 function doAfterContent() { }
774 function pageTitleLinks() {
775 global $wgOut, $wgTitle, $wgUser, $wgRequest;
777 $oldid = $wgRequest->getVal( 'oldid' );
778 $diff = $wgRequest->getVal( 'diff' );
779 $action = $wgRequest->getText( 'action' );
781 $s = $this->printableLink();
782 $disclaimer = $this->disclaimerLink(); # may be empty
784 $s .= ' | ' . $disclaimer;
786 $privacy = $this->privacyLink(); # may be empty too
788 $s .= ' | ' . $privacy;
791 if ( $wgOut->isArticleRelated() ) {
792 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
793 $name = $wgTitle->getDBkey();
794 $image = wfFindFile( $wgTitle );
796 $link = htmlspecialchars( $image->getURL() );
797 $style = $this->getInternalLinkAttributes( $link, $name );
798 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
802 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
803 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
804 wfMsg( 'currentrev' ) );
807 if ( $wgUser->getNewtalk() ) {
808 # do not show "You have new messages" text when we are viewing our
810 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
811 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
812 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
813 $s.= ' | <strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
815 $wgOut->setSquidMaxage(0);
816 $wgOut->enableClientCache(false);
820 $undelete = $this->getUndeleteLink();
821 if( !empty( $undelete ) ) {
822 $s .= ' | '.$undelete;
827 function getUndeleteLink() {
828 global $wgUser, $wgTitle, $wgContLang, $wgLang, $action;
829 if( $wgUser->isAllowed( 'deletedhistory' ) &&
830 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
831 ($n = $wgTitle->isDeleted() ) )
833 if ( $wgUser->isAllowed( 'undelete' ) ) {
834 $msg = 'thisisdeleted';
836 $msg = 'viewdeleted';
839 $this->makeKnownLinkObj(
840 SpecialPage
::getTitleFor( 'Undelete', $wgTitle->getPrefixedDBkey() ),
841 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ) ) );
846 function printableLink() {
847 global $wgOut, $wgFeedClasses, $wgRequest;
849 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
851 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
852 if( $wgOut->isSyndicated() ) {
853 foreach( $wgFeedClasses as $format => $class ) {
854 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
855 $s .= " | <a href=\"$feedurl\">{$format}</a>";
861 function pageTitle() {
863 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
867 function pageSubtitle() {
870 $sub = $wgOut->getSubtitle();
872 global $wgExtraSubtitle;
873 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
875 $subpages = $this->subPageSubtitle();
876 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
877 $s = "<p class='subtitle'>{$sub}</p>\n";
881 function subPageSubtitle() {
883 if(!wfRunHooks('SkinSubPageSubtitle', array(&$subpages)))
886 global $wgOut, $wgTitle, $wgNamespacesWithSubpages;
887 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
888 $ptext=$wgTitle->getPrefixedText();
889 if(preg_match('/\//',$ptext)) {
890 $links = explode('/',$ptext);
895 foreach($links as $link) {
896 $growinglink .= $link;
898 $linkObj = Title
::newFromText( $growinglink );
899 if( $linkObj->exists() ){
900 $getlink = $this->makeKnownLinkObj( $linkObj, htmlspecialchars( $display ) );
905 $subpages .= '< ';
907 $subpages .= $getlink;
920 * Returns true if the IP should be shown in the header
922 function showIPinHeader() {
923 global $wgShowIPinHeader;
924 return $wgShowIPinHeader && session_id() != '';
927 function nameAndLogin() {
928 global $wgUser, $wgTitle, $wgLang, $wgContLang;
930 $lo = $wgContLang->specialPage( 'Userlogout' );
933 if ( $wgUser->isAnon() ) {
934 if( $this->showIPinHeader() ) {
937 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
938 $wgLang->getNsText( NS_TALK
) );
940 $s .= $n . ' ('.$tl.')';
942 $s .= wfMsg('notloggedin');
945 $rt = $wgTitle->getPrefixedURL();
946 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
948 } else { $q = "returnto={$rt}"; }
950 $loginlink = $wgUser->isAllowed( 'createaccount' )
951 ?
'nav-login-createaccount'
953 $s .= "\n<br />" . $this->makeKnownLinkObj(
954 SpecialPage
::getTitleFor( 'Userlogin' ),
955 wfMsg( $loginlink ), $q );
957 $n = $wgUser->getName();
958 $rt = $wgTitle->getPrefixedURL();
959 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
960 $wgLang->getNsText( NS_TALK
) );
964 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
965 $n ) . "{$tl}<br />" .
966 $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
967 "returnto={$rt}" ) . ' | ' .
968 $this->specialLink( 'preferences' );
970 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
976 function getSearchLink() {
977 $searchPage = SpecialPage
::getTitleFor( 'Search' );
978 return $searchPage->getLocalURL();
981 function escapeSearchLink() {
982 return htmlspecialchars( $this->getSearchLink() );
985 function searchForm() {
987 $search = $wgRequest->getText( 'search' );
989 $s = '<form name="search" class="inline" method="post" action="'
990 . $this->escapeSearchLink() . "\">\n"
991 . '<input type="text" name="search" size="19" value="'
992 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
993 . '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" /> '
994 . '<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n</form>";
999 function topLinks() {
1003 $s = $this->mainPageLink() . $sep
1004 . $this->specialLink( 'recentchanges' );
1006 if ( $wgOut->isArticleRelated() ) {
1007 $s .= $sep . $this->editThisPage()
1008 . $sep . $this->historyLink();
1010 # Many people don't like this dropdown box
1011 #$s .= $sep . $this->specialPagesList();
1013 $s .= $this->variantLinks();
1015 $s .= $this->extensionTabLinks();
1021 * Compatibility for extensions adding functionality through tabs.
1022 * Eventually these old skins should be replaced with SkinTemplate-based
1026 function extensionTabLinks() {
1029 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1030 foreach( $tabs as $tab ) {
1031 $s .= ' | ' . Xml
::element( 'a',
1032 array( 'href' => $tab['href'] ),
1039 * Language/charset variant links for classic-style skins
1042 function variantLinks() {
1044 /* show links to different language variants */
1045 global $wgDisableLangConversion, $wgContLang, $wgTitle;
1046 $variants = $wgContLang->getVariants();
1047 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1048 foreach( $variants as $code ) {
1049 $varname = $wgContLang->getVariantname( $code );
1050 if( $varname == 'disable' )
1052 $s .= ' | <a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>';
1058 function bottomLinks() {
1059 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
1063 if ( $wgOut->isArticleRelated() ) {
1064 $s .= '<strong>' . $this->editThisPage() . '</strong>';
1065 if ( $wgUser->isLoggedIn() ) {
1066 $s .= $sep . $this->watchThisPage();
1068 $s .= $sep . $this->talkLink()
1069 . $sep . $this->historyLink()
1070 . $sep . $this->whatLinksHere()
1071 . $sep . $this->watchPageLinksLink();
1073 if ($wgUseTrackbacks)
1074 $s .= $sep . $this->trackbackLink();
1076 if ( $wgTitle->getNamespace() == NS_USER
1077 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
1080 $id=User
::idFromName($wgTitle->getText());
1081 $ip=User
::isIP($wgTitle->getText());
1083 if($id ||
$ip) { # both anons and non-anons have contri list
1084 $s .= $sep . $this->userContribsLink();
1086 if( $this->showEmailUser( $id ) ) {
1087 $s .= $sep . $this->emailUserLink();
1090 if ( $wgTitle->getArticleId() ) {
1092 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
1093 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
1094 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
1096 $s .= "<br />\n" . $this->otherLanguages();
1101 function pageStats() {
1102 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1103 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
1105 $oldid = $wgRequest->getVal( 'oldid' );
1106 $diff = $wgRequest->getVal( 'diff' );
1107 if ( ! $wgOut->isArticle() ) { return ''; }
1108 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1109 if ( 0 == $wgArticle->getID() ) { return ''; }
1112 if ( !$wgDisableCounters ) {
1113 $count = $wgLang->formatNum( $wgArticle->getCount() );
1115 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1119 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
1120 require_once('Credits.php');
1121 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
1123 $s .= $this->lastModified();
1126 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
1127 $dbr = wfGetDB( DB_SLAVE
);
1128 $watchlist = $dbr->tableName( 'watchlist' );
1129 $sql = "SELECT COUNT(*) AS n FROM $watchlist
1130 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBkey()) .
1131 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
1132 $res = $dbr->query( $sql, 'Skin::pageStats');
1133 $x = $dbr->fetchObject( $res );
1135 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1136 array( 'parseinline' ), $wgLang->formatNum($x->n
)
1140 return $s . ' ' . $this->getCopyright();
1143 function getCopyright( $type = 'detect' ) {
1144 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
1146 if ( $type == 'detect' ) {
1147 $oldid = $wgRequest->getVal( 'oldid' );
1148 $diff = $wgRequest->getVal( 'diff' );
1150 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1157 if ( $type == 'history' ) {
1158 $msg = 'history_copyright';
1164 if( $wgRightsPage ) {
1165 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
1166 } elseif( $wgRightsUrl ) {
1167 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1172 $out .= wfMsgForContent( $msg, $link );
1176 function getCopyrightIcon() {
1177 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1179 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1180 $out = $wgCopyrightIcon;
1181 } else if ( $wgRightsIcon ) {
1182 $icon = htmlspecialchars( $wgRightsIcon );
1183 if ( $wgRightsUrl ) {
1184 $url = htmlspecialchars( $wgRightsUrl );
1185 $out .= '<a href="'.$url.'">';
1187 $text = htmlspecialchars( $wgRightsText );
1188 $out .= "<img src=\"$icon\" alt='$text' />";
1189 if ( $wgRightsUrl ) {
1196 function getPoweredBy() {
1197 global $wgStylePath;
1198 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1199 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1203 function lastModified() {
1204 global $wgLang, $wgArticle;
1206 $timestamp = $wgArticle->getTimestamp();
1208 $d = $wgLang->date( $timestamp, true );
1209 $t = $wgLang->time( $timestamp, true );
1210 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1214 if ( wfGetLB()->getLaggedSlaveMode() ) {
1215 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1220 function logoText( $align = '' ) {
1221 if ( '' != $align ) { $a = " align='{$align}'"; }
1224 $mp = wfMsg( 'mainpage' );
1225 $mptitle = Title
::newMainPage();
1226 $url = ( is_object($mptitle) ?
$mptitle->escapeLocalURL() : '' );
1228 $logourl = $this->getLogo();
1229 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1234 * show a drop-down box of special pages
1236 function specialPagesList() {
1237 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1238 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1239 foreach ( $pages as $name => $page ) {
1240 $pages[$name] = $page->getDescription();
1243 $go = wfMsg( 'go' );
1244 $sp = wfMsg( 'specialpages' );
1245 $spp = $wgContLang->specialPage( 'Specialpages' );
1247 $s = '<form id="specialpages" method="get" class="inline" ' .
1248 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1249 $s .= "<select name=\"wpDropdown\">\n";
1250 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1253 foreach ( $pages as $name => $desc ) {
1254 $p = $wgContLang->specialPage( $name );
1255 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1257 $s .= "</select>\n";
1258 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1263 function mainPageLink() {
1264 $s = $this->makeKnownLinkObj( Title
::newMainPage(), wfMsg( 'mainpage' ) );
1268 function copyrightLink() {
1269 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1270 wfMsg( 'copyrightpagename' ) );
1274 private function footerLink ( $desc, $page ) {
1275 // if the link description has been set to "-" in the default language,
1276 if ( wfMsgForContent( $desc ) == '-') {
1277 // then it is disabled, for all languages.
1280 // Otherwise, we display the link for the user, described in their
1281 // language (which may or may not be the same as the default language),
1282 // but we make the link target be the one site-wide page.
1283 return $this->makeKnownLink( wfMsgForContent( $page ),
1284 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) ) );
1288 function privacyLink() {
1289 return $this->footerLink( 'privacy', 'privacypage' );
1292 function aboutLink() {
1293 return $this->footerLink( 'aboutsite', 'aboutpage' );
1296 function disclaimerLink() {
1297 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1300 function editThisPage() {
1301 global $wgOut, $wgTitle;
1303 if ( !$wgOut->isArticleRelated() ) {
1304 $s = wfMsg( 'protectedpage' );
1306 if( $wgTitle->userCan( 'edit' ) && $wgTitle->exists() ) {
1307 $t = wfMsg( 'editthispage' );
1308 } elseif( $wgTitle->userCan( 'create' ) && !$wgTitle->exists() ) {
1309 $t = wfMsg( 'create-this-page' );
1311 $t = wfMsg( 'viewsource' );
1314 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1320 * Return URL options for the 'edit page' link.
1321 * This may include an 'oldid' specifier, if the current page view is such.
1326 function editUrlOptions() {
1329 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1330 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1332 return "action=edit";
1336 function deleteThisPage() {
1337 global $wgUser, $wgTitle, $wgRequest;
1339 $diff = $wgRequest->getVal( 'diff' );
1340 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1341 $t = wfMsg( 'deletethispage' );
1343 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1350 function protectThisPage() {
1351 global $wgUser, $wgTitle, $wgRequest;
1353 $diff = $wgRequest->getVal( 'diff' );
1354 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1355 if ( $wgTitle->isProtected() ) {
1356 $t = wfMsg( 'unprotectthispage' );
1357 $q = 'action=unprotect';
1359 $t = wfMsg( 'protectthispage' );
1360 $q = 'action=protect';
1362 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1369 function watchThisPage() {
1370 global $wgOut, $wgTitle;
1371 ++
$this->mWatchLinkNum
;
1373 if ( $wgOut->isArticleRelated() ) {
1374 if ( $wgTitle->userIsWatching() ) {
1375 $t = wfMsg( 'unwatchthispage' );
1376 $q = 'action=unwatch';
1377 $id = "mw-unwatch-link".$this->mWatchLinkNum
;
1379 $t = wfMsg( 'watchthispage' );
1380 $q = 'action=watch';
1381 $id = 'mw-watch-link'.$this->mWatchLinkNum
;
1383 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q, '', '', " id=\"$id\"" );
1385 $s = wfMsg( 'notanarticle' );
1390 function moveThisPage() {
1393 if ( $wgTitle->userCan( 'move' ) ) {
1394 return $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
1395 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1397 // no message if page is protected - would be redundant
1402 function historyLink() {
1405 return $this->makeKnownLinkObj( $wgTitle,
1406 wfMsg( 'history' ), 'action=history' );
1409 function whatLinksHere() {
1412 return $this->makeKnownLinkObj(
1413 SpecialPage
::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ),
1414 wfMsg( 'whatlinkshere' ) );
1417 function userContribsLink() {
1420 return $this->makeKnownLinkObj(
1421 SpecialPage
::getTitleFor( 'Contributions', $wgTitle->getDBkey() ),
1422 wfMsg( 'contributions' ) );
1425 function showEmailUser( $id ) {
1426 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1427 return $wgEnableEmail &&
1428 $wgEnableUserEmail &&
1429 $wgUser->isLoggedIn() && # show only to signed in users
1430 0 != $id; # we can only email to non-anons ..
1431 # '' != $id->getEmail() && # who must have an email address stored ..
1432 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1433 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1436 function emailUserLink() {
1439 return $this->makeKnownLinkObj(
1440 SpecialPage
::getTitleFor( 'Emailuser', $wgTitle->getDBkey() ),
1441 wfMsg( 'emailuser' ) );
1444 function watchPageLinksLink() {
1445 global $wgOut, $wgTitle;
1447 if ( ! $wgOut->isArticleRelated() ) {
1448 return '(' . wfMsg( 'notanarticle' ) . ')';
1450 return $this->makeKnownLinkObj(
1451 SpecialPage
::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ),
1452 wfMsg( 'recentchangeslinked' ) );
1456 function trackbackLink() {
1459 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1460 . wfMsg('trackbacklink') . "</a>";
1463 function otherLanguages() {
1464 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1466 if ( $wgHideInterlanguageLinks ) {
1470 $a = $wgOut->getLanguageLinks();
1471 if ( 0 == count( $a ) ) {
1475 $s = wfMsg( 'otherlanguages' ) . ': ';
1477 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1478 foreach( $a as $l ) {
1479 if ( ! $first ) { $s .= ' | '; }
1482 $nt = Title
::newFromText( $l );
1483 $url = $nt->escapeFullURL();
1484 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1486 if ( '' == $text ) { $text = $l; }
1487 $style = $this->getExternalLinkAttributes( $l, $text );
1488 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1490 if($wgContLang->isRTL()) $s .= '</span>';
1494 function bugReportsLink() {
1495 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1496 wfMsg( 'bugreports' ) );
1500 function talkLink() {
1503 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1504 # No discussion links for special pages
1508 if( $wgTitle->isTalkPage() ) {
1509 $link = $wgTitle->getSubjectPage();
1510 switch( $link->getNamespace() ) {
1512 $text = wfMsg( 'articlepage' );
1515 $text = wfMsg( 'userpage' );
1518 $text = wfMsg( 'projectpage' );
1521 $text = wfMsg( 'imagepage' );
1524 $text = wfMsg( 'mediawikipage' );
1527 $text = wfMsg( 'templatepage' );
1530 $text = wfMsg( 'viewhelppage' );
1533 $text = wfMsg( 'categorypage' );
1536 $text = wfMsg( 'articlepage' );
1539 $link = $wgTitle->getTalkPage();
1540 $text = wfMsg( 'talkpage' );
1543 $s = $this->makeLinkObj( $link, $text );
1548 function commentLink() {
1549 global $wgTitle, $wgOut;
1551 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1555 # __NEWSECTIONLINK___ changes behaviour here
1556 # If it's present, the link points to this page, otherwise
1557 # it points to the talk page
1558 if( $wgTitle->isTalkPage() ) {
1560 } elseif( $wgOut->showNewSectionLink() ) {
1563 $title = $wgTitle->getTalkPage();
1566 return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1569 /* these are used extensively in SkinTemplate, but also some other places */
1570 static function makeMainPageUrl( $urlaction = '' ) {
1571 $title = Title
::newMainPage();
1572 self
::checkTitle( $title, '' );
1573 return $title->getLocalURL( $urlaction );
1576 static function makeSpecialUrl( $name, $urlaction = '' ) {
1577 $title = SpecialPage
::getTitleFor( $name );
1578 return $title->getLocalURL( $urlaction );
1581 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1582 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1583 return $title->getLocalURL( $urlaction );
1586 static function makeI18nUrl( $name, $urlaction = '' ) {
1587 $title = Title
::newFromText( wfMsgForContent( $name ) );
1588 self
::checkTitle( $title, $name );
1589 return $title->getLocalURL( $urlaction );
1592 static function makeUrl( $name, $urlaction = '' ) {
1593 $title = Title
::newFromText( $name );
1594 self
::checkTitle( $title, $name );
1595 return $title->getLocalURL( $urlaction );
1598 # If url string starts with http, consider as external URL, else
1600 static function makeInternalOrExternalUrl( $name ) {
1601 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1604 return self
::makeUrl( $name );
1608 # this can be passed the NS number as defined in Language.php
1609 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1610 $title = Title
::makeTitleSafe( $namespace, $name );
1611 self
::checkTitle( $title, $name );
1612 return $title->getLocalURL( $urlaction );
1615 /* these return an array with the 'href' and boolean 'exists' */
1616 static function makeUrlDetails( $name, $urlaction = '' ) {
1617 $title = Title
::newFromText( $name );
1618 self
::checkTitle( $title, $name );
1620 'href' => $title->getLocalURL( $urlaction ),
1621 'exists' => $title->getArticleID() != 0 ?
true : false
1626 * Make URL details where the article exists (or at least it's convenient to think so)
1628 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1629 $title = Title
::newFromText( $name );
1630 self
::checkTitle( $title, $name );
1632 'href' => $title->getLocalURL( $urlaction ),
1637 # make sure we have some title to operate on
1638 static function checkTitle( &$title, $name ) {
1639 if( !is_object( $title ) ) {
1640 $title = Title
::newFromText( $name );
1641 if( !is_object( $title ) ) {
1642 $title = Title
::newFromText( '--error: link target missing--' );
1648 * Build an array that represents the sidebar(s), the navigation bar among them
1653 function buildSidebar() {
1654 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
1655 global $wgLang, $wgContLang;
1657 $fname = 'SkinTemplate::buildSidebar';
1659 wfProfileIn( $fname );
1661 $key = wfMemcKey( 'sidebar' );
1662 $cacheSidebar = $wgEnableSidebarCache &&
1663 ($wgLang->getCode() == $wgContLang->getCode());
1665 if ($cacheSidebar) {
1666 $cachedsidebar = $parserMemc->get( $key );
1667 if ($cachedsidebar!="") {
1668 wfProfileOut($fname);
1669 return $cachedsidebar;
1674 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1676 foreach ($lines as $line) {
1677 if (strpos($line, '*') !== 0)
1679 if (strpos($line, '**') !== 0) {
1680 $line = trim($line, '* ');
1683 if (strpos($line, '|') !== false) { // sanity check
1684 $line = explode( '|' , trim($line, '* '), 2 );
1685 $link = wfMsgForContent( $line[0] );
1688 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1690 if (wfEmptyMsg($line[0], $link))
1693 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1696 $title = Title
::newFromText( $link );
1698 $title = $title->fixSpecialName();
1699 $href = $title->getLocalURL();
1701 $href = 'INVALID-TITLE';
1705 $bar[$heading][] = array(
1708 'id' => 'n-' . strtr($line[1], ' ', '-'),
1711 } else { continue; }
1715 $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
1716 wfProfileOut( $fname );