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