Restored line accidentally removed in r70520
[mediawiki.git] / includes / Skin.php
blobf000fbfffe82dd7dc28bbc8de6232f360e1cbc2c
1 <?php
2 /**
3 * @defgroup Skins Skins
4 */
6 if ( !defined( 'MEDIAWIKI' ) ) {
7 die( 1 );
10 /**
11 * The main skin class that provide methods and properties for all other skins.
12 * This base class is also the "Standard" skin.
14 * See docs/skin.txt for more information.
16 * @ingroup Skins
18 class Skin extends Linker {
19 /**#@+
20 * @private
22 var $mWatchLinkNum = 0; // Appended to end of watch link id's
23 // How many search boxes have we made? Avoid duplicate id's.
24 protected $searchboxes = '';
25 /**#@-*/
26 protected $mRevisionId; // The revision ID we're looking at, null if not applicable.
27 protected $skinname = 'standard';
28 // @todo Fixme: should be protected :-\
29 var $mTitle = null;
31 /** Constructor, call parent constructor */
32 function __construct() {
33 parent::__construct();
36 /**
37 * Fetch the set of available skins.
38 * @return array of strings
40 static function getSkinNames() {
41 global $wgValidSkinNames;
42 static $skinsInitialised = false;
43 if ( !$skinsInitialised ) {
44 # Get a list of available skins
45 # Build using the regular expression '^(.*).php$'
46 # Array keys are all lower case, array value keep the case used by filename
48 wfProfileIn( __METHOD__ . '-init' );
49 global $wgStyleDirectory;
50 $skinDir = dir( $wgStyleDirectory );
52 # while code from www.php.net
53 while( false !== ( $file = $skinDir->read() ) ) {
54 // Skip non-PHP files, hidden files, and '.dep' includes
55 $matches = array();
56 if( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) {
57 $aSkin = $matches[1];
58 $wgValidSkinNames[strtolower( $aSkin )] = $aSkin;
61 $skinDir->close();
62 $skinsInitialised = true;
63 wfProfileOut( __METHOD__ . '-init' );
65 return $wgValidSkinNames;
68 /**
69 * Fetch the list of usable skins in regards to $wgSkipSkins.
70 * Useful for Special:Preferences and other places where you
71 * only want to show skins users _can_ use.
72 * @return array of strings
74 public static function getUsableSkins() {
75 global $wgSkipSkins;
76 $usableSkins = self::getSkinNames();
77 foreach ( $wgSkipSkins as $skip ) {
78 unset( $usableSkins[$skip] );
80 return $usableSkins;
83 /**
84 * Normalize a skin preference value to a form that can be loaded.
85 * If a skin can't be found, it will fall back to the configured
86 * default (or the old 'Classic' skin if that's broken).
87 * @param $key String: 'monobook', 'standard', etc.
88 * @return string
90 static function normalizeKey( $key ) {
91 global $wgDefaultSkin;
92 $skinNames = Skin::getSkinNames();
94 if( $key == '' ) {
95 // Don't return the default immediately;
96 // in a misconfiguration we need to fall back.
97 $key = $wgDefaultSkin;
100 if( isset( $skinNames[$key] ) ) {
101 return $key;
104 // Older versions of the software used a numeric setting
105 // in the user preferences.
106 $fallback = array(
107 0 => $wgDefaultSkin,
108 1 => 'nostalgia',
109 2 => 'cologneblue'
112 if( isset( $fallback[$key] ) ) {
113 $key = $fallback[$key];
116 if( isset( $skinNames[$key] ) ) {
117 return $key;
118 } else if( isset( $skinNames[$wgDefaultSkin] ) ) {
119 return $wgDefaultSkin;
120 } else {
121 return 'vector';
126 * Factory method for loading a skin of a given type
127 * @param $key String: 'monobook', 'standard', etc.
128 * @return Skin
130 static function &newFromKey( $key ) {
131 global $wgStyleDirectory;
133 $key = Skin::normalizeKey( $key );
135 $skinNames = Skin::getSkinNames();
136 $skinName = $skinNames[$key];
137 $className = 'Skin' . ucfirst( $key );
139 # Grab the skin class and initialise it.
140 if ( !class_exists( $className ) ) {
141 // Preload base classes to work around APC/PHP5 bug
142 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
143 if( file_exists( $deps ) ) {
144 include_once( $deps );
146 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
148 # Check if we got if not failback to default skin
149 if( !class_exists( $className ) ) {
150 # DO NOT die if the class isn't found. This breaks maintenance
151 # scripts and can cause a user account to be unrecoverable
152 # except by SQL manipulation if a previously valid skin name
153 # is no longer valid.
154 wfDebug( "Skin class does not exist: $className\n" );
155 $className = 'SkinVector';
156 require_once( "{$wgStyleDirectory}/Vector.php" );
159 $skin = new $className;
160 return $skin;
163 /** @return string path to the skin stylesheet */
164 function getStylesheet() {
165 return 'common/wikistandard.css';
168 /** @return string skin name */
169 public function getSkinName() {
170 return $this->skinname;
173 function qbSetting() {
174 global $wgOut, $wgUser;
176 if ( $wgOut->isQuickbarSuppressed() ) {
177 return 0;
179 $q = $wgUser->getOption( 'quickbar', 0 );
180 return $q;
183 function initPage( OutputPage $out ) {
184 global $wgFavicon, $wgAppleTouchIcon;
186 wfProfileIn( __METHOD__ );
188 # Generally the order of the favicon and apple-touch-icon links
189 # should not matter, but Konqueror (3.5.9 at least) incorrectly
190 # uses whichever one appears later in the HTML source. Make sure
191 # apple-touch-icon is specified first to avoid this.
192 if( false !== $wgAppleTouchIcon ) {
193 $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
196 if( false !== $wgFavicon ) {
197 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
200 # OpenSearch description link
201 $out->addLink( array(
202 'rel' => 'search',
203 'type' => 'application/opensearchdescription+xml',
204 'href' => wfScript( 'opensearch_desc' ),
205 'title' => wfMsgForContent( 'opensearch-desc' ),
208 $this->addMetadataLinks( $out );
210 $this->mRevisionId = $out->mRevisionId;
212 $this->preloadExistence();
214 wfProfileOut( __METHOD__ );
218 * Preload the existence of three commonly-requested pages in a single query
220 function preloadExistence() {
221 global $wgUser;
223 // User/talk link
224 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
226 // Other tab link
227 if ( $this->mTitle->getNamespace() == NS_SPECIAL ) {
228 // nothing
229 } elseif ( $this->mTitle->isTalkPage() ) {
230 $titles[] = $this->mTitle->getSubjectPage();
231 } else {
232 $titles[] = $this->mTitle->getTalkPage();
235 $lb = new LinkBatch( $titles );
236 $lb->execute();
240 * Adds metadata links (Creative Commons/Dublin Core/copyright) to the HTML
241 * output.
242 * @param $out Object: instance of OutputPage
244 function addMetadataLinks( OutputPage $out ) {
245 global $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
246 global $wgRightsPage, $wgRightsUrl;
248 if( $out->isArticleRelated() ) {
249 # note: buggy CC software only reads first "meta" link
250 if( $wgEnableCreativeCommonsRdf ) {
251 $out->addMetadataLink( array(
252 'title' => 'Creative Commons',
253 'type' => 'application/rdf+xml',
254 'href' => $this->mTitle->getLocalURL( 'action=creativecommons' ) )
257 if( $wgEnableDublinCoreRdf ) {
258 $out->addMetadataLink( array(
259 'title' => 'Dublin Core',
260 'type' => 'application/rdf+xml',
261 'href' => $this->mTitle->getLocalURL( 'action=dublincore' ) )
265 $copyright = '';
266 if( $wgRightsPage ) {
267 $copy = Title::newFromText( $wgRightsPage );
268 if( $copy ) {
269 $copyright = $copy->getLocalURL();
272 if( !$copyright && $wgRightsUrl ) {
273 $copyright = $wgRightsUrl;
275 if( $copyright ) {
276 $out->addLink( array(
277 'rel' => 'copyright',
278 'href' => $copyright )
284 * Set some local variables
286 protected function setMembers() {
287 global $wgUser;
288 $this->mUser = $wgUser;
289 $this->userpage = $wgUser->getUserPage()->getPrefixedText();
290 $this->usercss = false;
294 * Set the title
295 * @param $t Title object to use
297 public function setTitle( $t ) {
298 $this->mTitle = $t;
301 /** Get the title */
302 public function getTitle() {
303 return $this->mTitle;
307 * Outputs the HTML generated by other functions.
308 * @param $out Object: instance of OutputPage
310 function outputPage( OutputPage $out ) {
311 global $wgDebugComments;
312 wfProfileIn( __METHOD__ );
314 $this->setMembers();
315 $this->initPage( $out );
317 // See self::afterContentHook() for documentation
318 $afterContent = $this->afterContentHook();
320 $out->out( $out->headElement( $this ) );
322 if ( $wgDebugComments ) {
323 $out->out( "<!-- Wiki debugging output:\n" .
324 $out->mDebugtext . "-->\n" );
327 $out->out( $this->beforeContent() );
329 $out->out( $out->mBodytext . "\n" );
331 $out->out( $this->afterContent() );
333 $out->out( $afterContent );
335 $out->out( $this->bottomScripts() );
337 $out->out( wfReportTime() );
339 $out->out( "\n</body></html>" );
340 wfProfileOut( __METHOD__ );
343 static function makeVariablesScript( $data ) {
344 if( $data ) {
345 $r = array();
346 foreach ( $data as $name => $value ) {
347 $encValue = Xml::encodeJsVar( $value );
348 $r[] = "$name=$encValue";
350 $js = 'var ' . implode( ",\n", $r ) . ';';
351 return Html::inlineScript( "\n$js\n" );
352 } else {
353 return '';
358 * Make a <script> tag containing global variables
359 * @param $skinName string Name of the skin
360 * The odd calling convention is for backwards compatibility
361 * @todo FIXME: Make this not depend on $wgTitle!
363 static function makeGlobalVariablesScript( $skinName ) {
364 if ( is_array( $skinName ) ) {
365 # Weird back-compat stuff.
366 $skinName = $skinName['skinname'];
368 global $wgScript, $wgTitle, $wgStylePath, $wgUser, $wgScriptExtension;
369 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
370 global $wgOut, $wgArticle;
371 global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
372 global $wgUseAjax, $wgAjaxWatch;
373 global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
374 global $wgRestrictionTypes;
375 global $wgDBname, $wgEnableMWSuggest;
376 global $wgSitename;
378 $ns = $wgTitle->getNamespace();
379 $nsname = MWNamespace::exists( $ns ) ? MWNamespace::getCanonicalName( $ns ) : $wgTitle->getNsText();
380 $separatorTransTable = $wgContLang->separatorTransformTable();
381 $separatorTransTable = $separatorTransTable ? $separatorTransTable : array();
382 $compactSeparatorTransTable = array(
383 implode( "\t", array_keys( $separatorTransTable ) ),
384 implode( "\t", $separatorTransTable ),
386 $digitTransTable = $wgContLang->digitTransformTable();
387 $digitTransTable = $digitTransTable ? $digitTransTable : array();
388 $compactDigitTransTable = array(
389 implode( "\t", array_keys( $digitTransTable ) ),
390 implode( "\t", $digitTransTable ),
393 $mainPage = Title::newMainPage();
394 $vars = array(
395 'skin' => $skinName,
396 'stylepath' => $wgStylePath,
397 'wgUrlProtocols' => wfUrlProtocols(),
398 'wgArticlePath' => $wgArticlePath,
399 'wgScriptPath' => $wgScriptPath,
400 'wgScriptExtension' => $wgScriptExtension,
401 'wgScript' => $wgScript,
402 'wgVariantArticlePath' => $wgVariantArticlePath,
403 'wgActionPaths' => (object)$wgActionPaths,
404 'wgServer' => $wgServer,
405 'wgCanonicalNamespace' => $nsname,
406 'wgCanonicalSpecialPageName' => $ns == NS_SPECIAL ?
407 SpecialPage::resolveAlias( $wgTitle->getDBkey() ) : false, # bug 21115
408 'wgNamespaceNumber' => $wgTitle->getNamespace(),
409 'wgPageName' => $wgTitle->getPrefixedDBKey(),
410 'wgTitle' => $wgTitle->getText(),
411 'wgAction' => $wgRequest->getText( 'action', 'view' ),
412 'wgArticleId' => $wgTitle->getArticleId(),
413 'wgIsArticle' => $wgOut->isArticle(),
414 'wgUserName' => $wgUser->isAnon() ? null : $wgUser->getName(),
415 'wgUserGroups' => $wgUser->getEffectiveGroups(),
416 'wgUserLanguage' => $wgLang->getCode(),
417 'wgContentLanguage' => $wgContLang->getCode(),
418 'wgBreakFrames' => $wgBreakFrames,
419 'wgCurRevisionId' => isset( $wgArticle ) ? $wgArticle->getLatest() : 0,
420 'wgVersion' => $wgVersion,
421 'wgEnableAPI' => $wgEnableAPI,
422 'wgEnableWriteAPI' => $wgEnableWriteAPI,
423 'wgSeparatorTransformTable' => $compactSeparatorTransTable,
424 'wgDigitTransformTable' => $compactDigitTransTable,
425 'wgMainPageTitle' => $mainPage ? $mainPage->getPrefixedText() : null,
426 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(),
427 'wgNamespaceIds' => $wgContLang->getNamespaceIds(),
428 'wgSiteName' => $wgSitename,
429 'wgCategories' => $wgOut->getCategories(),
431 if ( $wgContLang->hasVariants() ) {
432 $vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
435 // if on upload page output the extension list & js_upload
436 if( SpecialPage::resolveAlias( $wgTitle->getDBkey() ) == 'Upload' ) {
437 global $wgFileExtensions;
438 $vars['wgFileExtensions'] = $wgFileExtensions;
441 if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ) {
442 $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
443 $vars['wgDBname'] = $wgDBname;
444 $vars['wgSearchNamespaces'] = SearchEngine::userNamespaces( $wgUser );
445 $vars['wgMWSuggestMessages'] = array( wfMsg( 'search-mwsuggest-enabled' ), wfMsg( 'search-mwsuggest-disabled' ) );
448 foreach( $wgRestrictionTypes as $type ) {
449 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
452 if ( $wgOut->isArticleRelated() && $wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
453 $msgs = (object)array();
454 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching',
455 'tooltip-ca-watch', 'tooltip-ca-unwatch' ) as $msgName ) {
456 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
458 $vars['wgAjaxWatch'] = $msgs;
461 // Allow extensions to add their custom variables to the global JS variables
462 wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
464 return self::makeVariablesScript( $vars );
468 * To make it harder for someone to slip a user a fake
469 * user-JavaScript or user-CSS preview, a random token
470 * is associated with the login session. If it's not
471 * passed back with the preview request, we won't render
472 * the code.
474 * @param $action String: 'edit', 'submit' etc.
475 * @return bool
477 public function userCanPreview( $action ) {
478 global $wgRequest, $wgUser;
480 if( $action != 'submit' ) {
481 return false;
483 if( !$wgRequest->wasPosted() ) {
484 return false;
486 if( !$this->mTitle->userCanEditCssSubpage() ) {
487 return false;
489 if( !$this->mTitle->userCanEditJsSubpage() ) {
490 return false;
492 return $wgUser->matchEditToken(
493 $wgRequest->getVal( 'wpEditToken' ) );
497 * Generated JavaScript action=raw&gen=js
498 * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
499 * nated together. For some bizarre reason, it does *not* return any
500 * custom user JS from subpages. Huh?
502 * There's absolutely no reason to have separate Monobook/Common JSes.
503 * Any JS that cares can just check the skin variable generated at the
504 * top. For now Monobook.js will be maintained, but it should be consi-
505 * dered deprecated.
507 * @param $skinName String: If set, overrides the skin name
508 * @return string
510 public function generateUserJs( $skinName = null ) {
511 global $wgStylePath;
513 wfProfileIn( __METHOD__ );
514 if( !$skinName ) {
515 $skinName = $this->getSkinName();
518 $s = "/* generated javascript */\n";
519 $s .= "var skin = '" . Xml::escapeJsString( $skinName ) . "';\n";
520 $s .= "var stylepath = '" . Xml::escapeJsString( $wgStylePath ) . "';";
521 $s .= "\n\n/* MediaWiki:Common.js */\n";
522 $commonJs = wfMsgExt( 'common.js', 'content' );
523 if ( !wfEmptyMsg( 'common.js', $commonJs ) ) {
524 $s .= $commonJs;
527 $s .= "\n\n/* MediaWiki:" . ucfirst( $skinName ) . ".js */\n";
528 // avoid inclusion of non defined user JavaScript (with custom skins only)
529 // by checking for default message content
530 $msgKey = ucfirst( $skinName ) . '.js';
531 $userJS = wfMsgExt( $msgKey, 'content' );
532 if ( !wfEmptyMsg( $msgKey, $userJS ) ) {
533 $s .= $userJS;
536 wfProfileOut( __METHOD__ );
537 return $s;
541 * Generate user stylesheet for action=raw&gen=css
543 public function generateUserStylesheet() {
544 wfProfileIn( __METHOD__ );
545 $s = "/* generated user stylesheet */\n" .
546 $this->reallyGenerateUserStylesheet();
547 wfProfileOut( __METHOD__ );
548 return $s;
552 * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
553 * Anything in here won't be generated if $wgAllowUserCssPrefs is false.
555 protected function reallyGenerateUserStylesheet() {
556 global $wgUser;
557 $s = '';
558 if( ( $undopt = $wgUser->getOption( 'underline' ) ) < 2 ) {
559 $underline = $undopt ? 'underline' : 'none';
560 $s .= "a { text-decoration: $underline; }\n";
562 if( $wgUser->getOption( 'highlightbroken' ) ) {
563 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
564 } else {
565 $s .= <<<CSS
566 a.new, #quickbar a.new,
567 a.stub, #quickbar a.stub {
568 color: inherit;
570 a.new:after, #quickbar a.new:after {
571 content: "?";
572 color: #CC2200;
574 a.stub:after, #quickbar a.stub:after {
575 content: "!";
576 color: #772233;
578 CSS;
580 if( $wgUser->getOption( 'justify' ) ) {
581 $s .= "#article, #bodyContent, #mw_content { text-align: justify; }\n";
583 if( !$wgUser->getOption( 'showtoc' ) ) {
584 $s .= "#toc { display: none; }\n";
586 if( !$wgUser->getOption( 'editsection' ) ) {
587 $s .= ".editsection { display: none; }\n";
589 $fontstyle = $wgUser->getOption( 'editfont' );
590 if ( $fontstyle !== 'default' ) {
591 $s .= "textarea { font-family: $fontstyle; }\n";
593 return $s;
597 * @private
599 function setupUserCss( OutputPage $out ) {
600 global $wgRequest, $wgUser;
601 global $wgAllowUserCss, $wgUseSiteCss, $wgSquidMaxage;
603 wfProfileIn( __METHOD__ );
605 $this->setupSkinUserCss( $out );
607 $siteargs = array(
608 'action' => 'raw',
609 'maxage' => $wgSquidMaxage,
612 // Add any extension CSS
613 foreach ( $out->getExtStyle() as $url ) {
614 $out->addStyle( $url );
617 // If we use the site's dynamic CSS, throw that in, too
618 // Per-site custom styles
619 if( $wgUseSiteCss ) {
620 global $wgHandheldStyle;
621 $query = wfArrayToCGI( self::getDynamicStylesheetQuery() );
622 # Site settings must override extension css! (bug 15025)
623 $out->addStyle( self::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI ) );
624 $out->addStyle( self::makeNSUrl( 'Print.css', $query, NS_MEDIAWIKI ), 'print' );
625 if( $wgHandheldStyle ) {
626 $out->addStyle( self::makeNSUrl( 'Handheld.css', $query, NS_MEDIAWIKI ), 'handheld' );
628 $out->addStyle( self::makeNSUrl( $this->getSkinName() . '.css', $query, NS_MEDIAWIKI ) );
631 global $wgAllowUserCssPrefs;
632 if( $wgAllowUserCssPrefs ){
633 if( $wgUser->isLoggedIn() ) {
634 // Ensure that logged-in users' generated CSS isn't clobbered
635 // by anons' publicly cacheable generated CSS.
636 $siteargs['smaxage'] = '0';
637 $siteargs['ts'] = $wgUser->mTouched;
639 // Per-user styles based on preferences
640 $siteargs['gen'] = 'css';
641 if( ( $us = $wgRequest->getVal( 'useskin', '' ) ) !== '' ) {
642 $siteargs['useskin'] = $us;
644 $out->addStyle( self::makeUrl( '-', wfArrayToCGI( $siteargs ) ) );
647 // Per-user custom style pages
648 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) {
649 $action = $wgRequest->getVal( 'action' );
650 # If we're previewing the CSS page, use it
651 if( $this->mTitle->isCssSubpage() && $this->userCanPreview( $action ) ) {
652 // @FIXME: properly escape the cdata!
653 $out->addInlineStyle( $wgRequest->getText( 'wpTextbox1' ) );
654 } else {
655 $names = array( 'common', $this->getSkinName() );
656 foreach( $names as $name ) {
657 $out->addStyle( self::makeUrl(
658 $this->userpage . '/' . $name . '.css',
659 'action=raw&ctype=text/css' )
665 wfProfileOut( __METHOD__ );
669 * Get the query to generate a dynamic stylesheet
671 * @return array
673 public static function getDynamicStylesheetQuery() {
674 global $wgSquidMaxage;
675 return array(
676 'action' => 'raw',
677 'maxage' => $wgSquidMaxage,
678 'usemsgcache' => 'yes',
679 'ctype' => 'text/css',
680 'smaxage' => $wgSquidMaxage,
685 * Add skin specific stylesheets
686 * @param $out OutputPage
688 function setupSkinUserCss( OutputPage $out ) {
689 $out->addStyle( 'common/shared.css' );
690 $out->addStyle( 'common/oldshared.css' );
691 $out->addStyle( $this->getStylesheet() );
692 $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' );
695 function getPageClasses( $title ) {
696 $numeric = 'ns-' . $title->getNamespace();
697 if( $title->getNamespace() == NS_SPECIAL ) {
698 $type = 'ns-special';
699 } elseif( $title->isTalkPage() ) {
700 $type = 'ns-talk';
701 } else {
702 $type = 'ns-subject';
704 $name = Sanitizer::escapeClass( 'page-' . $title->getPrefixedText() );
705 return "$numeric $type $name";
709 * URL to the logo
711 function getLogo() {
712 global $wgLogo;
713 return $wgLogo;
717 * This will be called immediately after the <body> tag. Split into
718 * two functions to make it easier to subclass.
720 function beforeContent() {
721 return $this->doBeforeContent();
724 function doBeforeContent() {
725 global $wgContLang;
726 wfProfileIn( __METHOD__ );
728 $s = '';
729 $qb = $this->qbSetting();
731 $langlinks = $this->otherLanguages();
732 if( $langlinks ) {
733 $rows = 2;
734 $borderhack = '';
735 } else {
736 $rows = 1;
737 $langlinks = false;
738 $borderhack = 'class="top"';
741 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
742 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
744 $shove = ( $qb != 0 );
745 $left = ( $qb == 1 || $qb == 3 );
746 if( $wgContLang->isRTL() ) {
747 $left = !$left;
750 if( !$shove ) {
751 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
752 $this->logoText() . '</td>';
753 } elseif( $left ) {
754 $s .= $this->getQuickbarCompensator( $rows );
756 $l = $wgContLang->alignStart();
757 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
759 $s .= $this->topLinks();
760 $s .= '<p class="subtitle">' . $this->pageTitleLinks() . "</p>\n";
762 $r = $wgContLang->alignEnd();
763 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
764 $s .= $this->nameAndLogin();
765 $s .= "\n<br />" . $this->searchForm() . '</td>';
767 if ( $langlinks ) {
768 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
771 if ( $shove && !$left ) { # Right
772 $s .= $this->getQuickbarCompensator( $rows );
774 $s .= "</tr>\n</table>\n</div>\n";
775 $s .= "\n<div id='article'>\n";
777 $notice = wfGetSiteNotice();
778 if( $notice ) {
779 $s .= "\n<div id='siteNotice'>$notice</div>\n";
781 $s .= $this->pageTitle();
782 $s .= $this->pageSubtitle();
783 $s .= $this->getCategories();
784 wfProfileOut( __METHOD__ );
785 return $s;
788 function getCategoryLinks() {
789 global $wgOut, $wgUseCategoryBrowser;
790 global $wgContLang, $wgUser;
792 if( count( $wgOut->mCategoryLinks ) == 0 ) {
793 return '';
796 # Separator
797 $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) );
799 // Use Unicode bidi embedding override characters,
800 // to make sure links don't smash each other up in ugly ways.
801 $dir = $wgContLang->getDir();
802 $embed = "<span dir='$dir'>";
803 $pop = '</span>';
805 $allCats = $wgOut->getCategoryLinks();
806 $s = '';
807 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
808 if ( !empty( $allCats['normal'] ) ) {
809 $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
811 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
812 $s .= '<div id="mw-normal-catlinks">' .
813 $this->link( Title::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
814 . $colon . $t . '</div>';
817 # Hidden categories
818 if ( isset( $allCats['hidden'] ) ) {
819 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
820 $class ='mw-hidden-cats-user-shown';
821 } elseif ( $this->mTitle->getNamespace() == NS_CATEGORY ) {
822 $class = 'mw-hidden-cats-ns-shown';
823 } else {
824 $class = 'mw-hidden-cats-hidden';
826 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
827 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
828 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
829 '</div>';
832 # optional 'dmoz-like' category browser. Will be shown under the list
833 # of categories an article belong to
834 if( $wgUseCategoryBrowser ) {
835 $s .= '<br /><hr />';
837 # get a big array of the parents tree
838 $parenttree = $this->mTitle->getParentCategoryTree();
839 # Skin object passed by reference cause it can not be
840 # accessed under the method subfunction drawCategoryBrowser
841 $tempout = explode( "\n", $this->drawCategoryBrowser( $parenttree, $this ) );
842 # Clean out bogus first entry and sort them
843 unset( $tempout[0] );
844 asort( $tempout );
845 # Output one per line
846 $s .= implode( "<br />\n", $tempout );
849 return $s;
853 * Render the array as a serie of links.
854 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
855 * @param &skin Object: skin passed by reference
856 * @return String separated by &gt;, terminate with "\n"
858 function drawCategoryBrowser( $tree, &$skin ) {
859 $return = '';
860 foreach( $tree as $element => $parent ) {
861 if( empty( $parent ) ) {
862 # element start a new list
863 $return .= "\n";
864 } else {
865 # grab the others elements
866 $return .= $this->drawCategoryBrowser( $parent, $skin ) . ' &gt; ';
868 # add our current element to the list
869 $eltitle = Title::newFromText( $element );
870 $return .= $skin->link( $eltitle, $eltitle->getText() );
872 return $return;
875 function getCategories() {
876 $catlinks = $this->getCategoryLinks();
878 $classes = 'catlinks';
880 // Check what we're showing
881 global $wgOut, $wgUser;
882 $allCats = $wgOut->getCategoryLinks();
883 $showHidden = $wgUser->getBoolOption( 'showhiddencats' ) ||
884 $this->mTitle->getNamespace() == NS_CATEGORY;
886 if( empty( $allCats['normal'] ) && !( !empty( $allCats['hidden'] ) && $showHidden ) ) {
887 $classes .= ' catlinks-allhidden';
890 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
893 function getQuickbarCompensator( $rows = 1 ) {
894 return "<td width='152' rowspan='{$rows}'>&#160;</td>";
898 * This runs a hook to allow extensions placing their stuff after content
899 * and article metadata (e.g. categories).
900 * Note: This function has nothing to do with afterContent().
902 * This hook is placed here in order to allow using the same hook for all
903 * skins, both the SkinTemplate based ones and the older ones, which directly
904 * use this class to get their data.
906 * The output of this function gets processed in SkinTemplate::outputPage() for
907 * the SkinTemplate based skins, all other skins should directly echo it.
909 * Returns an empty string by default, if not changed by any hook function.
911 protected function afterContentHook() {
912 $data = '';
914 if( wfRunHooks( 'SkinAfterContent', array( &$data ) ) ) {
915 // adding just some spaces shouldn't toggle the output
916 // of the whole <div/>, so we use trim() here
917 if( trim( $data ) != '' ) {
918 // Doing this here instead of in the skins to
919 // ensure that the div has the same ID in all
920 // skins
921 $data = "<div id='mw-data-after-content'>\n" .
922 "\t$data\n" .
923 "</div>\n";
925 } else {
926 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
929 return $data;
933 * Generate debug data HTML for displaying at the bottom of the main content
934 * area.
935 * @return String HTML containing debug data, if enabled (otherwise empty).
937 protected function generateDebugHTML() {
938 global $wgShowDebug, $wgOut;
939 if ( $wgShowDebug ) {
940 $listInternals = $this->formatDebugHTML( $wgOut->mDebugtext );
941 return "\n<hr />\n<strong>Debug data:</strong><ul style=\"font-family:monospace;\" id=\"mw-debug-html\">" .
942 $listInternals . "</ul>\n";
944 return '';
947 private function formatDebugHTML( $debugText ) {
948 $lines = explode( "\n", $debugText );
949 $curIdent = 0;
950 $ret = '<li>';
951 foreach( $lines as $line ) {
952 $m = array();
953 $display = ltrim( $line );
954 $ident = strlen( $line ) - strlen( $display );
955 $diff = $ident - $curIdent;
957 if ( $display == '' ) {
958 $display = "\xc2\xa0";
961 if ( !$ident && $diff < 0 && substr( $display, 0, 9 ) != 'Entering ' && substr( $display, 0, 8 ) != 'Exiting ' ) {
962 $ident = $curIdent;
963 $diff = 0;
964 $display = '<span style="background:yellow;">' . htmlspecialchars( $display ) . '</span>';
965 } else {
966 $display = htmlspecialchars( $display );
969 if ( $diff < 0 ) {
970 $ret .= str_repeat( "</li></ul>\n", -$diff ) . "</li><li>\n";
971 } elseif ( $diff == 0 ) {
972 $ret .= "</li><li>\n";
973 } else {
974 $ret .= str_repeat( "<ul><li>\n", $diff );
976 $ret .= $display . "\n";
978 $curIdent = $ident;
980 $ret .= str_repeat( '</li></ul>', $curIdent ) . '</li>';
981 return $ret;
985 * This gets called shortly before the </body> tag.
986 * @return String HTML to be put before </body>
988 function afterContent() {
989 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
990 return $printfooter . $this->generateDebugHTML() . $this->doAfterContent();
994 * This gets called shortly before the </body> tag.
995 * @return String HTML-wrapped JS code to be put before </body>
997 function bottomScripts() {
998 $bottomScriptText = "\n" . Html::inlineScript( 'if (window.runOnloadHook) runOnloadHook();' ) . "\n";
999 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
1000 return $bottomScriptText;
1003 /** @return string Retrievied from HTML text */
1004 function printSource() {
1005 $url = htmlspecialchars( $this->mTitle->getFullURL() );
1006 return wfMsg( 'retrievedfrom', '<a href="' . $url . '">' . $url . '</a>' );
1009 function printFooter() {
1010 return "<p>" . $this->printSource() .
1011 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
1014 /** overloaded by derived classes */
1015 function doAfterContent() {
1016 return '</div></div>';
1019 function pageTitleLinks() {
1020 global $wgOut, $wgUser, $wgRequest, $wgLang;
1022 $oldid = $wgRequest->getVal( 'oldid' );
1023 $diff = $wgRequest->getVal( 'diff' );
1024 $action = $wgRequest->getText( 'action' );
1026 $s[] = $this->printableLink();
1027 $disclaimer = $this->disclaimerLink(); # may be empty
1028 if( $disclaimer ) {
1029 $s[] = $disclaimer;
1031 $privacy = $this->privacyLink(); # may be empty too
1032 if( $privacy ) {
1033 $s[] = $privacy;
1036 if ( $wgOut->isArticleRelated() ) {
1037 if ( $this->mTitle->getNamespace() == NS_FILE ) {
1038 $name = $this->mTitle->getDBkey();
1039 $image = wfFindFile( $this->mTitle );
1040 if( $image ) {
1041 $link = htmlspecialchars( $image->getURL() );
1042 $style = $this->getInternalLinkAttributes( $link, $name );
1043 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
1047 if ( 'history' == $action || isset( $diff ) || isset( $oldid ) ) {
1048 $s[] .= $this->link(
1049 $this->mTitle,
1050 wfMsg( 'currentrev' ),
1051 array(),
1052 array(),
1053 array( 'known', 'noclasses' )
1057 if ( $wgUser->getNewtalk() ) {
1058 # do not show "You have new messages" text when we are viewing our
1059 # own talk page
1060 if( !$this->mTitle->equals( $wgUser->getTalkPage() ) ) {
1061 $tl = $this->link(
1062 $wgUser->getTalkPage(),
1063 wfMsgHtml( 'newmessageslink' ),
1064 array(),
1065 array( 'redirect' => 'no' ),
1066 array( 'known', 'noclasses' )
1069 $dl = $this->link(
1070 $wgUser->getTalkPage(),
1071 wfMsgHtml( 'newmessagesdifflink' ),
1072 array(),
1073 array( 'diff' => 'cur' ),
1074 array( 'known', 'noclasses' )
1076 $s[] = '<strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
1077 # disable caching
1078 $wgOut->setSquidMaxage( 0 );
1079 $wgOut->enableClientCache( false );
1083 $undelete = $this->getUndeleteLink();
1084 if( !empty( $undelete ) ) {
1085 $s[] = $undelete;
1087 return $wgLang->pipeList( $s );
1090 function getUndeleteLink() {
1091 global $wgUser, $wgLang, $wgRequest;
1093 $action = $wgRequest->getVal( 'action', 'view' );
1095 if ( $wgUser->isAllowed( 'deletedhistory' ) &&
1096 ( $this->mTitle->getArticleId() == 0 || $action == 'history' ) ) {
1097 $n = $this->mTitle->isDeleted();
1098 if ( $n ) {
1099 if ( $wgUser->isAllowed( 'undelete' ) ) {
1100 $msg = 'thisisdeleted';
1101 } else {
1102 $msg = 'viewdeleted';
1104 return wfMsg(
1105 $msg,
1106 $this->link(
1107 SpecialPage::getTitleFor( 'Undelete', $this->mTitle->getPrefixedDBkey() ),
1108 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ),
1109 array(),
1110 array(),
1111 array( 'known', 'noclasses' )
1116 return '';
1119 function printableLink() {
1120 global $wgOut, $wgFeedClasses, $wgRequest, $wgLang;
1122 $s = array();
1124 if ( !$wgOut->isPrintable() ) {
1125 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
1126 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
1129 if( $wgOut->isSyndicated() ) {
1130 foreach( $wgFeedClasses as $format => $class ) {
1131 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
1132 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
1133 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
1136 return $wgLang->pipeList( $s );
1140 * Gets the h1 element with the page title.
1141 * @return string
1143 function pageTitle() {
1144 global $wgOut;
1145 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
1146 return $s;
1149 function pageSubtitle() {
1150 global $wgOut;
1152 $sub = $wgOut->getSubtitle();
1153 if ( $sub == '' ) {
1154 global $wgExtraSubtitle;
1155 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
1157 $subpages = $this->subPageSubtitle();
1158 $sub .= !empty( $subpages ) ? "</p><p class='subpages'>$subpages" : '';
1159 $s = "<p class='subtitle'>{$sub}</p>\n";
1160 return $s;
1163 function subPageSubtitle() {
1164 $subpages = '';
1165 if( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages ) ) ) {
1166 return $subpages;
1169 global $wgOut;
1170 if( $wgOut->isArticle() && MWNamespace::hasSubpages( $this->mTitle->getNamespace() ) ) {
1171 $ptext = $this->mTitle->getPrefixedText();
1172 if( preg_match( '/\//', $ptext ) ) {
1173 $links = explode( '/', $ptext );
1174 array_pop( $links );
1175 $c = 0;
1176 $growinglink = '';
1177 $display = '';
1178 foreach( $links as $link ) {
1179 $growinglink .= $link;
1180 $display .= $link;
1181 $linkObj = Title::newFromText( $growinglink );
1182 if( is_object( $linkObj ) && $linkObj->exists() ) {
1183 $getlink = $this->link(
1184 $linkObj,
1185 htmlspecialchars( $display ),
1186 array(),
1187 array(),
1188 array( 'known', 'noclasses' )
1190 $c++;
1191 if( $c > 1 ) {
1192 $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1193 } else {
1194 $subpages .= '&lt; ';
1196 $subpages .= $getlink;
1197 $display = '';
1198 } else {
1199 $display .= '/';
1201 $growinglink .= '/';
1205 return $subpages;
1209 * Returns true if the IP should be shown in the header
1211 function showIPinHeader() {
1212 global $wgShowIPinHeader;
1213 return $wgShowIPinHeader && session_id() != '';
1216 function nameAndLogin() {
1217 global $wgUser, $wgLang, $wgContLang;
1219 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
1221 $ret = '';
1222 if ( $wgUser->isAnon() ) {
1223 if( $this->showIPinHeader() ) {
1224 $name = wfGetIP();
1226 $talkLink = $this->link( $wgUser->getTalkPage(),
1227 $wgLang->getNsText( NS_TALK ) );
1229 $ret .= "$name ($talkLink)";
1230 } else {
1231 $ret .= wfMsg( 'notloggedin' );
1234 $returnTo = $this->mTitle->getPrefixedDBkey();
1235 $query = array();
1236 if ( $logoutPage != $returnTo ) {
1237 $query['returnto'] = $returnTo;
1240 $loginlink = $wgUser->isAllowed( 'createaccount' )
1241 ? 'nav-login-createaccount'
1242 : 'login';
1243 $ret .= "\n<br />" . $this->link(
1244 SpecialPage::getTitleFor( 'Userlogin' ),
1245 wfMsg( $loginlink ), array(), $query
1247 } else {
1248 $returnTo = $this->mTitle->getPrefixedDBkey();
1249 $talkLink = $this->link( $wgUser->getTalkPage(),
1250 $wgLang->getNsText( NS_TALK ) );
1252 $ret .= $this->link( $wgUser->getUserPage(),
1253 htmlspecialchars( $wgUser->getName() ) );
1254 $ret .= " ($talkLink)<br />";
1255 $ret .= $wgLang->pipeList( array(
1256 $this->link(
1257 SpecialPage::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
1258 array(), array( 'returnto' => $returnTo )
1260 $this->specialLink( 'preferences' ),
1261 ) );
1263 $ret = $wgLang->pipeList( array(
1264 $ret,
1265 $this->link(
1266 Title::newFromText( wfMsgForContent( 'helppage' ) ),
1267 wfMsg( 'help' )
1269 ) );
1271 return $ret;
1274 function getSearchLink() {
1275 $searchPage = SpecialPage::getTitleFor( 'Search' );
1276 return $searchPage->getLocalURL();
1279 function escapeSearchLink() {
1280 return htmlspecialchars( $this->getSearchLink() );
1283 function searchForm() {
1284 global $wgRequest, $wgUseTwoButtonsSearchForm;
1285 $search = $wgRequest->getText( 'search' );
1287 $s = '<form id="searchform' . $this->searchboxes . '" name="search" class="inline" method="post" action="'
1288 . $this->escapeSearchLink() . "\">\n"
1289 . '<input type="text" id="searchInput' . $this->searchboxes . '" name="search" size="19" value="'
1290 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
1291 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
1293 if( $wgUseTwoButtonsSearchForm ) {
1294 $s .= '&#160;<input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
1295 } else {
1296 $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
1299 $s .= '</form>';
1301 // Ensure unique id's for search boxes made after the first
1302 $this->searchboxes = $this->searchboxes == '' ? 2 : $this->searchboxes + 1;
1304 return $s;
1307 function topLinks() {
1308 global $wgOut;
1310 $s = array(
1311 $this->mainPageLink(),
1312 $this->specialLink( 'recentchanges' )
1315 if ( $wgOut->isArticleRelated() ) {
1316 $s[] = $this->editThisPage();
1317 $s[] = $this->historyLink();
1319 # Many people don't like this dropdown box
1320 #$s[] = $this->specialPagesList();
1322 if( $this->variantLinks() ) {
1323 $s[] = $this->variantLinks();
1326 if( $this->extensionTabLinks() ) {
1327 $s[] = $this->extensionTabLinks();
1330 // FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
1331 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
1335 * Compatibility for extensions adding functionality through tabs.
1336 * Eventually these old skins should be replaced with SkinTemplate-based
1337 * versions, sigh...
1338 * @return string
1340 function extensionTabLinks() {
1341 $tabs = array();
1342 $out = '';
1343 $s = array();
1344 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1345 foreach( $tabs as $tab ) {
1346 $s[] = Xml::element( 'a',
1347 array( 'href' => $tab['href'] ),
1348 $tab['text'] );
1351 if( count( $s ) ) {
1352 global $wgLang;
1354 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
1355 $out .= $wgLang->pipeList( $s );
1358 return $out;
1362 * Language/charset variant links for classic-style skins
1363 * @return string
1365 function variantLinks() {
1366 $s = '';
1367 /* show links to different language variants */
1368 global $wgDisableLangConversion, $wgLang, $wgContLang;
1369 $variants = $wgContLang->getVariants();
1370 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1371 foreach( $variants as $code ) {
1372 $varname = $wgContLang->getVariantname( $code );
1373 if( $varname == 'disable' ) {
1374 continue;
1376 $s = $wgLang->pipeList( array(
1378 '<a href="' . $this->mTitle->escapeLocalURL( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
1379 ) );
1382 return $s;
1385 function bottomLinks() {
1386 global $wgOut, $wgUser, $wgUseTrackbacks;
1387 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
1389 $s = '';
1390 if ( $wgOut->isArticleRelated() ) {
1391 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
1392 if ( $wgUser->isLoggedIn() ) {
1393 $element[] = $this->watchThisPage();
1395 $element[] = $this->talkLink();
1396 $element[] = $this->historyLink();
1397 $element[] = $this->whatLinksHere();
1398 $element[] = $this->watchPageLinksLink();
1400 if( $wgUseTrackbacks ) {
1401 $element[] = $this->trackbackLink();
1404 if (
1405 $this->mTitle->getNamespace() == NS_USER ||
1406 $this->mTitle->getNamespace() == NS_USER_TALK
1409 $id = User::idFromName( $this->mTitle->getText() );
1410 $ip = User::isIP( $this->mTitle->getText() );
1412 # Both anons and non-anons have contributions list
1413 if( $id || $ip ) {
1414 $element[] = $this->userContribsLink();
1416 if( $this->showEmailUser( $id ) ) {
1417 $element[] = $this->emailUserLink();
1421 $s = implode( $element, $sep );
1423 if ( $this->mTitle->getArticleId() ) {
1424 $s .= "\n<br />";
1425 // Delete/protect/move links for privileged users
1426 if( $wgUser->isAllowed( 'delete' ) ) {
1427 $s .= $this->deleteThisPage();
1429 if( $wgUser->isAllowed( 'protect' ) ) {
1430 $s .= $sep . $this->protectThisPage();
1432 if( $wgUser->isAllowed( 'move' ) ) {
1433 $s .= $sep . $this->moveThisPage();
1436 $s .= "<br />\n" . $this->otherLanguages();
1439 return $s;
1442 function pageStats() {
1443 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1444 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
1446 $oldid = $wgRequest->getVal( 'oldid' );
1447 $diff = $wgRequest->getVal( 'diff' );
1448 if ( !$wgOut->isArticle() ) {
1449 return '';
1451 if( !$wgArticle instanceof Article ) {
1452 return '';
1454 if ( isset( $oldid ) || isset( $diff ) ) {
1455 return '';
1457 if ( 0 == $wgArticle->getID() ) {
1458 return '';
1461 $s = '';
1462 if ( !$wgDisableCounters ) {
1463 $count = $wgLang->formatNum( $wgArticle->getCount() );
1464 if ( $count ) {
1465 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1469 if( $wgMaxCredits != 0 ) {
1470 $s .= ' ' . Credits::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
1471 } else {
1472 $s .= $this->lastModified();
1475 if( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
1476 $dbr = wfGetDB( DB_SLAVE );
1477 $res = $dbr->select(
1478 'watchlist',
1479 array( 'COUNT(*) AS n' ),
1480 array(
1481 'wl_title' => $dbr->strencode( $this->mTitle->getDBkey() ),
1482 'wl_namespace' => $this->mTitle->getNamespace()
1484 __METHOD__
1486 $x = $dbr->fetchObject( $res );
1488 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1489 array( 'parseinline' ), $wgLang->formatNum( $x->n )
1493 return $s . ' ' . $this->getCopyright();
1496 function getCopyright( $type = 'detect' ) {
1497 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest, $wgArticle;
1499 if ( $type == 'detect' ) {
1500 $diff = $wgRequest->getVal( 'diff' );
1501 $isCur = $wgArticle && $wgArticle->isCurrent();
1502 if ( is_null( $diff ) && !$isCur && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1503 $type = 'history';
1504 } else {
1505 $type = 'normal';
1509 if ( $type == 'history' ) {
1510 $msg = 'history_copyright';
1511 } else {
1512 $msg = 'copyright';
1515 $out = '';
1516 if( $wgRightsPage ) {
1517 $title = Title::newFromText( $wgRightsPage );
1518 $link = $this->linkKnown( $title, $wgRightsText );
1519 } elseif( $wgRightsUrl ) {
1520 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1521 } elseif( $wgRightsText ) {
1522 $link = $wgRightsText;
1523 } else {
1524 # Give up now
1525 return $out;
1527 // Allow for site and per-namespace customization of copyright notice.
1528 $forContent = true;
1529 if( isset( $wgArticle ) ) {
1530 wfRunHooks( 'SkinCopyrightFooter', array( $wgArticle->getTitle(), $type, &$msg, &$link, &$forContent ) );
1533 if ( $forContent ) {
1534 $out .= wfMsgForContent( $msg, $link );
1535 } else {
1536 $out .= wfMsg( $msg, $link );
1538 return $out;
1541 function getCopyrightIcon() {
1542 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1543 $out = '';
1544 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1545 $out = $wgCopyrightIcon;
1546 } elseif ( $wgRightsIcon ) {
1547 $icon = htmlspecialchars( $wgRightsIcon );
1548 if ( $wgRightsUrl ) {
1549 $url = htmlspecialchars( $wgRightsUrl );
1550 $out .= '<a href="'.$url.'">';
1552 $text = htmlspecialchars( $wgRightsText );
1553 $out .= "<img src=\"$icon\" alt=\"$text\" width=\"88\" height=\"31\" />";
1554 if ( $wgRightsUrl ) {
1555 $out .= '</a>';
1558 return $out;
1562 * Gets the powered by MediaWiki icon.
1563 * @return string
1565 function getPoweredBy() {
1566 global $wgStylePath;
1567 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1568 $img = '<a href="http://www.mediawiki.org/"><img src="' . $url . '" height="31" width="88" alt="Powered by MediaWiki" /></a>';
1569 return $img;
1572 function lastModified() {
1573 global $wgLang, $wgArticle;
1574 if( $this->mRevisionId && $this->mRevisionId != $wgArticle->getLatest() ) {
1575 $timestamp = Revision::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId );
1576 } else {
1577 $timestamp = $wgArticle->getTimestamp();
1579 if ( $timestamp ) {
1580 $d = $wgLang->date( $timestamp, true );
1581 $t = $wgLang->time( $timestamp, true );
1582 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1583 } else {
1584 $s = '';
1586 if ( wfGetLB()->getLaggedSlaveMode() ) {
1587 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1589 return $s;
1592 function logoText( $align = '' ) {
1593 if ( $align != '' ) {
1594 $a = " align='{$align}'";
1595 } else {
1596 $a = '';
1599 $mp = wfMsg( 'mainpage' );
1600 $mptitle = Title::newMainPage();
1601 $url = ( is_object( $mptitle ) ? $mptitle->escapeLocalURL() : '' );
1603 $logourl = $this->getLogo();
1604 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1605 return $s;
1609 * Show a drop-down box of special pages
1611 function specialPagesList() {
1612 global $wgContLang, $wgServer, $wgRedirectScript;
1613 $pages = array_merge( SpecialPage::getRegularPages(), SpecialPage::getRestrictedPages() );
1614 foreach ( $pages as $name => $page ) {
1615 $pages[$name] = $page->getDescription();
1618 $go = wfMsg( 'go' );
1619 $sp = wfMsg( 'specialpages' );
1620 $spp = $wgContLang->specialPage( 'Specialpages' );
1622 $s = '<form id="specialpages" method="get" ' .
1623 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1624 $s .= "<select name=\"wpDropdown\">\n";
1625 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1628 foreach ( $pages as $name => $desc ) {
1629 $p = $wgContLang->specialPage( $name );
1630 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1632 $s .= "</select>\n";
1633 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1634 $s .= "</form>\n";
1635 return $s;
1639 * Gets the link to the wiki's main page.
1640 * @return string
1642 function mainPageLink() {
1643 $s = $this->link(
1644 Title::newMainPage(),
1645 wfMsg( 'mainpage' ),
1646 array(),
1647 array(),
1648 array( 'known', 'noclasses' )
1650 return $s;
1653 private function footerLink( $desc, $page ) {
1654 // if the link description has been set to "-" in the default language,
1655 if ( wfMsgForContent( $desc ) == '-') {
1656 // then it is disabled, for all languages.
1657 return '';
1658 } else {
1659 // Otherwise, we display the link for the user, described in their
1660 // language (which may or may not be the same as the default language),
1661 // but we make the link target be the one site-wide page.
1662 $title = Title::newFromText( wfMsgForContent( $page ) );
1663 return $this->linkKnown(
1664 $title,
1665 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) )
1671 * Gets the link to the wiki's privacy policy page.
1673 function privacyLink() {
1674 return $this->footerLink( 'privacy', 'privacypage' );
1678 * Gets the link to the wiki's about page.
1680 function aboutLink() {
1681 return $this->footerLink( 'aboutsite', 'aboutpage' );
1685 * Gets the link to the wiki's general disclaimers page.
1687 function disclaimerLink() {
1688 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1691 function editThisPage() {
1692 global $wgOut;
1694 if ( !$wgOut->isArticleRelated() ) {
1695 $s = wfMsg( 'protectedpage' );
1696 } else {
1697 if( $this->mTitle->quickUserCan( 'edit' ) && $this->mTitle->exists() ) {
1698 $t = wfMsg( 'editthispage' );
1699 } elseif( $this->mTitle->quickUserCan( 'create' ) && !$this->mTitle->exists() ) {
1700 $t = wfMsg( 'create-this-page' );
1701 } else {
1702 $t = wfMsg( 'viewsource' );
1705 $s = $this->link(
1706 $this->mTitle,
1708 array(),
1709 $this->editUrlOptions(),
1710 array( 'known', 'noclasses' )
1713 return $s;
1717 * Return URL options for the 'edit page' link.
1718 * This may include an 'oldid' specifier, if the current page view is such.
1720 * @return array
1721 * @private
1723 function editUrlOptions() {
1724 global $wgArticle;
1726 $options = array( 'action' => 'edit' );
1728 if( $this->mRevisionId && ! $wgArticle->isCurrent() ) {
1729 $options['oldid'] = intval( $this->mRevisionId );
1732 return $options;
1735 function deleteThisPage() {
1736 global $wgUser, $wgRequest;
1738 $diff = $wgRequest->getVal( 'diff' );
1739 if ( $this->mTitle->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
1740 $t = wfMsg( 'deletethispage' );
1742 $s = $this->link(
1743 $this->mTitle,
1745 array(),
1746 array( 'action' => 'delete' ),
1747 array( 'known', 'noclasses' )
1749 } else {
1750 $s = '';
1752 return $s;
1755 function protectThisPage() {
1756 global $wgUser, $wgRequest;
1758 $diff = $wgRequest->getVal( 'diff' );
1759 if ( $this->mTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1760 if ( $this->mTitle->isProtected() ) {
1761 $text = wfMsg( 'unprotectthispage' );
1762 $query = array( 'action' => 'unprotect' );
1763 } else {
1764 $text = wfMsg( 'protectthispage' );
1765 $query = array( 'action' => 'protect' );
1768 $s = $this->link(
1769 $this->mTitle,
1770 $text,
1771 array(),
1772 $query,
1773 array( 'known', 'noclasses' )
1775 } else {
1776 $s = '';
1778 return $s;
1781 function watchThisPage() {
1782 global $wgOut;
1783 ++$this->mWatchLinkNum;
1785 if ( $wgOut->isArticleRelated() ) {
1786 if ( $this->mTitle->userIsWatching() ) {
1787 $text = wfMsg( 'unwatchthispage' );
1788 $query = array( 'action' => 'unwatch' );
1789 $id = 'mw-unwatch-link' . $this->mWatchLinkNum;
1790 } else {
1791 $text = wfMsg( 'watchthispage' );
1792 $query = array( 'action' => 'watch' );
1793 $id = 'mw-watch-link' . $this->mWatchLinkNum;
1796 $s = $this->link(
1797 $this->mTitle,
1798 $text,
1799 array( 'id' => $id ),
1800 $query,
1801 array( 'known', 'noclasses' )
1803 } else {
1804 $s = wfMsg( 'notanarticle' );
1806 return $s;
1809 function moveThisPage() {
1810 if ( $this->mTitle->quickUserCan( 'move' ) ) {
1811 return $this->link(
1812 SpecialPage::getTitleFor( 'Movepage' ),
1813 wfMsg( 'movethispage' ),
1814 array(),
1815 array( 'target' => $this->mTitle->getPrefixedDBkey() ),
1816 array( 'known', 'noclasses' )
1818 } else {
1819 // no message if page is protected - would be redundant
1820 return '';
1824 function historyLink() {
1825 return $this->link(
1826 $this->mTitle,
1827 wfMsgHtml( 'history' ),
1828 array( 'rel' => 'archives' ),
1829 array( 'action' => 'history' )
1833 function whatLinksHere() {
1834 return $this->link(
1835 SpecialPage::getTitleFor( 'Whatlinkshere', $this->mTitle->getPrefixedDBkey() ),
1836 wfMsgHtml( 'whatlinkshere' ),
1837 array(),
1838 array(),
1839 array( 'known', 'noclasses' )
1843 function userContribsLink() {
1844 return $this->link(
1845 SpecialPage::getTitleFor( 'Contributions', $this->mTitle->getDBkey() ),
1846 wfMsgHtml( 'contributions' ),
1847 array(),
1848 array(),
1849 array( 'known', 'noclasses' )
1853 function showEmailUser( $id ) {
1854 global $wgUser;
1855 $targetUser = User::newFromId( $id );
1856 return $wgUser->canSendEmail() && # the sending user must have a confirmed email address
1857 $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
1860 function emailUserLink() {
1861 return $this->link(
1862 SpecialPage::getTitleFor( 'Emailuser', $this->mTitle->getDBkey() ),
1863 wfMsg( 'emailuser' ),
1864 array(),
1865 array(),
1866 array( 'known', 'noclasses' )
1870 function watchPageLinksLink() {
1871 global $wgOut;
1872 if ( !$wgOut->isArticleRelated() ) {
1873 return '(' . wfMsg( 'notanarticle' ) . ')';
1874 } else {
1875 return $this->link(
1876 SpecialPage::getTitleFor( 'Recentchangeslinked', $this->mTitle->getPrefixedDBkey() ),
1877 wfMsg( 'recentchangeslinked-toolbox' ),
1878 array(),
1879 array(),
1880 array( 'known', 'noclasses' )
1885 function trackbackLink() {
1886 return '<a href="' . $this->mTitle->trackbackURL() . '">'
1887 . wfMsg( 'trackbacklink' ) . '</a>';
1890 function otherLanguages() {
1891 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1893 if ( $wgHideInterlanguageLinks ) {
1894 return '';
1897 $a = $wgOut->getLanguageLinks();
1898 if ( 0 == count( $a ) ) {
1899 return '';
1902 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
1903 $first = true;
1904 if( $wgContLang->isRTL() ) {
1905 $s .= '<span dir="LTR">';
1907 foreach( $a as $l ) {
1908 if ( !$first ) {
1909 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1911 $first = false;
1913 $nt = Title::newFromText( $l );
1914 $url = $nt->escapeFullURL();
1915 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1916 $title = htmlspecialchars( $nt->getText() );
1918 if ( $text == '' ) {
1919 $text = $l;
1921 $style = $this->getExternalLinkAttributes();
1922 $s .= "<a href=\"{$url}\" title=\"{$title}\"{$style}>{$text}</a>";
1924 if( $wgContLang->isRTL() ) {
1925 $s .= '</span>';
1927 return $s;
1930 function talkLink() {
1931 if ( NS_SPECIAL == $this->mTitle->getNamespace() ) {
1932 # No discussion links for special pages
1933 return '';
1936 $linkOptions = array();
1938 if( $this->mTitle->isTalkPage() ) {
1939 $link = $this->mTitle->getSubjectPage();
1940 switch( $link->getNamespace() ) {
1941 case NS_MAIN:
1942 $text = wfMsg( 'articlepage' );
1943 break;
1944 case NS_USER:
1945 $text = wfMsg( 'userpage' );
1946 break;
1947 case NS_PROJECT:
1948 $text = wfMsg( 'projectpage' );
1949 break;
1950 case NS_FILE:
1951 $text = wfMsg( 'imagepage' );
1952 # Make link known if image exists, even if the desc. page doesn't.
1953 if( wfFindFile( $link ) )
1954 $linkOptions[] = 'known';
1955 break;
1956 case NS_MEDIAWIKI:
1957 $text = wfMsg( 'mediawikipage' );
1958 break;
1959 case NS_TEMPLATE:
1960 $text = wfMsg( 'templatepage' );
1961 break;
1962 case NS_HELP:
1963 $text = wfMsg( 'viewhelppage' );
1964 break;
1965 case NS_CATEGORY:
1966 $text = wfMsg( 'categorypage' );
1967 break;
1968 default:
1969 $text = wfMsg( 'articlepage' );
1971 } else {
1972 $link = $this->mTitle->getTalkPage();
1973 $text = wfMsg( 'talkpage' );
1976 $s = $this->link( $link, $text, array(), array(), $linkOptions );
1978 return $s;
1981 function commentLink() {
1982 global $wgOut;
1984 if ( $this->mTitle->getNamespace() == NS_SPECIAL ) {
1985 return '';
1988 # __NEWSECTIONLINK___ changes behaviour here
1989 # If it is present, the link points to this page, otherwise
1990 # it points to the talk page
1991 if( $this->mTitle->isTalkPage() ) {
1992 $title = $this->mTitle;
1993 } elseif( $wgOut->showNewSectionLink() ) {
1994 $title = $this->mTitle;
1995 } else {
1996 $title = $this->mTitle->getTalkPage();
1999 return $this->link(
2000 $title,
2001 wfMsg( 'postcomment' ),
2002 array(),
2003 array(
2004 'action' => 'edit',
2005 'section' => 'new'
2007 array( 'known', 'noclasses' )
2011 function getUploadLink() {
2012 global $wgUploadNavigationUrl;
2014 if( $wgUploadNavigationUrl ) {
2015 # Using an empty class attribute to avoid automatic setting of "external" class
2016 return $this->makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '') );
2017 } else {
2018 return $this->link(
2019 SpecialPage::getTitleFor('Upload'),
2020 wfMsgHtml( 'upload' ),
2021 array(),
2022 array(),
2023 array( 'known', 'noclasses' )
2028 /* these are used extensively in SkinTemplate, but also some other places */
2029 static function makeMainPageUrl( $urlaction = '' ) {
2030 $title = Title::newMainPage();
2031 self::checkTitle( $title, '' );
2032 return $title->getLocalURL( $urlaction );
2035 static function makeSpecialUrl( $name, $urlaction = '' ) {
2036 $title = SpecialPage::getTitleFor( $name );
2037 return $title->getLocalURL( $urlaction );
2040 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
2041 $title = SpecialPage::getSafeTitleFor( $name, $subpage );
2042 return $title->getLocalURL( $urlaction );
2045 static function makeI18nUrl( $name, $urlaction = '' ) {
2046 $title = Title::newFromText( wfMsgForContent( $name ) );
2047 self::checkTitle( $title, $name );
2048 return $title->getLocalURL( $urlaction );
2051 static function makeUrl( $name, $urlaction = '' ) {
2052 $title = Title::newFromText( $name );
2053 self::checkTitle( $title, $name );
2054 return $title->getLocalURL( $urlaction );
2058 * If url string starts with http, consider as external URL, else
2059 * internal
2061 static function makeInternalOrExternalUrl( $name ) {
2062 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
2063 return $name;
2064 } else {
2065 return self::makeUrl( $name );
2069 # this can be passed the NS number as defined in Language.php
2070 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN ) {
2071 $title = Title::makeTitleSafe( $namespace, $name );
2072 self::checkTitle( $title, $name );
2073 return $title->getLocalURL( $urlaction );
2076 /* these return an array with the 'href' and boolean 'exists' */
2077 static function makeUrlDetails( $name, $urlaction = '' ) {
2078 $title = Title::newFromText( $name );
2079 self::checkTitle( $title, $name );
2080 return array(
2081 'href' => $title->getLocalURL( $urlaction ),
2082 'exists' => $title->getArticleID() != 0 ? true : false
2087 * Make URL details where the article exists (or at least it's convenient to think so)
2089 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
2090 $title = Title::newFromText( $name );
2091 self::checkTitle( $title, $name );
2092 return array(
2093 'href' => $title->getLocalURL( $urlaction ),
2094 'exists' => true
2098 # make sure we have some title to operate on
2099 static function checkTitle( &$title, $name ) {
2100 if( !is_object( $title ) ) {
2101 $title = Title::newFromText( $name );
2102 if( !is_object( $title ) ) {
2103 $title = Title::newFromText( '--error: link target missing--' );
2109 * Build an array that represents the sidebar(s), the navigation bar among them
2111 * @return array
2113 function buildSidebar() {
2114 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
2115 global $wgLang;
2116 wfProfileIn( __METHOD__ );
2118 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
2120 if ( $wgEnableSidebarCache ) {
2121 $cachedsidebar = $parserMemc->get( $key );
2122 if ( $cachedsidebar ) {
2123 wfProfileOut( __METHOD__ );
2124 return $cachedsidebar;
2128 $bar = array();
2129 $this->addToSidebar( $bar, 'sidebar' );
2131 wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
2132 if ( $wgEnableSidebarCache ) {
2133 $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
2135 wfProfileOut( __METHOD__ );
2136 return $bar;
2139 * Add content from a sidebar system message
2140 * Currently only used for MediaWiki:Sidebar (but may be used by Extensions)
2142 * This is just a wrapper around addToSidebarPlain() for backwards compatibility
2144 * @param &$bar array
2145 * @param $message String
2147 function addToSidebar( &$bar, $message ) {
2148 $this->addToSidebarPlain( $bar, wfMsgForContent( $message ) );
2152 * Add content from plain text
2153 * @since 1.17
2154 * @param &$bar array
2155 * @param $text string
2157 function addToSidebarPlain( &$bar, $text ) {
2158 $lines = explode( "\n", $text );
2159 $wikiBar = array(); # We need to handle the wikitext on a different variable, to avoid trying to do an array operation on text, which would be a fatal error.
2161 $heading = '';
2162 foreach( $lines as $line ) {
2163 if( strpos( $line, '*' ) !== 0 ) {
2164 continue;
2166 if( strpos( $line, '**') !== 0 ) {
2167 $heading = trim( $line, '* ' );
2168 if( !array_key_exists( $heading, $bar ) ) {
2169 $bar[$heading] = array();
2171 } else {
2172 $line = trim( $line, '* ' );
2173 if( strpos( $line, '|' ) !== false ) { // sanity check
2174 $line = array_map( 'trim', explode( '|', $line, 2 ) );
2175 $link = wfMsgForContent( $line[0] );
2176 if( $link == '-' ) {
2177 continue;
2180 $text = wfMsgExt( $line[1], 'parsemag' );
2181 if( wfEmptyMsg( $line[1], $text ) ) {
2182 $text = $line[1];
2184 if( wfEmptyMsg( $line[0], $link ) ) {
2185 $link = $line[0];
2188 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
2189 $href = $link;
2190 } else {
2191 $title = Title::newFromText( $link );
2192 if ( $title ) {
2193 $title = $title->fixSpecialName();
2194 $href = $title->getLocalURL();
2195 } else {
2196 $href = 'INVALID-TITLE';
2200 $bar[$heading][] = array(
2201 'text' => $text,
2202 'href' => $href,
2203 'id' => 'n-' . strtr( $line[1], ' ', '-' ),
2204 'active' => false
2206 } else if ( (substr($line, 0, 2) == '{{') && (substr($line, -2) == '}}') ) {
2207 global $wgParser, $wgTitle;
2209 $line = substr($line, 2, strlen($line) - 4 );
2211 if (is_null($wgParser->mOptions))
2212 $wgParser->mOptions = new ParserOptions();
2214 $wgParser->mOptions->setEditSection(false);
2215 $wikiBar[$heading] = $wgParser->parse( wfMsgForContentNoTrans( $line ) , $wgTitle, $wgParser->mOptions )->getText();
2216 } else {
2217 continue;
2222 if ( count($wikiBar) > 0 )
2223 $bar = array_merge($bar, $wikiBar);
2225 return $bar;
2229 * Should we include common/wikiprintable.css? Skins that have their own
2230 * print stylesheet should override this and return false. (This is an
2231 * ugly hack to get Monobook to play nicely with
2232 * OutputPage::headElement().)
2234 * @return bool
2236 public function commonPrintStylesheet() {
2237 return true;
2241 * Gets new talk page messages for the current user.
2242 * @return MediaWiki message or if no new talk page messages, nothing
2244 function getNewtalks() {
2245 global $wgUser, $wgOut;
2246 $newtalks = $wgUser->getNewMessageLinks();
2247 $ntl = '';
2249 if( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
2250 $userTitle = $this->mUser->getUserPage();
2251 $userTalkTitle = $userTitle->getTalkPage();
2253 if( !$userTalkTitle->equals( $this->mTitle ) ) {
2254 $newMessagesLink = $this->link(
2255 $userTalkTitle,
2256 wfMsgHtml( 'newmessageslink' ),
2257 array(),
2258 array( 'redirect' => 'no' ),
2259 array( 'known', 'noclasses' )
2262 $newMessagesDiffLink = $this->link(
2263 $userTalkTitle,
2264 wfMsgHtml( 'newmessagesdifflink' ),
2265 array(),
2266 array( 'diff' => 'cur' ),
2267 array( 'known', 'noclasses' )
2270 $ntl = wfMsg(
2271 'youhavenewmessages',
2272 $newMessagesLink,
2273 $newMessagesDiffLink
2275 # Disable Squid cache
2276 $wgOut->setSquidMaxage( 0 );
2278 } elseif( count( $newtalks ) ) {
2279 // _>" " for BC <= 1.16
2280 $sep = str_replace( '_', ' ', wfMsgHtml( 'newtalkseparator' ) );
2281 $msgs = array();
2282 foreach( $newtalks as $newtalk ) {
2283 $msgs[] = Xml::element(
2284 'a',
2285 array( 'href' => $newtalk['link'] ), $newtalk['wiki']
2288 $parts = implode( $sep, $msgs );
2289 $ntl = wfMsgHtml( 'youhavenewmessagesmulti', $parts );
2290 $wgOut->setSquidMaxage( 0 );
2292 return $ntl;