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