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