Introduced Maintenance::getDB() and corresponding setDB() to control externally what...
[mediawiki.git] / includes / SkinLegacy.php
blob81638915cab26f572dc34c5439c1742b3f52d67a
1 <?php
2 /**
3 * @defgroup Skins Skins
4 */
6 if ( !defined( 'MEDIAWIKI' ) ) {
7 die( 1 );
10 class SkinLegacy extends SkinTemplate {
11 var $useHeadElement = true;
12 protected $mWatchLinkNum = 0; // Appended to end of watch link id's
14 /**
15 * Add skin specific stylesheets
16 * @param $out OutputPage
18 function setupSkinUserCss( OutputPage $out ) {
19 $out->addModuleStyles( 'mediawiki.legacy.shared' );
20 $out->addModuleStyles( 'mediawiki.legacy.oldshared' );
23 public function commonPrintStylesheet() {
24 return true;
27 /**
28 * This was for the old skins and for users with 640x480 screen.
29 * Please note old skins are still used and might prove useful for
30 * users having old computers or visually impaired.
32 var $mSuppressQuickbar = false;
34 /**
35 * Suppress the quickbar from the output, only for skin supporting
36 * the quickbar
38 public function suppressQuickbar() {
39 $this->mSuppressQuickbar = true;
42 /**
43 * Return whether the quickbar should be suppressed from the output
45 * @return Boolean
47 public function isQuickbarSuppressed() {
48 return $this->mSuppressQuickbar;
51 function qbSetting() {
52 global $wgUser;
53 if ( $this->isQuickbarSuppressed() ) {
54 return 0;
56 $q = $wgUser->getOption( 'quickbar', 0 );
57 return $q;
62 class LegacyTemplate extends BaseTemplate {
64 // How many search boxes have we made? Avoid duplicate id's.
65 protected $searchboxes = '';
67 function execute() {
68 $this->html( 'headelement' );
69 echo $this->beforeContent();
70 $this->html( 'bodytext' );
71 echo '<div class="printfooter">';
72 $this->html( 'printfooter' );
73 echo '</div>';
74 $this->html( 'debughtml' );
75 echo "\n";
76 echo $this->afterContent();
77 $this->html( 'dataAfterContent' );
78 $this->printTrail();
79 echo "\n</body></html>";
82 /**
83 * This will be called immediately after the <body> tag. Split into
84 * two functions to make it easier to subclass.
86 function beforeContent() {
87 return $this->doBeforeContent();
90 function doBeforeContent() {
91 global $wgContLang;
92 wfProfileIn( __METHOD__ );
94 $s = '';
95 $qb = $this->getSkin()->qbSetting();
97 $langlinks = $this->otherLanguages();
98 if ( $langlinks ) {
99 $rows = 2;
100 $borderhack = '';
101 } else {
102 $rows = 1;
103 $langlinks = false;
104 $borderhack = 'class="top"';
107 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
108 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
110 $shove = ( $qb != 0 );
111 $left = ( $qb == 1 || $qb == 3 );
113 if ( !$shove ) {
114 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
115 $this->getSkin()->logoText() . '</td>';
116 } elseif ( $left ) {
117 $s .= $this->getQuickbarCompensator( $rows );
120 $l = $wgContLang->alignStart();
121 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
123 $s .= $this->topLinks();
124 $s .= '<p class="subtitle">' . $this->pageTitleLinks() . "</p>\n";
126 $r = $wgContLang->alignEnd();
127 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
128 $s .= $this->nameAndLogin();
129 $s .= "\n<br />" . $this->searchForm() . '</td>';
131 if ( $langlinks ) {
132 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
135 if ( $shove && !$left ) { # Right
136 $s .= $this->getQuickbarCompensator( $rows );
139 $s .= "</tr>\n</table>\n</div>\n";
140 $s .= "\n<div id='article'>\n";
142 $notice = $this->getSkin()->getSiteNotice();
144 if ( $notice ) {
145 $s .= "\n<div id='siteNotice'>$notice</div>\n";
147 $s .= $this->pageTitle();
148 $s .= $this->pageSubtitle();
149 $s .= $this->getSkin()->getCategories();
151 wfProfileOut( __METHOD__ );
152 return $s;
156 * This gets called shortly before the </body> tag.
157 * @return String HTML to be put before </body>
159 function afterContent() {
160 return $this->doAfterContent();
163 /** overloaded by derived classes */
164 function doAfterContent() {
165 return '</div></div>';
168 function searchForm() {
169 global $wgRequest, $wgUseTwoButtonsSearchForm;
171 $search = $wgRequest->getText( 'search' );
173 $s = '<form id="searchform' . $this->searchboxes . '" name="search" class="inline" method="post" action="'
174 . $this->getSkin()->escapeSearchLink() . "\">\n"
175 . '<input type="text" id="searchInput' . $this->searchboxes . '" name="search" size="19" value="'
176 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
177 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
179 if ( $wgUseTwoButtonsSearchForm ) {
180 $s .= '&#160;<input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
181 } else {
182 $s .= ' <a href="' . $this->getSkin()->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
185 $s .= '</form>';
187 // Ensure unique id's for search boxes made after the first
188 $this->searchboxes = $this->searchboxes == '' ? 2 : $this->searchboxes + 1;
190 return $s;
193 function pageStats() {
194 global $wgOut, $wgLang, $wgRequest, $wgUser;
195 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
197 if ( !is_null( $wgRequest->getVal( 'oldid' ) ) || !is_null( $wgRequest->getVal( 'diff' ) ) ) {
198 return '';
201 if ( !$wgOut->isArticle() || !$this->getSkin()->getTitle()->exists() ) {
202 return '';
205 $article = new Article( $this->getSkin()->getTitle(), 0 );
207 $s = '';
209 if ( !$wgDisableCounters ) {
210 $count = $wgLang->formatNum( $article->getCount() );
212 if ( $count ) {
213 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
217 if ( $wgMaxCredits != 0 ) {
218 $s .= ' ' . Action::factory( 'credits', $article )->getCredits( $wgMaxCredits, $wgShowCreditsIfMax );
219 } else {
220 $s .= $this->data['lastmod'];
223 if ( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
224 $dbr = wfGetDB( DB_SLAVE );
225 $res = $dbr->select(
226 'watchlist',
227 array( 'COUNT(*) AS n' ),
228 array(
229 'wl_title' => $dbr->strencode( $this->getSkin()->getTitle()->getDBkey() ),
230 'wl_namespace' => $this->getSkin()->getTitle()->getNamespace()
232 __METHOD__
234 $x = $dbr->fetchObject( $res );
236 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
237 array( 'parseinline' ), $wgLang->formatNum( $x->n )
241 return $s . ' ' . $this->getSkin()->getCopyright();
244 function topLinks() {
245 global $wgOut;
247 $s = array(
248 $this->getSkin()->mainPageLink(),
249 $this->getSkin()->specialLink( 'Recentchanges' )
252 if ( $wgOut->isArticleRelated() ) {
253 $s[] = $this->editThisPage();
254 $s[] = $this->historyLink();
257 # Many people don't like this dropdown box
258 # $s[] = $this->specialPagesList();
260 if ( $this->variantLinks() ) {
261 $s[] = $this->variantLinks();
264 if ( $this->extensionTabLinks() ) {
265 $s[] = $this->extensionTabLinks();
268 // @todo FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
269 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
273 * Language/charset variant links for classic-style skins
274 * @return string
276 function variantLinks() {
277 $s = '';
279 /* show links to different language variants */
280 global $wgDisableLangConversion, $wgLang, $wgContLang;
282 $variants = $wgContLang->getVariants();
284 if ( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
285 foreach ( $variants as $code ) {
286 $varname = $wgContLang->getVariantname( $code );
288 if ( $varname == 'disable' ) {
289 continue;
291 $s = $wgLang->pipeList( array(
293 '<a href="' . $this->getSkin()->getTitle()->escapeLocalURL( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
294 ) );
298 return $s;
302 * Compatibility for extensions adding functionality through tabs.
303 * Eventually these old skins should be replaced with SkinTemplate-based
304 * versions, sigh...
305 * @return string
306 * @todo Exterminate! ...that, and replace it with normal SkinTemplate stuff
308 function extensionTabLinks() {
309 $tabs = array();
310 $out = '';
311 $s = array();
312 wfRunHooks( 'SkinTemplateTabs', array( $this->getSkin(), &$tabs ) );
313 foreach ( $tabs as $tab ) {
314 $s[] = Xml::element( 'a',
315 array( 'href' => $tab['href'] ),
316 $tab['text'] );
319 if ( count( $s ) ) {
320 global $wgLang;
322 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
323 $out .= $wgLang->pipeList( $s );
326 return $out;
329 function bottomLinks() {
330 global $wgOut, $wgUser, $wgUseTrackbacks;
331 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
333 $s = '';
334 if ( $wgOut->isArticleRelated() ) {
335 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
337 if ( $wgUser->isLoggedIn() ) {
338 $element[] = $this->watchThisPage();
341 $element[] = $this->talkLink();
342 $element[] = $this->historyLink();
343 $element[] = $this->whatLinksHere();
344 $element[] = $this->watchPageLinksLink();
346 if ( $wgUseTrackbacks ) {
347 $element[] = $this->trackbackLink();
350 if (
351 $this->getSkin()->getTitle()->getNamespace() == NS_USER ||
352 $this->getSkin()->getTitle()->getNamespace() == NS_USER_TALK
354 $id = User::idFromName( $this->getSkin()->getTitle()->getText() );
355 $ip = User::isIP( $this->getSkin()->getTitle()->getText() );
357 # Both anons and non-anons have contributions list
358 if ( $id || $ip ) {
359 $element[] = $this->userContribsLink();
362 if ( $this->getSkin()->showEmailUser( $id ) ) {
363 $element[] = $this->emailUserLink();
367 $s = implode( $element, $sep );
369 if ( $this->getSkin()->getTitle()->getArticleId() ) {
370 $s .= "\n<br />";
372 // Delete/protect/move links for privileged users
373 if ( $wgUser->isAllowed( 'delete' ) ) {
374 $s .= $this->deleteThisPage();
377 if ( $wgUser->isAllowed( 'protect' ) ) {
378 $s .= $sep . $this->protectThisPage();
381 if ( $wgUser->isAllowed( 'move' ) ) {
382 $s .= $sep . $this->moveThisPage();
386 $s .= "<br />\n" . $this->otherLanguages();
389 return $s;
392 function otherLanguages() {
393 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
395 if ( $wgHideInterlanguageLinks ) {
396 return '';
399 $a = $wgOut->getLanguageLinks();
401 if ( 0 == count( $a ) ) {
402 return '';
405 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
406 $first = true;
408 if ( $wgContLang->isRTL() ) {
409 $s .= '<span dir="LTR">';
412 foreach ( $a as $l ) {
413 if ( !$first ) {
414 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
417 $first = false;
419 $nt = Title::newFromText( $l );
420 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
422 $s .= Html::element( 'a',
423 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
424 $text == '' ? $l : $text );
427 if ( $wgContLang->isRTL() ) {
428 $s .= '</span>';
431 return $s;
435 * Show a drop-down box of special pages
437 function specialPagesList() {
438 global $wgContLang, $wgServer, $wgRedirectScript;
440 $pages = SpecialPageFactory::getUsablePages();
442 foreach ( $pages as $name => $page ) {
443 $pages[$name] = $page->getDescription();
446 $go = wfMsg( 'go' );
447 $sp = wfMsg( 'specialpages' );
448 $spp = $wgContLang->specialPage( 'Specialpages' );
450 $s = '<form id="specialpages" method="get" ' .
451 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
452 $s .= "<select name=\"wpDropdown\">\n";
453 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
456 foreach ( $pages as $name => $desc ) {
457 $p = $wgContLang->specialPage( $name );
458 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
461 $s .= "</select>\n";
462 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
463 $s .= "</form>\n";
465 return $s;
468 function pageTitleLinks() {
469 global $wgOut, $wgUser, $wgRequest, $wgLang;
471 $oldid = $wgRequest->getVal( 'oldid' );
472 $diff = $wgRequest->getVal( 'diff' );
473 $action = $wgRequest->getText( 'action' );
475 $s[] = $this->printableLink();
476 $disclaimer = $this->getSkin()->disclaimerLink(); # may be empty
478 if ( $disclaimer ) {
479 $s[] = $disclaimer;
482 $privacy = $this->getSkin()->privacyLink(); # may be empty too
484 if ( $privacy ) {
485 $s[] = $privacy;
488 if ( $wgOut->isArticleRelated() ) {
489 if ( $this->getSkin()->getTitle()->getNamespace() == NS_FILE ) {
490 $name = $this->getSkin()->getTitle()->getDBkey();
491 $image = wfFindFile( $this->getSkin()->getTitle() );
493 if ( $image ) {
494 $link = htmlspecialchars( $image->getURL() );
495 $style = $this->getInternalLinkAttributes( $link, $name );
496 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
501 if ( 'history' == $action || isset( $diff ) || isset( $oldid ) ) {
502 $s[] .= $this->getSkin()->link(
503 $this->getSkin()->getTitle(),
504 wfMsg( 'currentrev' ),
505 array(),
506 array(),
507 array( 'known', 'noclasses' )
511 if ( $wgUser->getNewtalk() ) {
512 # do not show "You have new messages" text when we are viewing our
513 # own talk page
514 if ( !$this->getSkin()->getTitle()->equals( $wgUser->getTalkPage() ) ) {
515 $tl = $this->getSkin()->link(
516 $wgUser->getTalkPage(),
517 wfMsgHtml( 'newmessageslink' ),
518 array(),
519 array( 'redirect' => 'no' ),
520 array( 'known', 'noclasses' )
523 $dl = $this->getSkin()->link(
524 $wgUser->getTalkPage(),
525 wfMsgHtml( 'newmessagesdifflink' ),
526 array(),
527 array( 'diff' => 'cur' ),
528 array( 'known', 'noclasses' )
530 $s[] = '<strong>' . wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
531 # disable caching
532 $wgOut->setSquidMaxage( 0 );
533 $wgOut->enableClientCache( false );
537 $undelete = $this->getSkin()->getUndeleteLink();
539 if ( !empty( $undelete ) ) {
540 $s[] = $undelete;
543 return $wgLang->pipeList( $s );
547 * Gets the h1 element with the page title.
548 * @return string
550 function pageTitle() {
551 global $wgOut;
552 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
553 return $s;
556 function pageSubtitle() {
557 global $wgOut;
559 $sub = $wgOut->getSubtitle();
561 if ( $sub == '' ) {
562 global $wgExtraSubtitle;
563 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
566 $subpages = $this->getSkin()->subPageSubtitle();
567 $sub .= !empty( $subpages ) ? "</p><p class='subpages'>$subpages" : '';
568 $s = "<p class='subtitle'>{$sub}</p>\n";
570 return $s;
573 function printableLink() {
574 global $wgOut, $wgRequest, $wgLang;
576 $s = array();
578 if ( !$wgOut->isPrintable() ) {
579 $printurl = htmlspecialchars( $this->getSkin()->getTitle()->getLocalUrl(
580 $wgRequest->appendQueryValue( 'printable', 'yes', true ) ) );
581 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
584 if ( $wgOut->isSyndicated() ) {
585 foreach ( $wgOut->getSyndicationLinks() as $format => $link ) {
586 $feedurl = htmlspecialchars( $link );
587 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
588 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
591 return $wgLang->pipeList( $s );
594 function getQuickbarCompensator( $rows = 1 ) {
595 return "<td width='152' rowspan='{$rows}'>&#160;</td>";
598 function editThisPage() {
599 global $wgOut;
601 if ( !$wgOut->isArticleRelated() ) {
602 $s = wfMsg( 'protectedpage' );
603 } else {
604 if ( $this->getSkin()->getTitle()->quickUserCan( 'edit' ) && $this->getSkin()->getTitle()->exists() ) {
605 $t = wfMsg( 'editthispage' );
606 } elseif ( $this->getSkin()->getTitle()->quickUserCan( 'create' ) && !$this->getSkin()->getTitle()->exists() ) {
607 $t = wfMsg( 'create-this-page' );
608 } else {
609 $t = wfMsg( 'viewsource' );
612 $s = $this->getSkin()->link(
613 $this->getSkin()->getTitle(),
615 array(),
616 $this->getSkin()->editUrlOptions(),
617 array( 'known', 'noclasses' )
621 return $s;
624 function deleteThisPage() {
625 global $wgUser, $wgRequest;
627 $diff = $wgRequest->getVal( 'diff' );
629 if ( $this->getSkin()->getTitle()->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
630 $t = wfMsg( 'deletethispage' );
632 $s = $this->getSkin()->link(
633 $this->getSkin()->getTitle(),
635 array(),
636 array( 'action' => 'delete' ),
637 array( 'known', 'noclasses' )
639 } else {
640 $s = '';
643 return $s;
646 function protectThisPage() {
647 global $wgUser, $wgRequest;
649 $diff = $wgRequest->getVal( 'diff' );
651 if ( $this->getSkin()->getTitle()->getArticleId() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
652 if ( $this->getSkin()->getTitle()->isProtected() ) {
653 $text = wfMsg( 'unprotectthispage' );
654 $query = array( 'action' => 'unprotect' );
655 } else {
656 $text = wfMsg( 'protectthispage' );
657 $query = array( 'action' => 'protect' );
660 $s = $this->getSkin()->link(
661 $this->getSkin()->getTitle(),
662 $text,
663 array(),
664 $query,
665 array( 'known', 'noclasses' )
667 } else {
668 $s = '';
671 return $s;
674 function watchThisPage() {
675 global $wgOut;
676 ++$this->mWatchLinkNum;
678 if ( $wgOut->isArticleRelated() ) {
679 if ( $this->getSkin()->getTitle()->userIsWatching() ) {
680 $text = wfMsg( 'unwatchthispage' );
681 $query = array( 'action' => 'unwatch' );
682 $id = 'mw-unwatch-link' . $this->mWatchLinkNum;
683 } else {
684 $text = wfMsg( 'watchthispage' );
685 $query = array( 'action' => 'watch' );
686 $id = 'mw-watch-link' . $this->mWatchLinkNum;
689 $s = $this->getSkin()->link(
690 $this->getSkin()->getTitle(),
691 $text,
692 array( 'id' => $id ),
693 $query,
694 array( 'known', 'noclasses' )
696 } else {
697 $s = wfMsg( 'notanarticle' );
700 return $s;
703 function moveThisPage() {
704 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
705 return $this->getSkin()->link(
706 SpecialPage::getTitleFor( 'Movepage' ),
707 wfMsg( 'movethispage' ),
708 array(),
709 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() ),
710 array( 'known', 'noclasses' )
712 } else {
713 // no message if page is protected - would be redundant
714 return '';
718 function historyLink() {
719 return $this->getSkin()->link(
720 $this->getSkin()->getTitle(),
721 wfMsgHtml( 'history' ),
722 array( 'rel' => 'archives' ),
723 array( 'action' => 'history' )
727 function whatLinksHere() {
728 return $this->getSkin()->link(
729 SpecialPage::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
730 wfMsgHtml( 'whatlinkshere' ),
731 array(),
732 array(),
733 array( 'known', 'noclasses' )
737 function userContribsLink() {
738 return $this->getSkin()->link(
739 SpecialPage::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
740 wfMsgHtml( 'contributions' ),
741 array(),
742 array(),
743 array( 'known', 'noclasses' )
747 function emailUserLink() {
748 return $this->getSkin()->link(
749 SpecialPage::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
750 wfMsg( 'emailuser' ),
751 array(),
752 array(),
753 array( 'known', 'noclasses' )
757 function watchPageLinksLink() {
758 global $wgOut;
760 if ( !$wgOut->isArticleRelated() ) {
761 return '(' . wfMsg( 'notanarticle' ) . ')';
762 } else {
763 return $this->getSkin()->link(
764 SpecialPage::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
765 wfMsg( 'recentchangeslinked-toolbox' ),
766 array(),
767 array(),
768 array( 'known', 'noclasses' )
773 function trackbackLink() {
774 return '<a href="' . $this->getSkin()->getTitle()->trackbackURL() . '">'
775 . wfMsg( 'trackbacklink' ) . '</a>';
778 function talkLink() {
779 if ( NS_SPECIAL == $this->getSkin()->getTitle()->getNamespace() ) {
780 # No discussion links for special pages
781 return '';
784 $linkOptions = array();
786 if ( $this->getSkin()->getTitle()->isTalkPage() ) {
787 $link = $this->getSkin()->getTitle()->getSubjectPage();
788 switch( $link->getNamespace() ) {
789 case NS_MAIN:
790 $text = wfMsg( 'articlepage' );
791 break;
792 case NS_USER:
793 $text = wfMsg( 'userpage' );
794 break;
795 case NS_PROJECT:
796 $text = wfMsg( 'projectpage' );
797 break;
798 case NS_FILE:
799 $text = wfMsg( 'imagepage' );
800 # Make link known if image exists, even if the desc. page doesn't.
801 if ( wfFindFile( $link ) )
802 $linkOptions[] = 'known';
803 break;
804 case NS_MEDIAWIKI:
805 $text = wfMsg( 'mediawikipage' );
806 break;
807 case NS_TEMPLATE:
808 $text = wfMsg( 'templatepage' );
809 break;
810 case NS_HELP:
811 $text = wfMsg( 'viewhelppage' );
812 break;
813 case NS_CATEGORY:
814 $text = wfMsg( 'categorypage' );
815 break;
816 default:
817 $text = wfMsg( 'articlepage' );
819 } else {
820 $link = $this->getSkin()->getTitle()->getTalkPage();
821 $text = wfMsg( 'talkpage' );
824 $s = $this->getSkin()->link( $link, $text, array(), array(), $linkOptions );
826 return $s;
829 function commentLink() {
830 global $wgOut;
832 if ( $this->getSkin()->getTitle()->getNamespace() == NS_SPECIAL ) {
833 return '';
836 # __NEWSECTIONLINK___ changes behaviour here
837 # If it is present, the link points to this page, otherwise
838 # it points to the talk page
839 if ( $this->getSkin()->getTitle()->isTalkPage() ) {
840 $title = $this->getSkin()->getTitle();
841 } elseif ( $wgOut->showNewSectionLink() ) {
842 $title = $this->getSkin()->getTitle();
843 } else {
844 $title = $this->getSkin()->getTitle()->getTalkPage();
847 return $this->getSkin()->link(
848 $title,
849 wfMsg( 'postcomment' ),
850 array(),
851 array(
852 'action' => 'edit',
853 'section' => 'new'
855 array( 'known', 'noclasses' )
859 function getUploadLink() {
860 global $wgUploadNavigationUrl;
862 if ( $wgUploadNavigationUrl ) {
863 # Using an empty class attribute to avoid automatic setting of "external" class
864 return $this->makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '' ) );
865 } else {
866 return $this->getSkin()->link(
867 SpecialPage::getTitleFor( 'Upload' ),
868 wfMsgHtml( 'upload' ),
869 array(),
870 array(),
871 array( 'known', 'noclasses' )
876 function nameAndLogin() {
877 global $wgUser, $wgLang, $wgContLang;
879 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
881 $ret = '';
883 if ( $wgUser->isAnon() ) {
884 if ( $this->getSkin()->showIPinHeader() ) {
885 $name = wfGetIP();
887 $talkLink = $this->getSkin()->link( $wgUser->getTalkPage(),
888 $wgLang->getNsText( NS_TALK ) );
890 $ret .= "$name ($talkLink)";
891 } else {
892 $ret .= wfMsg( 'notloggedin' );
895 $returnTo = $this->getSkin()->getTitle()->getPrefixedDBkey();
896 $query = array();
898 if ( $logoutPage != $returnTo ) {
899 $query['returnto'] = $returnTo;
902 $loginlink = $wgUser->isAllowed( 'createaccount' )
903 ? 'nav-login-createaccount'
904 : 'login';
905 $ret .= "\n<br />" . $this->getSkin()->link(
906 SpecialPage::getTitleFor( 'Userlogin' ),
907 wfMsg( $loginlink ), array(), $query
909 } else {
910 $returnTo = $this->getSkin()->getTitle()->getPrefixedDBkey();
911 $talkLink = $this->getSkin()->link( $wgUser->getTalkPage(),
912 $wgLang->getNsText( NS_TALK ) );
914 $ret .= $this->getSkin()->link( $wgUser->getUserPage(),
915 htmlspecialchars( $wgUser->getName() ) );
916 $ret .= " ($talkLink)<br />";
917 $ret .= $wgLang->pipeList( array(
918 $this->getSkin()->link(
919 SpecialPage::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
920 array(), array( 'returnto' => $returnTo )
922 $this->getSkin()->specialLink( 'Preferences' ),
923 ) );
926 $ret = $wgLang->pipeList( array(
927 $ret,
928 $this->getSkin()->link(
929 Title::newFromText( wfMsgForContent( 'helppage' ) ),
930 wfMsg( 'help' )
932 ) );
934 return $ret;