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