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);
893 foreach($links as $link) {
895 if ($c<count($links)) {
896 $growinglink .= $link;
897 $getlink = $this->makeLink( $growinglink, htmlspecialchars( $link ) );
898 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
902 $subpages .= '< ';
904 $subpages .= $getlink;
914 * Returns true if the IP should be shown in the header
916 function showIPinHeader() {
917 global $wgShowIPinHeader;
918 return $wgShowIPinHeader && session_id() != '';
921 function nameAndLogin() {
922 global $wgUser, $wgTitle, $wgLang, $wgContLang;
924 $lo = $wgContLang->specialPage( 'Userlogout' );
927 if ( $wgUser->isAnon() ) {
928 if( $this->showIPinHeader() ) {
931 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
932 $wgLang->getNsText( NS_TALK
) );
934 $s .= $n . ' ('.$tl.')';
936 $s .= wfMsg('notloggedin');
939 $rt = $wgTitle->getPrefixedURL();
940 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
942 } else { $q = "returnto={$rt}"; }
944 $loginlink = $wgUser->isAllowed( 'createaccount' )
945 ?
'nav-login-createaccount'
947 $s .= "\n<br />" . $this->makeKnownLinkObj(
948 SpecialPage
::getTitleFor( 'Userlogin' ),
949 wfMsg( $loginlink ), $q );
951 $n = $wgUser->getName();
952 $rt = $wgTitle->getPrefixedURL();
953 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
954 $wgLang->getNsText( NS_TALK
) );
958 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
959 $n ) . "{$tl}<br />" .
960 $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
961 "returnto={$rt}" ) . ' | ' .
962 $this->specialLink( 'preferences' );
964 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
970 function getSearchLink() {
971 $searchPage = SpecialPage
::getTitleFor( 'Search' );
972 return $searchPage->getLocalURL();
975 function escapeSearchLink() {
976 return htmlspecialchars( $this->getSearchLink() );
979 function searchForm() {
981 $search = $wgRequest->getText( 'search' );
983 $s = '<form name="search" class="inline" method="post" action="'
984 . $this->escapeSearchLink() . "\">\n"
985 . '<input type="text" name="search" size="19" value="'
986 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
987 . '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" /> '
988 . '<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n</form>";
993 function topLinks() {
997 $s = $this->mainPageLink() . $sep
998 . $this->specialLink( 'recentchanges' );
1000 if ( $wgOut->isArticleRelated() ) {
1001 $s .= $sep . $this->editThisPage()
1002 . $sep . $this->historyLink();
1004 # Many people don't like this dropdown box
1005 #$s .= $sep . $this->specialPagesList();
1007 $s .= $this->variantLinks();
1009 $s .= $this->extensionTabLinks();
1015 * Compatibility for extensions adding functionality through tabs.
1016 * Eventually these old skins should be replaced with SkinTemplate-based
1020 function extensionTabLinks() {
1023 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1024 foreach( $tabs as $tab ) {
1025 $s .= ' | ' . Xml
::element( 'a',
1026 array( 'href' => $tab['href'] ),
1033 * Language/charset variant links for classic-style skins
1036 function variantLinks() {
1038 /* show links to different language variants */
1039 global $wgDisableLangConversion, $wgContLang, $wgTitle;
1040 $variants = $wgContLang->getVariants();
1041 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1042 foreach( $variants as $code ) {
1043 $varname = $wgContLang->getVariantname( $code );
1044 if( $varname == 'disable' )
1046 $s .= ' | <a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>';
1052 function bottomLinks() {
1053 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
1057 if ( $wgOut->isArticleRelated() ) {
1058 $s .= '<strong>' . $this->editThisPage() . '</strong>';
1059 if ( $wgUser->isLoggedIn() ) {
1060 $s .= $sep . $this->watchThisPage();
1062 $s .= $sep . $this->talkLink()
1063 . $sep . $this->historyLink()
1064 . $sep . $this->whatLinksHere()
1065 . $sep . $this->watchPageLinksLink();
1067 if ($wgUseTrackbacks)
1068 $s .= $sep . $this->trackbackLink();
1070 if ( $wgTitle->getNamespace() == NS_USER
1071 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
1074 $id=User
::idFromName($wgTitle->getText());
1075 $ip=User
::isIP($wgTitle->getText());
1077 if($id ||
$ip) { # both anons and non-anons have contri list
1078 $s .= $sep . $this->userContribsLink();
1080 if( $this->showEmailUser( $id ) ) {
1081 $s .= $sep . $this->emailUserLink();
1084 if ( $wgTitle->getArticleId() ) {
1086 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
1087 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
1088 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
1090 $s .= "<br />\n" . $this->otherLanguages();
1095 function pageStats() {
1096 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1097 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
1099 $oldid = $wgRequest->getVal( 'oldid' );
1100 $diff = $wgRequest->getVal( 'diff' );
1101 if ( ! $wgOut->isArticle() ) { return ''; }
1102 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1103 if ( 0 == $wgArticle->getID() ) { return ''; }
1106 if ( !$wgDisableCounters ) {
1107 $count = $wgLang->formatNum( $wgArticle->getCount() );
1109 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1113 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
1114 require_once('Credits.php');
1115 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
1117 $s .= $this->lastModified();
1120 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
1121 $dbr = wfGetDB( DB_SLAVE
);
1122 $watchlist = $dbr->tableName( 'watchlist' );
1123 $sql = "SELECT COUNT(*) AS n FROM $watchlist
1124 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBkey()) .
1125 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
1126 $res = $dbr->query( $sql, 'Skin::pageStats');
1127 $x = $dbr->fetchObject( $res );
1129 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1130 array( 'parseinline' ), $wgLang->formatNum($x->n
)
1134 return $s . ' ' . $this->getCopyright();
1137 function getCopyright( $type = 'detect' ) {
1138 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
1140 if ( $type == 'detect' ) {
1141 $oldid = $wgRequest->getVal( 'oldid' );
1142 $diff = $wgRequest->getVal( 'diff' );
1144 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1151 if ( $type == 'history' ) {
1152 $msg = 'history_copyright';
1158 if( $wgRightsPage ) {
1159 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
1160 } elseif( $wgRightsUrl ) {
1161 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1166 $out .= wfMsgForContent( $msg, $link );
1170 function getCopyrightIcon() {
1171 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1173 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1174 $out = $wgCopyrightIcon;
1175 } else if ( $wgRightsIcon ) {
1176 $icon = htmlspecialchars( $wgRightsIcon );
1177 if ( $wgRightsUrl ) {
1178 $url = htmlspecialchars( $wgRightsUrl );
1179 $out .= '<a href="'.$url.'">';
1181 $text = htmlspecialchars( $wgRightsText );
1182 $out .= "<img src=\"$icon\" alt='$text' />";
1183 if ( $wgRightsUrl ) {
1190 function getPoweredBy() {
1191 global $wgStylePath;
1192 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1193 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1197 function lastModified() {
1198 global $wgLang, $wgArticle;
1200 $timestamp = $wgArticle->getTimestamp();
1202 $d = $wgLang->date( $timestamp, true );
1203 $t = $wgLang->time( $timestamp, true );
1204 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1208 if ( wfGetLB()->getLaggedSlaveMode() ) {
1209 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1214 function logoText( $align = '' ) {
1215 if ( '' != $align ) { $a = " align='{$align}'"; }
1218 $mp = wfMsg( 'mainpage' );
1219 $mptitle = Title
::newMainPage();
1220 $url = ( is_object($mptitle) ?
$mptitle->escapeLocalURL() : '' );
1222 $logourl = $this->getLogo();
1223 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1228 * show a drop-down box of special pages
1230 function specialPagesList() {
1231 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1232 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1233 foreach ( $pages as $name => $page ) {
1234 $pages[$name] = $page->getDescription();
1237 $go = wfMsg( 'go' );
1238 $sp = wfMsg( 'specialpages' );
1239 $spp = $wgContLang->specialPage( 'Specialpages' );
1241 $s = '<form id="specialpages" method="get" class="inline" ' .
1242 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1243 $s .= "<select name=\"wpDropdown\">\n";
1244 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1247 foreach ( $pages as $name => $desc ) {
1248 $p = $wgContLang->specialPage( $name );
1249 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1251 $s .= "</select>\n";
1252 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1257 function mainPageLink() {
1258 $s = $this->makeKnownLinkObj( Title
::newMainPage(), wfMsg( 'mainpage' ) );
1262 function copyrightLink() {
1263 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1264 wfMsg( 'copyrightpagename' ) );
1268 private function footerLink ( $desc, $page ) {
1269 // if the link description has been set to "-" in the default language,
1270 if ( wfMsgForContent( $desc ) == '-') {
1271 // then it is disabled, for all languages.
1274 // Otherwise, we display the link for the user, described in their
1275 // language (which may or may not be the same as the default language),
1276 // but we make the link target be the one site-wide page.
1277 return $this->makeKnownLink( wfMsgForContent( $page ),
1278 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) ) );
1282 function privacyLink() {
1283 return $this->footerLink( 'privacy', 'privacypage' );
1286 function aboutLink() {
1287 return $this->footerLink( 'aboutsite', 'aboutpage' );
1290 function disclaimerLink() {
1291 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1294 function editThisPage() {
1295 global $wgOut, $wgTitle;
1297 if ( !$wgOut->isArticleRelated() ) {
1298 $s = wfMsg( 'protectedpage' );
1300 if( $wgTitle->userCan( 'edit' ) && $wgTitle->exists() ) {
1301 $t = wfMsg( 'editthispage' );
1302 } elseif( $wgTitle->userCan( 'create' ) && !$wgTitle->exists() ) {
1303 $t = wfMsg( 'create-this-page' );
1305 $t = wfMsg( 'viewsource' );
1308 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1314 * Return URL options for the 'edit page' link.
1315 * This may include an 'oldid' specifier, if the current page view is such.
1320 function editUrlOptions() {
1323 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1324 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1326 return "action=edit";
1330 function deleteThisPage() {
1331 global $wgUser, $wgTitle, $wgRequest;
1333 $diff = $wgRequest->getVal( 'diff' );
1334 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1335 $t = wfMsg( 'deletethispage' );
1337 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1344 function protectThisPage() {
1345 global $wgUser, $wgTitle, $wgRequest;
1347 $diff = $wgRequest->getVal( 'diff' );
1348 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1349 if ( $wgTitle->isProtected() ) {
1350 $t = wfMsg( 'unprotectthispage' );
1351 $q = 'action=unprotect';
1353 $t = wfMsg( 'protectthispage' );
1354 $q = 'action=protect';
1356 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1363 function watchThisPage() {
1364 global $wgOut, $wgTitle;
1365 ++
$this->mWatchLinkNum
;
1367 if ( $wgOut->isArticleRelated() ) {
1368 if ( $wgTitle->userIsWatching() ) {
1369 $t = wfMsg( 'unwatchthispage' );
1370 $q = 'action=unwatch';
1371 $id = "mw-unwatch-link".$this->mWatchLinkNum
;
1373 $t = wfMsg( 'watchthispage' );
1374 $q = 'action=watch';
1375 $id = 'mw-watch-link'.$this->mWatchLinkNum
;
1377 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q, '', '', " id=\"$id\"" );
1379 $s = wfMsg( 'notanarticle' );
1384 function moveThisPage() {
1387 if ( $wgTitle->userCan( 'move' ) ) {
1388 return $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
1389 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1391 // no message if page is protected - would be redundant
1396 function historyLink() {
1399 return $this->makeKnownLinkObj( $wgTitle,
1400 wfMsg( 'history' ), 'action=history' );
1403 function whatLinksHere() {
1406 return $this->makeKnownLinkObj(
1407 SpecialPage
::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ),
1408 wfMsg( 'whatlinkshere' ) );
1411 function userContribsLink() {
1414 return $this->makeKnownLinkObj(
1415 SpecialPage
::getTitleFor( 'Contributions', $wgTitle->getDBkey() ),
1416 wfMsg( 'contributions' ) );
1419 function showEmailUser( $id ) {
1420 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1421 return $wgEnableEmail &&
1422 $wgEnableUserEmail &&
1423 $wgUser->isLoggedIn() && # show only to signed in users
1424 0 != $id; # we can only email to non-anons ..
1425 # '' != $id->getEmail() && # who must have an email address stored ..
1426 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1427 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1430 function emailUserLink() {
1433 return $this->makeKnownLinkObj(
1434 SpecialPage
::getTitleFor( 'Emailuser', $wgTitle->getDBkey() ),
1435 wfMsg( 'emailuser' ) );
1438 function watchPageLinksLink() {
1439 global $wgOut, $wgTitle;
1441 if ( ! $wgOut->isArticleRelated() ) {
1442 return '(' . wfMsg( 'notanarticle' ) . ')';
1444 return $this->makeKnownLinkObj(
1445 SpecialPage
::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ),
1446 wfMsg( 'recentchangeslinked' ) );
1450 function trackbackLink() {
1453 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1454 . wfMsg('trackbacklink') . "</a>";
1457 function otherLanguages() {
1458 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1460 if ( $wgHideInterlanguageLinks ) {
1464 $a = $wgOut->getLanguageLinks();
1465 if ( 0 == count( $a ) ) {
1469 $s = wfMsg( 'otherlanguages' ) . ': ';
1471 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1472 foreach( $a as $l ) {
1473 if ( ! $first ) { $s .= ' | '; }
1476 $nt = Title
::newFromText( $l );
1477 $url = $nt->escapeFullURL();
1478 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1480 if ( '' == $text ) { $text = $l; }
1481 $style = $this->getExternalLinkAttributes( $l, $text );
1482 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1484 if($wgContLang->isRTL()) $s .= '</span>';
1488 function bugReportsLink() {
1489 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1490 wfMsg( 'bugreports' ) );
1494 function talkLink() {
1497 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1498 # No discussion links for special pages
1502 if( $wgTitle->isTalkPage() ) {
1503 $link = $wgTitle->getSubjectPage();
1504 switch( $link->getNamespace() ) {
1506 $text = wfMsg( 'articlepage' );
1509 $text = wfMsg( 'userpage' );
1512 $text = wfMsg( 'projectpage' );
1515 $text = wfMsg( 'imagepage' );
1518 $text = wfMsg( 'mediawikipage' );
1521 $text = wfMsg( 'templatepage' );
1524 $text = wfMsg( 'viewhelppage' );
1527 $text = wfMsg( 'categorypage' );
1530 $text = wfMsg( 'articlepage' );
1533 $link = $wgTitle->getTalkPage();
1534 $text = wfMsg( 'talkpage' );
1537 $s = $this->makeLinkObj( $link, $text );
1542 function commentLink() {
1543 global $wgTitle, $wgOut;
1545 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1549 # __NEWSECTIONLINK___ changes behaviour here
1550 # If it's present, the link points to this page, otherwise
1551 # it points to the talk page
1552 if( $wgTitle->isTalkPage() ) {
1554 } elseif( $wgOut->showNewSectionLink() ) {
1557 $title = $wgTitle->getTalkPage();
1560 return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1563 /* these are used extensively in SkinTemplate, but also some other places */
1564 static function makeMainPageUrl( $urlaction = '' ) {
1565 $title = Title
::newMainPage();
1566 self
::checkTitle( $title, '' );
1567 return $title->getLocalURL( $urlaction );
1570 static function makeSpecialUrl( $name, $urlaction = '' ) {
1571 $title = SpecialPage
::getTitleFor( $name );
1572 return $title->getLocalURL( $urlaction );
1575 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1576 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1577 return $title->getLocalURL( $urlaction );
1580 static function makeI18nUrl( $name, $urlaction = '' ) {
1581 $title = Title
::newFromText( wfMsgForContent( $name ) );
1582 self
::checkTitle( $title, $name );
1583 return $title->getLocalURL( $urlaction );
1586 static function makeUrl( $name, $urlaction = '' ) {
1587 $title = Title
::newFromText( $name );
1588 self
::checkTitle( $title, $name );
1589 return $title->getLocalURL( $urlaction );
1592 # If url string starts with http, consider as external URL, else
1594 static function makeInternalOrExternalUrl( $name ) {
1595 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1598 return self
::makeUrl( $name );
1602 # this can be passed the NS number as defined in Language.php
1603 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1604 $title = Title
::makeTitleSafe( $namespace, $name );
1605 self
::checkTitle( $title, $name );
1606 return $title->getLocalURL( $urlaction );
1609 /* these return an array with the 'href' and boolean 'exists' */
1610 static function makeUrlDetails( $name, $urlaction = '' ) {
1611 $title = Title
::newFromText( $name );
1612 self
::checkTitle( $title, $name );
1614 'href' => $title->getLocalURL( $urlaction ),
1615 'exists' => $title->getArticleID() != 0 ?
true : false
1620 * Make URL details where the article exists (or at least it's convenient to think so)
1622 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1623 $title = Title
::newFromText( $name );
1624 self
::checkTitle( $title, $name );
1626 'href' => $title->getLocalURL( $urlaction ),
1631 # make sure we have some title to operate on
1632 static function checkTitle( &$title, $name ) {
1633 if( !is_object( $title ) ) {
1634 $title = Title
::newFromText( $name );
1635 if( !is_object( $title ) ) {
1636 $title = Title
::newFromText( '--error: link target missing--' );
1642 * Build an array that represents the sidebar(s), the navigation bar among them
1647 function buildSidebar() {
1648 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
1649 global $wgLang, $wgContLang;
1651 $fname = 'SkinTemplate::buildSidebar';
1653 wfProfileIn( $fname );
1655 $key = wfMemcKey( 'sidebar' );
1656 $cacheSidebar = $wgEnableSidebarCache &&
1657 ($wgLang->getCode() == $wgContLang->getCode());
1659 if ($cacheSidebar) {
1660 $cachedsidebar = $parserMemc->get( $key );
1661 if ($cachedsidebar!="") {
1662 wfProfileOut($fname);
1663 return $cachedsidebar;
1668 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1670 foreach ($lines as $line) {
1671 if (strpos($line, '*') !== 0)
1673 if (strpos($line, '**') !== 0) {
1674 $line = trim($line, '* ');
1677 if (strpos($line, '|') !== false) { // sanity check
1678 $line = explode( '|' , trim($line, '* '), 2 );
1679 $link = wfMsgForContent( $line[0] );
1682 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1684 if (wfEmptyMsg($line[0], $link))
1687 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1690 $title = Title
::newFromText( $link );
1692 $title = $title->fixSpecialName();
1693 $href = $title->getLocalURL();
1695 $href = 'INVALID-TITLE';
1699 $bar[$heading][] = array(
1702 'id' => 'n-' . strtr($line[1], ' ', '-'),
1705 } else { continue; }
1709 $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
1710 wfProfileOut( $fname );