(bug 30074) Moving user JS subpages resulted in JS errors because #REDIRECT [[Foo...
[mediawiki.git] / includes / SkinLegacy.php
blob5311634bc76443024eecd671cb2186b696f6312f
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 if( $q == 5 ) {
58 # 5 is the default, which chooses the setting
59 # depending on the directionality of your interface language
60 global $wgLang;
61 return $wgLang->isRTL() ? 2 : 1;
63 return $q;
68 class LegacyTemplate extends BaseTemplate {
70 // How many search boxes have we made? Avoid duplicate id's.
71 protected $searchboxes = '';
73 function execute() {
74 $this->html( 'headelement' );
75 echo $this->beforeContent();
76 $this->html( 'bodytext' );
77 echo '<div class="printfooter">';
78 $this->html( 'printfooter' );
79 echo '</div>';
80 $this->html( 'debughtml' );
81 echo "\n";
82 echo $this->afterContent();
83 $this->html( 'dataAfterContent' );
84 $this->printTrail();
85 echo "\n</body></html>";
88 /**
89 * This will be called immediately after the <body> tag. Split into
90 * two functions to make it easier to subclass.
92 function beforeContent() {
93 return $this->doBeforeContent();
96 function doBeforeContent() {
97 global $wgContLang;
98 wfProfileIn( __METHOD__ );
100 $s = '';
101 $qb = $this->getSkin()->qbSetting();
103 $langlinks = $this->otherLanguages();
104 if ( $langlinks ) {
105 $rows = 2;
106 $borderhack = '';
107 } else {
108 $rows = 1;
109 $langlinks = false;
110 $borderhack = 'class="top"';
113 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
114 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
116 $shove = ( $qb != 0 );
117 $left = ( $qb == 1 || $qb == 3 );
119 if ( !$shove ) {
120 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
121 $this->getSkin()->logoText() . '</td>';
122 } elseif ( $left ) {
123 $s .= $this->getQuickbarCompensator( $rows );
126 $l = $wgContLang->alignStart();
127 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
129 $s .= $this->topLinks();
130 $s .= '<p class="subtitle">' . $this->pageTitleLinks() . "</p>\n";
132 $r = $wgContLang->alignEnd();
133 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
134 $s .= $this->nameAndLogin();
135 $s .= "\n<br />" . $this->searchForm() . '</td>';
137 if ( $langlinks ) {
138 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
141 if ( $shove && !$left ) { # Right
142 $s .= $this->getQuickbarCompensator( $rows );
145 $s .= "</tr>\n</table>\n</div>\n";
146 $s .= "\n<div id='article'>\n";
148 $notice = $this->getSkin()->getSiteNotice();
150 if ( $notice ) {
151 $s .= "\n<div id='siteNotice'>$notice</div>\n";
153 $s .= $this->pageTitle();
154 $s .= $this->pageSubtitle();
155 $s .= $this->getSkin()->getCategories();
157 wfProfileOut( __METHOD__ );
158 return $s;
162 * This gets called shortly before the </body> tag.
163 * @return String HTML to be put before </body>
165 function afterContent() {
166 return $this->doAfterContent();
169 /** overloaded by derived classes */
170 function doAfterContent() {
171 return '</div></div>';
174 function searchForm() {
175 global $wgRequest, $wgUseTwoButtonsSearchForm;
177 $search = $wgRequest->getText( 'search' );
179 $s = '<form id="searchform' . $this->searchboxes . '" name="search" class="inline" method="post" action="'
180 . $this->getSkin()->escapeSearchLink() . "\">\n"
181 . '<input type="text" id="searchInput' . $this->searchboxes . '" name="search" size="19" value="'
182 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
183 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
185 if ( $wgUseTwoButtonsSearchForm ) {
186 $s .= '&#160;<input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
187 } else {
188 $s .= ' <a href="' . $this->getSkin()->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
191 $s .= '</form>';
193 // Ensure unique id's for search boxes made after the first
194 $this->searchboxes = $this->searchboxes == '' ? 2 : $this->searchboxes + 1;
196 return $s;
199 function pageStats() {
200 global $wgOut, $wgLang, $wgRequest, $wgUser;
201 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
203 if ( !is_null( $wgRequest->getVal( 'oldid' ) ) || !is_null( $wgRequest->getVal( 'diff' ) ) ) {
204 return '';
207 if ( !$wgOut->isArticle() || !$this->getSkin()->getTitle()->exists() ) {
208 return '';
211 $article = new Article( $this->getSkin()->getTitle(), 0 );
213 $s = '';
215 if ( !$wgDisableCounters ) {
216 $count = $wgLang->formatNum( $article->getCount() );
218 if ( $count ) {
219 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
223 if ( $wgMaxCredits != 0 ) {
224 $s .= ' ' . Action::factory( 'credits', $article )->getCredits( $wgMaxCredits, $wgShowCreditsIfMax );
225 } else {
226 $s .= $this->data['lastmod'];
229 if ( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
230 $dbr = wfGetDB( DB_SLAVE );
231 $res = $dbr->select(
232 'watchlist',
233 array( 'COUNT(*) AS n' ),
234 array(
235 'wl_title' => $dbr->strencode( $this->getSkin()->getTitle()->getDBkey() ),
236 'wl_namespace' => $this->getSkin()->getTitle()->getNamespace()
238 __METHOD__
240 $x = $dbr->fetchObject( $res );
242 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
243 array( 'parseinline' ), $wgLang->formatNum( $x->n )
247 return $s . ' ' . $this->getSkin()->getCopyright();
250 function topLinks() {
251 global $wgOut;
253 $s = array(
254 $this->getSkin()->mainPageLink(),
255 Linker::specialLink( 'Recentchanges' )
258 if ( $wgOut->isArticleRelated() ) {
259 $s[] = $this->editThisPage();
260 $s[] = $this->historyLink();
263 # Many people don't like this dropdown box
264 # $s[] = $this->specialPagesList();
266 if ( $this->variantLinks() ) {
267 $s[] = $this->variantLinks();
270 if ( $this->extensionTabLinks() ) {
271 $s[] = $this->extensionTabLinks();
274 // @todo FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
275 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
279 * Language/charset variant links for classic-style skins
280 * @return string
282 function variantLinks() {
283 $s = '';
285 /* show links to different language variants */
286 global $wgDisableLangConversion, $wgLang, $wgContLang;
288 $variants = $wgContLang->getVariants();
290 if ( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
291 foreach ( $variants as $code ) {
292 $varname = $wgContLang->getVariantname( $code );
294 if ( $varname == 'disable' ) {
295 continue;
297 $s = $wgLang->pipeList( array(
299 '<a href="' . $this->getSkin()->getTitle()->escapeLocalURL( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
300 ) );
304 return $s;
308 * Compatibility for extensions adding functionality through tabs.
309 * Eventually these old skins should be replaced with SkinTemplate-based
310 * versions, sigh...
311 * @return string
312 * @todo Exterminate! ...that, and replace it with normal SkinTemplate stuff
314 function extensionTabLinks() {
315 $tabs = array();
316 $out = '';
317 $s = array();
318 wfRunHooks( 'SkinTemplateTabs', array( $this->getSkin(), &$tabs ) );
319 foreach ( $tabs as $tab ) {
320 $s[] = Xml::element( 'a',
321 array( 'href' => $tab['href'] ),
322 $tab['text'] );
325 if ( count( $s ) ) {
326 global $wgLang;
328 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
329 $out .= $wgLang->pipeList( $s );
332 return $out;
335 function bottomLinks() {
336 global $wgOut, $wgUser, $wgUseTrackbacks;
337 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
339 $s = '';
340 if ( $wgOut->isArticleRelated() ) {
341 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
343 if ( $wgUser->isLoggedIn() ) {
344 $element[] = $this->watchThisPage();
347 $element[] = $this->talkLink();
348 $element[] = $this->historyLink();
349 $element[] = $this->whatLinksHere();
350 $element[] = $this->watchPageLinksLink();
352 if ( $wgUseTrackbacks ) {
353 $element[] = $this->trackbackLink();
356 if (
357 $this->getSkin()->getTitle()->getNamespace() == NS_USER ||
358 $this->getSkin()->getTitle()->getNamespace() == NS_USER_TALK
360 $id = User::idFromName( $this->getSkin()->getTitle()->getText() );
361 $ip = User::isIP( $this->getSkin()->getTitle()->getText() );
363 # Both anons and non-anons have contributions list
364 if ( $id || $ip ) {
365 $element[] = $this->userContribsLink();
368 if ( $this->getSkin()->showEmailUser( $id ) ) {
369 $element[] = $this->emailUserLink();
373 $s = implode( $element, $sep );
375 if ( $this->getSkin()->getTitle()->getArticleId() ) {
376 $s .= "\n<br />";
378 // Delete/protect/move links for privileged users
379 if ( $wgUser->isAllowed( 'delete' ) ) {
380 $s .= $this->deleteThisPage();
383 if ( $wgUser->isAllowed( 'protect' ) ) {
384 $s .= $sep . $this->protectThisPage();
387 if ( $wgUser->isAllowed( 'move' ) ) {
388 $s .= $sep . $this->moveThisPage();
392 $s .= "<br />\n" . $this->otherLanguages();
395 return $s;
398 function otherLanguages() {
399 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
401 if ( $wgHideInterlanguageLinks ) {
402 return '';
405 $a = $wgOut->getLanguageLinks();
407 if ( 0 == count( $a ) ) {
408 return '';
411 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
412 $first = true;
414 if ( $wgContLang->isRTL() ) {
415 $s .= '<span dir="LTR">';
418 foreach ( $a as $l ) {
419 if ( !$first ) {
420 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
423 $first = false;
425 $nt = Title::newFromText( $l );
426 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
428 $s .= Html::element( 'a',
429 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
430 $text == '' ? $l : $text );
433 if ( $wgContLang->isRTL() ) {
434 $s .= '</span>';
437 return $s;
441 * Show a drop-down box of special pages
443 function specialPagesList() {
444 global $wgContLang, $wgServer, $wgRedirectScript;
446 $pages = SpecialPageFactory::getUsablePages();
448 foreach ( $pages as $name => $page ) {
449 $pages[$name] = $page->getDescription();
452 $go = wfMsg( 'go' );
453 $sp = wfMsg( 'specialpages' );
454 $spp = $wgContLang->specialPage( 'Specialpages' );
456 $s = '<form id="specialpages" method="get" ' .
457 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
458 $s .= "<select name=\"wpDropdown\">\n";
459 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
462 foreach ( $pages as $name => $desc ) {
463 $p = $wgContLang->specialPage( $name );
464 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
467 $s .= "</select>\n";
468 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
469 $s .= "</form>\n";
471 return $s;
474 function pageTitleLinks() {
475 global $wgOut, $wgUser, $wgRequest, $wgLang;
477 $oldid = $wgRequest->getVal( 'oldid' );
478 $diff = $wgRequest->getVal( 'diff' );
479 $action = $wgRequest->getText( 'action' );
481 $s[] = $this->printableLink();
482 $disclaimer = $this->getSkin()->disclaimerLink(); # may be empty
484 if ( $disclaimer ) {
485 $s[] = $disclaimer;
488 $privacy = $this->getSkin()->privacyLink(); # may be empty too
490 if ( $privacy ) {
491 $s[] = $privacy;
494 if ( $wgOut->isArticleRelated() ) {
495 if ( $this->getSkin()->getTitle()->getNamespace() == NS_FILE ) {
496 $name = $this->getSkin()->getTitle()->getDBkey();
497 $image = wfFindFile( $this->getSkin()->getTitle() );
499 if ( $image ) {
500 $link = htmlspecialchars( $image->getURL() );
501 $style = $this->getInternalLinkAttributes( $link, $name );
502 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
507 if ( 'history' == $action || isset( $diff ) || isset( $oldid ) ) {
508 $s[] .= Linker::link(
509 $this->getSkin()->getTitle(),
510 wfMsg( 'currentrev' ),
511 array(),
512 array(),
513 array( 'known', 'noclasses' )
517 if ( $wgUser->getNewtalk() ) {
518 # do not show "You have new messages" text when we are viewing our
519 # own talk page
520 if ( !$this->getSkin()->getTitle()->equals( $wgUser->getTalkPage() ) ) {
521 $tl = Linker::link(
522 $wgUser->getTalkPage(),
523 wfMsgHtml( 'newmessageslink' ),
524 array(),
525 array( 'redirect' => 'no' ),
526 array( 'known', 'noclasses' )
529 $dl = Linker::link(
530 $wgUser->getTalkPage(),
531 wfMsgHtml( 'newmessagesdifflink' ),
532 array(),
533 array( 'diff' => 'cur' ),
534 array( 'known', 'noclasses' )
536 $s[] = '<strong>' . wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
537 # disable caching
538 $wgOut->setSquidMaxage( 0 );
539 $wgOut->enableClientCache( false );
543 $undelete = $this->getSkin()->getUndeleteLink();
545 if ( !empty( $undelete ) ) {
546 $s[] = $undelete;
549 return $wgLang->pipeList( $s );
553 * Gets the h1 element with the page title.
554 * @return string
556 function pageTitle() {
557 global $wgOut;
558 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
559 return $s;
562 function pageSubtitle() {
563 global $wgOut;
565 $sub = $wgOut->getSubtitle();
567 if ( $sub == '' ) {
568 global $wgExtraSubtitle;
569 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
572 $subpages = $this->getSkin()->subPageSubtitle();
573 $sub .= !empty( $subpages ) ? "</p><p class='subpages'>$subpages" : '';
574 $s = "<p class='subtitle'>{$sub}</p>\n";
576 return $s;
579 function printableLink() {
580 global $wgOut, $wgRequest, $wgLang;
582 $s = array();
584 if ( !$wgOut->isPrintable() ) {
585 $printurl = htmlspecialchars( $this->getSkin()->getTitle()->getLocalUrl(
586 $wgRequest->appendQueryValue( 'printable', 'yes', true ) ) );
587 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
590 if ( $wgOut->isSyndicated() ) {
591 foreach ( $wgOut->getSyndicationLinks() as $format => $link ) {
592 $feedurl = htmlspecialchars( $link );
593 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
594 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
597 return $wgLang->pipeList( $s );
600 function getQuickbarCompensator( $rows = 1 ) {
601 return "<td width='152' rowspan='{$rows}'>&#160;</td>";
604 function editThisPage() {
605 global $wgOut;
607 if ( !$wgOut->isArticleRelated() ) {
608 $s = wfMsg( 'protectedpage' );
609 } else {
610 if ( $this->getSkin()->getTitle()->quickUserCan( 'edit' ) && $this->getSkin()->getTitle()->exists() ) {
611 $t = wfMsg( 'editthispage' );
612 } elseif ( $this->getSkin()->getTitle()->quickUserCan( 'create' ) && !$this->getSkin()->getTitle()->exists() ) {
613 $t = wfMsg( 'create-this-page' );
614 } else {
615 $t = wfMsg( 'viewsource' );
618 $s = Linker::link(
619 $this->getSkin()->getTitle(),
621 array(),
622 $this->getSkin()->editUrlOptions(),
623 array( 'known', 'noclasses' )
627 return $s;
630 function deleteThisPage() {
631 global $wgUser, $wgRequest;
633 $diff = $wgRequest->getVal( 'diff' );
635 if ( $this->getSkin()->getTitle()->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
636 $t = wfMsg( 'deletethispage' );
638 $s = Linker::link(
639 $this->getSkin()->getTitle(),
641 array(),
642 array( 'action' => 'delete' ),
643 array( 'known', 'noclasses' )
645 } else {
646 $s = '';
649 return $s;
652 function protectThisPage() {
653 global $wgUser, $wgRequest;
655 $diff = $wgRequest->getVal( 'diff' );
657 if ( $this->getSkin()->getTitle()->getArticleId() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
658 if ( $this->getSkin()->getTitle()->isProtected() ) {
659 $text = wfMsg( 'unprotectthispage' );
660 $query = array( 'action' => 'unprotect' );
661 } else {
662 $text = wfMsg( 'protectthispage' );
663 $query = array( 'action' => 'protect' );
666 $s = Linker::link(
667 $this->getSkin()->getTitle(),
668 $text,
669 array(),
670 $query,
671 array( 'known', 'noclasses' )
673 } else {
674 $s = '';
677 return $s;
680 function watchThisPage() {
681 global $wgOut, $wgUser;
682 ++$this->mWatchLinkNum;
684 // Cache
685 $title = $this->getSkin()->getTitle();
687 if ( $wgOut->isArticleRelated() ) {
688 if ( $title->userIsWatching() ) {
689 $text = wfMsg( 'unwatchthispage' );
690 $query = array(
691 'action' => 'unwatch',
692 'token' => UnwatchAction::getUnwatchToken( $title, $wgUser ),
694 $id = 'mw-unwatch-link' . $this->mWatchLinkNum;
695 } else {
696 $text = wfMsg( 'watchthispage' );
697 $query = array(
698 'action' => 'watch',
699 'token' => WatchAction::getWatchToken( $title, $wgUser ),
701 $id = 'mw-watch-link' . $this->mWatchLinkNum;
704 $s = Linker::link(
705 $title,
706 $text,
707 array( 'id' => $id ),
708 $query,
709 array( 'known', 'noclasses' )
711 } else {
712 $s = wfMsg( 'notanarticle' );
715 return $s;
718 function moveThisPage() {
719 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
720 return Linker::link(
721 SpecialPage::getTitleFor( 'Movepage' ),
722 wfMsg( 'movethispage' ),
723 array(),
724 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() ),
725 array( 'known', 'noclasses' )
727 } else {
728 // no message if page is protected - would be redundant
729 return '';
733 function historyLink() {
734 return Linker::link(
735 $this->getSkin()->getTitle(),
736 wfMsgHtml( 'history' ),
737 array( 'rel' => 'archives' ),
738 array( 'action' => 'history' )
742 function whatLinksHere() {
743 return Linker::link(
744 SpecialPage::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
745 wfMsgHtml( 'whatlinkshere' ),
746 array(),
747 array(),
748 array( 'known', 'noclasses' )
752 function userContribsLink() {
753 return Linker::link(
754 SpecialPage::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
755 wfMsgHtml( 'contributions' ),
756 array(),
757 array(),
758 array( 'known', 'noclasses' )
762 function emailUserLink() {
763 return Linker::link(
764 SpecialPage::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
765 wfMsg( 'emailuser' ),
766 array(),
767 array(),
768 array( 'known', 'noclasses' )
772 function watchPageLinksLink() {
773 global $wgOut;
775 if ( !$wgOut->isArticleRelated() ) {
776 return '(' . wfMsg( 'notanarticle' ) . ')';
777 } else {
778 return Linker::link(
779 SpecialPage::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
780 wfMsg( 'recentchangeslinked-toolbox' ),
781 array(),
782 array(),
783 array( 'known', 'noclasses' )
788 function trackbackLink() {
789 return '<a href="' . $this->getSkin()->getTitle()->trackbackURL() . '">'
790 . wfMsg( 'trackbacklink' ) . '</a>';
793 function talkLink() {
794 if ( NS_SPECIAL == $this->getSkin()->getTitle()->getNamespace() ) {
795 # No discussion links for special pages
796 return '';
799 $linkOptions = array();
801 if ( $this->getSkin()->getTitle()->isTalkPage() ) {
802 $link = $this->getSkin()->getTitle()->getSubjectPage();
803 switch( $link->getNamespace() ) {
804 case NS_MAIN:
805 $text = wfMsg( 'articlepage' );
806 break;
807 case NS_USER:
808 $text = wfMsg( 'userpage' );
809 break;
810 case NS_PROJECT:
811 $text = wfMsg( 'projectpage' );
812 break;
813 case NS_FILE:
814 $text = wfMsg( 'imagepage' );
815 # Make link known if image exists, even if the desc. page doesn't.
816 if ( wfFindFile( $link ) )
817 $linkOptions[] = 'known';
818 break;
819 case NS_MEDIAWIKI:
820 $text = wfMsg( 'mediawikipage' );
821 break;
822 case NS_TEMPLATE:
823 $text = wfMsg( 'templatepage' );
824 break;
825 case NS_HELP:
826 $text = wfMsg( 'viewhelppage' );
827 break;
828 case NS_CATEGORY:
829 $text = wfMsg( 'categorypage' );
830 break;
831 default:
832 $text = wfMsg( 'articlepage' );
834 } else {
835 $link = $this->getSkin()->getTitle()->getTalkPage();
836 $text = wfMsg( 'talkpage' );
839 $s = Linker::link( $link, $text, array(), array(), $linkOptions );
841 return $s;
844 function commentLink() {
845 global $wgOut;
847 if ( $this->getSkin()->getTitle()->getNamespace() == NS_SPECIAL ) {
848 return '';
851 # __NEWSECTIONLINK___ changes behaviour here
852 # If it is present, the link points to this page, otherwise
853 # it points to the talk page
854 if ( $this->getSkin()->getTitle()->isTalkPage() ) {
855 $title = $this->getSkin()->getTitle();
856 } elseif ( $wgOut->showNewSectionLink() ) {
857 $title = $this->getSkin()->getTitle();
858 } else {
859 $title = $this->getSkin()->getTitle()->getTalkPage();
862 return Linker::link(
863 $title,
864 wfMsg( 'postcomment' ),
865 array(),
866 array(
867 'action' => 'edit',
868 'section' => 'new'
870 array( 'known', 'noclasses' )
874 function getUploadLink() {
875 global $wgUploadNavigationUrl;
877 if ( $wgUploadNavigationUrl ) {
878 # Using an empty class attribute to avoid automatic setting of "external" class
879 return Linker::makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '' ) );
880 } else {
881 return Linker::link(
882 SpecialPage::getTitleFor( 'Upload' ),
883 wfMsgHtml( 'upload' ),
884 array(),
885 array(),
886 array( 'known', 'noclasses' )
891 function nameAndLogin() {
892 global $wgUser, $wgLang, $wgContLang;
894 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
896 $ret = '';
898 if ( $wgUser->isAnon() ) {
899 if ( $this->getSkin()->showIPinHeader() ) {
900 $name = wfGetIP();
902 $talkLink = Linker::link( $wgUser->getTalkPage(),
903 $wgLang->getNsText( NS_TALK ) );
905 $ret .= "$name ($talkLink)";
906 } else {
907 $ret .= wfMsg( 'notloggedin' );
910 $returnTo = $this->getSkin()->getTitle()->getPrefixedDBkey();
911 $query = array();
913 if ( $logoutPage != $returnTo ) {
914 $query['returnto'] = $returnTo;
917 $loginlink = $wgUser->isAllowed( 'createaccount' )
918 ? 'nav-login-createaccount'
919 : 'login';
920 $ret .= "\n<br />" . Linker::link(
921 SpecialPage::getTitleFor( 'Userlogin' ),
922 wfMsg( $loginlink ), array(), $query
924 } else {
925 $returnTo = $this->getSkin()->getTitle()->getPrefixedDBkey();
926 $talkLink = Linker::link( $wgUser->getTalkPage(),
927 $wgLang->getNsText( NS_TALK ) );
929 $ret .= Linker::link( $wgUser->getUserPage(),
930 htmlspecialchars( $wgUser->getName() ) );
931 $ret .= " ($talkLink)<br />";
932 $ret .= $wgLang->pipeList( array(
933 Linker::link(
934 SpecialPage::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
935 array(), array( 'returnto' => $returnTo )
937 Linker::specialLink( 'Preferences' ),
938 ) );
941 $ret = $wgLang->pipeList( array(
942 $ret,
943 Linker::link(
944 Title::newFromText( wfMsgForContent( 'helppage' ) ),
945 wfMsg( 'help' )
947 ) );
949 return $ret;