9d657f7b715d949ccaa0981cce2372aafee4c06c
[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 if ( $varname == 'disable' ) {
222 continue;
223 }
224 $s = $wgLang->pipeList( array(
225 $s,
226 '<a href="' . htmlspecialchars( $title->getLocalURL( 'variant=' . $code ) ) . '" lang="' . $code . '" hreflang="' . $code . '">' . htmlspecialchars( $varname ) . '</a>'
227 ) );
228 }
229 }
230
231 return $s;
232 }
233
234 /**
235 * Compatibility for extensions adding functionality through tabs.
236 * Eventually these old skins should be replaced with SkinTemplate-based
237 * versions, sigh...
238 * @return string
239 * @todo Exterminate! ...that, and replace it with normal SkinTemplate stuff
240 */
241 function extensionTabLinks() {
242 $tabs = array();
243 $out = '';
244 $s = array();
245 wfRunHooks( 'SkinTemplateTabs', array( $this->getSkin(), &$tabs ) );
246 foreach ( $tabs as $tab ) {
247 $s[] = Xml::element( 'a',
248 array( 'href' => $tab['href'] ),
249 $tab['text'] );
250 }
251
252 if ( count( $s ) ) {
253 global $wgLang;
254
255 $out = wfMessage( 'pipe-separator' )->escaped();
256 $out .= $wgLang->pipeList( $s );
257 }
258
259 return $out;
260 }
261
262 function bottomLinks() {
263 global $wgOut, $wgUser;
264 $sep = wfMessage( 'pipe-separator' )->escaped() . "\n";
265
266 $s = '';
267 if ( $wgOut->isArticleRelated() ) {
268 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
269
270 if ( $wgUser->isLoggedIn() ) {
271 $element[] = $this->watchThisPage();
272 }
273
274 $element[] = $this->talkLink();
275 $element[] = $this->historyLink();
276 $element[] = $this->whatLinksHere();
277 $element[] = $this->watchPageLinksLink();
278
279 $title = $this->getSkin()->getTitle();
280
281 if (
282 $title->getNamespace() == NS_USER ||
283 $title->getNamespace() == NS_USER_TALK
284 ) {
285 $id = User::idFromName( $title->getText() );
286 $ip = User::isIP( $title->getText() );
287
288 # Both anons and non-anons have contributions list
289 if ( $id || $ip ) {
290 $element[] = $this->userContribsLink();
291 }
292
293 if ( $this->getSkin()->showEmailUser( $id ) ) {
294 $element[] = $this->emailUserLink();
295 }
296 }
297
298 $s = implode( $element, $sep );
299
300 if ( $title->getArticleID() ) {
301 $s .= "\n<br />";
302
303 // Delete/protect/move links for privileged users
304 if ( $wgUser->isAllowed( 'delete' ) ) {
305 $s .= $this->deleteThisPage();
306 }
307
308 if ( $wgUser->isAllowed( 'protect' ) && $title->getRestrictionTypes() ) {
309 $s .= $sep . $this->protectThisPage();
310 }
311
312 if ( $wgUser->isAllowed( 'move' ) ) {
313 $s .= $sep . $this->moveThisPage();
314 }
315 }
316
317 $s .= "<br />\n" . $this->otherLanguages();
318 }
319
320 return $s;
321 }
322
323 function otherLanguages() {
324 global $wgOut, $wgLang, $wgHideInterlanguageLinks;
325
326 if ( $wgHideInterlanguageLinks ) {
327 return '';
328 }
329
330 $a = $wgOut->getLanguageLinks();
331
332 if ( 0 == count( $a ) ) {
333 return '';
334 }
335
336 $s = wfMessage( 'otherlanguages' )->text() . wfMessage( 'colon-separator' )->text();
337 $first = true;
338
339 if ( $wgLang->isRTL() ) {
340 $s .= '<span dir="ltr">';
341 }
342
343 foreach ( $a as $l ) {
344 if ( !$first ) {
345 $s .= wfMessage( 'pipe-separator' )->escaped();
346 }
347
348 $first = false;
349
350 $nt = Title::newFromText( $l );
351 $text = Language::fetchLanguageName( $nt->getInterwiki() );
352
353 $s .= Html::element( 'a',
354 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
355 $text == '' ? $l : $text );
356 }
357
358 if ( $wgLang->isRTL() ) {
359 $s .= '</span>';
360 }
361
362 return $s;
363 }
364
365 /**
366 * Show a drop-down box of special pages
367 * @return string
368 */
369 function specialPagesList() {
370 global $wgScript;
371
372 $select = new XmlSelect( 'title' );
373 $pages = SpecialPageFactory::getUsablePages();
374 array_unshift( $pages, SpecialPageFactory::getPage( 'SpecialPages' ) );
375 foreach ( $pages as $obj ) {
376 $select->addOption( $obj->getDescription(),
377 $obj->getTitle()->getPrefixedDBkey() );
378 }
379
380 return Html::rawElement( 'form',
381 array( 'id' => 'specialpages', 'method' => 'get', 'action' => $wgScript ),
382 $select->getHTML() . Xml::submitButton( wfMessage( 'go' )->text() ) );
383 }
384
385 function pageTitleLinks() {
386 global $wgOut, $wgUser, $wgRequest, $wgLang;
387
388 $oldid = $wgRequest->getVal( 'oldid' );
389 $diff = $wgRequest->getVal( 'diff' );
390 $action = $wgRequest->getText( 'action' );
391
392 $skin = $this->getSkin();
393 $title = $skin->getTitle();
394
395 $s[] = $this->printableLink();
396 $disclaimer = $skin->disclaimerLink(); # may be empty
397
398 if ( $disclaimer ) {
399 $s[] = $disclaimer;
400 }
401
402 $privacy = $skin->privacyLink(); # may be empty too
403
404 if ( $privacy ) {
405 $s[] = $privacy;
406 }
407
408 if ( $wgOut->isArticleRelated() ) {
409 if ( $title->getNamespace() == NS_FILE ) {
410 $image = wfFindFile( $title );
411
412 if ( $image ) {
413 $href = $image->getURL();
414 $s[] = Html::element( 'a', array( 'href' => $href,
415 'title' => $href ), $title->getText() );
416
417 }
418 }
419 }
420
421 if ( 'history' == $action || isset( $diff ) || isset( $oldid ) ) {
422 $s[] .= Linker::linkKnown(
423 $title,
424 wfMessage( 'currentrev' )->text()
425 );
426 }
427
428 if ( $wgUser->getNewtalk() ) {
429 # do not show "You have new messages" text when we are viewing our
430 # own talk page
431 if ( !$title->equals( $wgUser->getTalkPage() ) ) {
432 $tl = Linker::linkKnown(
433 $wgUser->getTalkPage(),
434 wfMessage( 'newmessageslink' )->escaped(),
435 array(),
436 array( 'redirect' => 'no' )
437 );
438
439 $dl = Linker::linkKnown(
440 $wgUser->getTalkPage(),
441 wfMessage( 'newmessagesdifflink' )->escaped(),
442 array(),
443 array( 'diff' => 'cur' )
444 );
445 $s[] = '<strong>' . wfMessage( 'youhavenewmessages', $tl, $dl )->text() . '</strong>';
446 # disable caching
447 $wgOut->setSquidMaxage( 0 );
448 $wgOut->enableClientCache( false );
449 }
450 }
451
452 $undelete = $skin->getUndeleteLink();
453
454 if ( !empty( $undelete ) ) {
455 $s[] = $undelete;
456 }
457
458 return $wgLang->pipeList( $s );
459 }
460
461 /**
462 * Gets the h1 element with the page title.
463 * @return string
464 */
465 function pageTitle() {
466 global $wgOut;
467 $s = '<h1 class="pagetitle"><span dir="auto">' . $wgOut->getPageTitle() . '</span></h1>';
468 return $s;
469 }
470
471 function pageSubtitle() {
472 global $wgOut;
473
474 $sub = $wgOut->getSubtitle();
475
476 if ( $sub == '' ) {
477 global $wgExtraSubtitle;
478 $sub = wfMessage( 'tagline' )->parse() . $wgExtraSubtitle;
479 }
480
481 $subpages = $this->getSkin()->subPageSubtitle();
482 $sub .= !empty( $subpages ) ? "</p><p class='subpages'>$subpages" : '';
483 $s = "<p class='subtitle'>{$sub}</p>\n";
484
485 return $s;
486 }
487
488 function printableLink() {
489 global $wgOut, $wgRequest, $wgLang;
490
491 $s = array();
492
493 if ( !$wgOut->isPrintable() ) {
494 $printurl = htmlspecialchars( $this->getSkin()->getTitle()->getLocalURL(
495 $wgRequest->appendQueryValue( 'printable', 'yes', true ) ) );
496 $s[] = "<a href=\"$printurl\" rel=\"alternate\">"
497 . wfMessage( 'printableversion' )->text() . '</a>';
498 }
499
500 if ( $wgOut->isSyndicated() ) {
501 foreach ( $wgOut->getSyndicationLinks() as $format => $link ) {
502 $feedurl = htmlspecialchars( $link );
503 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
504 . " class=\"feedlink\">" . wfMessage( "feed-$format" )->escaped() . "</a>";
505 }
506 }
507 return $wgLang->pipeList( $s );
508 }
509
510 /**
511 * @deprecated in 1.19
512 * @return string
513 */
514 function getQuickbarCompensator( $rows = 1 ) {
515 wfDeprecated( __METHOD__, '1.19' );
516 return "<td style='width: 152px;' rowspan='{$rows}'>&#160;</td>";
517 }
518
519 function editThisPage() {
520 global $wgOut;
521
522 if ( !$wgOut->isArticleRelated() ) {
523 $s = wfMessage( 'protectedpage' )->text();
524 } else {
525 $title = $this->getSkin()->getTitle();
526 if ( $title->quickUserCan( 'edit' ) && $title->exists() ) {
527 $t = wfMessage( 'editthispage' )->text();
528 } elseif ( $title->quickUserCan( 'create' ) && !$title->exists() ) {
529 $t = wfMessage( 'create-this-page' )->text();
530 } else {
531 $t = wfMessage( 'viewsource' )->text();
532 }
533
534 $s = Linker::linkKnown(
535 $title,
536 $t,
537 array(),
538 $this->getSkin()->editUrlOptions()
539 );
540 }
541
542 return $s;
543 }
544
545 function deleteThisPage() {
546 global $wgUser, $wgRequest;
547
548 $diff = $wgRequest->getVal( 'diff' );
549 $title = $this->getSkin()->getTitle();
550
551 if ( $title->getArticleID() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
552 $t = wfMessage( 'deletethispage' )->text();
553
554 $s = Linker::linkKnown(
555 $title,
556 $t,
557 array(),
558 array( 'action' => 'delete' )
559 );
560 } else {
561 $s = '';
562 }
563
564 return $s;
565 }
566
567 function protectThisPage() {
568 global $wgUser, $wgRequest;
569
570 $diff = $wgRequest->getVal( 'diff' );
571 $title = $this->getSkin()->getTitle();
572
573 if ( $title->getArticleID() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) && $title->getRestrictionTypes() ) {
574 if ( $title->isProtected() ) {
575 $text = wfMessage( 'unprotectthispage' )->text();
576 $query = array( 'action' => 'unprotect' );
577 } else {
578 $text = wfMessage( 'protectthispage' )->text();
579 $query = array( 'action' => 'protect' );
580 }
581
582 $s = Linker::linkKnown(
583 $title,
584 $text,
585 array(),
586 $query
587 );
588 } else {
589 $s = '';
590 }
591
592 return $s;
593 }
594
595 function watchThisPage() {
596 global $wgOut, $wgUser;
597 ++$this->mWatchLinkNum;
598
599 // Cache
600 $title = $this->getSkin()->getTitle();
601
602 if ( $wgOut->isArticleRelated() ) {
603 if ( $wgUser->isWatched( $title ) ) {
604 $text = wfMessage( 'unwatchthispage' )->text();
605 $query = array(
606 'action' => 'unwatch',
607 'token' => UnwatchAction::getUnwatchToken( $title, $wgUser ),
608 );
609 $id = 'mw-unwatch-link' . $this->mWatchLinkNum;
610 } else {
611 $text = wfMessage( 'watchthispage' )->text();
612 $query = array(
613 'action' => 'watch',
614 'token' => WatchAction::getWatchToken( $title, $wgUser ),
615 );
616 $id = 'mw-watch-link' . $this->mWatchLinkNum;
617 }
618
619 $s = Linker::linkKnown(
620 $title,
621 $text,
622 array( 'id' => $id ),
623 $query
624 );
625 } else {
626 $s = wfMessage( 'notanarticle' )->text();
627 }
628
629 return $s;
630 }
631
632 function moveThisPage() {
633 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
634 return Linker::linkKnown(
635 SpecialPage::getTitleFor( 'Movepage' ),
636 wfMessage( 'movethispage' )->text(),
637 array(),
638 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() )
639 );
640 } else {
641 // no message if page is protected - would be redundant
642 return '';
643 }
644 }
645
646 function historyLink() {
647 return Linker::link(
648 $this->getSkin()->getTitle(),
649 wfMessage( 'history' )->escaped(),
650 array( 'rel' => 'archives' ),
651 array( 'action' => 'history' )
652 );
653 }
654
655 function whatLinksHere() {
656 return Linker::linkKnown(
657 SpecialPage::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
658 wfMessage( 'whatlinkshere' )->escaped()
659 );
660 }
661
662 function userContribsLink() {
663 return Linker::linkKnown(
664 SpecialPage::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
665 wfMessage( 'contributions' )->escaped()
666 );
667 }
668
669 function emailUserLink() {
670 return Linker::linkKnown(
671 SpecialPage::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
672 wfMessage( 'emailuser' )->escaped()
673 );
674 }
675
676 function watchPageLinksLink() {
677 global $wgOut;
678
679 if ( !$wgOut->isArticleRelated() ) {
680 return wfMessage( 'parentheses', wfMessage( 'notanarticle' )->text() )->escaped();
681 } else {
682 return Linker::linkKnown(
683 SpecialPage::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
684 wfMessage( 'recentchangeslinked-toolbox' )->escaped()
685 );
686 }
687 }
688
689 function talkLink() {
690 $title = $this->getSkin()->getTitle();
691 if ( NS_SPECIAL == $title->getNamespace() ) {
692 # No discussion links for special pages
693 return '';
694 }
695
696 $linkOptions = array();
697
698 if ( $title->isTalkPage() ) {
699 $link = $title->getSubjectPage();
700 switch( $link->getNamespace() ) {
701 case NS_MAIN:
702 $text = wfMessage( 'articlepage' );
703 break;
704 case NS_USER:
705 $text = wfMessage( 'userpage' );
706 break;
707 case NS_PROJECT:
708 $text = wfMessage( 'projectpage' );
709 break;
710 case NS_FILE:
711 $text = wfMessage( 'imagepage' );
712 # Make link known if image exists, even if the desc. page doesn't.
713 if ( wfFindFile( $link ) )
714 $linkOptions[] = 'known';
715 break;
716 case NS_MEDIAWIKI:
717 $text = wfMessage( 'mediawikipage' );
718 break;
719 case NS_TEMPLATE:
720 $text = wfMessage( 'templatepage' );
721 break;
722 case NS_HELP:
723 $text = wfMessage( 'viewhelppage' );
724 break;
725 case NS_CATEGORY:
726 $text = wfMessage( 'categorypage' );
727 break;
728 default:
729 $text = wfMessage( 'articlepage' );
730 }
731 } else {
732 $link = $title->getTalkPage();
733 $text = wfMessage( 'talkpage' );
734 }
735
736 $s = Linker::link( $link, $text->text(), array(), array(), $linkOptions );
737
738 return $s;
739 }
740
741 function commentLink() {
742 global $wgOut;
743
744 $title = $this->getSkin()->getTitle();
745 if ( $title->isSpecialPage() ) {
746 return '';
747 }
748
749 # __NEWSECTIONLINK___ changes behavior here
750 # If it is present, the link points to this page, otherwise
751 # it points to the talk page
752 if ( !$title->isTalkPage() && !$wgOut->showNewSectionLink() ) {
753 $title = $title->getTalkPage();
754 }
755
756 return Linker::linkKnown(
757 $title,
758 wfMessage( 'postcomment' )->text(),
759 array(),
760 array(
761 'action' => 'edit',
762 'section' => 'new'
763 )
764 );
765 }
766
767 function getUploadLink() {
768 global $wgUploadNavigationUrl;
769
770 if ( $wgUploadNavigationUrl ) {
771 # Using an empty class attribute to avoid automatic setting of "external" class
772 return Linker::makeExternalLink( $wgUploadNavigationUrl,
773 wfMessage( 'upload' )->escaped(),
774 false, null, array( 'class' => '' ) );
775 } else {
776 return Linker::linkKnown(
777 SpecialPage::getTitleFor( 'Upload' ),
778 wfMessage( 'upload' )->escaped()
779 );
780 }
781 }
782
783 function nameAndLogin() {
784 global $wgUser, $wgLang, $wgRequest;
785
786 $returnTo = $this->getSkin()->getTitle();
787 $ret = '';
788
789 if ( $wgUser->isAnon() ) {
790 if ( $this->getSkin()->showIPinHeader() ) {
791 $name = $wgRequest->getIP();
792
793 $talkLink = Linker::link( $wgUser->getTalkPage(),
794 $wgLang->getNsText( NS_TALK ) );
795 $talkLink = wfMessage( 'parentheses' )->rawParams( $talkLink )->escaped();
796
797 $ret .= "$name $talkLink";
798 } else {
799 $ret .= wfMessage( 'notloggedin' )->text();
800 }
801
802 $query = array();
803
804 if ( !$returnTo->isSpecial( 'Userlogout' ) ) {
805 $query['returnto'] = $returnTo->getPrefixedDBkey();
806 }
807
808 $loginlink = $wgUser->isAllowed( 'createaccount' )
809 ? 'nav-login-createaccount'
810 : 'login';
811 $ret .= "\n<br />" . Linker::link(
812 SpecialPage::getTitleFor( 'Userlogin' ),
813 wfMessage( $loginlink )->text(), array(), $query
814 );
815 } else {
816 $talkLink = Linker::link( $wgUser->getTalkPage(),
817 $wgLang->getNsText( NS_TALK ) );
818 $talkLink = wfMessage( 'parentheses' )->rawParams( $talkLink )->escaped();
819
820 $ret .= Linker::link( $wgUser->getUserPage(),
821 htmlspecialchars( $wgUser->getName() ) );
822 $ret .= " $talkLink<br />";
823 $ret .= $wgLang->pipeList( array(
824 Linker::link(
825 SpecialPage::getTitleFor( 'Userlogout' ), wfMessage( 'logout' )->text(),
826 array(), array( 'returnto' => $returnTo->getPrefixedDBkey() )
827 ),
828 Linker::specialLink( 'Preferences' ),
829 ) );
830 }
831
832 $ret = $wgLang->pipeList( array(
833 $ret,
834 Linker::link(
835 Title::newFromText( wfMessage( 'helppage' )->inContentLanguage()->text() ),
836 wfMessage( 'help' )->text()
837 ),
838 ) );
839
840 return $ret;
841 }
842 }