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