Wrap message querypage-no-updates into a class
[lhc/web/wiklou.git] / includes / SkinLegacy.php
1 <?php
2 /**
3 * Base class for legacy skins.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 */
22
23 if ( !defined( 'MEDIAWIKI' ) ) {
24 die( 1 );
25 }
26
27 class SkinLegacy extends SkinTemplate {
28 var $useHeadElement = true;
29 protected $mWatchLinkNum = 0; // Appended to end of watch link id's
30
31 /**
32 * Add skin specific stylesheets
33 * @param $out OutputPage
34 */
35 function setupSkinUserCss( OutputPage $out ) {
36 $out->addModuleStyles( 'mediawiki.legacy.shared' );
37 $out->addModuleStyles( 'mediawiki.legacy.oldshared' );
38 }
39
40 public function commonPrintStylesheet() {
41 return true;
42 }
43
44 /**
45 * This was for the old skins and for users with 640x480 screen.
46 * Please note old skins are still used and might prove useful for
47 * users having old computers or visually impaired.
48 */
49 var $mSuppressQuickbar = false;
50
51 /**
52 * Suppress the quickbar from the output, only for skin supporting
53 * the quickbar
54 */
55 public function suppressQuickbar() {
56 $this->mSuppressQuickbar = true;
57 }
58
59 /**
60 * Return whether the quickbar should be suppressed from the output
61 *
62 * @return Boolean
63 */
64 public function isQuickbarSuppressed() {
65 return $this->mSuppressQuickbar;
66 }
67
68 function qbSetting() {
69 global $wgUser;
70 if ( $this->isQuickbarSuppressed() ) {
71 return 0;
72 }
73 $q = $wgUser->getOption( 'quickbar', 0 );
74 if( $q == 5 ) {
75 # 5 is the default, which chooses the setting
76 # depending on the directionality of your interface language
77 global $wgLang;
78 return $wgLang->isRTL() ? 2 : 1;
79 }
80 return $q;
81 }
82
83 }
84
85 class LegacyTemplate extends BaseTemplate {
86
87 // How many search boxes have we made? Avoid duplicate id's.
88 protected $searchboxes = '';
89
90 function execute() {
91 $this->html( 'headelement' );
92 echo $this->beforeContent();
93 $this->html( 'bodytext' );
94 echo "\n";
95 echo $this->afterContent();
96 $this->html( 'dataAfterContent' );
97 $this->printTrail();
98 echo "\n</body></html>";
99 }
100
101 /**
102 * This will be called immediately after the <body> tag. Split into
103 * two functions to make it easier to subclass.
104 * @return string
105 */
106 function beforeContent() {
107 return $this->doBeforeContent();
108 }
109
110 function doBeforeContent() {
111 global $wgLang;
112 wfProfileIn( __METHOD__ );
113
114 $s = '';
115
116 $langlinks = $this->otherLanguages();
117 if ( $langlinks ) {
118 $rows = 2;
119 $borderhack = '';
120 } else {
121 $rows = 1;
122 $langlinks = false;
123 $borderhack = 'class="top"';
124 }
125
126 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
127 "<table border='0' cellspacing='0' width='100%'>\n<tr>\n";
128
129 if ( $this->getSkin()->qbSetting() == 0 ) {
130 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
131 $this->getSkin()->logoText( $wgLang->alignStart() ) . '</td>';
132 }
133
134 $l = $wgLang->alignStart();
135 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
136
137 $s .= $this->topLinks();
138 $s .= '<p class="subtitle">' . $this->pageTitleLinks() . "</p>\n";
139
140 $r = $wgLang->alignEnd();
141 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
142 $s .= $this->nameAndLogin();
143 $s .= "\n<br />" . $this->searchForm() . '</td>';
144
145 if ( $langlinks ) {
146 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
147 }
148
149 $s .= "</tr>\n</table>\n</div>\n";
150 $s .= "\n<div id='article'>\n";
151
152 $notice = $this->getSkin()->getSiteNotice();
153
154 if ( $notice ) {
155 $s .= "\n<div id='siteNotice'>$notice</div>\n";
156 }
157 $s .= $this->pageTitle();
158 $s .= $this->pageSubtitle();
159 $s .= $this->getSkin()->getCategories();
160
161 wfProfileOut( __METHOD__ );
162 return $s;
163 }
164
165 /**
166 * This gets called shortly before the </body> tag.
167 * @return String HTML to be put before </body>
168 */
169 function afterContent() {
170 return $this->doAfterContent();
171 }
172
173 /** overloaded by derived classes
174 * @return string
175 */
176 function doAfterContent() {
177 return '</div></div>';
178 }
179
180 function searchForm() {
181 global $wgRequest, $wgUseTwoButtonsSearchForm;
182
183 $search = $wgRequest->getText( 'search' );
184
185 $s = '<form id="searchform' . $this->searchboxes . '" name="search" class="inline" method="post" action="'
186 . $this->getSkin()->escapeSearchLink() . "\">\n"
187 . '<input type="text" id="searchInput' . $this->searchboxes . '" name="search" size="19" value="'
188 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
189 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
190
191 if ( $wgUseTwoButtonsSearchForm ) {
192 $s .= '&#160;<input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
193 } else {
194 $s .= ' <a href="' . $this->getSkin()->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
195 }
196
197 $s .= '</form>';
198
199 // Ensure unique id's for search boxes made after the first
200 $this->searchboxes = $this->searchboxes == '' ? 2 : $this->searchboxes + 1;
201
202 return $s;
203 }
204
205 function pageStats() {
206 $ret = array();
207 $items = array( 'viewcount', 'credits', 'lastmod', 'numberofwatchingusers', 'copyright' );
208
209 foreach( $items as $item ) {
210 if ( $this->data[$item] !== false ) {
211 $ret[] = $this->data[$item];
212 }
213 }
214
215 return implode( ' ', $ret );
216 }
217
218 function topLinks() {
219 global $wgOut;
220
221 $s = array(
222 $this->getSkin()->mainPageLink(),
223 Linker::specialLink( 'Recentchanges' )
224 );
225
226 if ( $wgOut->isArticleRelated() ) {
227 $s[] = $this->editThisPage();
228 $s[] = $this->historyLink();
229 }
230
231 # Many people don't like this dropdown box
232 # $s[] = $this->specialPagesList();
233
234 if ( $this->variantLinks() ) {
235 $s[] = $this->variantLinks();
236 }
237
238 if ( $this->extensionTabLinks() ) {
239 $s[] = $this->extensionTabLinks();
240 }
241
242 // @todo FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
243 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
244 }
245
246 /**
247 * Language/charset variant links for classic-style skins
248 * @return string
249 */
250 function variantLinks() {
251 $s = '';
252
253 /* show links to different language variants */
254 global $wgDisableLangConversion, $wgLang;
255
256 $title = $this->getSkin()->getTitle();
257 $lang = $title->getPageLanguage();
258 $variants = $lang->getVariants();
259
260 if ( !$wgDisableLangConversion && sizeof( $variants ) > 1
261 && !$title->isSpecialPage() ) {
262 foreach ( $variants as $code ) {
263 $varname = $lang->getVariantname( $code );
264
265 if ( $varname == 'disable' ) {
266 continue;
267 }
268 $s = $wgLang->pipeList( array(
269 $s,
270 '<a href="' . htmlspecialchars( $title->getLocalURL( 'variant=' . $code ) ) . '" lang="' . $code . '" hreflang="' . $code . '">' . htmlspecialchars( $varname ) . '</a>'
271 ) );
272 }
273 }
274
275 return $s;
276 }
277
278 /**
279 * Compatibility for extensions adding functionality through tabs.
280 * Eventually these old skins should be replaced with SkinTemplate-based
281 * versions, sigh...
282 * @return string
283 * @todo Exterminate! ...that, and replace it with normal SkinTemplate stuff
284 */
285 function extensionTabLinks() {
286 $tabs = array();
287 $out = '';
288 $s = array();
289 wfRunHooks( 'SkinTemplateTabs', array( $this->getSkin(), &$tabs ) );
290 foreach ( $tabs as $tab ) {
291 $s[] = Xml::element( 'a',
292 array( 'href' => $tab['href'] ),
293 $tab['text'] );
294 }
295
296 if ( count( $s ) ) {
297 global $wgLang;
298
299 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
300 $out .= $wgLang->pipeList( $s );
301 }
302
303 return $out;
304 }
305
306 function bottomLinks() {
307 global $wgOut, $wgUser;
308 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
309
310 $s = '';
311 if ( $wgOut->isArticleRelated() ) {
312 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
313
314 if ( $wgUser->isLoggedIn() ) {
315 $element[] = $this->watchThisPage();
316 }
317
318 $element[] = $this->talkLink();
319 $element[] = $this->historyLink();
320 $element[] = $this->whatLinksHere();
321 $element[] = $this->watchPageLinksLink();
322
323 $title = $this->getSkin()->getTitle();
324
325 if (
326 $title->getNamespace() == NS_USER ||
327 $title->getNamespace() == NS_USER_TALK
328 ) {
329 $id = User::idFromName( $title->getText() );
330 $ip = User::isIP( $title->getText() );
331
332 # Both anons and non-anons have contributions list
333 if ( $id || $ip ) {
334 $element[] = $this->userContribsLink();
335 }
336
337 if ( $this->getSkin()->showEmailUser( $id ) ) {
338 $element[] = $this->emailUserLink();
339 }
340 }
341
342 $s = implode( $element, $sep );
343
344 if ( $title->getArticleID() ) {
345 $s .= "\n<br />";
346
347 // Delete/protect/move links for privileged users
348 if ( $wgUser->isAllowed( 'delete' ) ) {
349 $s .= $this->deleteThisPage();
350 }
351
352 if ( $wgUser->isAllowed( 'protect' ) ) {
353 $s .= $sep . $this->protectThisPage();
354 }
355
356 if ( $wgUser->isAllowed( 'move' ) ) {
357 $s .= $sep . $this->moveThisPage();
358 }
359 }
360
361 $s .= "<br />\n" . $this->otherLanguages();
362 }
363
364 return $s;
365 }
366
367 function otherLanguages() {
368 global $wgOut, $wgLang, $wgHideInterlanguageLinks;
369
370 if ( $wgHideInterlanguageLinks ) {
371 return '';
372 }
373
374 $a = $wgOut->getLanguageLinks();
375
376 if ( 0 == count( $a ) ) {
377 return '';
378 }
379
380 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
381 $first = true;
382
383 if ( $wgLang->isRTL() ) {
384 $s .= '<span dir="ltr">';
385 }
386
387 foreach ( $a as $l ) {
388 if ( !$first ) {
389 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
390 }
391
392 $first = false;
393
394 $nt = Title::newFromText( $l );
395 $text = Language::fetchLanguageName( $nt->getInterwiki() );
396
397 $s .= Html::element( 'a',
398 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
399 $text == '' ? $l : $text );
400 }
401
402 if ( $wgLang->isRTL() ) {
403 $s .= '</span>';
404 }
405
406 return $s;
407 }
408
409 /**
410 * Show a drop-down box of special pages
411 * @return string
412 */
413 function specialPagesList() {
414 global $wgScript;
415
416 $select = new XmlSelect( 'title' );
417 $pages = SpecialPageFactory::getUsablePages();
418 array_unshift( $pages, SpecialPageFactory::getPage( 'SpecialPages' ) );
419 foreach ( $pages as $obj ) {
420 $select->addOption( $obj->getDescription(),
421 $obj->getTitle()->getPrefixedDBkey() );
422 }
423
424 return Html::rawElement( 'form', array( 'id' => 'specialpages', 'method' => 'get',
425 'action' => $wgScript ), $select->getHTML() . Xml::submitButton( wfMsg( 'go' ) ) );
426 }
427
428 function pageTitleLinks() {
429 global $wgOut, $wgUser, $wgRequest, $wgLang;
430
431 $oldid = $wgRequest->getVal( 'oldid' );
432 $diff = $wgRequest->getVal( 'diff' );
433 $action = $wgRequest->getText( 'action' );
434
435 $skin = $this->getSkin();
436 $title = $skin->getTitle();
437
438 $s[] = $this->printableLink();
439 $disclaimer = $skin->disclaimerLink(); # may be empty
440
441 if ( $disclaimer ) {
442 $s[] = $disclaimer;
443 }
444
445 $privacy = $skin->privacyLink(); # may be empty too
446
447 if ( $privacy ) {
448 $s[] = $privacy;
449 }
450
451 if ( $wgOut->isArticleRelated() ) {
452 if ( $title->getNamespace() == NS_FILE ) {
453 $name = $title->getDBkey();
454 $image = wfFindFile( $title );
455
456 if ( $image ) {
457 $link = htmlspecialchars( $image->getURL() );
458 $style = Linker::getInternalLinkAttributes( $link, $name );
459 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
460 }
461 }
462 }
463
464 if ( 'history' == $action || isset( $diff ) || isset( $oldid ) ) {
465 $s[] .= Linker::linkKnown(
466 $title,
467 wfMsg( 'currentrev' )
468 );
469 }
470
471 if ( $wgUser->getNewtalk() ) {
472 # do not show "You have new messages" text when we are viewing our
473 # own talk page
474 if ( !$title->equals( $wgUser->getTalkPage() ) ) {
475 $tl = Linker::linkKnown(
476 $wgUser->getTalkPage(),
477 wfMsgHtml( 'newmessageslink' ),
478 array(),
479 array( 'redirect' => 'no' )
480 );
481
482 $dl = Linker::linkKnown(
483 $wgUser->getTalkPage(),
484 wfMsgHtml( 'newmessagesdifflink' ),
485 array(),
486 array( 'diff' => 'cur' )
487 );
488 $s[] = '<strong>' . wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
489 # disable caching
490 $wgOut->setSquidMaxage( 0 );
491 $wgOut->enableClientCache( false );
492 }
493 }
494
495 $undelete = $skin->getUndeleteLink();
496
497 if ( !empty( $undelete ) ) {
498 $s[] = $undelete;
499 }
500
501 return $wgLang->pipeList( $s );
502 }
503
504 /**
505 * Gets the h1 element with the page title.
506 * @return string
507 */
508 function pageTitle() {
509 global $wgOut;
510 $s = '<h1 class="pagetitle"><span dir="auto">' . $wgOut->getPageTitle() . '</span></h1>';
511 return $s;
512 }
513
514 function pageSubtitle() {
515 global $wgOut;
516
517 $sub = $wgOut->getSubtitle();
518
519 if ( $sub == '' ) {
520 global $wgExtraSubtitle;
521 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
522 }
523
524 $subpages = $this->getSkin()->subPageSubtitle();
525 $sub .= !empty( $subpages ) ? "</p><p class='subpages'>$subpages" : '';
526 $s = "<p class='subtitle'>{$sub}</p>\n";
527
528 return $s;
529 }
530
531 function printableLink() {
532 global $wgOut, $wgRequest, $wgLang;
533
534 $s = array();
535
536 if ( !$wgOut->isPrintable() ) {
537 $printurl = htmlspecialchars( $this->getSkin()->getTitle()->getLocalUrl(
538 $wgRequest->appendQueryValue( 'printable', 'yes', true ) ) );
539 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
540 }
541
542 if ( $wgOut->isSyndicated() ) {
543 foreach ( $wgOut->getSyndicationLinks() as $format => $link ) {
544 $feedurl = htmlspecialchars( $link );
545 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
546 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
547 }
548 }
549 return $wgLang->pipeList( $s );
550 }
551
552 /**
553 * @deprecated in 1.19
554 * @return string
555 */
556 function getQuickbarCompensator( $rows = 1 ) {
557 wfDeprecated( __METHOD__, '1.19' );
558 return "<td width='152' rowspan='{$rows}'>&#160;</td>";
559 }
560
561 function editThisPage() {
562 global $wgOut;
563
564 if ( !$wgOut->isArticleRelated() ) {
565 $s = wfMsg( 'protectedpage' );
566 } else {
567 $title = $this->getSkin()->getTitle();
568 if ( $title->quickUserCan( 'edit' ) && $title->exists() ) {
569 $t = wfMsg( 'editthispage' );
570 } elseif ( $title->quickUserCan( 'create' ) && !$title->exists() ) {
571 $t = wfMsg( 'create-this-page' );
572 } else {
573 $t = wfMsg( 'viewsource' );
574 }
575
576 $s = Linker::linkKnown(
577 $title,
578 $t,
579 array(),
580 $this->getSkin()->editUrlOptions()
581 );
582 }
583
584 return $s;
585 }
586
587 function deleteThisPage() {
588 global $wgUser, $wgRequest;
589
590 $diff = $wgRequest->getVal( 'diff' );
591 $title = $this->getSkin()->getTitle();
592
593 if ( $title->getArticleID() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
594 $t = wfMsg( 'deletethispage' );
595
596 $s = Linker::linkKnown(
597 $title,
598 $t,
599 array(),
600 array( 'action' => 'delete' )
601 );
602 } else {
603 $s = '';
604 }
605
606 return $s;
607 }
608
609 function protectThisPage() {
610 global $wgUser, $wgRequest;
611
612 $diff = $wgRequest->getVal( 'diff' );
613 $title = $this->getSkin()->getTitle();
614
615 if ( $title->getArticleID() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
616 if ( $title->isProtected() ) {
617 $text = wfMsg( 'unprotectthispage' );
618 $query = array( 'action' => 'unprotect' );
619 } else {
620 $text = wfMsg( 'protectthispage' );
621 $query = array( 'action' => 'protect' );
622 }
623
624 $s = Linker::linkKnown(
625 $title,
626 $text,
627 array(),
628 $query
629 );
630 } else {
631 $s = '';
632 }
633
634 return $s;
635 }
636
637 function watchThisPage() {
638 global $wgOut, $wgUser;
639 ++$this->mWatchLinkNum;
640
641 // Cache
642 $title = $this->getSkin()->getTitle();
643
644 if ( $wgOut->isArticleRelated() ) {
645 if ( $title->userIsWatching() ) {
646 $text = wfMsg( 'unwatchthispage' );
647 $query = array(
648 'action' => 'unwatch',
649 'token' => UnwatchAction::getUnwatchToken( $title, $wgUser ),
650 );
651 $id = 'mw-unwatch-link' . $this->mWatchLinkNum;
652 } else {
653 $text = wfMsg( 'watchthispage' );
654 $query = array(
655 'action' => 'watch',
656 'token' => WatchAction::getWatchToken( $title, $wgUser ),
657 );
658 $id = 'mw-watch-link' . $this->mWatchLinkNum;
659 }
660
661 $s = Linker::linkKnown(
662 $title,
663 $text,
664 array( 'id' => $id ),
665 $query
666 );
667 } else {
668 $s = wfMsg( 'notanarticle' );
669 }
670
671 return $s;
672 }
673
674 function moveThisPage() {
675 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
676 return Linker::linkKnown(
677 SpecialPage::getTitleFor( 'Movepage' ),
678 wfMsg( 'movethispage' ),
679 array(),
680 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() )
681 );
682 } else {
683 // no message if page is protected - would be redundant
684 return '';
685 }
686 }
687
688 function historyLink() {
689 return Linker::link(
690 $this->getSkin()->getTitle(),
691 wfMsgHtml( 'history' ),
692 array( 'rel' => 'archives' ),
693 array( 'action' => 'history' )
694 );
695 }
696
697 function whatLinksHere() {
698 return Linker::linkKnown(
699 SpecialPage::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
700 wfMsgHtml( 'whatlinkshere' )
701 );
702 }
703
704 function userContribsLink() {
705 return Linker::linkKnown(
706 SpecialPage::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
707 wfMsgHtml( 'contributions' )
708 );
709 }
710
711 function emailUserLink() {
712 return Linker::linkKnown(
713 SpecialPage::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
714 wfMsgHtml( 'emailuser' )
715 );
716 }
717
718 function watchPageLinksLink() {
719 global $wgOut;
720
721 if ( !$wgOut->isArticleRelated() ) {
722 return wfMessage( 'parentheses', wfMessage( 'notanarticle' )->text() )->escaped();
723 } else {
724 return Linker::linkKnown(
725 SpecialPage::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
726 wfMsgHtml( 'recentchangeslinked-toolbox' )
727 );
728 }
729 }
730
731 function talkLink() {
732 $title = $this->getSkin()->getTitle();
733 if ( NS_SPECIAL == $title->getNamespace() ) {
734 # No discussion links for special pages
735 return '';
736 }
737
738 $linkOptions = array();
739
740 if ( $title->isTalkPage() ) {
741 $link = $title->getSubjectPage();
742 switch( $link->getNamespace() ) {
743 case NS_MAIN:
744 $text = wfMsg( 'articlepage' );
745 break;
746 case NS_USER:
747 $text = wfMsg( 'userpage' );
748 break;
749 case NS_PROJECT:
750 $text = wfMsg( 'projectpage' );
751 break;
752 case NS_FILE:
753 $text = wfMsg( 'imagepage' );
754 # Make link known if image exists, even if the desc. page doesn't.
755 if ( wfFindFile( $link ) )
756 $linkOptions[] = 'known';
757 break;
758 case NS_MEDIAWIKI:
759 $text = wfMsg( 'mediawikipage' );
760 break;
761 case NS_TEMPLATE:
762 $text = wfMsg( 'templatepage' );
763 break;
764 case NS_HELP:
765 $text = wfMsg( 'viewhelppage' );
766 break;
767 case NS_CATEGORY:
768 $text = wfMsg( 'categorypage' );
769 break;
770 default:
771 $text = wfMsg( 'articlepage' );
772 }
773 } else {
774 $link = $title->getTalkPage();
775 $text = wfMsg( 'talkpage' );
776 }
777
778 $s = Linker::link( $link, $text, array(), array(), $linkOptions );
779
780 return $s;
781 }
782
783 function commentLink() {
784 global $wgOut;
785
786 $title = $this->getSkin()->getTitle();
787 if ( $title->isSpecialPage() ) {
788 return '';
789 }
790
791 # __NEWSECTIONLINK___ changes behaviour here
792 # If it is present, the link points to this page, otherwise
793 # it points to the talk page
794 if ( !$title->isTalkPage() && !$wgOut->showNewSectionLink() ) {
795 $title = $title->getTalkPage();
796 }
797
798 return Linker::linkKnown(
799 $title,
800 wfMsg( 'postcomment' ),
801 array(),
802 array(
803 'action' => 'edit',
804 'section' => 'new'
805 )
806 );
807 }
808
809 function getUploadLink() {
810 global $wgUploadNavigationUrl;
811
812 if ( $wgUploadNavigationUrl ) {
813 # Using an empty class attribute to avoid automatic setting of "external" class
814 return Linker::makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '' ) );
815 } else {
816 return Linker::linkKnown(
817 SpecialPage::getTitleFor( 'Upload' ),
818 wfMsgHtml( 'upload' )
819 );
820 }
821 }
822
823 function nameAndLogin() {
824 global $wgUser, $wgLang, $wgRequest;
825
826 $returnTo = $this->getSkin()->getTitle();
827 $ret = '';
828
829 if ( $wgUser->isAnon() ) {
830 if ( $this->getSkin()->showIPinHeader() ) {
831 $name = $wgRequest->getIP();
832
833 $talkLink = Linker::link( $wgUser->getTalkPage(),
834 $wgLang->getNsText( NS_TALK ) );
835 $talkLink = wfMessage( 'parentheses' )->rawParams( $talkLink )->escaped();
836
837 $ret .= "$name $talkLink";
838 } else {
839 $ret .= wfMsg( 'notloggedin' );
840 }
841
842 $query = array();
843
844 if ( !$returnTo->isSpecial( 'Userlogout' ) ) {
845 $query['returnto'] = $returnTo->getPrefixedDBkey();
846 }
847
848 $loginlink = $wgUser->isAllowed( 'createaccount' )
849 ? 'nav-login-createaccount'
850 : 'login';
851 $ret .= "\n<br />" . Linker::link(
852 SpecialPage::getTitleFor( 'Userlogin' ),
853 wfMsg( $loginlink ), array(), $query
854 );
855 } else {
856 $talkLink = Linker::link( $wgUser->getTalkPage(),
857 $wgLang->getNsText( NS_TALK ) );
858 $talkLink = wfMessage( 'parentheses' )->rawParams( $talkLink )->escaped();
859
860 $ret .= Linker::link( $wgUser->getUserPage(),
861 htmlspecialchars( $wgUser->getName() ) );
862 $ret .= " $talkLink<br />";
863 $ret .= $wgLang->pipeList( array(
864 Linker::link(
865 SpecialPage::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
866 array(), array( 'returnto' => $returnTo->getPrefixedDBkey() )
867 ),
868 Linker::specialLink( 'Preferences' ),
869 ) );
870 }
871
872 $ret = $wgLang->pipeList( array(
873 $ret,
874 Linker::link(
875 Title::newFromText( wfMsgForContent( 'helppage' ) ),
876 wfMsg( 'help' )
877 ),
878 ) );
879
880 return $ret;
881 }
882 }