3 * @defgroup Skins Skins
6 if ( ! defined( 'MEDIAWIKI' ) )
10 * The main skin class that provide methods and properties for all other skins.
11 * This base class is also the "Standard" skin.
13 * See docs/skin.txt for more information.
17 class Skin
extends Linker
{
21 var $mWatchLinkNum = 0; // Appended to end of watch link id's
22 // How many search boxes have we made? Avoid duplicate id's.
23 protected $searchboxes = '';
25 protected $mRevisionId; // The revision ID we're looking at, null if not applicable.
26 protected $skinname = 'standard' ;
28 /** Constructor, call parent constructor */
29 function Skin() { parent
::__construct(); }
32 * Fetch the set of available skins.
33 * @return array of strings
36 static function getSkinNames() {
37 global $wgValidSkinNames;
38 static $skinsInitialised = false;
39 if ( !$skinsInitialised ) {
40 # Get a list of available skins
41 # Build using the regular expression '^(.*).php$'
42 # Array keys are all lower case, array value keep the case used by filename
44 wfProfileIn( __METHOD__
. '-init' );
45 global $wgStyleDirectory;
46 $skinDir = dir( $wgStyleDirectory );
48 # while code from www.php.net
49 while (false !== ($file = $skinDir->read())) {
50 // Skip non-PHP files, hidden files, and '.dep' includes
52 if(preg_match('/^([^.]*)\.php$/',$file, $matches)) {
54 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
58 $skinsInitialised = true;
59 wfProfileOut( __METHOD__
. '-init' );
61 return $wgValidSkinNames;
65 * Fetch the list of usable skins in regards to $wgSkipSkins.
66 * Useful for Special:Preferences and other places where you
67 * only want to show skins users _can_ use.
68 * @return array of strings
70 public static function getUsableSkins() {
72 $usableSkins = self
::getSkinNames();
73 foreach ( $wgSkipSkins as $skip ) {
74 unset( $usableSkins[$skip] );
80 * Normalize a skin preference value to a form that can be loaded.
81 * If a skin can't be found, it will fall back to the configured
82 * default (or the old 'Classic' skin if that's broken).
87 static function normalizeKey( $key ) {
88 global $wgDefaultSkin;
89 $skinNames = Skin
::getSkinNames();
92 // Don't return the default immediately;
93 // in a misconfiguration we need to fall back.
94 $key = $wgDefaultSkin;
97 if( isset( $skinNames[$key] ) ) {
101 // Older versions of the software used a numeric setting
102 // in the user preferences.
106 2 => 'cologneblue' );
108 if( isset( $fallback[$key] ) ){
109 $key = $fallback[$key];
112 if( isset( $skinNames[$key] ) ) {
120 * Factory method for loading a skin of a given type
121 * @param string $key 'monobook', 'standard', etc
125 static function &newFromKey( $key ) {
126 global $wgStyleDirectory;
128 $key = Skin
::normalizeKey( $key );
130 $skinNames = Skin
::getSkinNames();
131 $skinName = $skinNames[$key];
132 $className = 'Skin'.ucfirst($key);
134 # Grab the skin class and initialise it.
135 if ( !class_exists( $className ) ) {
136 // Preload base classes to work around APC/PHP5 bug
137 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
138 if( file_exists( $deps ) ) include_once( $deps );
139 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
141 # Check if we got if not failback to default skin
142 if( !class_exists( $className ) ) {
143 # DO NOT die if the class isn't found. This breaks maintenance
144 # scripts and can cause a user account to be unrecoverable
145 # except by SQL manipulation if a previously valid skin name
146 # is no longer valid.
147 wfDebug( "Skin class does not exist: $className\n" );
148 $className = 'SkinMonobook';
149 require_once( "{$wgStyleDirectory}/MonoBook.php" );
152 $skin = new $className;
156 /** @return string path to the skin stylesheet */
157 function getStylesheet() {
158 return 'common/wikistandard.css';
161 /** @return string skin name */
162 public function getSkinName() {
163 return $this->skinname
;
166 function qbSetting() {
167 global $wgOut, $wgUser;
169 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
170 $q = $wgUser->getOption( 'quickbar', 0 );
174 function initPage( OutputPage
$out ) {
175 global $wgFavicon, $wgAppleTouchIcon;
177 wfProfileIn( __METHOD__
);
179 if( false !== $wgFavicon ) {
180 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
183 if( false !== $wgAppleTouchIcon ) {
184 $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
187 # OpenSearch description link
188 $out->addLink( array(
190 'type' => 'application/opensearchdescription+xml',
191 'href' => wfScript( 'opensearch_desc' ),
192 'title' => wfMsgForContent( 'opensearch-desc' ),
195 $this->addMetadataLinks($out);
197 $this->mRevisionId
= $out->mRevisionId
;
199 $this->preloadExistence();
201 wfProfileOut( __METHOD__
);
205 * Preload the existence of three commonly-requested pages in a single query
207 function preloadExistence() {
208 global $wgUser, $wgTitle;
211 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
214 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
216 } elseif ( $wgTitle->isTalkPage() ) {
217 $titles[] = $wgTitle->getSubjectPage();
219 $titles[] = $wgTitle->getTalkPage();
222 $lb = new LinkBatch( $titles );
226 function addMetadataLinks( OutputPage
$out ) {
227 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
228 global $wgRightsPage, $wgRightsUrl;
230 if( $out->isArticleRelated() ) {
231 # note: buggy CC software only reads first "meta" link
232 if( $wgEnableCreativeCommonsRdf ) {
233 $out->addMetadataLink( array(
234 'title' => 'Creative Commons',
235 'type' => 'application/rdf+xml',
236 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
238 if( $wgEnableDublinCoreRdf ) {
239 $out->addMetadataLink( array(
240 'title' => 'Dublin Core',
241 'type' => 'application/rdf+xml',
242 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
246 if( $wgRightsPage ) {
247 $copy = Title
::newFromText( $wgRightsPage );
249 $copyright = $copy->getLocalURL();
252 if( !$copyright && $wgRightsUrl ) {
253 $copyright = $wgRightsUrl;
256 $out->addLink( array(
257 'rel' => 'copyright',
258 'href' => $copyright ) );
262 function setMembers(){
263 global $wgTitle, $wgUser;
264 $this->mTitle
= $wgTitle;
265 $this->mUser
= $wgUser;
266 $this->userpage
= $wgUser->getUserPage()->getPrefixedText();
267 $this->usercss
= false;
270 function outputPage( OutputPage
$out ) {
271 global $wgDebugComments;
272 wfProfileIn( __METHOD__
);
275 $this->initPage( $out );
277 // See self::afterContentHook() for documentation
278 $afterContent = $this->afterContentHook();
280 $out->out( $out->headElement( $this ) );
282 $out->out( "\n<body" );
283 $ops = $this->getBodyOptions();
284 foreach ( $ops as $name => $val ) {
285 $out->out( " $name='$val'" );
288 if ( $wgDebugComments ) {
289 $out->out( "<!-- Wiki debugging output:\n" .
290 $out->mDebugtext
. "-->\n" );
293 $out->out( $this->beforeContent() );
295 $out->out( $out->mBodytext
. "\n" );
297 $out->out( $this->afterContent() );
299 $out->out( $afterContent );
301 $out->out( $this->bottomScripts() );
303 $out->out( wfReportTime() );
305 $out->out( "\n</body></html>" );
306 wfProfileOut( __METHOD__
);
309 static function makeVariablesScript( $data ) {
310 global $wgJsMimeType;
312 $r = array( "<script type= \"$wgJsMimeType\">/*<![CDATA[*/" );
313 foreach ( $data as $name => $value ) {
314 $encValue = Xml
::encodeJsVar( $value );
315 $r[] = "var $name = $encValue;";
317 $r[] = "/*]]>*/</script>\n";
319 return implode( "\n\t\t", $r );
323 * Make a <script> tag containing global variables
324 * @param array $data Associative array containing one element:
325 * skinname => the skin name
326 * The odd calling convention is for backwards compatibility
328 static function makeGlobalVariablesScript( $data ) {
329 global $wgScript, $wgStylePath, $wgUser;
330 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
331 global $wgTitle, $wgCanonicalNamespaceNames, $wgOut, $wgArticle;
332 global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
333 global $wgUseAjax, $wgAjaxWatch;
334 global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
335 global $wgRestrictionTypes, $wgLivePreview;
336 global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
338 $ns = $wgTitle->getNamespace();
339 $nsname = isset( $wgCanonicalNamespaceNames[ $ns ] ) ?
$wgCanonicalNamespaceNames[ $ns ] : $wgTitle->getNsText();
342 'skin' => $data['skinname'],
343 'stylepath' => $wgStylePath,
344 'wgArticlePath' => $wgArticlePath,
345 'wgScriptPath' => $wgScriptPath,
346 'wgScript' => $wgScript,
347 'wgVariantArticlePath' => $wgVariantArticlePath,
348 'wgActionPaths' => (object)$wgActionPaths,
349 'wgServer' => $wgServer,
350 'wgCanonicalNamespace' => $nsname,
351 'wgCanonicalSpecialPageName' => SpecialPage
::resolveAlias( $wgTitle->getDBkey() ),
352 'wgNamespaceNumber' => $wgTitle->getNamespace(),
353 'wgPageName' => $wgTitle->getPrefixedDBKey(),
354 'wgTitle' => $wgTitle->getText(),
355 'wgAction' => $wgRequest->getText( 'action', 'view' ),
356 'wgArticleId' => $wgTitle->getArticleId(),
357 'wgIsArticle' => $wgOut->isArticle(),
358 'wgUserName' => $wgUser->isAnon() ?
NULL : $wgUser->getName(),
359 'wgUserGroups' => $wgUser->isAnon() ?
NULL : $wgUser->getEffectiveGroups(),
360 'wgUserLanguage' => $wgLang->getCode(),
361 'wgContentLanguage' => $wgContLang->getCode(),
362 'wgBreakFrames' => $wgBreakFrames,
363 'wgCurRevisionId' => isset( $wgArticle ) ?
$wgArticle->getLatest() : 0,
364 'wgVersion' => $wgVersion,
365 'wgEnableAPI' => $wgEnableAPI,
366 'wgEnableWriteAPI' => $wgEnableWriteAPI,
369 if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false )){
370 $vars['wgMWSuggestTemplate'] = SearchEngine
::getMWSuggestTemplate();
371 $vars['wgDBname'] = $wgDBname;
372 $vars['wgSearchNamespaces'] = SearchEngine
::userNamespaces( $wgUser );
373 $vars['wgMWSuggestMessages'] = array( wfMsg('search-mwsuggest-enabled'), wfMsg('search-mwsuggest-disabled'));
376 foreach( $wgRestrictionTypes as $type )
377 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
379 if ( $wgLivePreview && $wgUser->getOption( 'uselivepreview' ) ) {
380 $vars['wgLivepreviewMessageLoading'] = wfMsg( 'livepreview-loading' );
381 $vars['wgLivepreviewMessageReady'] = wfMsg( 'livepreview-ready' );
382 $vars['wgLivepreviewMessageFailed'] = wfMsg( 'livepreview-failed' );
383 $vars['wgLivepreviewMessageError'] = wfMsg( 'livepreview-error' );
386 if($wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
387 $msgs = (object)array();
388 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching' ) as $msgName ) {
389 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
391 $vars['wgAjaxWatch'] = $msgs;
394 wfRunHooks('MakeGlobalVariablesScript', array(&$vars));
396 return self
::makeVariablesScript( $vars );
399 function getHeadScripts( $allowUserJs ) {
400 global $wgStylePath, $wgUser, $wgJsMimeType, $wgStyleVersion;
402 $vars = self
::makeGlobalVariablesScript( array( 'skinname' => $this->getSkinName() ) );
404 $r = array( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>" );
407 $jsCache = $wgUser->isLoggedIn() ?
'&smaxage=0' : '';
408 $r[] = "<script type=\"$wgJsMimeType\" src=\"".
409 htmlspecialchars(self
::makeUrl('-',
410 "action=raw$jsCache&gen=js&useskin=" .
411 urlencode( $this->getSkinName() ) ) ) .
412 "\"><!-- site js --></script>";
414 if( $allowUserJs && $wgUser->isLoggedIn() ) {
415 $userpage = $wgUser->getUserPage();
416 $userjs = htmlspecialchars( self
::makeUrl(
417 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
418 'action=raw&ctype='.$wgJsMimeType));
419 $r[] = '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>";
421 return $vars . "\t\t" . implode ( "\n\t\t", $r );
425 * To make it harder for someone to slip a user a fake
426 * user-JavaScript or user-CSS preview, a random token
427 * is associated with the login session. If it's not
428 * passed back with the preview request, we won't render
431 * @param string $action
435 function userCanPreview( $action ) {
436 global $wgTitle, $wgRequest, $wgUser;
438 if( $action != 'submit' )
440 if( !$wgRequest->wasPosted() )
442 if( !$wgTitle->userCanEditCssJsSubpage() )
444 return $wgUser->matchEditToken(
445 $wgRequest->getVal( 'wpEditToken' ) );
449 * generated JavaScript action=raw&gen=js
450 * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
451 * nated together. For some bizarre reason, it does *not* return any
452 * custom user JS from subpages. Huh?
454 * There's absolutely no reason to have separate Monobook/Common JSes.
455 * Any JS that cares can just check the skin variable generated at the
456 * top. For now Monobook.js will be maintained, but it should be consi-
461 public function generateUserJs() {
464 wfProfileIn( __METHOD__
);
466 $s = "/* generated javascript */\n";
467 $s .= "var skin = '" . Xml
::escapeJsString( $this->getSkinName() ) . "';\n";
468 $s .= "var stylepath = '" . Xml
::escapeJsString( $wgStylePath ) . "';";
469 $s .= "\n\n/* MediaWiki:Common.js */\n";
470 $commonJs = wfMsgForContent('common.js');
471 if ( !wfEmptyMsg ( 'common.js', $commonJs ) ) {
475 $s .= "\n\n/* MediaWiki:".ucfirst( $this->getSkinName() ).".js */\n";
476 // avoid inclusion of non defined user JavaScript (with custom skins only)
477 // by checking for default message content
478 $msgKey = ucfirst( $this->getSkinName() ).'.js';
479 $userJS = wfMsgForContent($msgKey);
480 if ( !wfEmptyMsg( $msgKey, $userJS ) ) {
484 wfProfileOut( __METHOD__
);
489 * generate user stylesheet for action=raw&gen=css
491 public function generateUserStylesheet() {
492 wfProfileIn( __METHOD__
);
493 $s = "/* generated user stylesheet */\n" .
494 $this->reallyGenerateUserStylesheet();
495 wfProfileOut( __METHOD__
);
500 * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
502 protected function reallyGenerateUserStylesheet(){
505 if (($undopt = $wgUser->getOption("underline")) < 2) {
506 $underline = $undopt ?
'underline' : 'none';
507 $s .= "a { text-decoration: $underline; }\n";
509 if( $wgUser->getOption( 'highlightbroken' ) ) {
510 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
513 a.new, #quickbar a.new,
514 a.stub, #quickbar a.stub {
517 a.new:after, #quickbar a.new:after {
521 a.stub:after, #quickbar a.stub:after {
527 if( $wgUser->getOption( 'justify' ) ) {
528 $s .= "#article, #bodyContent, #mw_content { text-align: justify; }\n";
530 if( !$wgUser->getOption( 'showtoc' ) ) {
531 $s .= "#toc { display: none; }\n";
533 if( !$wgUser->getOption( 'editsection' ) ) {
534 $s .= ".editsection { display: none; }\n";
542 function setupUserCss( OutputPage
$out ) {
543 global $wgRequest, $wgContLang, $wgUser;
544 global $wgAllowUserCss, $wgUseSiteCss, $wgSquidMaxage, $wgStylePath;
546 wfProfileIn( __METHOD__
);
548 $this->setupSkinUserCss( $out );
552 'maxage' => $wgSquidMaxage,
555 // Add any extension CSS
556 foreach( $out->getExtStyle() as $tag ) {
557 $out->addStyle( $tag['href'] );
560 // If we use the site's dynamic CSS, throw that in, too
561 // Per-site custom styles
562 if( $wgUseSiteCss ) {
563 global $wgHandheldStyle;
564 $query = wfArrayToCGI( array(
565 'usemsgcache' => 'yes',
566 'ctype' => 'text/css',
567 'smaxage' => $wgSquidMaxage
569 # Site settings must override extension css! (bug 15025)
570 $out->addStyle( self
::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) );
571 $out->addStyle( self
::makeNSUrl( 'Print.css', $query, NS_MEDIAWIKI
), 'print' );
572 if( $wgHandheldStyle ) {
573 $out->addStyle( self
::makeNSUrl( 'Handheld.css', $query, NS_MEDIAWIKI
), 'handheld' );
575 $out->addStyle( self
::makeNSUrl( $this->getSkinName() . '.css', $query, NS_MEDIAWIKI
) );
578 if( $wgUser->isLoggedIn() ) {
579 // Ensure that logged-in users' generated CSS isn't clobbered
580 // by anons' publicly cacheable generated CSS.
581 $siteargs['smaxage'] = '0';
582 $siteargs['ts'] = $wgUser->mTouched
;
584 // Per-user styles based on preferences
585 $siteargs['gen'] = 'css';
586 if( ( $us = $wgRequest->getVal( 'useskin', '' ) ) !== '' ) {
587 $siteargs['useskin'] = $us;
589 $out->addStyle( self
::makeUrl( '-', wfArrayToCGI( $siteargs ) ) );
591 // Per-user custom style pages
592 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) {
593 $action = $wgRequest->getVal('action');
594 # If we're previewing the CSS page, use it
595 if( $this->mTitle
->isCssSubpage() && $this->userCanPreview( $action ) ) {
596 $previewCss = $wgRequest->getText('wpTextbox1');
597 // @FIXME: properly escape the cdata!
598 $this->usercss
= "/*<![CDATA[*/\n" . $previewCss . "/*]]>*/";
600 $out->addStyle( self
::makeUrl($this->userpage
. '/' . $this->getSkinName() .'.css',
601 'action=raw&ctype=text/css' ) );
605 wfProfileOut( __METHOD__
);
609 * Add skin specific stylesheets
610 * @param $out OutputPage
612 function setupSkinUserCss( OutputPage
$out ) {
613 $out->addStyle( 'common/shared.css' );
614 $out->addStyle( 'common/oldshared.css' );
615 $out->addStyle( $this->getStylesheet() );
616 $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' );
619 function getBodyOptions() {
620 global $wgUser, $wgTitle, $wgOut, $wgRequest, $wgContLang;
622 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
624 if ( 0 != $wgTitle->getNamespace() ) {
625 $a = array( 'bgcolor' => '#ffffec' );
627 else $a = array( 'bgcolor' => '#FFFFFF' );
628 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
629 $wgTitle->quickUserCan( 'edit' ) ) {
630 $s = $wgTitle->getFullURL( $this->editUrlOptions() );
631 $s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
632 $a +
= array ('ondblclick' => $s);
635 $a['onload'] = $wgOut->getOnloadHandler();
638 ' '.( $wgContLang->isRTL() ?
"rtl" : "ltr" ).
639 ' '.$this->getPageClasses( $wgTitle ) .
640 ' skin-'. Sanitizer
::escapeClass( $this->getSkinName( ) );
644 function getPageClasses( $title ) {
645 $numeric = 'ns-'.$title->getNamespace();
646 if( $title->getNamespace() == NS_SPECIAL
) {
647 $type = "ns-special";
648 } elseif( $title->isTalkPage() ) {
651 $type = "ns-subject";
653 $name = Sanitizer
::escapeClass( 'page-'.$title->getPrefixedText() );
654 return "$numeric $type $name";
666 * This will be called immediately after the <body> tag. Split into
667 * two functions to make it easier to subclass.
669 function beforeContent() {
670 return $this->doBeforeContent();
673 function doBeforeContent() {
675 $fname = 'Skin::doBeforeContent';
676 wfProfileIn( $fname );
679 $qb = $this->qbSetting();
681 if( $langlinks = $this->otherLanguages() ) {
687 $borderhack = 'class="top"';
690 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
691 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
693 $shove = ( $qb != 0 );
694 $left = ( $qb == 1 ||
$qb == 3 );
695 if( $wgContLang->isRTL() ) $left = !$left;
698 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
699 $this->logoText() . '</td>';
701 $s .= $this->getQuickbarCompensator( $rows );
703 $l = $wgContLang->isRTL() ?
'right' : 'left';
704 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
706 $s .= $this->topLinks() ;
707 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
709 $r = $wgContLang->isRTL() ?
"left" : "right";
710 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
711 $s .= $this->nameAndLogin();
712 $s .= "\n<br />" . $this->searchForm() . "</td>";
715 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
718 if ( $shove && !$left ) { # Right
719 $s .= $this->getQuickbarCompensator( $rows );
721 $s .= "</tr>\n</table>\n</div>\n";
722 $s .= "\n<div id='article'>\n";
724 $notice = wfGetSiteNotice();
726 $s .= "\n<div id='siteNotice'>$notice</div>\n";
728 $s .= $this->pageTitle();
729 $s .= $this->pageSubtitle() ;
730 $s .= $this->getCategories();
731 wfProfileOut( $fname );
736 function getCategoryLinks() {
737 global $wgOut, $wgTitle, $wgUseCategoryBrowser;
738 global $wgContLang, $wgUser;
740 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
743 $sep = wfMsgHtml( 'catseparator' );
745 // Use Unicode bidi embedding override characters,
746 // to make sure links don't smash each other up in ugly ways.
747 $dir = $wgContLang->isRTL() ?
'rtl' : 'ltr';
748 $embed = "<span dir='$dir'>";
751 $allCats = $wgOut->getCategoryLinks();
753 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
754 if ( !empty( $allCats['normal'] ) ) {
755 $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
757 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
758 $s .= '<div id="mw-normal-catlinks">' .
759 $this->link( Title
::newFromText( wfMsgForContent('pagecategorieslink') ), $msg )
760 . $colon . $t . '</div>';
764 if ( isset( $allCats['hidden'] ) ) {
765 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
766 $class ='mw-hidden-cats-user-shown';
767 } elseif ( $wgTitle->getNamespace() == NS_CATEGORY
) {
768 $class = 'mw-hidden-cats-ns-shown';
770 $class = 'mw-hidden-cats-hidden';
772 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
773 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
774 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
778 # optional 'dmoz-like' category browser. Will be shown under the list
779 # of categories an article belong to
780 if( $wgUseCategoryBrowser ){
781 $s .= '<br /><hr />';
783 # get a big array of the parents tree
784 $parenttree = $wgTitle->getParentCategoryTree();
785 # Skin object passed by reference cause it can not be
786 # accessed under the method subfunction drawCategoryBrowser
787 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
788 # Clean out bogus first entry and sort them
791 # Output one per line
792 $s .= implode("<br />\n", $tempout);
798 /** Render the array as a serie of links.
799 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
800 * @param &skin Object: skin passed by reference
801 * @return String separated by >, terminate with "\n"
803 function drawCategoryBrowser( $tree, &$skin ){
805 foreach ($tree as $element => $parent) {
806 if (empty($parent)) {
807 # element start a new list
810 # grab the others elements
811 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
813 # add our current element to the list
814 $eltitle = Title
::newFromText($element);
815 $return .= $skin->link( $eltitle, $eltitle->getText() ) ;
820 function getCategories() {
821 $catlinks=$this->getCategoryLinks();
823 $classes = 'catlinks';
825 if( strpos( $catlinks, '<div id="mw-normal-catlinks">' ) === false &&
826 strpos( $catlinks, '<div id="mw-hidden-catlinks" class="mw-hidden-cats-hidden">' ) !== false ) {
827 $classes .= ' catlinks-allhidden';
830 if( !empty( $catlinks ) ){
831 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
835 function getQuickbarCompensator( $rows = 1 ) {
836 return "<td width='152' rowspan='{$rows}'> </td>";
840 * This runs a hook to allow extensions placing their stuff after content
841 * and article metadata (e.g. categories).
842 * Note: This function has nothing to do with afterContent().
844 * This hook is placed here in order to allow using the same hook for all
845 * skins, both the SkinTemplate based ones and the older ones, which directly
846 * use this class to get their data.
848 * The output of this function gets processed in SkinTemplate::outputPage() for
849 * the SkinTemplate based skins, all other skins should directly echo it.
851 * Returns an empty string by default, if not changed by any hook function.
853 protected function afterContentHook() {
856 if( wfRunHooks( 'SkinAfterContent', array( &$data ) ) ){
857 // adding just some spaces shouldn't toggle the output
858 // of the whole <div/>, so we use trim() here
859 if( trim( $data ) != '' ){
860 // Doing this here instead of in the skins to
861 // ensure that the div has the same ID in all
863 $data = "<div id='mw-data-after-content'>\n" .
868 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
875 * This gets called shortly before the </body> tag.
876 * @return String HTML to be put before </body>
878 function afterContent() {
879 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
880 return $printfooter . $this->doAfterContent();
884 * This gets called shortly before the </body> tag.
885 * @return String HTML-wrapped JS code to be put before </body>
887 function bottomScripts() {
888 global $wgJsMimeType;
889 $bottomScriptText = "\n\t\t<script type=\"$wgJsMimeType\">if (window.runOnloadHook) runOnloadHook();</script>\n";
890 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
891 return $bottomScriptText;
894 /** @return string Retrievied from HTML text */
895 function printSource() {
897 $url = htmlspecialchars( $wgTitle->getFullURL() );
898 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
901 function printFooter() {
902 return "<p>" . $this->printSource() .
903 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
906 /** overloaded by derived classes */
907 function doAfterContent() { return "</div></div>"; }
909 function pageTitleLinks() {
910 global $wgOut, $wgTitle, $wgUser, $wgRequest;
912 $oldid = $wgRequest->getVal( 'oldid' );
913 $diff = $wgRequest->getVal( 'diff' );
914 $action = $wgRequest->getText( 'action' );
916 $separator = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
917 $s = $this->printableLink();
918 $disclaimer = $this->disclaimerLink(); # may be empty
920 $s .= $separator . $disclaimer;
922 $privacy = $this->privacyLink(); # may be empty too
924 $s .= $separator . $privacy;
927 if ( $wgOut->isArticleRelated() ) {
928 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
929 $name = $wgTitle->getDBkey();
930 $image = wfFindFile( $wgTitle );
932 $link = htmlspecialchars( $image->getURL() );
933 $style = $this->getInternalLinkAttributes( $link, $name );
934 $s .= $separator . "<a href=\"{$link}\"{$style}>{$name}</a>";
938 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
939 $s .= $separator . $this->makeKnownLinkObj( $wgTitle,
940 wfMsg( 'currentrev' ) );
943 if ( $wgUser->getNewtalk() ) {
944 # do not show "You have new messages" text when we are viewing our
946 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
947 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
948 $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
949 $s.= $separator . '<strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
951 $wgOut->setSquidMaxage(0);
952 $wgOut->enableClientCache(false);
956 $undelete = $this->getUndeleteLink();
957 if( !empty( $undelete ) ) {
958 $s .= $separator . $undelete;
963 function getUndeleteLink() {
964 global $wgUser, $wgTitle, $wgContLang, $wgLang, $action;
965 if( $wgUser->isAllowed( 'deletedhistory' ) &&
966 (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
967 ($n = $wgTitle->isDeleted() ) )
969 if ( $wgUser->isAllowed( 'undelete' ) ) {
970 $msg = 'thisisdeleted';
972 $msg = 'viewdeleted';
975 $this->makeKnownLinkObj(
976 SpecialPage
::getTitleFor( 'Undelete', $wgTitle->getPrefixedDBkey() ),
977 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ) ) );
982 function printableLink() {
983 global $wgOut, $wgFeedClasses, $wgRequest;
985 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
987 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
988 if( $wgOut->isSyndicated() ) {
989 foreach( $wgFeedClasses as $format => $class ) {
990 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
991 $s .= wfMsgExt( 'pipe-separator' , 'escapenoentities' ) . "<a href=\"$feedurl\">{$format}</a>";
997 function pageTitle() {
999 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
1003 function pageSubtitle() {
1006 $sub = $wgOut->getSubtitle();
1008 global $wgExtraSubtitle;
1009 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
1011 $subpages = $this->subPageSubtitle();
1012 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
1013 $s = "<p class='subtitle'>{$sub}</p>\n";
1017 function subPageSubtitle() {
1019 if(!wfRunHooks('SkinSubPageSubtitle', array(&$subpages)))
1022 global $wgOut, $wgTitle;
1023 if($wgOut->isArticle() && MWNamespace
::hasSubpages( $wgTitle->getNamespace() )) {
1024 $ptext=$wgTitle->getPrefixedText();
1025 if(preg_match('/\//',$ptext)) {
1026 $links = explode('/',$ptext);
1027 array_pop( $links );
1031 foreach($links as $link) {
1032 $growinglink .= $link;
1034 $linkObj = Title
::newFromText( $growinglink );
1035 if( is_object( $linkObj ) && $linkObj->exists() ){
1036 $getlink = $this->makeKnownLinkObj( $linkObj, htmlspecialchars( $display ) );
1039 $subpages .= wfMsgExt( 'pipe-separator' , 'escapenoentities' );
1041 $subpages .= '< ';
1043 $subpages .= $getlink;
1048 $growinglink .= '/';
1056 * Returns true if the IP should be shown in the header
1058 function showIPinHeader() {
1059 global $wgShowIPinHeader;
1060 return $wgShowIPinHeader && session_id() != '';
1063 function nameAndLogin() {
1064 global $wgUser, $wgTitle, $wgLang, $wgContLang;
1066 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
1069 if ( $wgUser->isAnon() ) {
1070 if( $this->showIPinHeader() ) {
1073 $talkLink = $this->link( $wgUser->getTalkPage(),
1074 $wgLang->getNsText( NS_TALK
) );
1076 $ret .= "$name ($talkLink)";
1078 $ret .= wfMsg( 'notloggedin' );
1081 $returnTo = $wgTitle->getPrefixedDBkey();
1083 if ( $logoutPage != $returnTo ) {
1084 $query['returnto'] = $returnTo;
1087 $loginlink = $wgUser->isAllowed( 'createaccount' )
1088 ?
'nav-login-createaccount'
1090 $ret .= "\n<br />" . $this->link(
1091 SpecialPage
::getTitleFor( 'Userlogin' ),
1092 wfMsg( $loginlink ), array(), $query
1095 $returnTo = $wgTitle->getPrefixedDBkey();
1096 $talkLink = $this->link( $wgUser->getTalkPage(),
1097 $wgLang->getNsText( NS_TALK
) );
1099 $ret .= $this->link( $wgUser->getUserPage(),
1100 htmlspecialchars( $wgUser->getName() ) );
1101 $ret .= " ($talkLink)<br />";
1102 $ret .= $this->link(
1103 SpecialPage
::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
1104 array(), array( 'returnto' => $returnTo )
1106 $ret .= wfMsgExt( 'pipe-separator' , 'escapenoentities' ) . $this->specialLink( 'preferences' );
1108 $ret .= wfMsgExt( 'pipe-separator' , 'escapenoentities' ) . $this->link(
1109 Title
::newFromText( wfMsgForContent( 'helppage' ) ),
1116 function getSearchLink() {
1117 $searchPage = SpecialPage
::getTitleFor( 'Search' );
1118 return $searchPage->getLocalURL();
1121 function escapeSearchLink() {
1122 return htmlspecialchars( $this->getSearchLink() );
1125 function searchForm() {
1127 $search = $wgRequest->getText( 'search' );
1129 $s = '<form id="searchform'.$this->searchboxes
.'" name="search" class="inline" method="post" action="'
1130 . $this->escapeSearchLink() . "\">\n"
1131 . '<input type="text" id="searchInput'.$this->searchboxes
.'" name="search" size="19" value="'
1132 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
1133 . '<input type="submit" name="go" value="' . wfMsg ('searcharticle') . '" /> '
1134 . '<input type="submit" name="fulltext" value="' . wfMsg ('searchbutton') . "\" />\n</form>";
1136 // Ensure unique id's for search boxes made after the first
1137 $this->searchboxes
= $this->searchboxes
== '' ?
2 : $this->searchboxes +
1;
1142 function topLinks() {
1146 $s = $this->mainPageLink() . $sep
1147 . $this->specialLink( 'recentchanges' );
1149 if ( $wgOut->isArticleRelated() ) {
1150 $s .= $sep . $this->editThisPage()
1151 . $sep . $this->historyLink();
1153 # Many people don't like this dropdown box
1154 #$s .= $sep . $this->specialPagesList();
1156 $s .= $this->variantLinks();
1158 $s .= $this->extensionTabLinks();
1164 * Compatibility for extensions adding functionality through tabs.
1165 * Eventually these old skins should be replaced with SkinTemplate-based
1169 function extensionTabLinks() {
1172 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1173 foreach( $tabs as $tab ) {
1174 $s .= wfMsgExt( 'pipe-separator' , 'escapenoentities' ) . Xml
::element( 'a',
1175 array( 'href' => $tab['href'] ),
1182 * Language/charset variant links for classic-style skins
1185 function variantLinks() {
1187 /* show links to different language variants */
1188 global $wgDisableLangConversion, $wgContLang, $wgTitle;
1189 $variants = $wgContLang->getVariants();
1190 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1191 foreach( $variants as $code ) {
1192 $varname = $wgContLang->getVariantname( $code );
1193 if( $varname == 'disable' )
1195 $s .= wfMsgExt( 'pipe-separator' , 'escapenoentities' ) . '<a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>';
1201 function bottomLinks() {
1202 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
1206 if ( $wgOut->isArticleRelated() ) {
1207 $s .= '<strong>' . $this->editThisPage() . '</strong>';
1208 if ( $wgUser->isLoggedIn() ) {
1209 $s .= $sep . $this->watchThisPage();
1211 $s .= $sep . $this->talkLink()
1212 . $sep . $this->historyLink()
1213 . $sep . $this->whatLinksHere()
1214 . $sep . $this->watchPageLinksLink();
1216 if ($wgUseTrackbacks)
1217 $s .= $sep . $this->trackbackLink();
1219 if ( $wgTitle->getNamespace() == NS_USER
1220 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
1223 $id=User
::idFromName($wgTitle->getText());
1224 $ip=User
::isIP($wgTitle->getText());
1226 if($id ||
$ip) { # both anons and non-anons have contri list
1227 $s .= $sep . $this->userContribsLink();
1229 if( $this->showEmailUser( $id ) ) {
1230 $s .= $sep . $this->emailUserLink();
1233 if ( $wgTitle->getArticleId() ) {
1235 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
1236 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
1237 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
1239 $s .= "<br />\n" . $this->otherLanguages();
1244 function pageStats() {
1245 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1246 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
1248 $oldid = $wgRequest->getVal( 'oldid' );
1249 $diff = $wgRequest->getVal( 'diff' );
1250 if ( ! $wgOut->isArticle() ) { return ''; }
1251 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
1252 if ( 0 == $wgArticle->getID() ) { return ''; }
1255 if ( !$wgDisableCounters ) {
1256 $count = $wgLang->formatNum( $wgArticle->getCount() );
1258 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1262 if( $wgMaxCredits != 0 ){
1263 $s .= ' ' . Credits
::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
1265 $s .= $this->lastModified();
1268 if( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
1269 $dbr = wfGetDB( DB_SLAVE
);
1270 $watchlist = $dbr->tableName( 'watchlist' );
1271 $sql = "SELECT COUNT(*) AS n FROM $watchlist
1272 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBkey()) .
1273 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
1274 $res = $dbr->query( $sql, 'Skin::pageStats');
1275 $x = $dbr->fetchObject( $res );
1277 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1278 array( 'parseinline' ), $wgLang->formatNum($x->n
)
1282 return $s . ' ' . $this->getCopyright();
1285 function getCopyright( $type = 'detect' ) {
1286 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
1288 if ( $type == 'detect' ) {
1289 $oldid = $wgRequest->getVal( 'oldid' );
1290 $diff = $wgRequest->getVal( 'diff' );
1292 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1299 if ( $type == 'history' ) {
1300 $msg = 'history_copyright';
1306 if( $wgRightsPage ) {
1307 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
1308 } elseif( $wgRightsUrl ) {
1309 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1310 } elseif( $wgRightsText ) {
1311 $link = $wgRightsText;
1316 $out .= wfMsgForContent( $msg, $link );
1320 function getCopyrightIcon() {
1321 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1323 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1324 $out = $wgCopyrightIcon;
1325 } else if ( $wgRightsIcon ) {
1326 $icon = htmlspecialchars( $wgRightsIcon );
1327 if ( $wgRightsUrl ) {
1328 $url = htmlspecialchars( $wgRightsUrl );
1329 $out .= '<a href="'.$url.'">';
1331 $text = htmlspecialchars( $wgRightsText );
1332 $out .= "<img src=\"$icon\" alt='$text' />";
1333 if ( $wgRightsUrl ) {
1340 function getPoweredBy() {
1341 global $wgStylePath;
1342 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1343 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="Powered by MediaWiki" /></a>';
1347 function lastModified() {
1348 global $wgLang, $wgArticle;
1349 if( $this->mRevisionId
) {
1350 $timestamp = Revision
::getTimestampFromId( $this->mRevisionId
, $wgArticle->getId() );
1352 $timestamp = $wgArticle->getTimestamp();
1355 $d = $wgLang->date( $timestamp, true );
1356 $t = $wgLang->time( $timestamp, true );
1357 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1361 if ( wfGetLB()->getLaggedSlaveMode() ) {
1362 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1367 function logoText( $align = '' ) {
1368 if ( '' != $align ) { $a = " align='{$align}'"; }
1371 $mp = wfMsg( 'mainpage' );
1372 $mptitle = Title
::newMainPage();
1373 $url = ( is_object($mptitle) ?
$mptitle->escapeLocalURL() : '' );
1375 $logourl = $this->getLogo();
1376 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1381 * show a drop-down box of special pages
1383 function specialPagesList() {
1384 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1385 $pages = array_merge( SpecialPage
::getRegularPages(), SpecialPage
::getRestrictedPages() );
1386 foreach ( $pages as $name => $page ) {
1387 $pages[$name] = $page->getDescription();
1390 $go = wfMsg( 'go' );
1391 $sp = wfMsg( 'specialpages' );
1392 $spp = $wgContLang->specialPage( 'Specialpages' );
1394 $s = '<form id="specialpages" method="get" class="inline" ' .
1395 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1396 $s .= "<select name=\"wpDropdown\">\n";
1397 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1400 foreach ( $pages as $name => $desc ) {
1401 $p = $wgContLang->specialPage( $name );
1402 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1404 $s .= "</select>\n";
1405 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1410 function mainPageLink() {
1411 $s = $this->makeKnownLinkObj( Title
::newMainPage(), wfMsg( 'mainpage' ) );
1415 function copyrightLink() {
1416 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
1417 wfMsg( 'copyrightpagename' ) );
1421 private function footerLink ( $desc, $page ) {
1422 // if the link description has been set to "-" in the default language,
1423 if ( wfMsgForContent( $desc ) == '-') {
1424 // then it is disabled, for all languages.
1427 // Otherwise, we display the link for the user, described in their
1428 // language (which may or may not be the same as the default language),
1429 // but we make the link target be the one site-wide page.
1430 return $this->makeKnownLink( wfMsgForContent( $page ),
1431 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) ) );
1435 function privacyLink() {
1436 return $this->footerLink( 'privacy', 'privacypage' );
1439 function aboutLink() {
1440 return $this->footerLink( 'aboutsite', 'aboutpage' );
1443 function disclaimerLink() {
1444 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1447 function editThisPage() {
1448 global $wgOut, $wgTitle;
1450 if ( !$wgOut->isArticleRelated() ) {
1451 $s = wfMsg( 'protectedpage' );
1453 if( $wgTitle->quickUserCan( 'edit' ) && $wgTitle->exists() ) {
1454 $t = wfMsg( 'editthispage' );
1455 } elseif( $wgTitle->quickUserCan( 'create' ) && !$wgTitle->exists() ) {
1456 $t = wfMsg( 'create-this-page' );
1458 $t = wfMsg( 'viewsource' );
1461 $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() );
1467 * Return URL options for the 'edit page' link.
1468 * This may include an 'oldid' specifier, if the current page view is such.
1473 function editUrlOptions() {
1476 if( $this->mRevisionId
&& ! $wgArticle->isCurrent() ) {
1477 return "action=edit&oldid=" . intval( $this->mRevisionId
);
1479 return "action=edit";
1483 function deleteThisPage() {
1484 global $wgUser, $wgTitle, $wgRequest;
1486 $diff = $wgRequest->getVal( 'diff' );
1487 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1488 $t = wfMsg( 'deletethispage' );
1490 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1497 function protectThisPage() {
1498 global $wgUser, $wgTitle, $wgRequest;
1500 $diff = $wgRequest->getVal( 'diff' );
1501 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1502 if ( $wgTitle->isProtected() ) {
1503 $t = wfMsg( 'unprotectthispage' );
1504 $q = 'action=unprotect';
1506 $t = wfMsg( 'protectthispage' );
1507 $q = 'action=protect';
1509 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1516 function watchThisPage() {
1517 global $wgOut, $wgTitle;
1518 ++
$this->mWatchLinkNum
;
1520 if ( $wgOut->isArticleRelated() ) {
1521 if ( $wgTitle->userIsWatching() ) {
1522 $t = wfMsg( 'unwatchthispage' );
1523 $q = 'action=unwatch';
1524 $id = "mw-unwatch-link".$this->mWatchLinkNum
;
1526 $t = wfMsg( 'watchthispage' );
1527 $q = 'action=watch';
1528 $id = 'mw-watch-link'.$this->mWatchLinkNum
;
1530 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q, '', '', " id=\"$id\"" );
1532 $s = wfMsg( 'notanarticle' );
1537 function moveThisPage() {
1540 if ( $wgTitle->quickUserCan( 'move' ) ) {
1541 return $this->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Movepage' ),
1542 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1544 // no message if page is protected - would be redundant
1549 function historyLink() {
1552 return $this->makeKnownLinkObj( $wgTitle,
1553 wfMsg( 'history' ), 'action=history' );
1556 function whatLinksHere() {
1559 return $this->makeKnownLinkObj(
1560 SpecialPage
::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ),
1561 wfMsg( 'whatlinkshere' ) );
1564 function userContribsLink() {
1567 return $this->makeKnownLinkObj(
1568 SpecialPage
::getTitleFor( 'Contributions', $wgTitle->getDBkey() ),
1569 wfMsg( 'contributions' ) );
1572 function showEmailUser( $id ) {
1573 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1574 return $wgEnableEmail &&
1575 $wgEnableUserEmail &&
1576 $wgUser->isLoggedIn() && # show only to signed in users
1577 0 != $id; # we can only email to non-anons ..
1578 # '' != $id->getEmail() && # who must have an email address stored ..
1579 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1580 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1583 function emailUserLink() {
1586 return $this->makeKnownLinkObj(
1587 SpecialPage
::getTitleFor( 'Emailuser', $wgTitle->getDBkey() ),
1588 wfMsg( 'emailuser' ) );
1591 function watchPageLinksLink() {
1592 global $wgOut, $wgTitle;
1594 if ( ! $wgOut->isArticleRelated() ) {
1595 return '(' . wfMsg( 'notanarticle' ) . ')';
1597 return $this->makeKnownLinkObj(
1598 SpecialPage
::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ),
1599 wfMsg( 'recentchangeslinked' ) );
1603 function trackbackLink() {
1606 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1607 . wfMsg('trackbacklink') . "</a>";
1610 function otherLanguages() {
1611 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1613 if ( $wgHideInterlanguageLinks ) {
1617 $a = $wgOut->getLanguageLinks();
1618 if ( 0 == count( $a ) ) {
1622 $s = wfMsg( 'otherlanguages' ) . ': ';
1624 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1625 foreach( $a as $l ) {
1626 if ( ! $first ) { $s .= wfMsgExt( 'pipe-separator' , 'escapenoentities' ); }
1629 $nt = Title
::newFromText( $l );
1630 $url = $nt->escapeFullURL();
1631 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1633 if ( '' == $text ) { $text = $l; }
1634 $style = $this->getExternalLinkAttributes( $l, $text );
1635 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1637 if($wgContLang->isRTL()) $s .= '</span>';
1641 function bugReportsLink() {
1642 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1643 wfMsg( 'bugreports' ) );
1647 function talkLink() {
1650 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1651 # No discussion links for special pages
1655 $linkOptions = array();
1657 if( $wgTitle->isTalkPage() ) {
1658 $link = $wgTitle->getSubjectPage();
1659 switch( $link->getNamespace() ) {
1661 $text = wfMsg( 'articlepage' );
1664 $text = wfMsg( 'userpage' );
1667 $text = wfMsg( 'projectpage' );
1670 $text = wfMsg( 'imagepage' );
1671 # Make link known if image exists, even if the desc. page doesn't.
1672 if( wfFindFile( $link ) )
1673 $linkOptions[] = 'known';
1676 $text = wfMsg( 'mediawikipage' );
1679 $text = wfMsg( 'templatepage' );
1682 $text = wfMsg( 'viewhelppage' );
1685 $text = wfMsg( 'categorypage' );
1688 $text = wfMsg( 'articlepage' );
1691 $link = $wgTitle->getTalkPage();
1692 $text = wfMsg( 'talkpage' );
1695 $s = $this->link( $link, $text, array(), array(), $linkOptions );
1700 function commentLink() {
1701 global $wgTitle, $wgOut;
1703 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1707 # __NEWSECTIONLINK___ changes behaviour here
1708 # If it's present, the link points to this page, otherwise
1709 # it points to the talk page
1710 if( $wgTitle->isTalkPage() ) {
1712 } elseif( $wgOut->showNewSectionLink() ) {
1715 $title = $wgTitle->getTalkPage();
1718 return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1721 /* these are used extensively in SkinTemplate, but also some other places */
1722 static function makeMainPageUrl( $urlaction = '' ) {
1723 $title = Title
::newMainPage();
1724 self
::checkTitle( $title, '' );
1725 return $title->getLocalURL( $urlaction );
1728 static function makeSpecialUrl( $name, $urlaction = '' ) {
1729 $title = SpecialPage
::getTitleFor( $name );
1730 return $title->getLocalURL( $urlaction );
1733 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
1734 $title = SpecialPage
::getSafeTitleFor( $name, $subpage );
1735 return $title->getLocalURL( $urlaction );
1738 static function makeI18nUrl( $name, $urlaction = '' ) {
1739 $title = Title
::newFromText( wfMsgForContent( $name ) );
1740 self
::checkTitle( $title, $name );
1741 return $title->getLocalURL( $urlaction );
1744 static function makeUrl( $name, $urlaction = '' ) {
1745 $title = Title
::newFromText( $name );
1746 self
::checkTitle( $title, $name );
1747 return $title->getLocalURL( $urlaction );
1750 # If url string starts with http, consider as external URL, else
1752 static function makeInternalOrExternalUrl( $name ) {
1753 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1756 return self
::makeUrl( $name );
1760 # this can be passed the NS number as defined in Language.php
1761 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN
) {
1762 $title = Title
::makeTitleSafe( $namespace, $name );
1763 self
::checkTitle( $title, $name );
1764 return $title->getLocalURL( $urlaction );
1767 /* these return an array with the 'href' and boolean 'exists' */
1768 static function makeUrlDetails( $name, $urlaction = '' ) {
1769 $title = Title
::newFromText( $name );
1770 self
::checkTitle( $title, $name );
1772 'href' => $title->getLocalURL( $urlaction ),
1773 'exists' => $title->getArticleID() != 0 ?
true : false
1778 * Make URL details where the article exists (or at least it's convenient to think so)
1780 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
1781 $title = Title
::newFromText( $name );
1782 self
::checkTitle( $title, $name );
1784 'href' => $title->getLocalURL( $urlaction ),
1789 # make sure we have some title to operate on
1790 static function checkTitle( &$title, $name ) {
1791 if( !is_object( $title ) ) {
1792 $title = Title
::newFromText( $name );
1793 if( !is_object( $title ) ) {
1794 $title = Title
::newFromText( '--error: link target missing--' );
1800 * Build an array that represents the sidebar(s), the navigation bar among them
1804 function buildSidebar() {
1805 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
1807 wfProfileIn( __METHOD__
);
1809 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
1811 if ( $wgEnableSidebarCache ) {
1812 $cachedsidebar = $parserMemc->get( $key );
1813 if ( $cachedsidebar ) {
1814 wfProfileOut( __METHOD__
);
1815 return $cachedsidebar;
1820 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1822 foreach ($lines as $line) {
1823 if (strpos($line, '*') !== 0)
1825 if (strpos($line, '**') !== 0) {
1826 $line = trim($line, '* ');
1828 if( !array_key_exists($heading, $bar) ) $bar[$heading] = array();
1830 if (strpos($line, '|') !== false) { // sanity check
1831 $line = array_map('trim', explode( '|' , trim($line, '* '), 2 ) );
1832 $link = wfMsgForContent( $line[0] );
1835 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1837 if (wfEmptyMsg($line[0], $link))
1840 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
1843 $title = Title
::newFromText( $link );
1845 $title = $title->fixSpecialName();
1846 $href = $title->getLocalURL();
1848 $href = 'INVALID-TITLE';
1852 $bar[$heading][] = array(
1855 'id' => 'n-' . strtr($line[1], ' ', '-'),
1858 } else { continue; }
1861 wfRunHooks('SkinBuildSidebar', array($this, &$bar));
1862 if ( $wgEnableSidebarCache ) $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
1863 wfProfileOut( __METHOD__
);