Fixes for SkinLegacy::specialPagesList():
[mediawiki.git] / includes / SkinLegacy.php
blobc11b08926bd22f61847e6dc848673832c0d3389a
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 "\n";
78 echo $this->afterContent();
79 $this->html( 'dataAfterContent' );
80 $this->printTrail();
81 echo "\n</body></html>";
84 /**
85 * This will be called immediately after the <body> tag. Split into
86 * two functions to make it easier to subclass.
88 function beforeContent() {
89 return $this->doBeforeContent();
92 function doBeforeContent() {
93 global $wgLang;
94 wfProfileIn( __METHOD__ );
96 $s = '';
98 $langlinks = $this->otherLanguages();
99 if ( $langlinks ) {
100 $rows = 2;
101 $borderhack = '';
102 } else {
103 $rows = 1;
104 $langlinks = false;
105 $borderhack = 'class="top"';
108 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
109 "<table border='0' cellspacing='0' width='100%'>\n<tr>\n";
111 if ( $this->getSkin()->qbSetting() == 0 ) {
112 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
113 $this->getSkin()->logoText( $wgLang->alignStart() ) . '</td>';
116 $l = $wgLang->alignStart();
117 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
119 $s .= $this->topLinks();
120 $s .= '<p class="subtitle">' . $this->pageTitleLinks() . "</p>\n";
122 $r = $wgLang->alignEnd();
123 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
124 $s .= $this->nameAndLogin();
125 $s .= "\n<br />" . $this->searchForm() . '</td>';
127 if ( $langlinks ) {
128 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
131 $s .= "</tr>\n</table>\n</div>\n";
132 $s .= "\n<div id='article'>\n";
134 $notice = $this->getSkin()->getSiteNotice();
136 if ( $notice ) {
137 $s .= "\n<div id='siteNotice'>$notice</div>\n";
139 $s .= $this->pageTitle();
140 $s .= $this->pageSubtitle();
141 $s .= $this->getSkin()->getCategories();
143 wfProfileOut( __METHOD__ );
144 return $s;
148 * This gets called shortly before the </body> tag.
149 * @return String HTML to be put before </body>
151 function afterContent() {
152 return $this->doAfterContent();
155 /** overloaded by derived classes */
156 function doAfterContent() {
157 return '</div></div>';
160 function searchForm() {
161 global $wgRequest, $wgUseTwoButtonsSearchForm;
163 $search = $wgRequest->getText( 'search' );
165 $s = '<form id="searchform' . $this->searchboxes . '" name="search" class="inline" method="post" action="'
166 . $this->getSkin()->escapeSearchLink() . "\">\n"
167 . '<input type="text" id="searchInput' . $this->searchboxes . '" name="search" size="19" value="'
168 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
169 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
171 if ( $wgUseTwoButtonsSearchForm ) {
172 $s .= '&#160;<input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
173 } else {
174 $s .= ' <a href="' . $this->getSkin()->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
177 $s .= '</form>';
179 // Ensure unique id's for search boxes made after the first
180 $this->searchboxes = $this->searchboxes == '' ? 2 : $this->searchboxes + 1;
182 return $s;
185 function pageStats() {
186 global $wgOut, $wgLang, $wgRequest, $wgUser;
187 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
189 if ( !is_null( $wgRequest->getVal( 'oldid' ) ) || !is_null( $wgRequest->getVal( 'diff' ) ) ) {
190 return '';
193 if ( !$wgOut->isArticle() || !$this->getSkin()->getTitle()->exists() ) {
194 return '';
197 $article = new Article( $this->getSkin()->getTitle(), 0 );
199 $s = '';
201 if ( !$wgDisableCounters ) {
202 $count = $wgLang->formatNum( $article->getCount() );
204 if ( $count ) {
205 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
209 if ( $wgMaxCredits != 0 ) {
210 $s .= ' ' . Action::factory( 'credits', $article )->getCredits( $wgMaxCredits, $wgShowCreditsIfMax );
211 } else {
212 $s .= $this->data['lastmod'];
215 if ( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
216 $dbr = wfGetDB( DB_SLAVE );
217 $res = $dbr->select(
218 'watchlist',
219 array( 'COUNT(*) AS n' ),
220 array(
221 'wl_title' => $dbr->strencode( $this->getSkin()->getTitle()->getDBkey() ),
222 'wl_namespace' => $this->getSkin()->getTitle()->getNamespace()
224 __METHOD__
226 $x = $dbr->fetchObject( $res );
228 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
229 array( 'parseinline' ), $wgLang->formatNum( $x->n )
233 return $s . ' ' . $this->getSkin()->getCopyright();
236 function topLinks() {
237 global $wgOut;
239 $s = array(
240 $this->getSkin()->mainPageLink(),
241 Linker::specialLink( 'Recentchanges' )
244 if ( $wgOut->isArticleRelated() ) {
245 $s[] = $this->editThisPage();
246 $s[] = $this->historyLink();
249 # Many people don't like this dropdown box
250 # $s[] = $this->specialPagesList();
252 if ( $this->variantLinks() ) {
253 $s[] = $this->variantLinks();
256 if ( $this->extensionTabLinks() ) {
257 $s[] = $this->extensionTabLinks();
260 // @todo FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
261 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
265 * Language/charset variant links for classic-style skins
266 * @return string
268 function variantLinks() {
269 $s = '';
271 /* show links to different language variants */
272 global $wgDisableLangConversion, $wgLang;
274 $title = $this->getSkin()->getTitle();
275 $lang = $title->getPageLanguage();
276 $variants = $lang->getVariants();
278 if ( !$wgDisableLangConversion && sizeof( $variants ) > 1
279 && $title->getNamespace() != NS_SPECIAL ) {
280 foreach ( $variants as $code ) {
281 $varname = $lang->getVariantname( $code );
283 if ( $varname == 'disable' ) {
284 continue;
286 $s = $wgLang->pipeList( array(
288 '<a href="' . $this->getSkin()->getTitle()->escapeLocalURL( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
289 ) );
293 return $s;
297 * Compatibility for extensions adding functionality through tabs.
298 * Eventually these old skins should be replaced with SkinTemplate-based
299 * versions, sigh...
300 * @return string
301 * @todo Exterminate! ...that, and replace it with normal SkinTemplate stuff
303 function extensionTabLinks() {
304 $tabs = array();
305 $out = '';
306 $s = array();
307 wfRunHooks( 'SkinTemplateTabs', array( $this->getSkin(), &$tabs ) );
308 foreach ( $tabs as $tab ) {
309 $s[] = Xml::element( 'a',
310 array( 'href' => $tab['href'] ),
311 $tab['text'] );
314 if ( count( $s ) ) {
315 global $wgLang;
317 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
318 $out .= $wgLang->pipeList( $s );
321 return $out;
324 function bottomLinks() {
325 global $wgOut, $wgUser, $wgUseTrackbacks;
326 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
328 $s = '';
329 if ( $wgOut->isArticleRelated() ) {
330 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
332 if ( $wgUser->isLoggedIn() ) {
333 $element[] = $this->watchThisPage();
336 $element[] = $this->talkLink();
337 $element[] = $this->historyLink();
338 $element[] = $this->whatLinksHere();
339 $element[] = $this->watchPageLinksLink();
341 if ( $wgUseTrackbacks ) {
342 $element[] = $this->trackbackLink();
345 if (
346 $this->getSkin()->getTitle()->getNamespace() == NS_USER ||
347 $this->getSkin()->getTitle()->getNamespace() == NS_USER_TALK
349 $id = User::idFromName( $this->getSkin()->getTitle()->getText() );
350 $ip = User::isIP( $this->getSkin()->getTitle()->getText() );
352 # Both anons and non-anons have contributions list
353 if ( $id || $ip ) {
354 $element[] = $this->userContribsLink();
357 if ( $this->getSkin()->showEmailUser( $id ) ) {
358 $element[] = $this->emailUserLink();
362 $s = implode( $element, $sep );
364 if ( $this->getSkin()->getTitle()->getArticleId() ) {
365 $s .= "\n<br />";
367 // Delete/protect/move links for privileged users
368 if ( $wgUser->isAllowed( 'delete' ) ) {
369 $s .= $this->deleteThisPage();
372 if ( $wgUser->isAllowed( 'protect' ) ) {
373 $s .= $sep . $this->protectThisPage();
376 if ( $wgUser->isAllowed( 'move' ) ) {
377 $s .= $sep . $this->moveThisPage();
381 $s .= "<br />\n" . $this->otherLanguages();
384 return $s;
387 function otherLanguages() {
388 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
390 if ( $wgHideInterlanguageLinks ) {
391 return '';
394 $a = $wgOut->getLanguageLinks();
396 if ( 0 == count( $a ) ) {
397 return '';
400 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
401 $first = true;
403 if ( $wgContLang->isRTL() ) {
404 $s .= '<span dir="LTR">';
407 foreach ( $a as $l ) {
408 if ( !$first ) {
409 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
412 $first = false;
414 $nt = Title::newFromText( $l );
415 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
417 $s .= Html::element( 'a',
418 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
419 $text == '' ? $l : $text );
422 if ( $wgContLang->isRTL() ) {
423 $s .= '</span>';
426 return $s;
430 * Show a drop-down box of special pages
432 function specialPagesList() {
433 global $wgScript;
435 $select = new XmlSelect( 'title' );
436 $pages = SpecialPageFactory::getUsablePages();
437 array_unshift( $pages, SpecialPageFactory::getPage( 'SpecialPages' ) );
438 foreach ( $pages as $obj ) {
439 $select->addOption( $obj->getDescription(),
440 $obj->getTitle()->getPrefixedDBkey() );
443 return Html::rawElement( 'form', array( 'id' => 'specialpages', 'method' => 'get',
444 'action' => $wgScript ), $select->getHTML() . Xml::submitButton( wfMsg( 'go' ) ) );
447 function pageTitleLinks() {
448 global $wgOut, $wgUser, $wgRequest, $wgLang;
450 $oldid = $wgRequest->getVal( 'oldid' );
451 $diff = $wgRequest->getVal( 'diff' );
452 $action = $wgRequest->getText( 'action' );
454 $s[] = $this->printableLink();
455 $disclaimer = $this->getSkin()->disclaimerLink(); # may be empty
457 if ( $disclaimer ) {
458 $s[] = $disclaimer;
461 $privacy = $this->getSkin()->privacyLink(); # may be empty too
463 if ( $privacy ) {
464 $s[] = $privacy;
467 if ( $wgOut->isArticleRelated() ) {
468 if ( $this->getSkin()->getTitle()->getNamespace() == NS_FILE ) {
469 $name = $this->getSkin()->getTitle()->getDBkey();
470 $image = wfFindFile( $this->getSkin()->getTitle() );
472 if ( $image ) {
473 $link = htmlspecialchars( $image->getURL() );
474 $style = Linker::getInternalLinkAttributes( $link, $name );
475 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
480 if ( 'history' == $action || isset( $diff ) || isset( $oldid ) ) {
481 $s[] .= Linker::link(
482 $this->getSkin()->getTitle(),
483 wfMsg( 'currentrev' ),
484 array(),
485 array(),
486 array( 'known', 'noclasses' )
490 if ( $wgUser->getNewtalk() ) {
491 # do not show "You have new messages" text when we are viewing our
492 # own talk page
493 if ( !$this->getSkin()->getTitle()->equals( $wgUser->getTalkPage() ) ) {
494 $tl = Linker::link(
495 $wgUser->getTalkPage(),
496 wfMsgHtml( 'newmessageslink' ),
497 array(),
498 array( 'redirect' => 'no' ),
499 array( 'known', 'noclasses' )
502 $dl = Linker::link(
503 $wgUser->getTalkPage(),
504 wfMsgHtml( 'newmessagesdifflink' ),
505 array(),
506 array( 'diff' => 'cur' ),
507 array( 'known', 'noclasses' )
509 $s[] = '<strong>' . wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
510 # disable caching
511 $wgOut->setSquidMaxage( 0 );
512 $wgOut->enableClientCache( false );
516 $undelete = $this->getSkin()->getUndeleteLink();
518 if ( !empty( $undelete ) ) {
519 $s[] = $undelete;
522 return $wgLang->pipeList( $s );
526 * Gets the h1 element with the page title.
527 * @return string
529 function pageTitle() {
530 global $wgOut;
531 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
532 return $s;
535 function pageSubtitle() {
536 global $wgOut;
538 $sub = $wgOut->getSubtitle();
540 if ( $sub == '' ) {
541 global $wgExtraSubtitle;
542 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
545 $subpages = $this->getSkin()->subPageSubtitle();
546 $sub .= !empty( $subpages ) ? "</p><p class='subpages'>$subpages" : '';
547 $s = "<p class='subtitle'>{$sub}</p>\n";
549 return $s;
552 function printableLink() {
553 global $wgOut, $wgRequest, $wgLang;
555 $s = array();
557 if ( !$wgOut->isPrintable() ) {
558 $printurl = htmlspecialchars( $this->getSkin()->getTitle()->getLocalUrl(
559 $wgRequest->appendQueryValue( 'printable', 'yes', true ) ) );
560 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
563 if ( $wgOut->isSyndicated() ) {
564 foreach ( $wgOut->getSyndicationLinks() as $format => $link ) {
565 $feedurl = htmlspecialchars( $link );
566 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
567 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
570 return $wgLang->pipeList( $s );
574 * @deprecated in 1.19
576 function getQuickbarCompensator( $rows = 1 ) {
577 return "<td width='152' rowspan='{$rows}'>&#160;</td>";
580 function editThisPage() {
581 global $wgOut;
583 if ( !$wgOut->isArticleRelated() ) {
584 $s = wfMsg( 'protectedpage' );
585 } else {
586 if ( $this->getSkin()->getTitle()->quickUserCan( 'edit' ) && $this->getSkin()->getTitle()->exists() ) {
587 $t = wfMsg( 'editthispage' );
588 } elseif ( $this->getSkin()->getTitle()->quickUserCan( 'create' ) && !$this->getSkin()->getTitle()->exists() ) {
589 $t = wfMsg( 'create-this-page' );
590 } else {
591 $t = wfMsg( 'viewsource' );
594 $s = Linker::link(
595 $this->getSkin()->getTitle(),
597 array(),
598 $this->getSkin()->editUrlOptions(),
599 array( 'known', 'noclasses' )
603 return $s;
606 function deleteThisPage() {
607 global $wgUser, $wgRequest;
609 $diff = $wgRequest->getVal( 'diff' );
611 if ( $this->getSkin()->getTitle()->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
612 $t = wfMsg( 'deletethispage' );
614 $s = Linker::link(
615 $this->getSkin()->getTitle(),
617 array(),
618 array( 'action' => 'delete' ),
619 array( 'known', 'noclasses' )
621 } else {
622 $s = '';
625 return $s;
628 function protectThisPage() {
629 global $wgUser, $wgRequest;
631 $diff = $wgRequest->getVal( 'diff' );
633 if ( $this->getSkin()->getTitle()->getArticleId() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
634 if ( $this->getSkin()->getTitle()->isProtected() ) {
635 $text = wfMsg( 'unprotectthispage' );
636 $query = array( 'action' => 'unprotect' );
637 } else {
638 $text = wfMsg( 'protectthispage' );
639 $query = array( 'action' => 'protect' );
642 $s = Linker::link(
643 $this->getSkin()->getTitle(),
644 $text,
645 array(),
646 $query,
647 array( 'known', 'noclasses' )
649 } else {
650 $s = '';
653 return $s;
656 function watchThisPage() {
657 global $wgOut, $wgUser;
658 ++$this->mWatchLinkNum;
660 // Cache
661 $title = $this->getSkin()->getTitle();
663 if ( $wgOut->isArticleRelated() ) {
664 if ( $title->userIsWatching() ) {
665 $text = wfMsg( 'unwatchthispage' );
666 $query = array(
667 'action' => 'unwatch',
668 'token' => UnwatchAction::getUnwatchToken( $title, $wgUser ),
670 $id = 'mw-unwatch-link' . $this->mWatchLinkNum;
671 } else {
672 $text = wfMsg( 'watchthispage' );
673 $query = array(
674 'action' => 'watch',
675 'token' => WatchAction::getWatchToken( $title, $wgUser ),
677 $id = 'mw-watch-link' . $this->mWatchLinkNum;
680 $s = Linker::link(
681 $title,
682 $text,
683 array( 'id' => $id ),
684 $query,
685 array( 'known', 'noclasses' )
687 } else {
688 $s = wfMsg( 'notanarticle' );
691 return $s;
694 function moveThisPage() {
695 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
696 return Linker::link(
697 SpecialPage::getTitleFor( 'Movepage' ),
698 wfMsg( 'movethispage' ),
699 array(),
700 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() ),
701 array( 'known', 'noclasses' )
703 } else {
704 // no message if page is protected - would be redundant
705 return '';
709 function historyLink() {
710 return Linker::link(
711 $this->getSkin()->getTitle(),
712 wfMsgHtml( 'history' ),
713 array( 'rel' => 'archives' ),
714 array( 'action' => 'history' )
718 function whatLinksHere() {
719 return Linker::link(
720 SpecialPage::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
721 wfMsgHtml( 'whatlinkshere' ),
722 array(),
723 array(),
724 array( 'known', 'noclasses' )
728 function userContribsLink() {
729 return Linker::link(
730 SpecialPage::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
731 wfMsgHtml( 'contributions' ),
732 array(),
733 array(),
734 array( 'known', 'noclasses' )
738 function emailUserLink() {
739 return Linker::link(
740 SpecialPage::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
741 wfMsg( 'emailuser' ),
742 array(),
743 array(),
744 array( 'known', 'noclasses' )
748 function watchPageLinksLink() {
749 global $wgOut;
751 if ( !$wgOut->isArticleRelated() ) {
752 return '(' . wfMsg( 'notanarticle' ) . ')';
753 } else {
754 return Linker::link(
755 SpecialPage::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
756 wfMsg( 'recentchangeslinked-toolbox' ),
757 array(),
758 array(),
759 array( 'known', 'noclasses' )
764 function trackbackLink() {
765 return '<a href="' . $this->getSkin()->getTitle()->trackbackURL() . '">'
766 . wfMsg( 'trackbacklink' ) . '</a>';
769 function talkLink() {
770 if ( NS_SPECIAL == $this->getSkin()->getTitle()->getNamespace() ) {
771 # No discussion links for special pages
772 return '';
775 $linkOptions = array();
777 if ( $this->getSkin()->getTitle()->isTalkPage() ) {
778 $link = $this->getSkin()->getTitle()->getSubjectPage();
779 switch( $link->getNamespace() ) {
780 case NS_MAIN:
781 $text = wfMsg( 'articlepage' );
782 break;
783 case NS_USER:
784 $text = wfMsg( 'userpage' );
785 break;
786 case NS_PROJECT:
787 $text = wfMsg( 'projectpage' );
788 break;
789 case NS_FILE:
790 $text = wfMsg( 'imagepage' );
791 # Make link known if image exists, even if the desc. page doesn't.
792 if ( wfFindFile( $link ) )
793 $linkOptions[] = 'known';
794 break;
795 case NS_MEDIAWIKI:
796 $text = wfMsg( 'mediawikipage' );
797 break;
798 case NS_TEMPLATE:
799 $text = wfMsg( 'templatepage' );
800 break;
801 case NS_HELP:
802 $text = wfMsg( 'viewhelppage' );
803 break;
804 case NS_CATEGORY:
805 $text = wfMsg( 'categorypage' );
806 break;
807 default:
808 $text = wfMsg( 'articlepage' );
810 } else {
811 $link = $this->getSkin()->getTitle()->getTalkPage();
812 $text = wfMsg( 'talkpage' );
815 $s = Linker::link( $link, $text, array(), array(), $linkOptions );
817 return $s;
820 function commentLink() {
821 global $wgOut;
823 if ( $this->getSkin()->getTitle()->getNamespace() == NS_SPECIAL ) {
824 return '';
827 # __NEWSECTIONLINK___ changes behaviour here
828 # If it is present, the link points to this page, otherwise
829 # it points to the talk page
830 if ( $this->getSkin()->getTitle()->isTalkPage() ) {
831 $title = $this->getSkin()->getTitle();
832 } elseif ( $wgOut->showNewSectionLink() ) {
833 $title = $this->getSkin()->getTitle();
834 } else {
835 $title = $this->getSkin()->getTitle()->getTalkPage();
838 return Linker::link(
839 $title,
840 wfMsg( 'postcomment' ),
841 array(),
842 array(
843 'action' => 'edit',
844 'section' => 'new'
846 array( 'known', 'noclasses' )
850 function getUploadLink() {
851 global $wgUploadNavigationUrl;
853 if ( $wgUploadNavigationUrl ) {
854 # Using an empty class attribute to avoid automatic setting of "external" class
855 return Linker::makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '' ) );
856 } else {
857 return Linker::link(
858 SpecialPage::getTitleFor( 'Upload' ),
859 wfMsgHtml( 'upload' ),
860 array(),
861 array(),
862 array( 'known', 'noclasses' )
867 function nameAndLogin() {
868 global $wgUser, $wgLang, $wgRequest, $wgContLang;
870 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
872 $ret = '';
874 if ( $wgUser->isAnon() ) {
875 if ( $this->getSkin()->showIPinHeader() ) {
876 $name = $wgRequest->getIP();
878 $talkLink = Linker::link( $wgUser->getTalkPage(),
879 $wgLang->getNsText( NS_TALK ) );
881 $ret .= "$name ($talkLink)";
882 } else {
883 $ret .= wfMsg( 'notloggedin' );
886 $returnTo = $this->getSkin()->getTitle()->getPrefixedDBkey();
887 $query = array();
889 if ( $logoutPage != $returnTo ) {
890 $query['returnto'] = $returnTo;
893 $loginlink = $wgUser->isAllowed( 'createaccount' )
894 ? 'nav-login-createaccount'
895 : 'login';
896 $ret .= "\n<br />" . Linker::link(
897 SpecialPage::getTitleFor( 'Userlogin' ),
898 wfMsg( $loginlink ), array(), $query
900 } else {
901 $returnTo = $this->getSkin()->getTitle()->getPrefixedDBkey();
902 $talkLink = Linker::link( $wgUser->getTalkPage(),
903 $wgLang->getNsText( NS_TALK ) );
905 $ret .= Linker::link( $wgUser->getUserPage(),
906 htmlspecialchars( $wgUser->getName() ) );
907 $ret .= " ($talkLink)<br />";
908 $ret .= $wgLang->pipeList( array(
909 Linker::link(
910 SpecialPage::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
911 array(), array( 'returnto' => $returnTo )
913 Linker::specialLink( 'Preferences' ),
914 ) );
917 $ret = $wgLang->pipeList( array(
918 $ret,
919 Linker::link(
920 Title::newFromText( wfMsgForContent( 'helppage' ) ),
921 wfMsg( 'help' )
923 ) );
925 return $ret;