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