Follow-up I0b781c11 (2a55449): use User::getAutomaticGroups().
[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="' . wfMsg( 'searcharticle' ) . '" />';
186
187 if ( $wgUseTwoButtonsSearchForm ) {
188 $s .= '&#160;<input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
189 } else {
190 $s .= ' <a href="' . $this->getSkin()->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</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, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\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 = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
296 $out .= $wgLang->pipeList( $s );
297 }
298
299 return $out;
300 }
301
302 function bottomLinks() {
303 global $wgOut, $wgUser;
304 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\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 = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
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 .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
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', array( 'id' => 'specialpages', 'method' => 'get',
421 'action' => $wgScript ), $select->getHTML() . Xml::submitButton( wfMsg( 'go' ) ) );
422 }
423
424 function pageTitleLinks() {
425 global $wgOut, $wgUser, $wgRequest, $wgLang;
426
427 $oldid = $wgRequest->getVal( 'oldid' );
428 $diff = $wgRequest->getVal( 'diff' );
429 $action = $wgRequest->getText( 'action' );
430
431 $skin = $this->getSkin();
432 $title = $skin->getTitle();
433
434 $s[] = $this->printableLink();
435 $disclaimer = $skin->disclaimerLink(); # may be empty
436
437 if ( $disclaimer ) {
438 $s[] = $disclaimer;
439 }
440
441 $privacy = $skin->privacyLink(); # may be empty too
442
443 if ( $privacy ) {
444 $s[] = $privacy;
445 }
446
447 if ( $wgOut->isArticleRelated() ) {
448 if ( $title->getNamespace() == NS_FILE ) {
449 $image = wfFindFile( $title );
450
451 if ( $image ) {
452 $href = $image->getURL();
453 $s[] = Html::element( 'a', array( 'href' => $href,
454 'title' => $href ), $title->getText() );
455
456 }
457 }
458 }
459
460 if ( 'history' == $action || isset( $diff ) || isset( $oldid ) ) {
461 $s[] .= Linker::linkKnown(
462 $title,
463 wfMsg( 'currentrev' )
464 );
465 }
466
467 if ( $wgUser->getNewtalk() ) {
468 # do not show "You have new messages" text when we are viewing our
469 # own talk page
470 if ( !$title->equals( $wgUser->getTalkPage() ) ) {
471 $tl = Linker::linkKnown(
472 $wgUser->getTalkPage(),
473 wfMsgHtml( 'newmessageslink' ),
474 array(),
475 array( 'redirect' => 'no' )
476 );
477
478 $dl = Linker::linkKnown(
479 $wgUser->getTalkPage(),
480 wfMsgHtml( 'newmessagesdifflink' ),
481 array(),
482 array( 'diff' => 'cur' )
483 );
484 $s[] = '<strong>' . wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
485 # disable caching
486 $wgOut->setSquidMaxage( 0 );
487 $wgOut->enableClientCache( false );
488 }
489 }
490
491 $undelete = $skin->getUndeleteLink();
492
493 if ( !empty( $undelete ) ) {
494 $s[] = $undelete;
495 }
496
497 return $wgLang->pipeList( $s );
498 }
499
500 /**
501 * Gets the h1 element with the page title.
502 * @return string
503 */
504 function pageTitle() {
505 global $wgOut;
506 $s = '<h1 class="pagetitle"><span dir="auto">' . $wgOut->getPageTitle() . '</span></h1>';
507 return $s;
508 }
509
510 function pageSubtitle() {
511 global $wgOut;
512
513 $sub = $wgOut->getSubtitle();
514
515 if ( $sub == '' ) {
516 global $wgExtraSubtitle;
517 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
518 }
519
520 $subpages = $this->getSkin()->subPageSubtitle();
521 $sub .= !empty( $subpages ) ? "</p><p class='subpages'>$subpages" : '';
522 $s = "<p class='subtitle'>{$sub}</p>\n";
523
524 return $s;
525 }
526
527 function printableLink() {
528 global $wgOut, $wgRequest, $wgLang;
529
530 $s = array();
531
532 if ( !$wgOut->isPrintable() ) {
533 $printurl = htmlspecialchars( $this->getSkin()->getTitle()->getLocalUrl(
534 $wgRequest->appendQueryValue( 'printable', 'yes', true ) ) );
535 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
536 }
537
538 if ( $wgOut->isSyndicated() ) {
539 foreach ( $wgOut->getSyndicationLinks() as $format => $link ) {
540 $feedurl = htmlspecialchars( $link );
541 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
542 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
543 }
544 }
545 return $wgLang->pipeList( $s );
546 }
547
548 /**
549 * @deprecated in 1.19
550 * @return string
551 */
552 function getQuickbarCompensator( $rows = 1 ) {
553 wfDeprecated( __METHOD__, '1.19' );
554 return "<td width='152' rowspan='{$rows}'>&#160;</td>";
555 }
556
557 function editThisPage() {
558 global $wgOut;
559
560 if ( !$wgOut->isArticleRelated() ) {
561 $s = wfMsg( 'protectedpage' );
562 } else {
563 $title = $this->getSkin()->getTitle();
564 if ( $title->quickUserCan( 'edit' ) && $title->exists() ) {
565 $t = wfMsg( 'editthispage' );
566 } elseif ( $title->quickUserCan( 'create' ) && !$title->exists() ) {
567 $t = wfMsg( 'create-this-page' );
568 } else {
569 $t = wfMsg( 'viewsource' );
570 }
571
572 $s = Linker::linkKnown(
573 $title,
574 $t,
575 array(),
576 $this->getSkin()->editUrlOptions()
577 );
578 }
579
580 return $s;
581 }
582
583 function deleteThisPage() {
584 global $wgUser, $wgRequest;
585
586 $diff = $wgRequest->getVal( 'diff' );
587 $title = $this->getSkin()->getTitle();
588
589 if ( $title->getArticleID() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
590 $t = wfMsg( 'deletethispage' );
591
592 $s = Linker::linkKnown(
593 $title,
594 $t,
595 array(),
596 array( 'action' => 'delete' )
597 );
598 } else {
599 $s = '';
600 }
601
602 return $s;
603 }
604
605 function protectThisPage() {
606 global $wgUser, $wgRequest;
607
608 $diff = $wgRequest->getVal( 'diff' );
609 $title = $this->getSkin()->getTitle();
610
611 if ( $title->getArticleID() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
612 if ( $title->isProtected() ) {
613 $text = wfMsg( 'unprotectthispage' );
614 $query = array( 'action' => 'unprotect' );
615 } else {
616 $text = wfMsg( 'protectthispage' );
617 $query = array( 'action' => 'protect' );
618 }
619
620 $s = Linker::linkKnown(
621 $title,
622 $text,
623 array(),
624 $query
625 );
626 } else {
627 $s = '';
628 }
629
630 return $s;
631 }
632
633 function watchThisPage() {
634 global $wgOut, $wgUser;
635 ++$this->mWatchLinkNum;
636
637 // Cache
638 $title = $this->getSkin()->getTitle();
639
640 if ( $wgOut->isArticleRelated() ) {
641 if ( $wgUser->isWatched( $title ) ) {
642 $text = wfMsg( 'unwatchthispage' );
643 $query = array(
644 'action' => 'unwatch',
645 'token' => UnwatchAction::getUnwatchToken( $title, $wgUser ),
646 );
647 $id = 'mw-unwatch-link' . $this->mWatchLinkNum;
648 } else {
649 $text = wfMsg( 'watchthispage' );
650 $query = array(
651 'action' => 'watch',
652 'token' => WatchAction::getWatchToken( $title, $wgUser ),
653 );
654 $id = 'mw-watch-link' . $this->mWatchLinkNum;
655 }
656
657 $s = Linker::linkKnown(
658 $title,
659 $text,
660 array( 'id' => $id ),
661 $query
662 );
663 } else {
664 $s = wfMsg( 'notanarticle' );
665 }
666
667 return $s;
668 }
669
670 function moveThisPage() {
671 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
672 return Linker::linkKnown(
673 SpecialPage::getTitleFor( 'Movepage' ),
674 wfMsg( 'movethispage' ),
675 array(),
676 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() )
677 );
678 } else {
679 // no message if page is protected - would be redundant
680 return '';
681 }
682 }
683
684 function historyLink() {
685 return Linker::link(
686 $this->getSkin()->getTitle(),
687 wfMsgHtml( 'history' ),
688 array( 'rel' => 'archives' ),
689 array( 'action' => 'history' )
690 );
691 }
692
693 function whatLinksHere() {
694 return Linker::linkKnown(
695 SpecialPage::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
696 wfMsgHtml( 'whatlinkshere' )
697 );
698 }
699
700 function userContribsLink() {
701 return Linker::linkKnown(
702 SpecialPage::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
703 wfMsgHtml( 'contributions' )
704 );
705 }
706
707 function emailUserLink() {
708 return Linker::linkKnown(
709 SpecialPage::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
710 wfMsgHtml( 'emailuser' )
711 );
712 }
713
714 function watchPageLinksLink() {
715 global $wgOut;
716
717 if ( !$wgOut->isArticleRelated() ) {
718 return wfMessage( 'parentheses', wfMessage( 'notanarticle' )->text() )->escaped();
719 } else {
720 return Linker::linkKnown(
721 SpecialPage::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
722 wfMsgHtml( 'recentchangeslinked-toolbox' )
723 );
724 }
725 }
726
727 function talkLink() {
728 $title = $this->getSkin()->getTitle();
729 if ( NS_SPECIAL == $title->getNamespace() ) {
730 # No discussion links for special pages
731 return '';
732 }
733
734 $linkOptions = array();
735
736 if ( $title->isTalkPage() ) {
737 $link = $title->getSubjectPage();
738 switch( $link->getNamespace() ) {
739 case NS_MAIN:
740 $text = wfMsg( 'articlepage' );
741 break;
742 case NS_USER:
743 $text = wfMsg( 'userpage' );
744 break;
745 case NS_PROJECT:
746 $text = wfMsg( 'projectpage' );
747 break;
748 case NS_FILE:
749 $text = wfMsg( 'imagepage' );
750 # Make link known if image exists, even if the desc. page doesn't.
751 if ( wfFindFile( $link ) )
752 $linkOptions[] = 'known';
753 break;
754 case NS_MEDIAWIKI:
755 $text = wfMsg( 'mediawikipage' );
756 break;
757 case NS_TEMPLATE:
758 $text = wfMsg( 'templatepage' );
759 break;
760 case NS_HELP:
761 $text = wfMsg( 'viewhelppage' );
762 break;
763 case NS_CATEGORY:
764 $text = wfMsg( 'categorypage' );
765 break;
766 default:
767 $text = wfMsg( 'articlepage' );
768 }
769 } else {
770 $link = $title->getTalkPage();
771 $text = wfMsg( 'talkpage' );
772 }
773
774 $s = Linker::link( $link, $text, array(), array(), $linkOptions );
775
776 return $s;
777 }
778
779 function commentLink() {
780 global $wgOut;
781
782 $title = $this->getSkin()->getTitle();
783 if ( $title->isSpecialPage() ) {
784 return '';
785 }
786
787 # __NEWSECTIONLINK___ changes behaviour here
788 # If it is present, the link points to this page, otherwise
789 # it points to the talk page
790 if ( !$title->isTalkPage() && !$wgOut->showNewSectionLink() ) {
791 $title = $title->getTalkPage();
792 }
793
794 return Linker::linkKnown(
795 $title,
796 wfMsg( 'postcomment' ),
797 array(),
798 array(
799 'action' => 'edit',
800 'section' => 'new'
801 )
802 );
803 }
804
805 function getUploadLink() {
806 global $wgUploadNavigationUrl;
807
808 if ( $wgUploadNavigationUrl ) {
809 # Using an empty class attribute to avoid automatic setting of "external" class
810 return Linker::makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '' ) );
811 } else {
812 return Linker::linkKnown(
813 SpecialPage::getTitleFor( 'Upload' ),
814 wfMsgHtml( 'upload' )
815 );
816 }
817 }
818
819 function nameAndLogin() {
820 global $wgUser, $wgLang, $wgRequest;
821
822 $returnTo = $this->getSkin()->getTitle();
823 $ret = '';
824
825 if ( $wgUser->isAnon() ) {
826 if ( $this->getSkin()->showIPinHeader() ) {
827 $name = $wgRequest->getIP();
828
829 $talkLink = Linker::link( $wgUser->getTalkPage(),
830 $wgLang->getNsText( NS_TALK ) );
831 $talkLink = wfMessage( 'parentheses' )->rawParams( $talkLink )->escaped();
832
833 $ret .= "$name $talkLink";
834 } else {
835 $ret .= wfMsg( 'notloggedin' );
836 }
837
838 $query = array();
839
840 if ( !$returnTo->isSpecial( 'Userlogout' ) ) {
841 $query['returnto'] = $returnTo->getPrefixedDBkey();
842 }
843
844 $loginlink = $wgUser->isAllowed( 'createaccount' )
845 ? 'nav-login-createaccount'
846 : 'login';
847 $ret .= "\n<br />" . Linker::link(
848 SpecialPage::getTitleFor( 'Userlogin' ),
849 wfMsg( $loginlink ), array(), $query
850 );
851 } else {
852 $talkLink = Linker::link( $wgUser->getTalkPage(),
853 $wgLang->getNsText( NS_TALK ) );
854 $talkLink = wfMessage( 'parentheses' )->rawParams( $talkLink )->escaped();
855
856 $ret .= Linker::link( $wgUser->getUserPage(),
857 htmlspecialchars( $wgUser->getName() ) );
858 $ret .= " $talkLink<br />";
859 $ret .= $wgLang->pipeList( array(
860 Linker::link(
861 SpecialPage::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
862 array(), array( 'returnto' => $returnTo->getPrefixedDBkey() )
863 ),
864 Linker::specialLink( 'Preferences' ),
865 ) );
866 }
867
868 $ret = $wgLang->pipeList( array(
869 $ret,
870 Linker::link(
871 Title::newFromText( wfMsgForContent( 'helppage' ) ),
872 wfMsg( 'help' )
873 ),
874 ) );
875
876 return $ret;
877 }
878 }