Fix a bunch of notices. Error was "Notice: Found alias defined for (some uppercased...
[lhc/web/wiklou.git] / includes / Skin.php
1 <?php
2 /**
3 * @defgroup Skins Skins
4 */
5
6 if ( !defined( 'MEDIAWIKI' ) ) {
7 die( 1 );
8 }
9
10 /**
11 * The main skin class that provide methods and properties for all other skins.
12 * This base class is also the "Standard" skin.
13 *
14 * See docs/skin.txt for more information.
15 *
16 * @ingroup Skins
17 */
18 class Skin extends Linker {
19 /**#@+
20 * @private
21 */
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;
30
31 /** Constructor, call parent constructor */
32 function __construct() {
33 parent::__construct();
34 }
35
36 /**
37 * Fetch the set of available skins.
38 * @return array of strings
39 */
40 static function getSkinNames() {
41 global $wgValidSkinNames;
42 static $skinsInitialised = false;
43
44 if ( !$skinsInitialised ) {
45 # Get a list of available skins
46 # Build using the regular expression '^(.*).php$'
47 # Array keys are all lower case, array value keep the case used by filename
48 #
49 wfProfileIn( __METHOD__ . '-init' );
50
51 global $wgStyleDirectory;
52
53 $skinDir = dir( $wgStyleDirectory );
54
55 # while code from www.php.net
56 while ( false !== ( $file = $skinDir->read() ) ) {
57 // Skip non-PHP files, hidden files, and '.dep' includes
58 $matches = array();
59
60 if ( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) {
61 $aSkin = $matches[1];
62 $wgValidSkinNames[strtolower( $aSkin )] = $aSkin;
63 }
64 }
65 $skinDir->close();
66 $skinsInitialised = true;
67 wfProfileOut( __METHOD__ . '-init' );
68 }
69 return $wgValidSkinNames;
70 }
71
72 /**
73 * Fetch the list of usable skins in regards to $wgSkipSkins.
74 * Useful for Special:Preferences and other places where you
75 * only want to show skins users _can_ use.
76 * @return array of strings
77 */
78 public static function getUsableSkins() {
79 global $wgSkipSkins;
80
81 $usableSkins = self::getSkinNames();
82
83 foreach ( $wgSkipSkins as $skip ) {
84 unset( $usableSkins[$skip] );
85 }
86
87 return $usableSkins;
88 }
89
90 /**
91 * Normalize a skin preference value to a form that can be loaded.
92 * If a skin can't be found, it will fall back to the configured
93 * default (or the old 'Classic' skin if that's broken).
94 * @param $key String: 'monobook', 'standard', etc.
95 * @return string
96 */
97 static function normalizeKey( $key ) {
98 global $wgDefaultSkin;
99
100 $skinNames = Skin::getSkinNames();
101
102 if ( $key == '' ) {
103 // Don't return the default immediately;
104 // in a misconfiguration we need to fall back.
105 $key = $wgDefaultSkin;
106 }
107
108 if ( isset( $skinNames[$key] ) ) {
109 return $key;
110 }
111
112 // Older versions of the software used a numeric setting
113 // in the user preferences.
114 $fallback = array(
115 0 => $wgDefaultSkin,
116 1 => 'nostalgia',
117 2 => 'cologneblue'
118 );
119
120 if ( isset( $fallback[$key] ) ) {
121 $key = $fallback[$key];
122 }
123
124 if ( isset( $skinNames[$key] ) ) {
125 return $key;
126 } else if ( isset( $skinNames[$wgDefaultSkin] ) ) {
127 return $wgDefaultSkin;
128 } else {
129 return 'vector';
130 }
131 }
132
133 /**
134 * Factory method for loading a skin of a given type
135 * @param $key String: 'monobook', 'standard', etc.
136 * @return Skin
137 */
138 static function &newFromKey( $key ) {
139 global $wgStyleDirectory;
140
141 $key = Skin::normalizeKey( $key );
142
143 $skinNames = Skin::getSkinNames();
144 $skinName = $skinNames[$key];
145 $className = 'Skin' . ucfirst( $key );
146
147 # Grab the skin class and initialise it.
148 if ( !class_exists( $className ) ) {
149 // Preload base classes to work around APC/PHP5 bug
150 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
151
152 if ( file_exists( $deps ) ) {
153 include_once( $deps );
154 }
155 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
156
157 # Check if we got if not failback to default skin
158 if ( !class_exists( $className ) ) {
159 # DO NOT die if the class isn't found. This breaks maintenance
160 # scripts and can cause a user account to be unrecoverable
161 # except by SQL manipulation if a previously valid skin name
162 # is no longer valid.
163 wfDebug( "Skin class does not exist: $className\n" );
164 $className = 'SkinVector';
165 require_once( "{$wgStyleDirectory}/Vector.php" );
166 }
167 }
168 $skin = new $className;
169 return $skin;
170 }
171
172 /** @return string path to the skin stylesheet */
173 function getStylesheet() {
174 return 'common/wikistandard.css';
175 }
176
177 /** @return string skin name */
178 public function getSkinName() {
179 return $this->skinname;
180 }
181
182 function qbSetting() {
183 global $wgOut, $wgUser;
184
185 if ( $wgOut->isQuickbarSuppressed() ) {
186 return 0;
187 }
188
189 $q = $wgUser->getOption( 'quickbar', 0 );
190
191 return $q;
192 }
193
194 function initPage( OutputPage $out ) {
195 global $wgFavicon, $wgAppleTouchIcon;
196
197 wfProfileIn( __METHOD__ );
198
199 # Generally the order of the favicon and apple-touch-icon links
200 # should not matter, but Konqueror (3.5.9 at least) incorrectly
201 # uses whichever one appears later in the HTML source. Make sure
202 # apple-touch-icon is specified first to avoid this.
203 if ( false !== $wgAppleTouchIcon ) {
204 $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
205 }
206
207 if ( false !== $wgFavicon ) {
208 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
209 }
210
211 # OpenSearch description link
212 $out->addLink( array(
213 'rel' => 'search',
214 'type' => 'application/opensearchdescription+xml',
215 'href' => wfScript( 'opensearch_desc' ),
216 'title' => wfMsgForContent( 'opensearch-desc' ),
217 ) );
218
219 $this->addMetadataLinks( $out );
220
221 $this->mRevisionId = $out->mRevisionId;
222
223 $this->preloadExistence();
224
225 wfProfileOut( __METHOD__ );
226 }
227
228 /**
229 * Preload the existence of three commonly-requested pages in a single query
230 */
231 function preloadExistence() {
232 global $wgUser;
233
234 // User/talk link
235 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
236
237 // Other tab link
238 if ( $this->mTitle->getNamespace() == NS_SPECIAL ) {
239 // nothing
240 } elseif ( $this->mTitle->isTalkPage() ) {
241 $titles[] = $this->mTitle->getSubjectPage();
242 } else {
243 $titles[] = $this->mTitle->getTalkPage();
244 }
245
246 $lb = new LinkBatch( $titles );
247 $lb->setCaller( __METHOD__ );
248 $lb->execute();
249 }
250
251 /**
252 * Adds metadata links (Creative Commons/Dublin Core/copyright) to the HTML
253 * output.
254 * @param $out Object: instance of OutputPage
255 */
256 function addMetadataLinks( OutputPage $out ) {
257 global $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
258 global $wgRightsPage, $wgRightsUrl;
259
260 if ( $out->isArticleRelated() ) {
261 # note: buggy CC software only reads first "meta" link
262 if ( $wgEnableCreativeCommonsRdf ) {
263 $out->addMetadataLink( array(
264 'title' => 'Creative Commons',
265 'type' => 'application/rdf+xml',
266 'href' => $this->mTitle->getLocalURL( 'action=creativecommons' ) )
267 );
268 }
269
270 if ( $wgEnableDublinCoreRdf ) {
271 $out->addMetadataLink( array(
272 'title' => 'Dublin Core',
273 'type' => 'application/rdf+xml',
274 'href' => $this->mTitle->getLocalURL( 'action=dublincore' ) )
275 );
276 }
277 }
278 $copyright = '';
279 if ( $wgRightsPage ) {
280 $copy = Title::newFromText( $wgRightsPage );
281
282 if ( $copy ) {
283 $copyright = $copy->getLocalURL();
284 }
285 }
286
287 if ( !$copyright && $wgRightsUrl ) {
288 $copyright = $wgRightsUrl;
289 }
290
291 if ( $copyright ) {
292 $out->addLink( array(
293 'rel' => 'copyright',
294 'href' => $copyright )
295 );
296 }
297 }
298
299 /**
300 * Set some local variables
301 */
302 protected function setMembers() {
303 global $wgUser;
304 $this->mUser = $wgUser;
305 $this->userpage = $wgUser->getUserPage()->getPrefixedText();
306 $this->usercss = false;
307 }
308
309 /**
310 * Set the title
311 * @param $t Title object to use
312 */
313 public function setTitle( $t ) {
314 $this->mTitle = $t;
315 }
316
317 /** Get the title */
318 public function getTitle() {
319 return $this->mTitle;
320 }
321
322 /**
323 * Outputs the HTML generated by other functions.
324 * @param $out Object: instance of OutputPage
325 */
326 function outputPage( OutputPage $out ) {
327 global $wgDebugComments;
328 wfProfileIn( __METHOD__ );
329
330 $this->setMembers();
331 $this->initPage( $out );
332
333 // See self::afterContentHook() for documentation
334 $afterContent = $this->afterContentHook();
335
336 $out->out( $out->headElement( $this ) );
337
338 if ( $wgDebugComments ) {
339 $out->out( "<!-- Wiki debugging output:\n" .
340 $out->mDebugtext . "-->\n" );
341 }
342
343 $out->out( $this->beforeContent() );
344
345 $out->out( $out->mBodytext . "\n" );
346
347 $out->out( $this->afterContent() );
348
349 $out->out( $afterContent );
350
351 $out->out( $this->bottomScripts( $out ) );
352
353 $out->out( wfReportTime() );
354
355 $out->out( "\n</body></html>" );
356 wfProfileOut( __METHOD__ );
357 }
358
359 static function makeVariablesScript( $data ) {
360 if ( $data ) {
361 return Html::inlineScript( 'mediaWiki.config.set(' . FormatJson::encode( $data ) . ');' );
362 } else {
363 return '';
364 }
365 }
366
367 /**
368 * Make a <script> tag containing global variables
369 * @param $skinName string Name of the skin
370 * The odd calling convention is for backwards compatibility
371 * @todo FIXME: Make this not depend on $wgTitle!
372 *
373 * Do not add things here which can be evaluated in ResourceLoaderStartupScript - in other words, without state.
374 * You will only be adding bloat to the page and causing page caches to have to be purged on configuration changes.
375 */
376 static function makeGlobalVariablesScript( $skinName ) {
377 global $wgTitle, $wgUser, $wgRequest, $wgArticle, $wgOut, $wgRestrictionTypes, $wgUseAjax, $wgEnableMWSuggest;
378
379 $ns = $wgTitle->getNamespace();
380 $nsname = MWNamespace::exists( $ns ) ? MWNamespace::getCanonicalName( $ns ) : $wgTitle->getNsText();
381 $vars = array(
382 'wgCanonicalNamespace' => $nsname,
383 'wgCanonicalSpecialPageName' => $ns == NS_SPECIAL ?
384 SpecialPage::resolveAlias( $wgTitle->getDBkey() ) : false, # bug 21115
385 'wgNamespaceNumber' => $wgTitle->getNamespace(),
386 'wgPageName' => $wgTitle->getPrefixedDBKey(),
387 'wgTitle' => $wgTitle->getText(),
388 'wgAction' => $wgRequest->getText( 'action', 'view' ),
389 'wgArticleId' => $wgTitle->getArticleId(),
390 'wgIsArticle' => $wgOut->isArticle(),
391 'wgUserName' => $wgUser->isAnon() ? null : $wgUser->getName(),
392 'wgUserGroups' => $wgUser->getEffectiveGroups(),
393 'wgCurRevisionId' => isset( $wgArticle ) ? $wgArticle->getLatest() : 0,
394 'wgCategories' => $wgOut->getCategories(),
395 );
396 foreach ( $wgRestrictionTypes as $type ) {
397 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
398 }
399 if ( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ) {
400 $vars['wgSearchNamespaces'] = SearchEngine::userNamespaces( $wgUser );
401 }
402
403 // Allow extensions to add their custom variables to the global JS variables
404 wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
405
406 return self::makeVariablesScript( $vars );
407 }
408
409 /**
410 * To make it harder for someone to slip a user a fake
411 * user-JavaScript or user-CSS preview, a random token
412 * is associated with the login session. If it's not
413 * passed back with the preview request, we won't render
414 * the code.
415 *
416 * @param $action String: 'edit', 'submit' etc.
417 * @return bool
418 */
419 public function userCanPreview( $action ) {
420 global $wgRequest, $wgUser;
421
422 if ( $action != 'submit' ) {
423 return false;
424 }
425 if ( !$wgRequest->wasPosted() ) {
426 return false;
427 }
428 if ( !$this->mTitle->userCanEditCssSubpage() ) {
429 return false;
430 }
431 if ( !$this->mTitle->userCanEditJsSubpage() ) {
432 return false;
433 }
434
435 return $wgUser->matchEditToken(
436 $wgRequest->getVal( 'wpEditToken' ) );
437 }
438
439 /**
440 * Generated JavaScript action=raw&gen=js
441 * This returns MediaWiki:Common.js and MediaWiki:[Skinname].js concate-
442 * nated together. For some bizarre reason, it does *not* return any
443 * custom user JS from subpages. Huh?
444 *
445 * There's absolutely no reason to have separate Monobook/Common JSes.
446 * Any JS that cares can just check the skin variable generated at the
447 * top. For now Monobook.js will be maintained, but it should be consi-
448 * dered deprecated.
449 *
450 * @param $skinName String: If set, overrides the skin name
451 * @return string
452 */
453 public function generateUserJs( $skinName = null ) {
454
455 // Stub - see ResourceLoaderSiteModule, CologneBlue, Simple and Standard skins override this
456
457 return '';
458 }
459
460 /**
461 * Generate user stylesheet for action=raw&gen=css
462 */
463 public function generateUserStylesheet() {
464
465 // Stub - see ResourceLoaderUserModule, CologneBlue, Simple and Standard skins override this
466
467 return '';
468 }
469
470 /**
471 * Split for easier subclassing in SkinSimple, SkinStandard and SkinCologneBlue
472 * Anything in here won't be generated if $wgAllowUserCssPrefs is false.
473 */
474 protected function reallyGenerateUserStylesheet() {
475
476 // Stub - see ResourceLoaderUserModule, CologneBlue, Simple and Standard skins override this
477
478 return '';
479 }
480
481 /**
482 * @private
483 */
484 function setupUserCss( OutputPage $out ) {
485 global $wgRequest;
486 global $wgUseSiteCss, $wgAllowUserCss, $wgAllowUserCssPrefs, $wgSquidMaxage;
487
488 wfProfileIn( __METHOD__ );
489
490 $this->setupSkinUserCss( $out );
491
492 $siteargs = array(
493 'action' => 'raw',
494 'maxage' => $wgSquidMaxage,
495 );
496
497 // Add any extension CSS
498 foreach ( $out->getExtStyle() as $url ) {
499 $out->addStyle( $url );
500 }
501
502 // Per-site custom styles
503 if ( $wgUseSiteCss ) {
504 $out->addModuleStyles( 'site' );
505 }
506
507 // Per-user custom styles
508 if ( $wgAllowUserCss ) {
509 if ( $this->mTitle->isCssSubpage() && $this->userCanPreview( $wgRequest->getVal( 'action' ) ) ) {
510 // @FIXME: properly escape the cdata!
511 $out->addInlineStyle( $wgRequest->getText( 'wpTextbox1' ) );
512 } else {
513 $out->addModuleStyles( 'user' );
514 }
515 }
516
517 // Per-user preference styles
518 if ( $wgAllowUserCssPrefs ) {
519 $out->addModuleStyles( 'user.options' );
520 }
521
522 wfProfileOut( __METHOD__ );
523 }
524
525 /**
526 * Get the query to generate a dynamic stylesheet
527 *
528 * @return array
529 */
530 public static function getDynamicStylesheetQuery() {
531 global $wgSquidMaxage;
532
533 return array(
534 'action' => 'raw',
535 'maxage' => $wgSquidMaxage,
536 'usemsgcache' => 'yes',
537 'ctype' => 'text/css',
538 'smaxage' => $wgSquidMaxage,
539 );
540 }
541
542 /**
543 * Add skin specific stylesheets
544 * @param $out OutputPage
545 */
546 function setupSkinUserCss( OutputPage $out ) {
547 $out->addModuleStyles( 'mediawiki.legacy.shared' );
548 $out->addModuleStyles( 'mediawiki.legacy.oldshared' );
549 // TODO: When converting old skins to use ResourceLoader (or removing them) the following should be reconsidered
550 $out->addStyle( $this->getStylesheet() );
551 $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' );
552 }
553
554 function getPageClasses( $title ) {
555 $numeric = 'ns-' . $title->getNamespace();
556
557 if ( $title->getNamespace() == NS_SPECIAL ) {
558 $type = 'ns-special';
559 } elseif ( $title->isTalkPage() ) {
560 $type = 'ns-talk';
561 } else {
562 $type = 'ns-subject';
563 }
564
565 $name = Sanitizer::escapeClass( 'page-' . $title->getPrefixedText() );
566
567 return "$numeric $type $name";
568 }
569
570 /**
571 * URL to the logo
572 */
573 function getLogo() {
574 global $wgLogo;
575 return $wgLogo;
576 }
577
578 /**
579 * This will be called immediately after the <body> tag. Split into
580 * two functions to make it easier to subclass.
581 */
582 function beforeContent() {
583 return $this->doBeforeContent();
584 }
585
586 function doBeforeContent() {
587 global $wgContLang;
588 wfProfileIn( __METHOD__ );
589
590 $s = '';
591 $qb = $this->qbSetting();
592
593 $langlinks = $this->otherLanguages();
594 if ( $langlinks ) {
595 $rows = 2;
596 $borderhack = '';
597 } else {
598 $rows = 1;
599 $langlinks = false;
600 $borderhack = 'class="top"';
601 }
602
603 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
604 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
605
606 $shove = ( $qb != 0 );
607 $left = ( $qb == 1 || $qb == 3 );
608
609 if ( $wgContLang->isRTL() ) {
610 $left = !$left;
611 }
612
613 if ( !$shove ) {
614 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
615 $this->logoText() . '</td>';
616 } elseif ( $left ) {
617 $s .= $this->getQuickbarCompensator( $rows );
618 }
619
620 $l = $wgContLang->alignStart();
621 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
622
623 $s .= $this->topLinks();
624 $s .= '<p class="subtitle">' . $this->pageTitleLinks() . "</p>\n";
625
626 $r = $wgContLang->alignEnd();
627 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
628 $s .= $this->nameAndLogin();
629 $s .= "\n<br />" . $this->searchForm() . '</td>';
630
631 if ( $langlinks ) {
632 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
633 }
634
635 if ( $shove && !$left ) { # Right
636 $s .= $this->getQuickbarCompensator( $rows );
637 }
638
639 $s .= "</tr>\n</table>\n</div>\n";
640 $s .= "\n<div id='article'>\n";
641
642 $notice = wfGetSiteNotice();
643
644 if ( $notice ) {
645 $s .= "\n<div id='siteNotice'>$notice</div>\n";
646 }
647 $s .= $this->pageTitle();
648 $s .= $this->pageSubtitle();
649 $s .= $this->getCategories();
650
651 wfProfileOut( __METHOD__ );
652 return $s;
653 }
654
655 function getCategoryLinks() {
656 global $wgOut, $wgUseCategoryBrowser;
657 global $wgContLang, $wgUser;
658
659 if ( count( $wgOut->mCategoryLinks ) == 0 ) {
660 return '';
661 }
662
663 # Separator
664 $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) );
665
666 // Use Unicode bidi embedding override characters,
667 // to make sure links don't smash each other up in ugly ways.
668 $dir = $wgContLang->getDir();
669 $embed = "<span dir='$dir'>";
670 $pop = '</span>';
671
672 $allCats = $wgOut->getCategoryLinks();
673 $s = '';
674 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
675
676 if ( !empty( $allCats['normal'] ) ) {
677 $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
678
679 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
680 $s .= '<div id="mw-normal-catlinks">' .
681 $this->link( Title::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
682 . $colon . $t . '</div>';
683 }
684
685 # Hidden categories
686 if ( isset( $allCats['hidden'] ) ) {
687 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
688 $class = 'mw-hidden-cats-user-shown';
689 } elseif ( $this->mTitle->getNamespace() == NS_CATEGORY ) {
690 $class = 'mw-hidden-cats-ns-shown';
691 } else {
692 $class = 'mw-hidden-cats-hidden';
693 }
694
695 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
696 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
697 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
698 '</div>';
699 }
700
701 # optional 'dmoz-like' category browser. Will be shown under the list
702 # of categories an article belong to
703 if ( $wgUseCategoryBrowser ) {
704 $s .= '<br /><hr />';
705
706 # get a big array of the parents tree
707 $parenttree = $this->mTitle->getParentCategoryTree();
708 # Skin object passed by reference cause it can not be
709 # accessed under the method subfunction drawCategoryBrowser
710 $tempout = explode( "\n", $this->drawCategoryBrowser( $parenttree, $this ) );
711 # Clean out bogus first entry and sort them
712 unset( $tempout[0] );
713 asort( $tempout );
714 # Output one per line
715 $s .= implode( "<br />\n", $tempout );
716 }
717
718 return $s;
719 }
720
721 /**
722 * Render the array as a serie of links.
723 * @param $tree Array: categories tree returned by Title::getParentCategoryTree
724 * @param &skin Object: skin passed by reference
725 * @return String separated by &gt;, terminate with "\n"
726 */
727 function drawCategoryBrowser( $tree, &$skin ) {
728 $return = '';
729
730 foreach ( $tree as $element => $parent ) {
731 if ( empty( $parent ) ) {
732 # element start a new list
733 $return .= "\n";
734 } else {
735 # grab the others elements
736 $return .= $this->drawCategoryBrowser( $parent, $skin ) . ' &gt; ';
737 }
738
739 # add our current element to the list
740 $eltitle = Title::newFromText( $element );
741 $return .= $skin->link( $eltitle, $eltitle->getText() );
742 }
743
744 return $return;
745 }
746
747 function getCategories() {
748 $catlinks = $this->getCategoryLinks();
749
750 $classes = 'catlinks';
751
752 global $wgOut, $wgUser;
753
754 // Check what we're showing
755 $allCats = $wgOut->getCategoryLinks();
756 $showHidden = $wgUser->getBoolOption( 'showhiddencats' ) ||
757 $this->mTitle->getNamespace() == NS_CATEGORY;
758
759 if ( empty( $allCats['normal'] ) && !( !empty( $allCats['hidden'] ) && $showHidden ) ) {
760 $classes .= ' catlinks-allhidden';
761 }
762
763 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
764 }
765
766 function getQuickbarCompensator( $rows = 1 ) {
767 return "<td width='152' rowspan='{$rows}'>&#160;</td>";
768 }
769
770 /**
771 * This runs a hook to allow extensions placing their stuff after content
772 * and article metadata (e.g. categories).
773 * Note: This function has nothing to do with afterContent().
774 *
775 * This hook is placed here in order to allow using the same hook for all
776 * skins, both the SkinTemplate based ones and the older ones, which directly
777 * use this class to get their data.
778 *
779 * The output of this function gets processed in SkinTemplate::outputPage() for
780 * the SkinTemplate based skins, all other skins should directly echo it.
781 *
782 * Returns an empty string by default, if not changed by any hook function.
783 */
784 protected function afterContentHook() {
785 $data = '';
786
787 if ( wfRunHooks( 'SkinAfterContent', array( &$data, $this ) ) ) {
788 // adding just some spaces shouldn't toggle the output
789 // of the whole <div/>, so we use trim() here
790 if ( trim( $data ) != '' ) {
791 // Doing this here instead of in the skins to
792 // ensure that the div has the same ID in all
793 // skins
794 $data = "<div id='mw-data-after-content'>\n" .
795 "\t$data\n" .
796 "</div>\n";
797 }
798 } else {
799 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
800 }
801
802 return $data;
803 }
804
805 /**
806 * Generate debug data HTML for displaying at the bottom of the main content
807 * area.
808 * @return String HTML containing debug data, if enabled (otherwise empty).
809 */
810 protected function generateDebugHTML() {
811 global $wgShowDebug, $wgOut;
812
813 if ( $wgShowDebug ) {
814 $listInternals = $this->formatDebugHTML( $wgOut->mDebugtext );
815 return "\n<hr />\n<strong>Debug data:</strong><ul style=\"font-family:monospace;\" id=\"mw-debug-html\">" .
816 $listInternals . "</ul>\n";
817 }
818
819 return '';
820 }
821
822 private function formatDebugHTML( $debugText ) {
823 $lines = explode( "\n", $debugText );
824 $curIdent = 0;
825 $ret = '<li>';
826
827 foreach ( $lines as $line ) {
828 $m = array();
829 $display = ltrim( $line );
830 $ident = strlen( $line ) - strlen( $display );
831 $diff = $ident - $curIdent;
832
833 if ( $display == '' ) {
834 $display = "\xc2\xa0";
835 }
836
837 if ( !$ident && $diff < 0 && substr( $display, 0, 9 ) != 'Entering ' && substr( $display, 0, 8 ) != 'Exiting ' ) {
838 $ident = $curIdent;
839 $diff = 0;
840 $display = '<span style="background:yellow;">' . htmlspecialchars( $display ) . '</span>';
841 } else {
842 $display = htmlspecialchars( $display );
843 }
844
845 if ( $diff < 0 ) {
846 $ret .= str_repeat( "</li></ul>\n", -$diff ) . "</li><li>\n";
847 } elseif ( $diff == 0 ) {
848 $ret .= "</li><li>\n";
849 } else {
850 $ret .= str_repeat( "<ul><li>\n", $diff );
851 }
852 $ret .= $display . "\n";
853
854 $curIdent = $ident;
855 }
856
857 $ret .= str_repeat( '</li></ul>', $curIdent ) . '</li>';
858
859 return $ret;
860 }
861
862 /**
863 * This gets called shortly before the </body> tag.
864 * @return String HTML to be put before </body>
865 */
866 function afterContent() {
867 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
868 return $printfooter . $this->generateDebugHTML() . $this->doAfterContent();
869 }
870
871 /**
872 * This gets called shortly before the </body> tag.
873 * @param $out OutputPage object
874 * @return String HTML-wrapped JS code to be put before </body>
875 */
876 function bottomScripts( $out ) {
877 $bottomScriptText = "\n" . $out->getHeadScripts( $this );
878 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
879
880 return $bottomScriptText;
881 }
882
883 /** @return string Retrievied from HTML text */
884 function printSource() {
885 $url = htmlspecialchars( $this->mTitle->getFullURL() );
886 return wfMsg( 'retrievedfrom', '<a href="' . $url . '">' . $url . '</a>' );
887 }
888
889 function printFooter() {
890 return "<p>" . $this->printSource() .
891 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
892 }
893
894 /** overloaded by derived classes */
895 function doAfterContent() {
896 return '</div></div>';
897 }
898
899 function pageTitleLinks() {
900 global $wgOut, $wgUser, $wgRequest, $wgLang;
901
902 $oldid = $wgRequest->getVal( 'oldid' );
903 $diff = $wgRequest->getVal( 'diff' );
904 $action = $wgRequest->getText( 'action' );
905
906 $s[] = $this->printableLink();
907 $disclaimer = $this->disclaimerLink(); # may be empty
908
909 if ( $disclaimer ) {
910 $s[] = $disclaimer;
911 }
912
913 $privacy = $this->privacyLink(); # may be empty too
914
915 if ( $privacy ) {
916 $s[] = $privacy;
917 }
918
919 if ( $wgOut->isArticleRelated() ) {
920 if ( $this->mTitle->getNamespace() == NS_FILE ) {
921 $name = $this->mTitle->getDBkey();
922 $image = wfFindFile( $this->mTitle );
923
924 if ( $image ) {
925 $link = htmlspecialchars( $image->getURL() );
926 $style = $this->getInternalLinkAttributes( $link, $name );
927 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
928 }
929 }
930 }
931
932 if ( 'history' == $action || isset( $diff ) || isset( $oldid ) ) {
933 $s[] .= $this->link(
934 $this->mTitle,
935 wfMsg( 'currentrev' ),
936 array(),
937 array(),
938 array( 'known', 'noclasses' )
939 );
940 }
941
942 if ( $wgUser->getNewtalk() ) {
943 # do not show "You have new messages" text when we are viewing our
944 # own talk page
945 if ( !$this->mTitle->equals( $wgUser->getTalkPage() ) ) {
946 $tl = $this->link(
947 $wgUser->getTalkPage(),
948 wfMsgHtml( 'newmessageslink' ),
949 array(),
950 array( 'redirect' => 'no' ),
951 array( 'known', 'noclasses' )
952 );
953
954 $dl = $this->link(
955 $wgUser->getTalkPage(),
956 wfMsgHtml( 'newmessagesdifflink' ),
957 array(),
958 array( 'diff' => 'cur' ),
959 array( 'known', 'noclasses' )
960 );
961 $s[] = '<strong>' . wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
962 # disable caching
963 $wgOut->setSquidMaxage( 0 );
964 $wgOut->enableClientCache( false );
965 }
966 }
967
968 $undelete = $this->getUndeleteLink();
969
970 if ( !empty( $undelete ) ) {
971 $s[] = $undelete;
972 }
973
974 return $wgLang->pipeList( $s );
975 }
976
977 function getUndeleteLink() {
978 global $wgUser, $wgLang, $wgRequest;
979
980 $action = $wgRequest->getVal( 'action', 'view' );
981
982 if ( $wgUser->isAllowed( 'deletedhistory' ) &&
983 ( $this->mTitle->getArticleId() == 0 || $action == 'history' ) ) {
984 $n = $this->mTitle->isDeleted();
985
986 if ( $n ) {
987 if ( $wgUser->isAllowed( 'undelete' ) ) {
988 $msg = 'thisisdeleted';
989 } else {
990 $msg = 'viewdeleted';
991 }
992
993 return wfMsg(
994 $msg,
995 $this->link(
996 SpecialPage::getTitleFor( 'Undelete', $this->mTitle->getPrefixedDBkey() ),
997 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ),
998 array(),
999 array(),
1000 array( 'known', 'noclasses' )
1001 )
1002 );
1003 }
1004 }
1005
1006 return '';
1007 }
1008
1009 function printableLink() {
1010 global $wgOut, $wgFeedClasses, $wgRequest, $wgLang;
1011
1012 $s = array();
1013
1014 if ( !$wgOut->isPrintable() ) {
1015 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
1016 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
1017 }
1018
1019 if ( $wgOut->isSyndicated() ) {
1020 foreach ( $wgFeedClasses as $format => $class ) {
1021 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
1022 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
1023 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
1024 }
1025 }
1026 return $wgLang->pipeList( $s );
1027 }
1028
1029 /**
1030 * Gets the h1 element with the page title.
1031 * @return string
1032 */
1033 function pageTitle() {
1034 global $wgOut;
1035 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
1036 return $s;
1037 }
1038
1039 function pageSubtitle() {
1040 global $wgOut;
1041
1042 $sub = $wgOut->getSubtitle();
1043
1044 if ( $sub == '' ) {
1045 global $wgExtraSubtitle;
1046 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
1047 }
1048
1049 $subpages = $this->subPageSubtitle();
1050 $sub .= !empty( $subpages ) ? "</p><p class='subpages'>$subpages" : '';
1051 $s = "<p class='subtitle'>{$sub}</p>\n";
1052
1053 return $s;
1054 }
1055
1056 function subPageSubtitle() {
1057 $subpages = '';
1058
1059 if ( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages ) ) ) {
1060 return $subpages;
1061 }
1062
1063 global $wgOut;
1064
1065 if ( $wgOut->isArticle() && MWNamespace::hasSubpages( $this->mTitle->getNamespace() ) ) {
1066 $ptext = $this->mTitle->getPrefixedText();
1067 if ( preg_match( '/\//', $ptext ) ) {
1068 $links = explode( '/', $ptext );
1069 array_pop( $links );
1070 $c = 0;
1071 $growinglink = '';
1072 $display = '';
1073
1074 foreach ( $links as $link ) {
1075 $growinglink .= $link;
1076 $display .= $link;
1077 $linkObj = Title::newFromText( $growinglink );
1078
1079 if ( is_object( $linkObj ) && $linkObj->exists() ) {
1080 $getlink = $this->link(
1081 $linkObj,
1082 htmlspecialchars( $display ),
1083 array(),
1084 array(),
1085 array( 'known', 'noclasses' )
1086 );
1087
1088 $c++;
1089
1090 if ( $c > 1 ) {
1091 $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1092 } else {
1093 $subpages .= '&lt; ';
1094 }
1095
1096 $subpages .= $getlink;
1097 $display = '';
1098 } else {
1099 $display .= '/';
1100 }
1101 $growinglink .= '/';
1102 }
1103 }
1104 }
1105
1106 return $subpages;
1107 }
1108
1109 /**
1110 * Returns true if the IP should be shown in the header
1111 */
1112 function showIPinHeader() {
1113 global $wgShowIPinHeader;
1114 return $wgShowIPinHeader && session_id() != '';
1115 }
1116
1117 function nameAndLogin() {
1118 global $wgUser, $wgLang, $wgContLang;
1119
1120 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
1121
1122 $ret = '';
1123
1124 if ( $wgUser->isAnon() ) {
1125 if ( $this->showIPinHeader() ) {
1126 $name = wfGetIP();
1127
1128 $talkLink = $this->link( $wgUser->getTalkPage(),
1129 $wgLang->getNsText( NS_TALK ) );
1130
1131 $ret .= "$name ($talkLink)";
1132 } else {
1133 $ret .= wfMsg( 'notloggedin' );
1134 }
1135
1136 $returnTo = $this->mTitle->getPrefixedDBkey();
1137 $query = array();
1138
1139 if ( $logoutPage != $returnTo ) {
1140 $query['returnto'] = $returnTo;
1141 }
1142
1143 $loginlink = $wgUser->isAllowed( 'createaccount' )
1144 ? 'nav-login-createaccount'
1145 : 'login';
1146 $ret .= "\n<br />" . $this->link(
1147 SpecialPage::getTitleFor( 'Userlogin' ),
1148 wfMsg( $loginlink ), array(), $query
1149 );
1150 } else {
1151 $returnTo = $this->mTitle->getPrefixedDBkey();
1152 $talkLink = $this->link( $wgUser->getTalkPage(),
1153 $wgLang->getNsText( NS_TALK ) );
1154
1155 $ret .= $this->link( $wgUser->getUserPage(),
1156 htmlspecialchars( $wgUser->getName() ) );
1157 $ret .= " ($talkLink)<br />";
1158 $ret .= $wgLang->pipeList( array(
1159 $this->link(
1160 SpecialPage::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
1161 array(), array( 'returnto' => $returnTo )
1162 ),
1163 $this->specialLink( 'Preferences' ),
1164 ) );
1165 }
1166
1167 $ret = $wgLang->pipeList( array(
1168 $ret,
1169 $this->link(
1170 Title::newFromText( wfMsgForContent( 'helppage' ) ),
1171 wfMsg( 'help' )
1172 ),
1173 ) );
1174
1175 return $ret;
1176 }
1177
1178 function getSearchLink() {
1179 $searchPage = SpecialPage::getTitleFor( 'Search' );
1180 return $searchPage->getLocalURL();
1181 }
1182
1183 function escapeSearchLink() {
1184 return htmlspecialchars( $this->getSearchLink() );
1185 }
1186
1187 function searchForm() {
1188 global $wgRequest, $wgUseTwoButtonsSearchForm;
1189
1190 $search = $wgRequest->getText( 'search' );
1191
1192 $s = '<form id="searchform' . $this->searchboxes . '" name="search" class="inline" method="post" action="'
1193 . $this->escapeSearchLink() . "\">\n"
1194 . '<input type="text" id="searchInput' . $this->searchboxes . '" name="search" size="19" value="'
1195 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
1196 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
1197
1198 if ( $wgUseTwoButtonsSearchForm ) {
1199 $s .= '&#160;<input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
1200 } else {
1201 $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
1202 }
1203
1204 $s .= '</form>';
1205
1206 // Ensure unique id's for search boxes made after the first
1207 $this->searchboxes = $this->searchboxes == '' ? 2 : $this->searchboxes + 1;
1208
1209 return $s;
1210 }
1211
1212 function topLinks() {
1213 global $wgOut;
1214
1215 $s = array(
1216 $this->mainPageLink(),
1217 $this->specialLink( 'Recentchanges' )
1218 );
1219
1220 if ( $wgOut->isArticleRelated() ) {
1221 $s[] = $this->editThisPage();
1222 $s[] = $this->historyLink();
1223 }
1224
1225 # Many people don't like this dropdown box
1226 # $s[] = $this->specialPagesList();
1227
1228 if ( $this->variantLinks() ) {
1229 $s[] = $this->variantLinks();
1230 }
1231
1232 if ( $this->extensionTabLinks() ) {
1233 $s[] = $this->extensionTabLinks();
1234 }
1235
1236 // @todo FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
1237 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
1238 }
1239
1240 /**
1241 * Compatibility for extensions adding functionality through tabs.
1242 * Eventually these old skins should be replaced with SkinTemplate-based
1243 * versions, sigh...
1244 * @return string
1245 */
1246 function extensionTabLinks() {
1247 $tabs = array();
1248 $out = '';
1249 $s = array();
1250 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
1251 foreach ( $tabs as $tab ) {
1252 $s[] = Xml::element( 'a',
1253 array( 'href' => $tab['href'] ),
1254 $tab['text'] );
1255 }
1256
1257 if ( count( $s ) ) {
1258 global $wgLang;
1259
1260 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
1261 $out .= $wgLang->pipeList( $s );
1262 }
1263
1264 return $out;
1265 }
1266
1267 /**
1268 * Language/charset variant links for classic-style skins
1269 * @return string
1270 */
1271 function variantLinks() {
1272 $s = '';
1273
1274 /* show links to different language variants */
1275 global $wgDisableLangConversion, $wgLang, $wgContLang;
1276
1277 $variants = $wgContLang->getVariants();
1278
1279 if ( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
1280 foreach ( $variants as $code ) {
1281 $varname = $wgContLang->getVariantname( $code );
1282
1283 if ( $varname == 'disable' ) {
1284 continue;
1285 }
1286 $s = $wgLang->pipeList( array(
1287 $s,
1288 '<a href="' . $this->mTitle->escapeLocalURL( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
1289 ) );
1290 }
1291 }
1292
1293 return $s;
1294 }
1295
1296 function bottomLinks() {
1297 global $wgOut, $wgUser, $wgUseTrackbacks;
1298 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
1299
1300 $s = '';
1301 if ( $wgOut->isArticleRelated() ) {
1302 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
1303
1304 if ( $wgUser->isLoggedIn() ) {
1305 $element[] = $this->watchThisPage();
1306 }
1307
1308 $element[] = $this->talkLink();
1309 $element[] = $this->historyLink();
1310 $element[] = $this->whatLinksHere();
1311 $element[] = $this->watchPageLinksLink();
1312
1313 if ( $wgUseTrackbacks ) {
1314 $element[] = $this->trackbackLink();
1315 }
1316
1317 if (
1318 $this->mTitle->getNamespace() == NS_USER ||
1319 $this->mTitle->getNamespace() == NS_USER_TALK
1320 ) {
1321 $id = User::idFromName( $this->mTitle->getText() );
1322 $ip = User::isIP( $this->mTitle->getText() );
1323
1324 # Both anons and non-anons have contributions list
1325 if ( $id || $ip ) {
1326 $element[] = $this->userContribsLink();
1327 }
1328
1329 if ( $this->showEmailUser( $id ) ) {
1330 $element[] = $this->emailUserLink();
1331 }
1332 }
1333
1334 $s = implode( $element, $sep );
1335
1336 if ( $this->mTitle->getArticleId() ) {
1337 $s .= "\n<br />";
1338
1339 // Delete/protect/move links for privileged users
1340 if ( $wgUser->isAllowed( 'delete' ) ) {
1341 $s .= $this->deleteThisPage();
1342 }
1343
1344 if ( $wgUser->isAllowed( 'protect' ) ) {
1345 $s .= $sep . $this->protectThisPage();
1346 }
1347
1348 if ( $wgUser->isAllowed( 'move' ) ) {
1349 $s .= $sep . $this->moveThisPage();
1350 }
1351 }
1352
1353 $s .= "<br />\n" . $this->otherLanguages();
1354 }
1355
1356 return $s;
1357 }
1358
1359 function pageStats() {
1360 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
1361 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
1362
1363 $oldid = $wgRequest->getVal( 'oldid' );
1364 $diff = $wgRequest->getVal( 'diff' );
1365
1366 if ( !$wgOut->isArticle() ) {
1367 return '';
1368 }
1369
1370 if ( !$wgArticle instanceof Article ) {
1371 return '';
1372 }
1373
1374 if ( isset( $oldid ) || isset( $diff ) ) {
1375 return '';
1376 }
1377
1378 if ( 0 == $wgArticle->getID() ) {
1379 return '';
1380 }
1381
1382 $s = '';
1383
1384 if ( !$wgDisableCounters ) {
1385 $count = $wgLang->formatNum( $wgArticle->getCount() );
1386
1387 if ( $count ) {
1388 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
1389 }
1390 }
1391
1392 if ( $wgMaxCredits != 0 ) {
1393 $s .= ' ' . Credits::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
1394 } else {
1395 $s .= $this->lastModified();
1396 }
1397
1398 if ( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
1399 $dbr = wfGetDB( DB_SLAVE );
1400 $res = $dbr->select(
1401 'watchlist',
1402 array( 'COUNT(*) AS n' ),
1403 array(
1404 'wl_title' => $dbr->strencode( $this->mTitle->getDBkey() ),
1405 'wl_namespace' => $this->mTitle->getNamespace()
1406 ),
1407 __METHOD__
1408 );
1409 $x = $dbr->fetchObject( $res );
1410
1411 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
1412 array( 'parseinline' ), $wgLang->formatNum( $x->n )
1413 );
1414 }
1415
1416 return $s . ' ' . $this->getCopyright();
1417 }
1418
1419 function getCopyright( $type = 'detect' ) {
1420 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest, $wgArticle;
1421
1422 if ( $type == 'detect' ) {
1423 $diff = $wgRequest->getVal( 'diff' );
1424 $isCur = $wgArticle && $wgArticle->isCurrent();
1425
1426 if ( is_null( $diff ) && !$isCur && wfMsgForContent( 'history_copyright' ) !== '-' ) {
1427 $type = 'history';
1428 } else {
1429 $type = 'normal';
1430 }
1431 }
1432
1433 if ( $type == 'history' ) {
1434 $msg = 'history_copyright';
1435 } else {
1436 $msg = 'copyright';
1437 }
1438
1439 $out = '';
1440
1441 if ( $wgRightsPage ) {
1442 $title = Title::newFromText( $wgRightsPage );
1443 $link = $this->linkKnown( $title, $wgRightsText );
1444 } elseif ( $wgRightsUrl ) {
1445 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
1446 } elseif ( $wgRightsText ) {
1447 $link = $wgRightsText;
1448 } else {
1449 # Give up now
1450 return $out;
1451 }
1452
1453 // Allow for site and per-namespace customization of copyright notice.
1454 $forContent = true;
1455
1456 if ( isset( $wgArticle ) ) {
1457 wfRunHooks( 'SkinCopyrightFooter', array( $wgArticle->getTitle(), $type, &$msg, &$link, &$forContent ) );
1458 }
1459
1460 if ( $forContent ) {
1461 $out .= wfMsgForContent( $msg, $link );
1462 } else {
1463 $out .= wfMsg( $msg, $link );
1464 }
1465
1466 return $out;
1467 }
1468
1469 function getCopyrightIcon() {
1470 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
1471
1472 $out = '';
1473
1474 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
1475 $out = $wgCopyrightIcon;
1476 } elseif ( $wgRightsIcon ) {
1477 $icon = htmlspecialchars( $wgRightsIcon );
1478
1479 if ( $wgRightsUrl ) {
1480 $url = htmlspecialchars( $wgRightsUrl );
1481 $out .= '<a href="' . $url . '">';
1482 }
1483
1484 $text = htmlspecialchars( $wgRightsText );
1485 $out .= "<img src=\"$icon\" alt=\"$text\" width=\"88\" height=\"31\" />";
1486
1487 if ( $wgRightsUrl ) {
1488 $out .= '</a>';
1489 }
1490 }
1491
1492 return $out;
1493 }
1494
1495 /**
1496 * Gets the powered by MediaWiki icon.
1497 * @return string
1498 */
1499 function getPoweredBy() {
1500 global $wgStylePath;
1501
1502 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
1503 $img = '<a href="http://www.mediawiki.org/"><img src="' . $url . '" height="31" width="88" alt="Powered by MediaWiki" /></a>';
1504
1505 return $img;
1506 }
1507
1508 function lastModified() {
1509 global $wgLang, $wgArticle;
1510
1511 if ( $this->mRevisionId && $this->mRevisionId != $wgArticle->getLatest() ) {
1512 $timestamp = Revision::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId );
1513 } else {
1514 $timestamp = $wgArticle->getTimestamp();
1515 }
1516
1517 if ( $timestamp ) {
1518 $d = $wgLang->date( $timestamp, true );
1519 $t = $wgLang->time( $timestamp, true );
1520 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
1521 } else {
1522 $s = '';
1523 }
1524
1525 if ( wfGetLB()->getLaggedSlaveMode() ) {
1526 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
1527 }
1528
1529 return $s;
1530 }
1531
1532 function logoText( $align = '' ) {
1533 if ( $align != '' ) {
1534 $a = " align='{$align}'";
1535 } else {
1536 $a = '';
1537 }
1538
1539 $mp = wfMsg( 'mainpage' );
1540 $mptitle = Title::newMainPage();
1541 $url = ( is_object( $mptitle ) ? $mptitle->escapeLocalURL() : '' );
1542
1543 $logourl = $this->getLogo();
1544 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
1545
1546 return $s;
1547 }
1548
1549 /**
1550 * Show a drop-down box of special pages
1551 */
1552 function specialPagesList() {
1553 global $wgContLang, $wgServer, $wgRedirectScript;
1554
1555 $pages = array_merge( SpecialPage::getRegularPages(), SpecialPage::getRestrictedPages() );
1556
1557 foreach ( $pages as $name => $page ) {
1558 $pages[$name] = $page->getDescription();
1559 }
1560
1561 $go = wfMsg( 'go' );
1562 $sp = wfMsg( 'specialpages' );
1563 $spp = $wgContLang->specialPage( 'Specialpages' );
1564
1565 $s = '<form id="specialpages" method="get" ' .
1566 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
1567 $s .= "<select name=\"wpDropdown\">\n";
1568 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
1569
1570
1571 foreach ( $pages as $name => $desc ) {
1572 $p = $wgContLang->specialPage( $name );
1573 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
1574 }
1575
1576 $s .= "</select>\n";
1577 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
1578 $s .= "</form>\n";
1579
1580 return $s;
1581 }
1582
1583 /**
1584 * Gets the link to the wiki's main page.
1585 * @return string
1586 */
1587 function mainPageLink() {
1588 $s = $this->link(
1589 Title::newMainPage(),
1590 wfMsg( 'mainpage' ),
1591 array(),
1592 array(),
1593 array( 'known', 'noclasses' )
1594 );
1595
1596 return $s;
1597 }
1598
1599 private function footerLink( $desc, $page ) {
1600 // if the link description has been set to "-" in the default language,
1601 if ( wfMsgForContent( $desc ) == '-' ) {
1602 // then it is disabled, for all languages.
1603 return '';
1604 } else {
1605 // Otherwise, we display the link for the user, described in their
1606 // language (which may or may not be the same as the default language),
1607 // but we make the link target be the one site-wide page.
1608 $title = Title::newFromText( wfMsgForContent( $page ) );
1609
1610 return $this->linkKnown(
1611 $title,
1612 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) )
1613 );
1614 }
1615 }
1616
1617 /**
1618 * Gets the link to the wiki's privacy policy page.
1619 */
1620 function privacyLink() {
1621 return $this->footerLink( 'privacy', 'privacypage' );
1622 }
1623
1624 /**
1625 * Gets the link to the wiki's about page.
1626 */
1627 function aboutLink() {
1628 return $this->footerLink( 'aboutsite', 'aboutpage' );
1629 }
1630
1631 /**
1632 * Gets the link to the wiki's general disclaimers page.
1633 */
1634 function disclaimerLink() {
1635 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
1636 }
1637
1638 function editThisPage() {
1639 global $wgOut;
1640
1641 if ( !$wgOut->isArticleRelated() ) {
1642 $s = wfMsg( 'protectedpage' );
1643 } else {
1644 if ( $this->mTitle->quickUserCan( 'edit' ) && $this->mTitle->exists() ) {
1645 $t = wfMsg( 'editthispage' );
1646 } elseif ( $this->mTitle->quickUserCan( 'create' ) && !$this->mTitle->exists() ) {
1647 $t = wfMsg( 'create-this-page' );
1648 } else {
1649 $t = wfMsg( 'viewsource' );
1650 }
1651
1652 $s = $this->link(
1653 $this->mTitle,
1654 $t,
1655 array(),
1656 $this->editUrlOptions(),
1657 array( 'known', 'noclasses' )
1658 );
1659 }
1660
1661 return $s;
1662 }
1663
1664 /**
1665 * Return URL options for the 'edit page' link.
1666 * This may include an 'oldid' specifier, if the current page view is such.
1667 *
1668 * @return array
1669 * @private
1670 */
1671 function editUrlOptions() {
1672 global $wgArticle;
1673
1674 $options = array( 'action' => 'edit' );
1675
1676 if ( $this->mRevisionId && ! $wgArticle->isCurrent() ) {
1677 $options['oldid'] = intval( $this->mRevisionId );
1678 }
1679
1680 return $options;
1681 }
1682
1683 function deleteThisPage() {
1684 global $wgUser, $wgRequest;
1685
1686 $diff = $wgRequest->getVal( 'diff' );
1687
1688 if ( $this->mTitle->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
1689 $t = wfMsg( 'deletethispage' );
1690
1691 $s = $this->link(
1692 $this->mTitle,
1693 $t,
1694 array(),
1695 array( 'action' => 'delete' ),
1696 array( 'known', 'noclasses' )
1697 );
1698 } else {
1699 $s = '';
1700 }
1701
1702 return $s;
1703 }
1704
1705 function protectThisPage() {
1706 global $wgUser, $wgRequest;
1707
1708 $diff = $wgRequest->getVal( 'diff' );
1709
1710 if ( $this->mTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
1711 if ( $this->mTitle->isProtected() ) {
1712 $text = wfMsg( 'unprotectthispage' );
1713 $query = array( 'action' => 'unprotect' );
1714 } else {
1715 $text = wfMsg( 'protectthispage' );
1716 $query = array( 'action' => 'protect' );
1717 }
1718
1719 $s = $this->link(
1720 $this->mTitle,
1721 $text,
1722 array(),
1723 $query,
1724 array( 'known', 'noclasses' )
1725 );
1726 } else {
1727 $s = '';
1728 }
1729
1730 return $s;
1731 }
1732
1733 function watchThisPage() {
1734 global $wgOut;
1735 ++$this->mWatchLinkNum;
1736
1737 if ( $wgOut->isArticleRelated() ) {
1738 if ( $this->mTitle->userIsWatching() ) {
1739 $text = wfMsg( 'unwatchthispage' );
1740 $query = array( 'action' => 'unwatch' );
1741 $id = 'mw-unwatch-link' . $this->mWatchLinkNum;
1742 } else {
1743 $text = wfMsg( 'watchthispage' );
1744 $query = array( 'action' => 'watch' );
1745 $id = 'mw-watch-link' . $this->mWatchLinkNum;
1746 }
1747
1748 $s = $this->link(
1749 $this->mTitle,
1750 $text,
1751 array( 'id' => $id ),
1752 $query,
1753 array( 'known', 'noclasses' )
1754 );
1755 } else {
1756 $s = wfMsg( 'notanarticle' );
1757 }
1758
1759 return $s;
1760 }
1761
1762 function moveThisPage() {
1763 if ( $this->mTitle->quickUserCan( 'move' ) ) {
1764 return $this->link(
1765 SpecialPage::getTitleFor( 'Movepage' ),
1766 wfMsg( 'movethispage' ),
1767 array(),
1768 array( 'target' => $this->mTitle->getPrefixedDBkey() ),
1769 array( 'known', 'noclasses' )
1770 );
1771 } else {
1772 // no message if page is protected - would be redundant
1773 return '';
1774 }
1775 }
1776
1777 function historyLink() {
1778 return $this->link(
1779 $this->mTitle,
1780 wfMsgHtml( 'history' ),
1781 array( 'rel' => 'archives' ),
1782 array( 'action' => 'history' )
1783 );
1784 }
1785
1786 function whatLinksHere() {
1787 return $this->link(
1788 SpecialPage::getTitleFor( 'Whatlinkshere', $this->mTitle->getPrefixedDBkey() ),
1789 wfMsgHtml( 'whatlinkshere' ),
1790 array(),
1791 array(),
1792 array( 'known', 'noclasses' )
1793 );
1794 }
1795
1796 function userContribsLink() {
1797 return $this->link(
1798 SpecialPage::getTitleFor( 'Contributions', $this->mTitle->getDBkey() ),
1799 wfMsgHtml( 'contributions' ),
1800 array(),
1801 array(),
1802 array( 'known', 'noclasses' )
1803 );
1804 }
1805
1806 function showEmailUser( $id ) {
1807 global $wgUser;
1808 $targetUser = User::newFromId( $id );
1809 return $wgUser->canSendEmail() && # the sending user must have a confirmed email address
1810 $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
1811 }
1812
1813 function emailUserLink() {
1814 return $this->link(
1815 SpecialPage::getTitleFor( 'Emailuser', $this->mTitle->getDBkey() ),
1816 wfMsg( 'emailuser' ),
1817 array(),
1818 array(),
1819 array( 'known', 'noclasses' )
1820 );
1821 }
1822
1823 function watchPageLinksLink() {
1824 global $wgOut;
1825
1826 if ( !$wgOut->isArticleRelated() ) {
1827 return '(' . wfMsg( 'notanarticle' ) . ')';
1828 } else {
1829 return $this->link(
1830 SpecialPage::getTitleFor( 'Recentchangeslinked', $this->mTitle->getPrefixedDBkey() ),
1831 wfMsg( 'recentchangeslinked-toolbox' ),
1832 array(),
1833 array(),
1834 array( 'known', 'noclasses' )
1835 );
1836 }
1837 }
1838
1839 function trackbackLink() {
1840 return '<a href="' . $this->mTitle->trackbackURL() . '">'
1841 . wfMsg( 'trackbacklink' ) . '</a>';
1842 }
1843
1844 function otherLanguages() {
1845 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
1846
1847 if ( $wgHideInterlanguageLinks ) {
1848 return '';
1849 }
1850
1851 $a = $wgOut->getLanguageLinks();
1852
1853 if ( 0 == count( $a ) ) {
1854 return '';
1855 }
1856
1857 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
1858 $first = true;
1859
1860 if ( $wgContLang->isRTL() ) {
1861 $s .= '<span dir="LTR">';
1862 }
1863
1864 foreach ( $a as $l ) {
1865 if ( !$first ) {
1866 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
1867 }
1868
1869 $first = false;
1870
1871 $nt = Title::newFromText( $l );
1872 $url = $nt->escapeFullURL();
1873 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1874 $title = htmlspecialchars( $nt->getText() );
1875
1876 if ( $text == '' ) {
1877 $text = $l;
1878 }
1879
1880 $style = $this->getExternalLinkAttributes();
1881 $s .= "<a href=\"{$url}\" title=\"{$title}\"{$style}>{$text}</a>";
1882 }
1883
1884 if ( $wgContLang->isRTL() ) {
1885 $s .= '</span>';
1886 }
1887
1888 return $s;
1889 }
1890
1891 function talkLink() {
1892 if ( NS_SPECIAL == $this->mTitle->getNamespace() ) {
1893 # No discussion links for special pages
1894 return '';
1895 }
1896
1897 $linkOptions = array();
1898
1899 if ( $this->mTitle->isTalkPage() ) {
1900 $link = $this->mTitle->getSubjectPage();
1901 switch( $link->getNamespace() ) {
1902 case NS_MAIN:
1903 $text = wfMsg( 'articlepage' );
1904 break;
1905 case NS_USER:
1906 $text = wfMsg( 'userpage' );
1907 break;
1908 case NS_PROJECT:
1909 $text = wfMsg( 'projectpage' );
1910 break;
1911 case NS_FILE:
1912 $text = wfMsg( 'imagepage' );
1913 # Make link known if image exists, even if the desc. page doesn't.
1914 if ( wfFindFile( $link ) )
1915 $linkOptions[] = 'known';
1916 break;
1917 case NS_MEDIAWIKI:
1918 $text = wfMsg( 'mediawikipage' );
1919 break;
1920 case NS_TEMPLATE:
1921 $text = wfMsg( 'templatepage' );
1922 break;
1923 case NS_HELP:
1924 $text = wfMsg( 'viewhelppage' );
1925 break;
1926 case NS_CATEGORY:
1927 $text = wfMsg( 'categorypage' );
1928 break;
1929 default:
1930 $text = wfMsg( 'articlepage' );
1931 }
1932 } else {
1933 $link = $this->mTitle->getTalkPage();
1934 $text = wfMsg( 'talkpage' );
1935 }
1936
1937 $s = $this->link( $link, $text, array(), array(), $linkOptions );
1938
1939 return $s;
1940 }
1941
1942 function commentLink() {
1943 global $wgOut;
1944
1945 if ( $this->mTitle->getNamespace() == NS_SPECIAL ) {
1946 return '';
1947 }
1948
1949 # __NEWSECTIONLINK___ changes behaviour here
1950 # If it is present, the link points to this page, otherwise
1951 # it points to the talk page
1952 if ( $this->mTitle->isTalkPage() ) {
1953 $title = $this->mTitle;
1954 } elseif ( $wgOut->showNewSectionLink() ) {
1955 $title = $this->mTitle;
1956 } else {
1957 $title = $this->mTitle->getTalkPage();
1958 }
1959
1960 return $this->link(
1961 $title,
1962 wfMsg( 'postcomment' ),
1963 array(),
1964 array(
1965 'action' => 'edit',
1966 'section' => 'new'
1967 ),
1968 array( 'known', 'noclasses' )
1969 );
1970 }
1971
1972 function getUploadLink() {
1973 global $wgUploadNavigationUrl;
1974
1975 if ( $wgUploadNavigationUrl ) {
1976 # Using an empty class attribute to avoid automatic setting of "external" class
1977 return $this->makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '' ) );
1978 } else {
1979 return $this->link(
1980 SpecialPage::getTitleFor( 'Upload' ),
1981 wfMsgHtml( 'upload' ),
1982 array(),
1983 array(),
1984 array( 'known', 'noclasses' )
1985 );
1986 }
1987 }
1988
1989 /* these are used extensively in SkinTemplate, but also some other places */
1990 static function makeMainPageUrl( $urlaction = '' ) {
1991 $title = Title::newMainPage();
1992 self::checkTitle( $title, '' );
1993
1994 return $title->getLocalURL( $urlaction );
1995 }
1996
1997 static function makeSpecialUrl( $name, $urlaction = '' ) {
1998 $title = SpecialPage::getTitleFor( $name );
1999 return $title->getLocalURL( $urlaction );
2000 }
2001
2002 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
2003 $title = SpecialPage::getSafeTitleFor( $name, $subpage );
2004 return $title->getLocalURL( $urlaction );
2005 }
2006
2007 static function makeI18nUrl( $name, $urlaction = '' ) {
2008 $title = Title::newFromText( wfMsgForContent( $name ) );
2009 self::checkTitle( $title, $name );
2010 return $title->getLocalURL( $urlaction );
2011 }
2012
2013 static function makeUrl( $name, $urlaction = '' ) {
2014 $title = Title::newFromText( $name );
2015 self::checkTitle( $title, $name );
2016
2017 return $title->getLocalURL( $urlaction );
2018 }
2019
2020 /**
2021 * If url string starts with http, consider as external URL, else
2022 * internal
2023 */
2024 static function makeInternalOrExternalUrl( $name ) {
2025 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
2026 return $name;
2027 } else {
2028 return self::makeUrl( $name );
2029 }
2030 }
2031
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
2037 return $title->getLocalURL( $urlaction );
2038 }
2039
2040 /* these return an array with the 'href' and boolean 'exists' */
2041 static function makeUrlDetails( $name, $urlaction = '' ) {
2042 $title = Title::newFromText( $name );
2043 self::checkTitle( $title, $name );
2044
2045 return array(
2046 'href' => $title->getLocalURL( $urlaction ),
2047 'exists' => $title->getArticleID() != 0 ? true : false
2048 );
2049 }
2050
2051 /**
2052 * Make URL details where the article exists (or at least it's convenient to think so)
2053 */
2054 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
2055 $title = Title::newFromText( $name );
2056 self::checkTitle( $title, $name );
2057
2058 return array(
2059 'href' => $title->getLocalURL( $urlaction ),
2060 'exists' => true
2061 );
2062 }
2063
2064 # make sure we have some title to operate on
2065 static function checkTitle( &$title, $name ) {
2066 if ( !is_object( $title ) ) {
2067 $title = Title::newFromText( $name );
2068 if ( !is_object( $title ) ) {
2069 $title = Title::newFromText( '--error: link target missing--' );
2070 }
2071 }
2072 }
2073
2074 /**
2075 * Build an array that represents the sidebar(s), the navigation bar among them
2076 *
2077 * @return array
2078 */
2079 function buildSidebar() {
2080 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
2081 global $wgLang;
2082 wfProfileIn( __METHOD__ );
2083
2084 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
2085
2086 if ( $wgEnableSidebarCache ) {
2087 $cachedsidebar = $parserMemc->get( $key );
2088 if ( $cachedsidebar ) {
2089 wfProfileOut( __METHOD__ );
2090 return $cachedsidebar;
2091 }
2092 }
2093
2094 $bar = array();
2095 $this->addToSidebar( $bar, 'sidebar' );
2096
2097 wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
2098 if ( $wgEnableSidebarCache ) {
2099 $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
2100 }
2101
2102 wfProfileOut( __METHOD__ );
2103 return $bar;
2104 }
2105 /**
2106 * Add content from a sidebar system message
2107 * Currently only used for MediaWiki:Sidebar (but may be used by Extensions)
2108 *
2109 * This is just a wrapper around addToSidebarPlain() for backwards compatibility
2110 *
2111 * @param &$bar array
2112 * @param $message String
2113 */
2114 function addToSidebar( &$bar, $message ) {
2115 $this->addToSidebarPlain( $bar, wfMsgForContent( $message ) );
2116 }
2117
2118 /**
2119 * Add content from plain text
2120 * @since 1.17
2121 * @param &$bar array
2122 * @param $text string
2123 */
2124 function addToSidebarPlain( &$bar, $text ) {
2125 $lines = explode( "\n", $text );
2126 $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.
2127
2128 $heading = '';
2129
2130 foreach ( $lines as $line ) {
2131 if ( strpos( $line, '*' ) !== 0 ) {
2132 continue;
2133 }
2134
2135 if ( strpos( $line, '**' ) !== 0 ) {
2136 $heading = trim( $line, '* ' );
2137 if ( !array_key_exists( $heading, $bar ) ) {
2138 $bar[$heading] = array();
2139 }
2140 } else {
2141 $line = trim( $line, '* ' );
2142
2143 if ( strpos( $line, '|' ) !== false ) { // sanity check
2144 $line = array_map( 'trim', explode( '|', $line, 2 ) );
2145 $link = wfMsgForContent( $line[0] );
2146
2147 if ( $link == '-' ) {
2148 continue;
2149 }
2150
2151 $text = wfMsgExt( $line[1], 'parsemag' );
2152
2153 if ( wfEmptyMsg( $line[1], $text ) ) {
2154 $text = $line[1];
2155 }
2156
2157 if ( wfEmptyMsg( $line[0], $link ) ) {
2158 $link = $line[0];
2159 }
2160
2161 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
2162 $href = $link;
2163 } else {
2164 $title = Title::newFromText( $link );
2165
2166 if ( $title ) {
2167 $title = $title->fixSpecialName();
2168 $href = $title->getLocalURL();
2169 } else {
2170 $href = 'INVALID-TITLE';
2171 }
2172 }
2173
2174 $bar[$heading][] = array(
2175 'text' => $text,
2176 'href' => $href,
2177 'id' => 'n-' . strtr( $line[1], ' ', '-' ),
2178 'active' => false
2179 );
2180 } else if ( ( substr( $line, 0, 2 ) == '{{' ) && ( substr( $line, -2 ) == '}}' ) ) {
2181 global $wgParser, $wgTitle;
2182
2183 $line = substr( $line, 2, strlen( $line ) - 4 );
2184
2185 if ( is_null( $wgParser->mOptions ) ) {
2186 $wgParser->mOptions = new ParserOptions();
2187 }
2188
2189 $wgParser->mOptions->setEditSection( false );
2190 $wikiBar[$heading] = $wgParser->parse( wfMsgForContentNoTrans( $line ) , $wgTitle, $wgParser->mOptions )->getText();
2191 } else {
2192 continue;
2193 }
2194 }
2195 }
2196
2197 if ( count( $wikiBar ) > 0 ) {
2198 $bar = array_merge( $bar, $wikiBar );
2199 }
2200
2201 return $bar;
2202 }
2203
2204 /**
2205 * Should we include common/wikiprintable.css? Skins that have their own
2206 * print stylesheet should override this and return false. (This is an
2207 * ugly hack to get Monobook to play nicely with
2208 * OutputPage::headElement().)
2209 *
2210 * @return bool
2211 */
2212 public function commonPrintStylesheet() {
2213 return true;
2214 }
2215
2216 /**
2217 * Gets new talk page messages for the current user.
2218 * @return MediaWiki message or if no new talk page messages, nothing
2219 */
2220 function getNewtalks() {
2221 global $wgUser, $wgOut;
2222
2223 $newtalks = $wgUser->getNewMessageLinks();
2224 $ntl = '';
2225
2226 if ( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
2227 $userTitle = $this->mUser->getUserPage();
2228 $userTalkTitle = $userTitle->getTalkPage();
2229
2230 if ( !$userTalkTitle->equals( $this->mTitle ) ) {
2231 $newMessagesLink = $this->link(
2232 $userTalkTitle,
2233 wfMsgHtml( 'newmessageslink' ),
2234 array(),
2235 array( 'redirect' => 'no' ),
2236 array( 'known', 'noclasses' )
2237 );
2238
2239 $newMessagesDiffLink = $this->link(
2240 $userTalkTitle,
2241 wfMsgHtml( 'newmessagesdifflink' ),
2242 array(),
2243 array( 'diff' => 'cur' ),
2244 array( 'known', 'noclasses' )
2245 );
2246
2247 $ntl = wfMsg(
2248 'youhavenewmessages',
2249 $newMessagesLink,
2250 $newMessagesDiffLink
2251 );
2252 # Disable Squid cache
2253 $wgOut->setSquidMaxage( 0 );
2254 }
2255 } elseif ( count( $newtalks ) ) {
2256 // _>" " for BC <= 1.16
2257 $sep = str_replace( '_', ' ', wfMsgHtml( 'newtalkseparator' ) );
2258 $msgs = array();
2259
2260 foreach ( $newtalks as $newtalk ) {
2261 $msgs[] = Xml::element(
2262 'a',
2263 array( 'href' => $newtalk['link'] ), $newtalk['wiki']
2264 );
2265 }
2266 $parts = implode( $sep, $msgs );
2267 $ntl = wfMsgHtml( 'youhavenewmessagesmulti', $parts );
2268 $wgOut->setSquidMaxage( 0 );
2269 }
2270
2271 return $ntl;
2272 }
2273 }