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