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