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