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