Patched jquery-1.4.2 to not crash in IE7 when a style property is set with 'null...
[mediawiki.git] / includes / Skin.php
blob8c327e4386d8850d85d0306cd985dbcfa810ad23
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 {
119 return 'monobook';
124 * Factory method for loading a skin of a given type
125 * @param $key String: 'monobook', 'standard', etc.
126 * @return Skin
128 static function &newFromKey( $key ) {
129 global $wgStyleDirectory;
131 $key = Skin::normalizeKey( $key );
133 $skinNames = Skin::getSkinNames();
134 $skinName = $skinNames[$key];
135 $className = 'Skin' . ucfirst( $key );
137 # Grab the skin class and initialise it.
138 if ( !class_exists( $className ) ) {
139 // Preload base classes to work around APC/PHP5 bug
140 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
141 if( file_exists( $deps ) ) {
142 include_once( $deps );
144 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
146 # Check if we got if not failback to default skin
147 if( !class_exists( $className ) ) {
148 # DO NOT die if the class isn't found. This breaks maintenance
149 # scripts and can cause a user account to be unrecoverable
150 # except by SQL manipulation if a previously valid skin name
151 # is no longer valid.
152 wfDebug( "Skin class does not exist: $className\n" );
153 $className = 'SkinMonobook';
154 require_once( "{$wgStyleDirectory}/MonoBook.php" );
157 $skin = new $className;
158 return $skin;
161 /** @return string path to the skin stylesheet */
162 function getStylesheet() {
163 return 'common/wikistandard.css';
166 /** @return string skin name */
167 public function getSkinName() {
168 return $this->skinname;
171 function qbSetting() {
172 global $wgOut, $wgUser;
174 if ( $wgOut->isQuickbarSuppressed() ) {
175 return 0;
177 $q = $wgUser->getOption( 'quickbar', 0 );
178 return $q;
181 function initPage( OutputPage $out ) {
182 global $wgFavicon, $wgAppleTouchIcon;
184 wfProfileIn( __METHOD__ );
186 # Generally the order of the favicon and apple-touch-icon links
187 # should not matter, but Konqueror (3.5.9 at least) incorrectly
188 # uses whichever one appears later in the HTML source. Make sure
189 # apple-touch-icon is specified first to avoid this.
190 if( false !== $wgAppleTouchIcon ) {
191 $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
194 if( false !== $wgFavicon ) {
195 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
198 # OpenSearch description link
199 $out->addLink( array(
200 'rel' => 'search',
201 'type' => 'application/opensearchdescription+xml',
202 'href' => wfScript( 'opensearch_desc' ),
203 'title' => wfMsgForContent( 'opensearch-desc' ),
206 $this->addMetadataLinks( $out );
208 $this->mRevisionId = $out->mRevisionId;
210 $this->preloadExistence();
212 wfProfileOut( __METHOD__ );
216 * Preload the existence of three commonly-requested pages in a single query
218 function preloadExistence() {
219 global $wgUser;
221 // User/talk link
222 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
224 // Other tab link
225 if ( $this->mTitle->getNamespace() == NS_SPECIAL ) {
226 // nothing
227 } elseif ( $this->mTitle->isTalkPage() ) {
228 $titles[] = $this->mTitle->getSubjectPage();
229 } else {
230 $titles[] = $this->mTitle->getTalkPage();
233 $lb = new LinkBatch( $titles );
234 $lb->execute();
238 * Adds metadata links (Creative Commons/Dublin Core/copyright) to the HTML
239 * output.
240 * @param $out Object: instance of OutputPage
242 function addMetadataLinks( OutputPage $out ) {
243 global $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
244 global $wgRightsPage, $wgRightsUrl;
246 if( $out->isArticleRelated() ) {
247 # note: buggy CC software only reads first "meta" link
248 if( $wgEnableCreativeCommonsRdf ) {
249 $out->addMetadataLink( array(
250 'title' => 'Creative Commons',
251 'type' => 'application/rdf+xml',
252 'href' => $this->mTitle->getLocalURL( 'action=creativecommons' ) )
255 if( $wgEnableDublinCoreRdf ) {
256 $out->addMetadataLink( array(
257 'title' => 'Dublin Core',
258 'type' => 'application/rdf+xml',
259 'href' => $this->mTitle->getLocalURL( 'action=dublincore' ) )
263 $copyright = '';
264 if( $wgRightsPage ) {
265 $copy = Title::newFromText( $wgRightsPage );
266 if( $copy ) {
267 $copyright = $copy->getLocalURL();
270 if( !$copyright && $wgRightsUrl ) {
271 $copyright = $wgRightsUrl;
273 if( $copyright ) {
274 $out->addLink( array(
275 'rel' => 'copyright',
276 'href' => $copyright )
282 * Set some local variables
284 protected function setMembers() {
285 global $wgUser;
286 $this->mUser = $wgUser;
287 $this->userpage = $wgUser->getUserPage()->getPrefixedText();
288 $this->usercss = false;
292 * Set the title
293 * @param Title $t The title to use
295 public function setTitle( $t ) {
296 $this->mTitle = $t;
299 /** Get the title */
300 public function getTitle() {
301 return $this->mTitle;
305 * Outputs the HTML generated by other functions.
306 * @param $out Object: instance of OutputPage
308 function outputPage( OutputPage $out ) {
309 global $wgDebugComments;
310 wfProfileIn( __METHOD__ );
312 $this->setMembers();
313 $this->initPage( $out );
315 // See self::afterContentHook() for documentation
316 $afterContent = $this->afterContentHook();
318 $out->out( $out->headElement( $this ) );
320 if ( $wgDebugComments ) {
321 $out->out( "<!-- Wiki debugging output:\n" .
322 $out->mDebugtext . "-->\n" );
325 $out->out( $this->beforeContent() );
327 $out->out( $out->mBodytext . "\n" );
329 $out->out( $this->afterContent() );
331 $out->out( $afterContent );
333 $out->out( $this->bottomScripts() );
335 $out->out( wfReportTime() );
337 $out->out( "\n</body></html>" );
338 wfProfileOut( __METHOD__ );
341 static function makeVariablesScript( $data ) {
342 if( $data ) {
343 $r = array();
344 foreach ( $data as $name => $value ) {
345 $encValue = Xml::encodeJsVar( $value );
346 $r[] = "$name=$encValue";
348 $js = 'var ' . implode( ",\n", $r ) . ';';
349 return Html::inlineScript( "\n$js\n" );
350 } else {
351 return '';
356 * Make a <script> tag containing global variables
357 * @param $skinName string Name of the skin
358 * The odd calling convention is for backwards compatibility
359 * @TODO @FIXME Make this not depend on $wgTitle!
361 static function makeGlobalVariablesScript( $skinName ) {
362 if ( is_array( $skinName ) ) {
363 # Weird back-compat stuff.
364 $skinName = $skinName['skinname'];
366 global $wgScript, $wgTitle, $wgStylePath, $wgUser, $wgScriptExtension;
367 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
368 global $wgOut, $wgArticle;
369 global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
370 global $wgUseAjax, $wgAjaxWatch;
371 global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
372 global $wgRestrictionTypes;
373 global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
374 global $wgSitename;
376 $ns = $wgTitle->getNamespace();
377 $nsname = MWNamespace::exists( $ns ) ? MWNamespace::getCanonicalName( $ns ) : $wgTitle->getNsText();
378 $separatorTransTable = $wgContLang->separatorTransformTable();
379 $separatorTransTable = $separatorTransTable ? $separatorTransTable : array();
380 $compactSeparatorTransTable = array(
381 implode( "\t", array_keys( $separatorTransTable ) ),
382 implode( "\t", $separatorTransTable ),
384 $digitTransTable = $wgContLang->digitTransformTable();
385 $digitTransTable = $digitTransTable ? $digitTransTable : array();
386 $compactDigitTransTable = array(
387 implode( "\t", array_keys( $digitTransTable ) ),
388 implode( "\t", $digitTransTable ),
391 $mainPage = Title::newFromText( wfMsgForContent( 'mainpage' ) );
392 $vars = array(
393 'skin' => $skinName,
394 'stylepath' => $wgStylePath,
395 'wgUrlProtocols' => wfUrlProtocols(),
396 'wgArticlePath' => $wgArticlePath,
397 'wgScriptPath' => $wgScriptPath,
398 'wgScriptExtension' => $wgScriptExtension,
399 'wgScript' => $wgScript,
400 'wgVariantArticlePath' => $wgVariantArticlePath,
401 'wgActionPaths' => (object)$wgActionPaths,
402 'wgServer' => $wgServer,
403 'wgCanonicalNamespace' => $nsname,
404 'wgCanonicalSpecialPageName' => $ns == NS_SPECIAL ?
405 SpecialPage::resolveAlias( $wgTitle->getDBkey() ) : false, # bug 21115
406 'wgNamespaceNumber' => $wgTitle->getNamespace(),
407 'wgPageName' => $wgTitle->getPrefixedDBKey(),
408 'wgTitle' => $wgTitle->getText(),
409 'wgAction' => $wgRequest->getText( 'action', 'view' ),
410 'wgArticleId' => $wgTitle->getArticleId(),
411 'wgIsArticle' => $wgOut->isArticle(),
412 'wgUserName' => $wgUser->isAnon() ? null : $wgUser->getName(),
413 'wgUserGroups' => $wgUser->getEffectiveGroups(),
414 'wgUserLanguage' => $wgLang->getCode(),
415 'wgContentLanguage' => $wgContLang->getCode(),
416 'wgBreakFrames' => $wgBreakFrames,
417 'wgCurRevisionId' => isset( $wgArticle ) ? $wgArticle->getLatest() : 0,
418 'wgVersion' => $wgVersion,
419 'wgEnableAPI' => $wgEnableAPI,
420 'wgEnableWriteAPI' => $wgEnableWriteAPI,
421 'wgSeparatorTransformTable' => $compactSeparatorTransTable,
422 'wgDigitTransformTable' => $compactDigitTransTable,
423 'wgMainPageTitle' => $mainPage ? $mainPage->getPrefixedText() : null,
424 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(),
425 'wgNamespaceIds' => $wgContLang->getNamespaceIds(),
426 'wgSiteName' => $wgSitename,
427 'wgCategories' => $wgOut->getCategories(),
429 if ( $wgContLang->hasVariants() ) {
430 $vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
433 // if on upload page output the extension list & js_upload
434 if( SpecialPage::resolveAlias( $wgTitle->getDBkey() ) == 'Upload' ) {
435 global $wgFileExtensions, $wgAjaxUploadInterface;
436 $vars['wgFileExtensions'] = $wgFileExtensions;
439 if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ) {
440 $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
441 $vars['wgDBname'] = $wgDBname;
442 $vars['wgSearchNamespaces'] = SearchEngine::userNamespaces( $wgUser );
443 $vars['wgMWSuggestMessages'] = array( wfMsg( 'search-mwsuggest-enabled' ), wfMsg( 'search-mwsuggest-disabled' ) );
446 foreach( $wgRestrictionTypes as $type ) {
447 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
450 if ( $wgOut->isArticleRelated() && $wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
451 $msgs = (object)array();
452 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching',
453 'tooltip-ca-watch', 'tooltip-ca-unwatch' ) as $msgName ) {
454 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
456 $vars['wgAjaxWatch'] = $msgs;
459 // Allow extensions to add their custom variables to the global JS variables
460 wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
462 return self::makeVariablesScript( $vars );
466 * To make it harder for someone to slip a user a fake
467 * user-JavaScript or user-CSS preview, a random token
468 * is associated with the login session. If it's not
469 * passed back with the preview request, we won't render
470 * the code.
472 * @param $action String: 'edit', 'submit' etc.
473 * @return bool
475 public function userCanPreview( $action ) {
476 global $wgRequest, $wgUser;
478 if( $action != 'submit' ) {
479 return false;
481 if( !$wgRequest->wasPosted() ) {
482 return false;
484 if( !$this->mTitle->userCanEditCssSubpage() ) {
485 return false;
487 if( !$this->mTitle->userCanEditJsSubpage() ) {
488 return false;
490 return $wgUser->matchEditToken(
491 $wgRequest->getVal( 'wpEditToken' ) );
495 * Generated JavaScript action=raw&gen=js
496 * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
497 * nated together. For some bizarre reason, it does *not* return any
498 * custom user JS from subpages. Huh?
500 * There's absolutely no reason to have separate Monobook/Common JSes.
501 * Any JS that cares can just check the skin variable generated at the
502 * top. For now Monobook.js will be maintained, but it should be consi-
503 * dered deprecated.
505 * @param $skinName String: If set, overrides the skin name
506 * @return string
508 public function generateUserJs( $skinName = null ) {
509 global $wgStylePath;
511 wfProfileIn( __METHOD__ );
512 if( !$skinName ) {
513 $skinName = $this->getSkinName();
516 $s = "/* generated javascript */\n";
517 $s .= "var skin = '" . Xml::escapeJsString( $skinName ) . "';\n";
518 $s .= "var stylepath = '" . Xml::escapeJsString( $wgStylePath ) . "';";
519 $s .= "\n\n/* MediaWiki:Common.js */\n";
520 $commonJs = wfMsgExt( 'common.js', 'content' );
521 if ( !wfEmptyMsg( 'common.js', $commonJs ) ) {
522 $s .= $commonJs;
525 $s .= "\n\n/* MediaWiki:" . ucfirst( $skinName ) . ".js */\n";
526 // avoid inclusion of non defined user JavaScript (with custom skins only)
527 // by checking for default message content
528 $msgKey = ucfirst( $skinName ) . '.js';
529 $userJS = wfMsgExt( $msgKey, 'content' );
530 if ( !wfEmptyMsg( $msgKey, $userJS ) ) {
531 $s .= $userJS;
534 wfProfileOut( __METHOD__ );
535 return $s;
539 * Generate user stylesheet for action=raw&gen=css
541 public function generateUserStylesheet() {
542 wfProfileIn( __METHOD__ );
543 $s = "/* generated user stylesheet */\n" .
544 $this->reallyGenerateUserStylesheet();
545 wfProfileOut( __METHOD__ );
546 return $s;
550 * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
551 * Anything in here won't be generated if $wgAllowUserCssPrefs is false.
553 protected function reallyGenerateUserStylesheet() {
554 global $wgUser;
555 $s = '';
556 if( ( $undopt = $wgUser->getOption( 'underline' ) ) < 2 ) {
557 $underline = $undopt ? 'underline' : 'none';
558 $s .= "a { text-decoration: $underline; }\n";
560 if( $wgUser->getOption( 'highlightbroken' ) ) {
561 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
562 } else {
563 $s .= <<<CSS
564 a.new, #quickbar a.new,
565 a.stub, #quickbar a.stub {
566 color: inherit;
568 a.new:after, #quickbar a.new:after {
569 content: "?";
570 color: #CC2200;
572 a.stub:after, #quickbar a.stub:after {
573 content: "!";
574 color: #772233;
576 CSS;
578 if( $wgUser->getOption( 'justify' ) ) {
579 $s .= "#article, #bodyContent, #mw_content { text-align: justify; }\n";
581 if( !$wgUser->getOption( 'showtoc' ) ) {
582 $s .= "#toc { display: none; }\n";
584 if( !$wgUser->getOption( 'editsection' ) ) {
585 $s .= ".editsection { display: none; }\n";
587 $fontstyle = $wgUser->getOption( 'editfont' );
588 if ( $fontstyle !== 'default' ) {
589 $s .= "textarea { font-family: $fontstyle; }\n";
591 return $s;
595 * @private
597 function setupUserCss( OutputPage $out ) {
598 global $wgRequest, $wgContLang, $wgUser;
599 global $wgAllowUserCss, $wgUseSiteCss, $wgSquidMaxage, $wgStylePath;
601 wfProfileIn( __METHOD__ );
603 $this->setupSkinUserCss( $out );
605 $siteargs = array(
606 'action' => 'raw',
607 'maxage' => $wgSquidMaxage,
610 // Add any extension CSS
611 foreach ( $out->getExtStyle() as $url ) {
612 $out->addStyle( $url );
615 // If we use the site's dynamic CSS, throw that in, too
616 // Per-site custom styles
617 if( $wgUseSiteCss ) {
618 global $wgHandheldStyle;
619 $query = wfArrayToCGI( array(
620 'usemsgcache' => 'yes',
621 'ctype' => 'text/css',
622 'smaxage' => $wgSquidMaxage
623 ) + $siteargs );
624 # Site settings must override extension css! (bug 15025)
625 $out->addStyle( self::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI ) );
626 $out->addStyle( self::makeNSUrl( 'Print.css', $query, NS_MEDIAWIKI ), 'print' );
627 if( $wgHandheldStyle ) {
628 $out->addStyle( self::makeNSUrl( 'Handheld.css', $query, NS_MEDIAWIKI ), 'handheld' );
630 $out->addStyle( self::makeNSUrl( $this->getSkinName() . '.css', $query, NS_MEDIAWIKI ) );
633 global $wgAllowUserCssPrefs;
634 if( $wgAllowUserCssPrefs ){
635 if( $wgUser->isLoggedIn() ) {
636 // Ensure that logged-in users' generated CSS isn't clobbered
637 // by anons' publicly cacheable generated CSS.
638 $siteargs['smaxage'] = '0';
639 $siteargs['ts'] = $wgUser->mTouched;
641 // Per-user styles based on preferences
642 $siteargs['gen'] = 'css';
643 if( ( $us = $wgRequest->getVal( 'useskin', '' ) ) !== '' ) {
644 $siteargs['useskin'] = $us;
646 $out->addStyle( self::makeUrl( '-', wfArrayToCGI( $siteargs ) ) );
649 // Per-user custom style pages
650 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) {
651 $action = $wgRequest->getVal( 'action' );
652 # If we're previewing the CSS page, use it
653 if( $this->mTitle->isCssSubpage() && $this->userCanPreview( $action ) ) {
654 // @FIXME: properly escape the cdata!
655 $out->addInlineStyle( $wgRequest->getText( 'wpTextbox1' ) );
656 } else {
657 $names = array( 'common', $this->getSkinName() );
658 foreach( $names as $name ) {
659 $out->addStyle( self::makeUrl(
660 $this->userpage . '/' . $name . '.css',
661 'action=raw&ctype=text/css' )
667 wfProfileOut( __METHOD__ );
671 * Add skin specific stylesheets
672 * @param $out OutputPage
674 function setupSkinUserCss( OutputPage $out ) {
675 $out->addStyle( 'common/shared.css' );
676 $out->addStyle( 'common/oldshared.css' );
677 $out->addStyle( $this->getStylesheet() );
678 $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' );
681 function getPageClasses( $title ) {
682 $numeric = 'ns-' . $title->getNamespace();
683 if( $title->getNamespace() == NS_SPECIAL ) {
684 $type = 'ns-special';
685 } elseif( $title->isTalkPage() ) {
686 $type = 'ns-talk';
687 } else {
688 $type = 'ns-subject';
690 $name = Sanitizer::escapeClass( 'page-' . $title->getPrefixedText() );
691 return "$numeric $type $name";
695 * URL to the logo
697 function getLogo() {
698 global $wgLogo;
699 return $wgLogo;
703 * This will be called immediately after the <body> tag. Split into
704 * two functions to make it easier to subclass.
706 function beforeContent() {
707 return $this->doBeforeContent();
710 function doBeforeContent() {
711 global $wgContLang;
712 wfProfileIn( __METHOD__ );
714 $s = '';
715 $qb = $this->qbSetting();
717 $langlinks = $this->otherLanguages();
718 if( $langlinks ) {
719 $rows = 2;
720 $borderhack = '';
721 } else {
722 $rows = 1;
723 $langlinks = false;
724 $borderhack = 'class="top"';
727 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
728 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
730 $shove = ( $qb != 0 );
731 $left = ( $qb == 1 || $qb == 3 );
732 if( $wgContLang->isRTL() ) {
733 $left = !$left;
736 if( !$shove ) {
737 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
738 $this->logoText() . '</td>';
739 } elseif( $left ) {
740 $s .= $this->getQuickbarCompensator( $rows );
742 $l = $wgContLang->alignStart();
743 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
745 $s .= $this->topLinks();
746 $s .= '<p class="subtitle">' . $this->pageTitleLinks() . "</p>\n";
748 $r = $wgContLang->alignEnd();
749 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
750 $s .= $this->nameAndLogin();
751 $s .= "\n<br />" . $this->searchForm() . '</td>';
753 if ( $langlinks ) {
754 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
757 if ( $shove && !$left ) { # Right
758 $s .= $this->getQuickbarCompensator( $rows );
760 $s .= "</tr>\n</table>\n</div>\n";
761 $s .= "\n<div id='article'>\n";
763 $notice = wfGetSiteNotice();
764 if( $notice ) {
765 $s .= "\n<div id='siteNotice'>$notice</div>\n";
767 $s .= $this->pageTitle();
768 $s .= $this->pageSubtitle();
769 $s .= $this->getCategories();
770 wfProfileOut( __METHOD__ );
771 return $s;
774 function getCategoryLinks() {
775 global $wgOut, $wgUseCategoryBrowser;
776 global $wgContLang, $wgUser;
778 if( count( $wgOut->mCategoryLinks ) == 0 ) {
779 return '';
782 # Separator
783 $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) );
785 // Use Unicode bidi embedding override characters,
786 // to make sure links don't smash each other up in ugly ways.
787 $dir = $wgContLang->getDir();
788 $embed = "<span dir='$dir'>";
789 $pop = '</span>';
791 $allCats = $wgOut->getCategoryLinks();
792 $s = '';
793 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
794 if ( !empty( $allCats['normal'] ) ) {
795 $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
797 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
798 $s .= '<div id="mw-normal-catlinks">' .
799 $this->link( Title::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
800 . $colon . $t . '</div>';
803 # Hidden categories
804 if ( isset( $allCats['hidden'] ) ) {
805 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
806 $class ='mw-hidden-cats-user-shown';
807 } elseif ( $this->mTitle->getNamespace() == NS_CATEGORY ) {
808 $class = 'mw-hidden-cats-ns-shown';
809 } else {
810 $class = 'mw-hidden-cats-hidden';
812 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
813 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
814 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
815 '</div>';
818 # optional 'dmoz-like' category browser. Will be shown under the list
819 # of categories an article belong to
820 if( $wgUseCategoryBrowser ) {
821 $s .= '<br /><hr />';
823 # get a big array of the parents tree
824 $parenttree = $this->mTitle->getParentCategoryTree();
825 # Skin object passed by reference cause it can not be
826 # accessed under the method subfunction drawCategoryBrowser
827 $tempout = explode( "\n", Skin::drawCategoryBrowser( $parenttree, $this ) );
828 # Clean out bogus first entry and sort them
829 unset( $tempout[0] );
830 asort( $tempout );
831 # Output one per line
832 $s .= implode( "<br />\n", $tempout );
835 return $s;
839 * Render the array as a serie of links.
840 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
841 * @param &skin Object: skin passed by reference
842 * @return String separated by &gt;, terminate with "\n"
844 function drawCategoryBrowser( $tree, &$skin ) {
845 $return = '';
846 foreach( $tree as $element => $parent ) {
847 if( empty( $parent ) ) {
848 # element start a new list
849 $return .= "\n";
850 } else {
851 # grab the others elements
852 $return .= Skin::drawCategoryBrowser( $parent, $skin ) . ' &gt; ';
854 # add our current element to the list
855 $eltitle = Title::newFromText( $element );
856 $return .= $skin->link( $eltitle, $eltitle->getText() );
858 return $return;
861 function getCategories() {
862 $catlinks = $this->getCategoryLinks();
864 $classes = 'catlinks';
866 // Check what we're showing
867 global $wgOut, $wgUser;
868 $allCats = $wgOut->getCategoryLinks();
869 $showHidden = $wgUser->getBoolOption( 'showhiddencats' ) ||
870 $this->mTitle->getNamespace() == NS_CATEGORY;
872 if( empty( $allCats['normal'] ) && !( !empty( $allCats['hidden'] ) && $showHidden ) ) {
873 $classes .= ' catlinks-allhidden';
876 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
879 function getQuickbarCompensator( $rows = 1 ) {
880 return "<td width='152' rowspan='{$rows}'>&nbsp;</td>";
884 * This runs a hook to allow extensions placing their stuff after content
885 * and article metadata (e.g. categories).
886 * Note: This function has nothing to do with afterContent().
888 * This hook is placed here in order to allow using the same hook for all
889 * skins, both the SkinTemplate based ones and the older ones, which directly
890 * use this class to get their data.
892 * The output of this function gets processed in SkinTemplate::outputPage() for
893 * the SkinTemplate based skins, all other skins should directly echo it.
895 * Returns an empty string by default, if not changed by any hook function.
897 protected function afterContentHook() {
898 $data = '';
900 if( wfRunHooks( 'SkinAfterContent', array( &$data ) ) ) {
901 // adding just some spaces shouldn't toggle the output
902 // of the whole <div/>, so we use trim() here
903 if( trim( $data ) != '' ) {
904 // Doing this here instead of in the skins to
905 // ensure that the div has the same ID in all
906 // skins
907 $data = "<div id='mw-data-after-content'>\n" .
908 "\t$data\n" .
909 "</div>\n";
911 } else {
912 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
915 return $data;
919 * Generate debug data HTML for displaying at the bottom of the main content
920 * area.
921 * @return String HTML containing debug data, if enabled (otherwise empty).
923 protected function generateDebugHTML() {
924 global $wgShowDebug, $wgOut;
925 if ( $wgShowDebug ) {
926 $listInternals = $this->formatDebugHTML( $wgOut->mDebugtext );
927 return "\n<hr />\n<strong>Debug data:</strong><ul style=\"font-family:monospace;\" id=\"mw-debug-html\">" .
928 $listInternals . "</ul>\n";
930 return '';
933 private function formatDebugHTML( $debugText ) {
934 $lines = explode( "\n", $debugText );
935 $curIdent = 0;
936 $ret = '<li>';
937 foreach( $lines as $line ) {
938 $m = array();
939 $display = ltrim( $line );
940 $ident = strlen( $line ) - strlen( $display );
941 $diff = $ident - $curIdent;
943 if ( $display == '' ) {
944 $display = "\xc2\xa0";
947 if ( !$ident && $diff < 0 && substr( $display, 0, 9 ) != 'Entering ' && substr( $display, 0, 8 ) != 'Exiting ' ) {
948 $ident = $curIdent;
949 $diff = 0;
950 $display = '<span style="background:yellow;">' . htmlspecialchars( $display ) . '</span>';
951 } else {
952 $display = htmlspecialchars( $display );
955 if ( $diff < 0 ) {
956 $ret .= str_repeat( "</li></ul>\n", -$diff ) . "</li><li>\n";
957 } elseif ( $diff == 0 ) {
958 $ret .= "</li><li>\n";
959 } else {
960 $ret .= str_repeat( "<ul><li>\n", $diff );
962 $ret .= $display . "\n";
964 $curIdent = $ident;
966 $ret .= str_repeat( '</li></ul>', $curIdent ) . '</li>';
967 return $ret;
971 * This gets called shortly before the </body> tag.
972 * @return String HTML to be put before </body>
974 function afterContent() {
975 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
976 return $printfooter . $this->generateDebugHTML() . $this->doAfterContent();
980 * This gets called shortly before the </body> tag.
981 * @return String HTML-wrapped JS code to be put before </body>
983 function bottomScripts() {
984 $bottomScriptText = "\n" . Html::inlineScript( 'if (window.runOnloadHook) runOnloadHook();' ) . "\n";
985 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
986 return $bottomScriptText;
989 /** @return string Retrievied from HTML text */
990 function printSource() {
991 $url = htmlspecialchars( $this->mTitle->getFullURL() );
992 return wfMsg( 'retrievedfrom', '<a href="' . $url . '">' . $url . '</a>' );
995 function printFooter() {
996 return "<p>" . $this->printSource() .
997 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
1000 /** overloaded by derived classes */
1001 function doAfterContent() {
1002 return '</div></div>';
1005 function pageTitleLinks() {
1006 global $wgOut, $wgUser, $wgRequest, $wgLang;
1008 $oldid = $wgRequest->getVal( 'oldid' );
1009 $diff = $wgRequest->getVal( 'diff' );
1010 $action = $wgRequest->getText( 'action' );
1012 $s[] = $this->printableLink();
1013 $disclaimer = $this->disclaimerLink(); # may be empty
1014 if( $disclaimer ) {
1015 $s[] = $disclaimer;
1017 $privacy = $this->privacyLink(); # may be empty too
1018 if( $privacy ) {
1019 $s[] = $privacy;
1022 if ( $wgOut->isArticleRelated() ) {
1023 if ( $this->mTitle->getNamespace() == NS_FILE ) {
1024 $name = $this->mTitle->getDBkey();
1025 $image = wfFindFile( $this->mTitle );
1026 if( $image ) {
1027 $link = htmlspecialchars( $image->getURL() );
1028 $style = $this->getInternalLinkAttributes( $link, $name );
1029 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
1033 if ( 'history' == $action || isset( $diff ) || isset( $oldid ) ) {
1034 $s[] .= $this->link(
1035 $this->mTitle,
1036 wfMsg( 'currentrev' ),
1037 array(),
1038 array(),
1039 array( 'known', 'noclasses' )
1043 if ( $wgUser->getNewtalk() ) {
1044 # do not show "You have new messages" text when we are viewing our
1045 # own talk page
1046 if( !$this->mTitle->equals( $wgUser->getTalkPage() ) ) {
1047 $tl = $this->link(
1048 $wgUser->getTalkPage(),
1049 wfMsgHtml( 'newmessageslink' ),
1050 array(),
1051 array( 'redirect' => 'no' ),
1052 array( 'known', 'noclasses' )
1055 $dl = $this->link(
1056 $wgUser->getTalkPage(),
1057 wfMsgHtml( 'newmessagesdifflink' ),
1058 array(),
1059 array( 'diff' => 'cur' ),
1060 array( 'known', 'noclasses' )
1062 $s[] = '<strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
1063 # disable caching
1064 $wgOut->setSquidMaxage( 0 );
1065 $wgOut->enableClientCache( false );
1069 $undelete = $this->getUndeleteLink();
1070 if( !empty( $undelete ) ) {
1071 $s[] = $undelete;
1073 return $wgLang->pipeList( $s );
1076 function getUndeleteLink() {
1077 global $wgUser, $wgContLang, $wgLang, $wgRequest;
1079 $action = $wgRequest->getVal( 'action', 'view' );
1081 if ( $wgUser->isAllowed( 'deletedhistory' ) &&
1082 ( $this->mTitle->getArticleId() == 0 || $action == 'history' ) ) {
1083 $n = $this->mTitle->isDeleted();
1084 if ( $n ) {
1085 if ( $wgUser->isAllowed( 'undelete' ) ) {
1086 $msg = 'thisisdeleted';
1087 } else {
1088 $msg = 'viewdeleted';
1090 return wfMsg(
1091 $msg,
1092 $this->link(
1093 SpecialPage::getTitleFor( 'Undelete', $this->mTitle->getPrefixedDBkey() ),
1094 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ),
1095 array(),
1096 array(),
1097 array( 'known', 'noclasses' )
1102 return '';
1105 function printableLink() {
1106 global $wgOut, $wgFeedClasses, $wgRequest, $wgLang;
1108 $s = array();
1110 if ( !$wgOut->isPrintable() ) {
1111 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
1112 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
1115 if( $wgOut->isSyndicated() ) {
1116 foreach( $wgFeedClasses as $format => $class ) {
1117 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
1118 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
1119 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
1122 return $wgLang->pipeList( $s );
1126 * Gets the h1 element with the page title.
1127 * @return string
1129 function pageTitle() {
1130 global $wgOut;
1131 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
1132 return $s;
1135 function pageSubtitle() {
1136 global $wgOut;
1138 $sub = $wgOut->getSubtitle();
1139 if ( $sub == '' ) {
1140 global $wgExtraSubtitle;
1141 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
1143 $subpages = $this->subPageSubtitle();
1144 $sub .= !empty( $subpages ) ? "</p><p class='subpages'>$subpages" : '';
1145 $s = "<p class='subtitle'>{$sub}</p>\n";
1146 return $s;
1149 function subPageSubtitle() {
1150 $subpages = '';
1151 if( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages ) ) ) {
1152 return $subpages;
1155 global $wgOut;
1156 if( $wgOut->isArticle() && MWNamespace::hasSubpages( $this->mTitle->getNamespace() ) ) {
1157 $ptext = $this->mTitle->getPrefixedText();
1158 if( preg_match( '/\//', $ptext ) ) {
1159 $links = explode( '/', $ptext );
1160 array_pop( $links );
1161 $c = 0;
1162 $growinglink = '';
1163 $display = '';
1164 foreach( $links as $link ) {
1165 $growinglink .= $link;
1166 $display .= $link;
1167 $linkObj = Title::newFromText( $growinglink );
1168 if( is_object( $linkObj ) && $linkObj->exists() ) {
1169 $getlink = $this->link(
1170 $linkObj,
1171 htmlspecialchars( $display ),
1172 array(),
1173 array(),
1174 array( 'known', 'noclasses' )
1176 $c++;
1177 if( $c > 1 ) {
1178 $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1179 } else {
1180 $subpages .= '&lt; ';
1182 $subpages .= $getlink;
1183 $display = '';
1184 } else {
1185 $display .= '/';
1187 $growinglink .= '/';
1191 return $subpages;
1195 * Returns true if the IP should be shown in the header
1197 function showIPinHeader() {
1198 global $wgShowIPinHeader;
1199 return $wgShowIPinHeader && session_id() != '';
1202 function nameAndLogin() {
1203 global $wgUser, $wgLang, $wgContLang;
1205 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
1207 $ret = '';
1208 if ( $wgUser->isAnon() ) {
1209 if( $this->showIPinHeader() ) {
1210 $name = wfGetIP();
1212 $talkLink = $this->link( $wgUser->getTalkPage(),
1213 $wgLang->getNsText( NS_TALK ) );
1215 $ret .= "$name ($talkLink)";
1216 } else {
1217 $ret .= wfMsg( 'notloggedin' );
1220 $returnTo = $this->mTitle->getPrefixedDBkey();
1221 $query = array();
1222 if ( $logoutPage != $returnTo ) {
1223 $query['returnto'] = $returnTo;
1226 $loginlink = $wgUser->isAllowed( 'createaccount' )
1227 ? 'nav-login-createaccount'
1228 : 'login';
1229 $ret .= "\n<br />" . $this->link(
1230 SpecialPage::getTitleFor( 'Userlogin' ),
1231 wfMsg( $loginlink ), array(), $query
1233 } else {
1234 $returnTo = $this->mTitle->getPrefixedDBkey();
1235 $talkLink = $this->link( $wgUser->getTalkPage(),
1236 $wgLang->getNsText( NS_TALK ) );
1238 $ret .= $this->link( $wgUser->getUserPage(),
1239 htmlspecialchars( $wgUser->getName() ) );
1240 $ret .= " ($talkLink)<br />";
1241 $ret .= $wgLang->pipeList( array(
1242 $this->link(
1243 SpecialPage::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
1244 array(), array( 'returnto' => $returnTo )
1246 $this->specialLink( 'preferences' ),
1247 ) );
1249 $ret = $wgLang->pipeList( array(
1250 $ret,
1251 $this->link(
1252 Title::newFromText( wfMsgForContent( 'helppage' ) ),
1253 wfMsg( 'help' )
1255 ) );
1257 return $ret;
1260 function getSearchLink() {
1261 $searchPage = SpecialPage::getTitleFor( 'Search' );
1262 return $searchPage->getLocalURL();
1265 function escapeSearchLink() {
1266 return htmlspecialchars( $this->getSearchLink() );
1269 function searchForm() {
1270 global $wgRequest, $wgUseTwoButtonsSearchForm;
1271 $search = $wgRequest->getText( 'search' );
1273 $s = '<form id="searchform' . $this->searchboxes . '" name="search" class="inline" method="post" action="'
1274 . $this->escapeSearchLink() . "\">\n"
1275 . '<input type="text" id="searchInput' . $this->searchboxes . '" name="search" size="19" value="'
1276 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
1277 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
1279 if( $wgUseTwoButtonsSearchForm ) {
1280 $s .= '&nbsp;<input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
1281 } else {
1282 $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
1285 $s .= '</form>';
1287 // Ensure unique id's for search boxes made after the first
1288 $this->searchboxes = $this->searchboxes == '' ? 2 : $this->searchboxes + 1;
1290 return $s;
1293 function topLinks() {
1294 global $wgOut;
1296 $s = array(
1297 $this->mainPageLink(),
1298 $this->specialLink( 'recentchanges' )
1301 if ( $wgOut->isArticleRelated() ) {
1302 $s[] = $this->editThisPage();
1303 $s[] = $this->historyLink();
1305 # Many people don't like this dropdown box
1306 #$s[] = $this->specialPagesList();
1308 if( $this->variantLinks() ) {
1309 $s[] = $this->variantLinks();
1312 if( $this->extensionTabLinks() ) {
1313 $s[] = $this->extensionTabLinks();
1316 // FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
1317 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
1321 * Compatibility for extensions adding functionality through tabs.
1322 * Eventually these old skins should be replaced with SkinTemplate-based
1323 * versions, sigh...
1324 * @return string
1326 function extensionTabLinks() {
1327 $tabs = array();
1328 $out = '';
1329 $s = array();
1330 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1331 foreach( $tabs as $tab ) {
1332 $s[] = Xml::element( 'a',
1333 array( 'href' => $tab['href'] ),
1334 $tab['text'] );
1337 if( count( $s ) ) {
1338 global $wgLang;
1340 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
1341 $out .= $wgLang->pipeList( $s );
1344 return $out;
1348 * Language/charset variant links for classic-style skins
1349 * @return string
1351 function variantLinks() {
1352 $s = '';
1353 /* show links to different language variants */
1354 global $wgDisableLangConversion, $wgLang, $wgContLang;
1355 $variants = $wgContLang->getVariants();
1356 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1357 foreach( $variants as $code ) {
1358 $varname = $wgContLang->getVariantname( $code );
1359 if( $varname == 'disable' ) {
1360 continue;
1362 $s = $wgLang->pipeList( array(
1364 '<a href="' . $this->mTitle->escapeLocalURL( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
1365 ) );
1368 return $s;
1371 function bottomLinks() {
1372 global $wgOut, $wgUser, $wgUseTrackbacks;
1373 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
1375 $s = '';
1376 if ( $wgOut->isArticleRelated() ) {
1377 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
1378 if ( $wgUser->isLoggedIn() ) {
1379 $element[] = $this->watchThisPage();
1381 $element[] = $this->talkLink();
1382 $element[] = $this->historyLink();
1383 $element[] = $this->whatLinksHere();
1384 $element[] = $this->watchPageLinksLink();
1386 if( $wgUseTrackbacks ) {
1387 $element[] = $this->trackbackLink();
1390 if (
1391 $this->mTitle->getNamespace() == NS_USER ||
1392 $this->mTitle->getNamespace() == NS_USER_TALK
1395 $id = User::idFromName( $this->mTitle->getText() );
1396 $ip = User::isIP( $this->mTitle->getText() );
1398 # Both anons and non-anons have contributions list
1399 if( $id || $ip ) {
1400 $element[] = $this->userContribsLink();
1402 if( $this->showEmailUser( $id ) ) {
1403 $element[] = $this->emailUserLink();
1407 $s = implode( $element, $sep );
1409 if ( $this->mTitle->getArticleId() ) {
1410 $s .= "\n<br />";
1411 // Delete/protect/move links for privileged users
1412 if( $wgUser->isAllowed( 'delete' ) ) {
1413 $s .= $this->deleteThisPage();
1415 if( $wgUser->isAllowed( 'protect' ) ) {
1416 $s .= $sep . $this->protectThisPage();
1418 if( $wgUser->isAllowed( 'move' ) ) {
1419 $s .= $sep . $this->moveThisPage();
1422 $s .= "<br />\n" . $this->otherLanguages();
1425 return $s;
1428 function pageStats() {
1429 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1430 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
1432 $oldid = $wgRequest->getVal( 'oldid' );
1433 $diff = $wgRequest->getVal( 'diff' );
1434 if ( !$wgOut->isArticle() ) {
1435 return '';
1437 if( !$wgArticle instanceof Article ) {
1438 return '';
1440 if ( isset( $oldid ) || isset( $diff ) ) {
1441 return '';
1443 if ( 0 == $wgArticle->getID() ) {
1444 return '';
1447 $s = '';
1448 if ( !$wgDisableCounters ) {
1449 $count = $wgLang->formatNum( $wgArticle->getCount() );
1450 if ( $count ) {
1451 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1455 if( $wgMaxCredits != 0 ) {
1456 $s .= ' ' . Credits::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
1457 } else {
1458 $s .= $this->lastModified();
1461 if( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
1462 $dbr = wfGetDB( DB_SLAVE );
1463 $res = $dbr->select(
1464 'watchlist',
1465 array( 'COUNT(*) AS n' ),
1466 array(
1467 'wl_title' => $dbr->strencode( $this->mTitle->getDBkey() ),
1468 'wl_namespace' => $this->mTitle->getNamespace()
1470 __METHOD__
1472 $x = $dbr->fetchObject( $res );
1474 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1475 array( 'parseinline' ), $wgLang->formatNum( $x->n )
1479 return $s . ' ' . $this->getCopyright();
1482 function getCopyright( $type = 'detect' ) {
1483 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest, $wgArticle;
1485 if ( $type == 'detect' ) {
1486 $diff = $wgRequest->getVal( 'diff' );
1487 $isCur = $wgArticle && $wgArticle->isCurrent();
1488 if ( is_null( $diff ) && !$isCur && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1489 $type = 'history';
1490 } else {
1491 $type = 'normal';
1495 if ( $type == 'history' ) {
1496 $msg = 'history_copyright';
1497 } else {
1498 $msg = 'copyright';
1501 $out = '';
1502 if( $wgRightsPage ) {
1503 $title = Title::newFromText( $wgRightsPage );
1504 $link = $this->linkKnown( $title, $wgRightsText );
1505 } elseif( $wgRightsUrl ) {
1506 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1507 } elseif( $wgRightsText ) {
1508 $link = $wgRightsText;
1509 } else {
1510 # Give up now
1511 return $out;
1513 // Allow for site and per-namespace customization of copyright notice.
1514 if( isset( $wgArticle ) ) {
1515 wfRunHooks( 'SkinCopyrightFooter', array( $wgArticle->getTitle(), $type, &$msg, &$link ) );
1518 $out .= wfMsgForContent( $msg, $link );
1519 return $out;
1522 function getCopyrightIcon() {
1523 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1524 $out = '';
1525 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1526 $out = $wgCopyrightIcon;
1527 } elseif ( $wgRightsIcon ) {
1528 $icon = htmlspecialchars( $wgRightsIcon );
1529 if ( $wgRightsUrl ) {
1530 $url = htmlspecialchars( $wgRightsUrl );
1531 $out .= '<a href="'.$url.'">';
1533 $text = htmlspecialchars( $wgRightsText );
1534 $out .= "<img src=\"$icon\" alt=\"$text\" width=\"88\" height=\"31\" />";
1535 if ( $wgRightsUrl ) {
1536 $out .= '</a>';
1539 return $out;
1543 * Gets the powered by MediaWiki icon.
1544 * @return string
1546 function getPoweredBy() {
1547 global $wgStylePath;
1548 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1549 $img = '<a href="http://www.mediawiki.org/"><img src="' . $url . '" height="31" width="88" alt="Powered by MediaWiki" /></a>';
1550 return $img;
1553 function lastModified() {
1554 global $wgLang, $wgArticle;
1555 if( $this->mRevisionId && $this->mRevisionId != $wgArticle->getLatest() ) {
1556 $timestamp = Revision::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId );
1557 } else {
1558 $timestamp = $wgArticle->getTimestamp();
1560 if ( $timestamp ) {
1561 $d = $wgLang->date( $timestamp, true );
1562 $t = $wgLang->time( $timestamp, true );
1563 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1564 } else {
1565 $s = '';
1567 if ( wfGetLB()->getLaggedSlaveMode() ) {
1568 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1570 return $s;
1573 function logoText( $align = '' ) {
1574 if ( $align != '' ) {
1575 $a = " align='{$align}'";
1576 } else {
1577 $a = '';
1580 $mp = wfMsg( 'mainpage' );
1581 $mptitle = Title::newMainPage();
1582 $url = ( is_object( $mptitle ) ? $mptitle->escapeLocalURL() : '' );
1584 $logourl = $this->getLogo();
1585 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1586 return $s;
1590 * Show a drop-down box of special pages
1592 function specialPagesList() {
1593 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
1594 $pages = array_merge( SpecialPage::getRegularPages(), SpecialPage::getRestrictedPages() );
1595 foreach ( $pages as $name => $page ) {
1596 $pages[$name] = $page->getDescription();
1599 $go = wfMsg( 'go' );
1600 $sp = wfMsg( 'specialpages' );
1601 $spp = $wgContLang->specialPage( 'Specialpages' );
1603 $s = '<form id="specialpages" method="get" ' .
1604 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1605 $s .= "<select name=\"wpDropdown\">\n";
1606 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1609 foreach ( $pages as $name => $desc ) {
1610 $p = $wgContLang->specialPage( $name );
1611 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1613 $s .= "</select>\n";
1614 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1615 $s .= "</form>\n";
1616 return $s;
1620 * Gets the link to the wiki's main page.
1621 * @return string
1623 function mainPageLink() {
1624 $s = $this->link(
1625 Title::newMainPage(),
1626 wfMsg( 'mainpage' ),
1627 array(),
1628 array(),
1629 array( 'known', 'noclasses' )
1631 return $s;
1634 private function footerLink( $desc, $page ) {
1635 // if the link description has been set to "-" in the default language,
1636 if ( wfMsgForContent( $desc ) == '-') {
1637 // then it is disabled, for all languages.
1638 return '';
1639 } else {
1640 // Otherwise, we display the link for the user, described in their
1641 // language (which may or may not be the same as the default language),
1642 // but we make the link target be the one site-wide page.
1643 $title = Title::newFromText( wfMsgForContent( $page ) );
1644 return $this->linkKnown(
1645 $title,
1646 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) )
1652 * Gets the link to the wiki's privacy policy page.
1654 function privacyLink() {
1655 return $this->footerLink( 'privacy', 'privacypage' );
1659 * Gets the link to the wiki's about page.
1661 function aboutLink() {
1662 return $this->footerLink( 'aboutsite', 'aboutpage' );
1666 * Gets the link to the wiki's general disclaimers page.
1668 function disclaimerLink() {
1669 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1672 function editThisPage() {
1673 global $wgOut;
1675 if ( !$wgOut->isArticleRelated() ) {
1676 $s = wfMsg( 'protectedpage' );
1677 } else {
1678 if( $this->mTitle->quickUserCan( 'edit' ) && $this->mTitle->exists() ) {
1679 $t = wfMsg( 'editthispage' );
1680 } elseif( $this->mTitle->quickUserCan( 'create' ) && !$this->mTitle->exists() ) {
1681 $t = wfMsg( 'create-this-page' );
1682 } else {
1683 $t = wfMsg( 'viewsource' );
1686 $s = $this->link(
1687 $this->mTitle,
1689 array(),
1690 $this->editUrlOptions(),
1691 array( 'known', 'noclasses' )
1694 return $s;
1698 * Return URL options for the 'edit page' link.
1699 * This may include an 'oldid' specifier, if the current page view is such.
1701 * @return array
1702 * @private
1704 function editUrlOptions() {
1705 global $wgArticle;
1707 $options = array( 'action' => 'edit' );
1709 if( $this->mRevisionId && ! $wgArticle->isCurrent() ) {
1710 $options['oldid'] = intval( $this->mRevisionId );
1713 return $options;
1716 function deleteThisPage() {
1717 global $wgUser, $wgRequest;
1719 $diff = $wgRequest->getVal( 'diff' );
1720 if ( $this->mTitle->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
1721 $t = wfMsg( 'deletethispage' );
1723 $s = $this->link(
1724 $this->mTitle,
1726 array(),
1727 array( 'action' => 'delete' ),
1728 array( 'known', 'noclasses' )
1730 } else {
1731 $s = '';
1733 return $s;
1736 function protectThisPage() {
1737 global $wgUser, $wgRequest;
1739 $diff = $wgRequest->getVal( 'diff' );
1740 if ( $this->mTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1741 if ( $this->mTitle->isProtected() ) {
1742 $text = wfMsg( 'unprotectthispage' );
1743 $query = array( 'action' => 'unprotect' );
1744 } else {
1745 $text = wfMsg( 'protectthispage' );
1746 $query = array( 'action' => 'protect' );
1749 $s = $this->link(
1750 $this->mTitle,
1751 $text,
1752 array(),
1753 $query,
1754 array( 'known', 'noclasses' )
1756 } else {
1757 $s = '';
1759 return $s;
1762 function watchThisPage() {
1763 global $wgOut;
1764 ++$this->mWatchLinkNum;
1766 if ( $wgOut->isArticleRelated() ) {
1767 if ( $this->mTitle->userIsWatching() ) {
1768 $text = wfMsg( 'unwatchthispage' );
1769 $query = array( 'action' => 'unwatch' );
1770 $id = 'mw-unwatch-link' . $this->mWatchLinkNum;
1771 } else {
1772 $text = wfMsg( 'watchthispage' );
1773 $query = array( 'action' => 'watch' );
1774 $id = 'mw-watch-link' . $this->mWatchLinkNum;
1777 $s = $this->link(
1778 $this->mTitle,
1779 $text,
1780 array( 'id' => $id ),
1781 $query,
1782 array( 'known', 'noclasses' )
1784 } else {
1785 $s = wfMsg( 'notanarticle' );
1787 return $s;
1790 function moveThisPage() {
1791 if ( $this->mTitle->quickUserCan( 'move' ) ) {
1792 return $this->link(
1793 SpecialPage::getTitleFor( 'Movepage' ),
1794 wfMsg( 'movethispage' ),
1795 array(),
1796 array( 'target' => $this->mTitle->getPrefixedDBkey() ),
1797 array( 'known', 'noclasses' )
1799 } else {
1800 // no message if page is protected - would be redundant
1801 return '';
1805 function historyLink() {
1806 return $this->link(
1807 $this->mTitle,
1808 wfMsgHtml( 'history' ),
1809 array( 'rel' => 'archives' ),
1810 array( 'action' => 'history' )
1814 function whatLinksHere() {
1815 return $this->link(
1816 SpecialPage::getTitleFor( 'Whatlinkshere', $this->mTitle->getPrefixedDBkey() ),
1817 wfMsgHtml( 'whatlinkshere' ),
1818 array(),
1819 array(),
1820 array( 'known', 'noclasses' )
1824 function userContribsLink() {
1825 return $this->link(
1826 SpecialPage::getTitleFor( 'Contributions', $this->mTitle->getDBkey() ),
1827 wfMsgHtml( 'contributions' ),
1828 array(),
1829 array(),
1830 array( 'known', 'noclasses' )
1834 function showEmailUser( $id ) {
1835 global $wgUser;
1836 $targetUser = User::newFromId( $id );
1837 return $wgUser->canSendEmail() && # the sending user must have a confirmed email address
1838 $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
1841 function emailUserLink() {
1842 return $this->link(
1843 SpecialPage::getTitleFor( 'Emailuser', $this->mTitle->getDBkey() ),
1844 wfMsg( 'emailuser' ),
1845 array(),
1846 array(),
1847 array( 'known', 'noclasses' )
1851 function watchPageLinksLink() {
1852 global $wgOut;
1853 if ( !$wgOut->isArticleRelated() ) {
1854 return '(' . wfMsg( 'notanarticle' ) . ')';
1855 } else {
1856 return $this->link(
1857 SpecialPage::getTitleFor( 'Recentchangeslinked', $this->mTitle->getPrefixedDBkey() ),
1858 wfMsg( 'recentchangeslinked-toolbox' ),
1859 array(),
1860 array(),
1861 array( 'known', 'noclasses' )
1866 function trackbackLink() {
1867 return '<a href="' . $this->mTitle->trackbackURL() . '">'
1868 . wfMsg( 'trackbacklink' ) . '</a>';
1871 function otherLanguages() {
1872 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1874 if ( $wgHideInterlanguageLinks ) {
1875 return '';
1878 $a = $wgOut->getLanguageLinks();
1879 if ( 0 == count( $a ) ) {
1880 return '';
1883 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
1884 $first = true;
1885 if( $wgContLang->isRTL() ) {
1886 $s .= '<span dir="LTR">';
1888 foreach( $a as $l ) {
1889 if ( !$first ) {
1890 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1892 $first = false;
1894 $nt = Title::newFromText( $l );
1895 $url = $nt->escapeFullURL();
1896 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1898 if ( $text == '' ) {
1899 $text = $l;
1901 $style = $this->getExternalLinkAttributes();
1902 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1904 if( $wgContLang->isRTL() ) {
1905 $s .= '</span>';
1907 return $s;
1910 function talkLink() {
1911 if ( NS_SPECIAL == $this->mTitle->getNamespace() ) {
1912 # No discussion links for special pages
1913 return '';
1916 $linkOptions = array();
1918 if( $this->mTitle->isTalkPage() ) {
1919 $link = $this->mTitle->getSubjectPage();
1920 switch( $link->getNamespace() ) {
1921 case NS_MAIN:
1922 $text = wfMsg( 'articlepage' );
1923 break;
1924 case NS_USER:
1925 $text = wfMsg( 'userpage' );
1926 break;
1927 case NS_PROJECT:
1928 $text = wfMsg( 'projectpage' );
1929 break;
1930 case NS_FILE:
1931 $text = wfMsg( 'imagepage' );
1932 # Make link known if image exists, even if the desc. page doesn't.
1933 if( wfFindFile( $link ) )
1934 $linkOptions[] = 'known';
1935 break;
1936 case NS_MEDIAWIKI:
1937 $text = wfMsg( 'mediawikipage' );
1938 break;
1939 case NS_TEMPLATE:
1940 $text = wfMsg( 'templatepage' );
1941 break;
1942 case NS_HELP:
1943 $text = wfMsg( 'viewhelppage' );
1944 break;
1945 case NS_CATEGORY:
1946 $text = wfMsg( 'categorypage' );
1947 break;
1948 default:
1949 $text = wfMsg( 'articlepage' );
1951 } else {
1952 $link = $this->mTitle->getTalkPage();
1953 $text = wfMsg( 'talkpage' );
1956 $s = $this->link( $link, $text, array(), array(), $linkOptions );
1958 return $s;
1961 function commentLink() {
1962 global $wgOut;
1964 if ( $this->mTitle->getNamespace() == NS_SPECIAL ) {
1965 return '';
1968 # __NEWSECTIONLINK___ changes behaviour here
1969 # If it is present, the link points to this page, otherwise
1970 # it points to the talk page
1971 if( $this->mTitle->isTalkPage() ) {
1972 $title = $this->mTitle;
1973 } elseif( $wgOut->showNewSectionLink() ) {
1974 $title = $this->mTitle;
1975 } else {
1976 $title = $this->mTitle->getTalkPage();
1979 return $this->link(
1980 $title,
1981 wfMsg( 'postcomment' ),
1982 array(),
1983 array(
1984 'action' => 'edit',
1985 'section' => 'new'
1987 array( 'known', 'noclasses' )
1991 /* these are used extensively in SkinTemplate, but also some other places */
1992 static function makeMainPageUrl( $urlaction = '' ) {
1993 $title = Title::newMainPage();
1994 self::checkTitle( $title, '' );
1995 return $title->getLocalURL( $urlaction );
1998 static function makeSpecialUrl( $name, $urlaction = '' ) {
1999 $title = SpecialPage::getTitleFor( $name );
2000 return $title->getLocalURL( $urlaction );
2003 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
2004 $title = SpecialPage::getSafeTitleFor( $name, $subpage );
2005 return $title->getLocalURL( $urlaction );
2008 static function makeI18nUrl( $name, $urlaction = '' ) {
2009 $title = Title::newFromText( wfMsgForContent( $name ) );
2010 self::checkTitle( $title, $name );
2011 return $title->getLocalURL( $urlaction );
2014 static function makeUrl( $name, $urlaction = '' ) {
2015 $title = Title::newFromText( $name );
2016 self::checkTitle( $title, $name );
2017 return $title->getLocalURL( $urlaction );
2021 * If url string starts with http, consider as external URL, else
2022 * internal
2024 static function makeInternalOrExternalUrl( $name ) {
2025 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
2026 return $name;
2027 } else {
2028 return self::makeUrl( $name );
2032 # this can be passed the NS number as defined in Language.php
2033 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN ) {
2034 $title = Title::makeTitleSafe( $namespace, $name );
2035 self::checkTitle( $title, $name );
2036 return $title->getLocalURL( $urlaction );
2039 /* these return an array with the 'href' and boolean 'exists' */
2040 static function makeUrlDetails( $name, $urlaction = '' ) {
2041 $title = Title::newFromText( $name );
2042 self::checkTitle( $title, $name );
2043 return array(
2044 'href' => $title->getLocalURL( $urlaction ),
2045 'exists' => $title->getArticleID() != 0 ? true : false
2050 * Make URL details where the article exists (or at least it's convenient to think so)
2052 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
2053 $title = Title::newFromText( $name );
2054 self::checkTitle( $title, $name );
2055 return array(
2056 'href' => $title->getLocalURL( $urlaction ),
2057 'exists' => true
2061 # make sure we have some title to operate on
2062 static function checkTitle( &$title, $name ) {
2063 if( !is_object( $title ) ) {
2064 $title = Title::newFromText( $name );
2065 if( !is_object( $title ) ) {
2066 $title = Title::newFromText( '--error: link target missing--' );
2072 * Build an array that represents the sidebar(s), the navigation bar among them
2074 * @return array
2076 function buildSidebar() {
2077 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
2078 global $wgLang;
2079 wfProfileIn( __METHOD__ );
2081 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
2083 if ( $wgEnableSidebarCache ) {
2084 $cachedsidebar = $parserMemc->get( $key );
2085 if ( $cachedsidebar ) {
2086 wfProfileOut( __METHOD__ );
2087 return $cachedsidebar;
2091 $bar = array();
2092 $this->addToSidebar( $bar, 'sidebar' );
2094 wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
2095 if ( $wgEnableSidebarCache ) {
2096 $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
2098 wfProfileOut( __METHOD__ );
2099 return $bar;
2102 * Add content from a sidebar system message
2103 * Currently only used for MediaWiki:Sidebar (but may be used by Extensions)
2105 * This is just a wrapper around addToSidebarPlain() for backwards compatibility
2107 * @param &$bar array
2108 * @param $message String
2110 function addToSidebar( &$bar, $message ) {
2111 $this->addToSidebarPlain( $bar, wfMsgForContent( $message ) );
2115 * Add content from plain text
2116 * @since 1.17
2117 * @param &$bar array
2118 * @param $text string
2120 function addToSidebarPlain( &$bar, $text ) {
2121 $lines = explode( "\n", $text );
2122 $heading = '';
2123 foreach( $lines as $line ) {
2124 if( strpos( $line, '*' ) !== 0 ) {
2125 continue;
2127 if( strpos( $line, '**') !== 0 ) {
2128 $heading = trim( $line, '* ' );
2129 if( !array_key_exists( $heading, $bar ) ) {
2130 $bar[$heading] = array();
2132 } else {
2133 if( strpos( $line, '|' ) !== false ) { // sanity check
2134 $line = array_map( 'trim', explode( '|', trim( $line, '* ' ), 2 ) );
2135 $link = wfMsgForContent( $line[0] );
2136 if( $link == '-' ) {
2137 continue;
2140 $text = wfMsgExt( $line[1], 'parsemag' );
2141 if( wfEmptyMsg( $line[1], $text ) ) {
2142 $text = $line[1];
2144 if( wfEmptyMsg( $line[0], $link ) ) {
2145 $link = $line[0];
2148 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
2149 $href = $link;
2150 } else {
2151 $title = Title::newFromText( $link );
2152 if ( $title ) {
2153 $title = $title->fixSpecialName();
2154 $href = $title->getLocalURL();
2155 } else {
2156 $href = 'INVALID-TITLE';
2160 $bar[$heading][] = array(
2161 'text' => $text,
2162 'href' => $href,
2163 'id' => 'n-' . strtr( $line[1], ' ', '-' ),
2164 'active' => false
2166 } else {
2167 continue;
2174 * Should we include common/wikiprintable.css? Skins that have their own
2175 * print stylesheet should override this and return false. (This is an
2176 * ugly hack to get Monobook to play nicely with
2177 * OutputPage::headElement().)
2179 * @return bool
2181 public function commonPrintStylesheet() {
2182 return true;
2186 * Gets new talk page messages for the current user.
2187 * @return MediaWiki message or if no new talk page messages, nothing
2189 function getNewtalks() {
2190 global $wgUser, $wgOut;
2191 $newtalks = $wgUser->getNewMessageLinks();
2192 $ntl = '';
2194 if( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
2195 $userTitle = $this->mUser->getUserPage();
2196 $userTalkTitle = $userTitle->getTalkPage();
2198 if( !$userTalkTitle->equals( $this->mTitle ) ) {
2199 $newMessagesLink = $this->link(
2200 $userTalkTitle,
2201 wfMsgHtml( 'newmessageslink' ),
2202 array(),
2203 array( 'redirect' => 'no' ),
2204 array( 'known', 'noclasses' )
2207 $newMessagesDiffLink = $this->link(
2208 $userTalkTitle,
2209 wfMsgHtml( 'newmessagesdifflink' ),
2210 array(),
2211 array( 'diff' => 'cur' ),
2212 array( 'known', 'noclasses' )
2215 $ntl = wfMsg(
2216 'youhavenewmessages',
2217 $newMessagesLink,
2218 $newMessagesDiffLink
2220 # Disable Squid cache
2221 $wgOut->setSquidMaxage( 0 );
2223 } elseif( count( $newtalks ) ) {
2224 // _>" " for BC <= 1.16
2225 $sep = str_replace( '_', ' ', wfMsgHtml( 'newtalkseparator' ) );
2226 $msgs = array();
2227 foreach( $newtalks as $newtalk ) {
2228 $msgs[] = Xml::element(
2229 'a',
2230 array( 'href' => $newtalk['link'] ), $newtalk['wiki']
2233 $parts = implode( $sep, $msgs );
2234 $ntl = wfMsgHtml( 'youhavenewmessagesmulti', $parts );
2235 $wgOut->setSquidMaxage( 0 );
2237 return $ntl;