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