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