Revert r113650 and reapply r113619 and r113649 with one modification: User::createNew...
[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 * @return string
88 */
89 function beforeContent() {
90 return $this->doBeforeContent();
91 }
92
93 function doBeforeContent() {
94 global $wgLang;
95 wfProfileIn( __METHOD__ );
96
97 $s = '';
98
99 $langlinks = $this->otherLanguages();
100 if ( $langlinks ) {
101 $rows = 2;
102 $borderhack = '';
103 } else {
104 $rows = 1;
105 $langlinks = false;
106 $borderhack = 'class="top"';
107 }
108
109 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
110 "<table border='0' cellspacing='0' width='100%'>\n<tr>\n";
111
112 if ( $this->getSkin()->qbSetting() == 0 ) {
113 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
114 $this->getSkin()->logoText( $wgLang->alignStart() ) . '</td>';
115 }
116
117 $l = $wgLang->alignStart();
118 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
119
120 $s .= $this->topLinks();
121 $s .= '<p class="subtitle">' . $this->pageTitleLinks() . "</p>\n";
122
123 $r = $wgLang->alignEnd();
124 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
125 $s .= $this->nameAndLogin();
126 $s .= "\n<br />" . $this->searchForm() . '</td>';
127
128 if ( $langlinks ) {
129 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
130 }
131
132 $s .= "</tr>\n</table>\n</div>\n";
133 $s .= "\n<div id='article'>\n";
134
135 $notice = $this->getSkin()->getSiteNotice();
136
137 if ( $notice ) {
138 $s .= "\n<div id='siteNotice'>$notice</div>\n";
139 }
140 $s .= $this->pageTitle();
141 $s .= $this->pageSubtitle();
142 $s .= $this->getSkin()->getCategories();
143
144 wfProfileOut( __METHOD__ );
145 return $s;
146 }
147
148 /**
149 * This gets called shortly before the </body> tag.
150 * @return String HTML to be put before </body>
151 */
152 function afterContent() {
153 return $this->doAfterContent();
154 }
155
156 /** overloaded by derived classes
157 * @return string
158 */
159 function doAfterContent() {
160 return '</div></div>';
161 }
162
163 function searchForm() {
164 global $wgRequest, $wgUseTwoButtonsSearchForm;
165
166 $search = $wgRequest->getText( 'search' );
167
168 $s = '<form id="searchform' . $this->searchboxes . '" name="search" class="inline" method="post" action="'
169 . $this->getSkin()->escapeSearchLink() . "\">\n"
170 . '<input type="text" id="searchInput' . $this->searchboxes . '" name="search" size="19" value="'
171 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
172 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
173
174 if ( $wgUseTwoButtonsSearchForm ) {
175 $s .= '&#160;<input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
176 } else {
177 $s .= ' <a href="' . $this->getSkin()->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
178 }
179
180 $s .= '</form>';
181
182 // Ensure unique id's for search boxes made after the first
183 $this->searchboxes = $this->searchboxes == '' ? 2 : $this->searchboxes + 1;
184
185 return $s;
186 }
187
188 function pageStats() {
189 $ret = array();
190 $items = array( 'viewcount', 'credits', 'lastmod', 'numberofwatchingusers', 'copyright' );
191
192 foreach( $items as $item ) {
193 if ( $this->data[$item] !== false ) {
194 $ret[] = $this->data[$item];
195 }
196 }
197
198 return implode( ' ', $ret );
199 }
200
201 function topLinks() {
202 global $wgOut;
203
204 $s = array(
205 $this->getSkin()->mainPageLink(),
206 Linker::specialLink( 'Recentchanges' )
207 );
208
209 if ( $wgOut->isArticleRelated() ) {
210 $s[] = $this->editThisPage();
211 $s[] = $this->historyLink();
212 }
213
214 # Many people don't like this dropdown box
215 # $s[] = $this->specialPagesList();
216
217 if ( $this->variantLinks() ) {
218 $s[] = $this->variantLinks();
219 }
220
221 if ( $this->extensionTabLinks() ) {
222 $s[] = $this->extensionTabLinks();
223 }
224
225 // @todo FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
226 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
227 }
228
229 /**
230 * Language/charset variant links for classic-style skins
231 * @return string
232 */
233 function variantLinks() {
234 $s = '';
235
236 /* show links to different language variants */
237 global $wgDisableLangConversion, $wgLang;
238
239 $title = $this->getSkin()->getTitle();
240 $lang = $title->getPageLanguage();
241 $variants = $lang->getVariants();
242
243 if ( !$wgDisableLangConversion && sizeof( $variants ) > 1
244 && !$title->isSpecialPage() ) {
245 foreach ( $variants as $code ) {
246 $varname = $lang->getVariantname( $code );
247
248 if ( $varname == 'disable' ) {
249 continue;
250 }
251 $s = $wgLang->pipeList( array(
252 $s,
253 '<a href="' . htmlspecialchars( $title->getLocalURL( 'variant=' . $code ) ) . '" lang="' . $code . '" hreflang="' . $code . '">' . htmlspecialchars( $varname ) . '</a>'
254 ) );
255 }
256 }
257
258 return $s;
259 }
260
261 /**
262 * Compatibility for extensions adding functionality through tabs.
263 * Eventually these old skins should be replaced with SkinTemplate-based
264 * versions, sigh...
265 * @return string
266 * @todo Exterminate! ...that, and replace it with normal SkinTemplate stuff
267 */
268 function extensionTabLinks() {
269 $tabs = array();
270 $out = '';
271 $s = array();
272 wfRunHooks( 'SkinTemplateTabs', array( $this->getSkin(), &$tabs ) );
273 foreach ( $tabs as $tab ) {
274 $s[] = Xml::element( 'a',
275 array( 'href' => $tab['href'] ),
276 $tab['text'] );
277 }
278
279 if ( count( $s ) ) {
280 global $wgLang;
281
282 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
283 $out .= $wgLang->pipeList( $s );
284 }
285
286 return $out;
287 }
288
289 function bottomLinks() {
290 global $wgOut, $wgUser;
291 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
292
293 $s = '';
294 if ( $wgOut->isArticleRelated() ) {
295 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
296
297 if ( $wgUser->isLoggedIn() ) {
298 $element[] = $this->watchThisPage();
299 }
300
301 $element[] = $this->talkLink();
302 $element[] = $this->historyLink();
303 $element[] = $this->whatLinksHere();
304 $element[] = $this->watchPageLinksLink();
305
306 $title = $this->getSkin()->getTitle();
307
308 if (
309 $title->getNamespace() == NS_USER ||
310 $title->getNamespace() == NS_USER_TALK
311 ) {
312 $id = User::idFromName( $title->getText() );
313 $ip = User::isIP( $title->getText() );
314
315 # Both anons and non-anons have contributions list
316 if ( $id || $ip ) {
317 $element[] = $this->userContribsLink();
318 }
319
320 if ( $this->getSkin()->showEmailUser( $id ) ) {
321 $element[] = $this->emailUserLink();
322 }
323 }
324
325 $s = implode( $element, $sep );
326
327 if ( $title->getArticleID() ) {
328 $s .= "\n<br />";
329
330 // Delete/protect/move links for privileged users
331 if ( $wgUser->isAllowed( 'delete' ) ) {
332 $s .= $this->deleteThisPage();
333 }
334
335 if ( $wgUser->isAllowed( 'protect' ) ) {
336 $s .= $sep . $this->protectThisPage();
337 }
338
339 if ( $wgUser->isAllowed( 'move' ) ) {
340 $s .= $sep . $this->moveThisPage();
341 }
342 }
343
344 $s .= "<br />\n" . $this->otherLanguages();
345 }
346
347 return $s;
348 }
349
350 function otherLanguages() {
351 global $wgOut, $wgLang, $wgHideInterlanguageLinks;
352
353 if ( $wgHideInterlanguageLinks ) {
354 return '';
355 }
356
357 $a = $wgOut->getLanguageLinks();
358
359 if ( 0 == count( $a ) ) {
360 return '';
361 }
362
363 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
364 $first = true;
365
366 if ( $wgLang->isRTL() ) {
367 $s .= '<span dir="ltr">';
368 }
369
370 foreach ( $a as $l ) {
371 if ( !$first ) {
372 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
373 }
374
375 $first = false;
376
377 $nt = Title::newFromText( $l );
378 $text = Language::fetchLanguageName( $nt->getInterwiki() );
379
380 $s .= Html::element( 'a',
381 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
382 $text == '' ? $l : $text );
383 }
384
385 if ( $wgLang->isRTL() ) {
386 $s .= '</span>';
387 }
388
389 return $s;
390 }
391
392 /**
393 * Show a drop-down box of special pages
394 * @return string
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"><span dir="auto">' . $wgOut->getPageTitle() . '</span></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 * @return string
538 */
539 function getQuickbarCompensator( $rows = 1 ) {
540 wfDeprecated( __METHOD__, '1.19' );
541 return "<td width='152' rowspan='{$rows}'>&#160;</td>";
542 }
543
544 function editThisPage() {
545 global $wgOut;
546
547 if ( !$wgOut->isArticleRelated() ) {
548 $s = wfMsg( 'protectedpage' );
549 } else {
550 $title = $this->getSkin()->getTitle();
551 if ( $title->quickUserCan( 'edit' ) && $title->exists() ) {
552 $t = wfMsg( 'editthispage' );
553 } elseif ( $title->quickUserCan( 'create' ) && !$title->exists() ) {
554 $t = wfMsg( 'create-this-page' );
555 } else {
556 $t = wfMsg( 'viewsource' );
557 }
558
559 $s = Linker::linkKnown(
560 $title,
561 $t,
562 array(),
563 $this->getSkin()->editUrlOptions()
564 );
565 }
566
567 return $s;
568 }
569
570 function deleteThisPage() {
571 global $wgUser, $wgRequest;
572
573 $diff = $wgRequest->getVal( 'diff' );
574 $title = $this->getSkin()->getTitle();
575
576 if ( $title->getArticleID() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
577 $t = wfMsg( 'deletethispage' );
578
579 $s = Linker::linkKnown(
580 $title,
581 $t,
582 array(),
583 array( 'action' => 'delete' )
584 );
585 } else {
586 $s = '';
587 }
588
589 return $s;
590 }
591
592 function protectThisPage() {
593 global $wgUser, $wgRequest;
594
595 $diff = $wgRequest->getVal( 'diff' );
596 $title = $this->getSkin()->getTitle();
597
598 if ( $title->getArticleID() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
599 if ( $title->isProtected() ) {
600 $text = wfMsg( 'unprotectthispage' );
601 $query = array( 'action' => 'unprotect' );
602 } else {
603 $text = wfMsg( 'protectthispage' );
604 $query = array( 'action' => 'protect' );
605 }
606
607 $s = Linker::linkKnown(
608 $title,
609 $text,
610 array(),
611 $query
612 );
613 } else {
614 $s = '';
615 }
616
617 return $s;
618 }
619
620 function watchThisPage() {
621 global $wgOut, $wgUser;
622 ++$this->mWatchLinkNum;
623
624 // Cache
625 $title = $this->getSkin()->getTitle();
626
627 if ( $wgOut->isArticleRelated() ) {
628 if ( $title->userIsWatching() ) {
629 $text = wfMsg( 'unwatchthispage' );
630 $query = array(
631 'action' => 'unwatch',
632 'token' => UnwatchAction::getUnwatchToken( $title, $wgUser ),
633 );
634 $id = 'mw-unwatch-link' . $this->mWatchLinkNum;
635 } else {
636 $text = wfMsg( 'watchthispage' );
637 $query = array(
638 'action' => 'watch',
639 'token' => WatchAction::getWatchToken( $title, $wgUser ),
640 );
641 $id = 'mw-watch-link' . $this->mWatchLinkNum;
642 }
643
644 $s = Linker::linkKnown(
645 $title,
646 $text,
647 array( 'id' => $id ),
648 $query
649 );
650 } else {
651 $s = wfMsg( 'notanarticle' );
652 }
653
654 return $s;
655 }
656
657 function moveThisPage() {
658 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
659 return Linker::linkKnown(
660 SpecialPage::getTitleFor( 'Movepage' ),
661 wfMsg( 'movethispage' ),
662 array(),
663 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() )
664 );
665 } else {
666 // no message if page is protected - would be redundant
667 return '';
668 }
669 }
670
671 function historyLink() {
672 return Linker::link(
673 $this->getSkin()->getTitle(),
674 wfMsgHtml( 'history' ),
675 array( 'rel' => 'archives' ),
676 array( 'action' => 'history' )
677 );
678 }
679
680 function whatLinksHere() {
681 return Linker::linkKnown(
682 SpecialPage::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
683 wfMsgHtml( 'whatlinkshere' )
684 );
685 }
686
687 function userContribsLink() {
688 return Linker::linkKnown(
689 SpecialPage::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
690 wfMsgHtml( 'contributions' )
691 );
692 }
693
694 function emailUserLink() {
695 return Linker::linkKnown(
696 SpecialPage::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
697 wfMsgHtml( 'emailuser' )
698 );
699 }
700
701 function watchPageLinksLink() {
702 global $wgOut;
703
704 if ( !$wgOut->isArticleRelated() ) {
705 return wfMessage( 'parentheses', wfMessage( 'notanarticle' )->text() )->escaped();
706 } else {
707 return Linker::linkKnown(
708 SpecialPage::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
709 wfMsgHtml( 'recentchangeslinked-toolbox' )
710 );
711 }
712 }
713
714 function talkLink() {
715 $title = $this->getSkin()->getTitle();
716 if ( NS_SPECIAL == $title->getNamespace() ) {
717 # No discussion links for special pages
718 return '';
719 }
720
721 $linkOptions = array();
722
723 if ( $title->isTalkPage() ) {
724 $link = $title->getSubjectPage();
725 switch( $link->getNamespace() ) {
726 case NS_MAIN:
727 $text = wfMsg( 'articlepage' );
728 break;
729 case NS_USER:
730 $text = wfMsg( 'userpage' );
731 break;
732 case NS_PROJECT:
733 $text = wfMsg( 'projectpage' );
734 break;
735 case NS_FILE:
736 $text = wfMsg( 'imagepage' );
737 # Make link known if image exists, even if the desc. page doesn't.
738 if ( wfFindFile( $link ) )
739 $linkOptions[] = 'known';
740 break;
741 case NS_MEDIAWIKI:
742 $text = wfMsg( 'mediawikipage' );
743 break;
744 case NS_TEMPLATE:
745 $text = wfMsg( 'templatepage' );
746 break;
747 case NS_HELP:
748 $text = wfMsg( 'viewhelppage' );
749 break;
750 case NS_CATEGORY:
751 $text = wfMsg( 'categorypage' );
752 break;
753 default:
754 $text = wfMsg( 'articlepage' );
755 }
756 } else {
757 $link = $title->getTalkPage();
758 $text = wfMsg( 'talkpage' );
759 }
760
761 $s = Linker::link( $link, $text, array(), array(), $linkOptions );
762
763 return $s;
764 }
765
766 function commentLink() {
767 global $wgOut;
768
769 $title = $this->getSkin()->getTitle();
770 if ( $title->isSpecialPage() ) {
771 return '';
772 }
773
774 # __NEWSECTIONLINK___ changes behaviour here
775 # If it is present, the link points to this page, otherwise
776 # it points to the talk page
777 if ( !$title->isTalkPage() && !$wgOut->showNewSectionLink() ) {
778 $title = $title->getTalkPage();
779 }
780
781 return Linker::linkKnown(
782 $title,
783 wfMsg( 'postcomment' ),
784 array(),
785 array(
786 'action' => 'edit',
787 'section' => 'new'
788 )
789 );
790 }
791
792 function getUploadLink() {
793 global $wgUploadNavigationUrl;
794
795 if ( $wgUploadNavigationUrl ) {
796 # Using an empty class attribute to avoid automatic setting of "external" class
797 return Linker::makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '' ) );
798 } else {
799 return Linker::linkKnown(
800 SpecialPage::getTitleFor( 'Upload' ),
801 wfMsgHtml( 'upload' )
802 );
803 }
804 }
805
806 function nameAndLogin() {
807 global $wgUser, $wgLang, $wgRequest;
808
809 $returnTo = $this->getSkin()->getTitle();
810 $ret = '';
811
812 if ( $wgUser->isAnon() ) {
813 if ( $this->getSkin()->showIPinHeader() ) {
814 $name = $wgRequest->getIP();
815
816 $talkLink = Linker::link( $wgUser->getTalkPage(),
817 $wgLang->getNsText( NS_TALK ) );
818 $talkLink = wfMessage( 'parentheses' )->rawParams( $talkLink )->escaped();
819
820 $ret .= "$name $talkLink";
821 } else {
822 $ret .= wfMsg( 'notloggedin' );
823 }
824
825 $query = array();
826
827 if ( !$returnTo->isSpecial( 'Userlogout' ) ) {
828 $query['returnto'] = $returnTo->getPrefixedDBkey();
829 }
830
831 $loginlink = $wgUser->isAllowed( 'createaccount' )
832 ? 'nav-login-createaccount'
833 : 'login';
834 $ret .= "\n<br />" . Linker::link(
835 SpecialPage::getTitleFor( 'Userlogin' ),
836 wfMsg( $loginlink ), array(), $query
837 );
838 } else {
839 $talkLink = Linker::link( $wgUser->getTalkPage(),
840 $wgLang->getNsText( NS_TALK ) );
841 $talkLink = wfMessage( 'parentheses' )->rawParams( $talkLink )->escaped();
842
843 $ret .= Linker::link( $wgUser->getUserPage(),
844 htmlspecialchars( $wgUser->getName() ) );
845 $ret .= " $talkLink<br />";
846 $ret .= $wgLang->pipeList( array(
847 Linker::link(
848 SpecialPage::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
849 array(), array( 'returnto' => $returnTo->getPrefixedDBkey() )
850 ),
851 Linker::specialLink( 'Preferences' ),
852 ) );
853 }
854
855 $ret = $wgLang->pipeList( array(
856 $ret,
857 Linker::link(
858 Title::newFromText( wfMsgForContent( 'helppage' ) ),
859 wfMsg( 'help' )
860 ),
861 ) );
862
863 return $ret;
864 }
865 }