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