minor typo in comment
[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
13 /**
14 * Add skin specific stylesheets
15 * @param $out OutputPage
16 */
17 function setupSkinUserCss( OutputPage $out ) {
18 $out->addModuleStyles( 'mediawiki.legacy.shared' );
19 $out->addModuleStyles( 'mediawiki.legacy.oldshared' );
20 }
21
22 public function commonPrintStylesheet() {
23 return true;
24 }
25
26 /**
27 * This was for the old skins and for users with 640x480 screen.
28 * Please note old skins are still used and might prove useful for
29 * users having old computers or visually impaired.
30 */
31 var $mSuppressQuickbar = false;
32
33 /**
34 * Suppress the quickbar from the output, only for skin supporting
35 * the quickbar
36 */
37 public function suppressQuickbar() {
38 $this->mSuppressQuickbar = true;
39 }
40
41 /**
42 * Return whether the quickbar should be suppressed from the output
43 *
44 * @return Boolean
45 */
46 public function isQuickbarSuppressed() {
47 return $this->mSuppressQuickbar;
48 }
49
50 function qbSetting() {
51 global $wgOut, $wgUser;
52 if ( $this->isQuickbarSuppressed() ) {
53 return 0;
54 }
55 $q = $wgUser->getOption( 'quickbar', 0 );
56 return $q;
57 }
58
59 }
60
61 class LegacyTemplate extends BaseTemplate {
62
63 // How many search boxes have we made? Avoid duplicate id's.
64 protected $searchboxes = '';
65
66 function execute() {
67 $this->html( 'headelement' );
68 echo $this->beforeContent();
69 $this->html( 'bodytext' );
70 echo "\n";
71 echo $this->afterContent();
72 $this->html( 'dataAfterContent' );
73 $this->printTrail();
74 echo "\n</body></html>";
75 }
76
77 /**
78 * This will be called immediately after the <body> tag. Split into
79 * two functions to make it easier to subclass.
80 */
81 function beforeContent() {
82 return $this->doBeforeContent();
83 }
84
85 function doBeforeContent() {
86 global $wgContLang;
87 wfProfileIn( __METHOD__ );
88
89 $s = '';
90 $qb = $this->getSkin()->qbSetting();
91
92 $langlinks = $this->otherLanguages();
93 if ( $langlinks ) {
94 $rows = 2;
95 $borderhack = '';
96 } else {
97 $rows = 1;
98 $langlinks = false;
99 $borderhack = 'class="top"';
100 }
101
102 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
103 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
104
105 $shove = ( $qb != 0 );
106 $left = ( $qb == 1 || $qb == 3 );
107
108 if ( !$shove ) {
109 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
110 $this->logoText() . '</td>';
111 } elseif ( $left ) {
112 $s .= $this->getQuickbarCompensator( $rows );
113 }
114
115 $l = $wgContLang->alignStart();
116 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
117
118 $s .= $this->topLinks();
119 $s .= '<p class="subtitle">' . $this->pageTitleLinks() . "</p>\n";
120
121 $r = $wgContLang->alignEnd();
122 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
123 $s .= $this->nameAndLogin();
124 $s .= "\n<br />" . $this->searchForm() . '</td>';
125
126 if ( $langlinks ) {
127 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
128 }
129
130 if ( $shove && !$left ) { # Right
131 $s .= $this->getQuickbarCompensator( $rows );
132 }
133
134 $s .= "</tr>\n</table>\n</div>\n";
135 $s .= "\n<div id='article'>\n";
136
137 $notice = wfGetSiteNotice();
138
139 if ( $notice ) {
140 $s .= "\n<div id='siteNotice'>$notice</div>\n";
141 }
142 $s .= $this->pageTitle();
143 $s .= $this->pageSubtitle();
144 $s .= $this->getSkin()->getCategories();
145
146 wfProfileOut( __METHOD__ );
147 return $s;
148 }
149
150 /**
151 * This gets called shortly before the </body> tag.
152 * @return String HTML to be put before </body>
153 */
154 function afterContent() {
155 return $this->doAfterContent();
156 }
157
158 /** overloaded by derived classes */
159 function doAfterContent() {
160 return '</div></div>';
161 }
162
163 function searchForm() {
164 global $wgRequest, $wgUseTwoButtonsSearchForm;
165
166 $search = $wgRequest->getText( 'search' );
167
168 $s = '<form id="searchform' . $this->searchboxes . '" name="search" class="inline" method="post" action="'
169 . $this->getSkin()->escapeSearchLink() . "\">\n"
170 . '<input type="text" id="searchInput' . $this->searchboxes . '" name="search" size="19" value="'
171 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
172 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
173
174 if ( $wgUseTwoButtonsSearchForm ) {
175 $s .= '&#160;<input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
176 } else {
177 $s .= ' <a href="' . $this->getSkin()->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
178 }
179
180 $s .= '</form>';
181
182 // Ensure unique id's for search boxes made after the first
183 $this->searchboxes = $this->searchboxes == '' ? 2 : $this->searchboxes + 1;
184
185 return $s;
186 }
187
188 function pageStats() {
189 global $wgOut, $wgLang, $wgRequest, $wgUser;
190 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
191
192 if ( !is_null( $wgRequest->getVal( 'oldid' ) ) || !is_null( $wgRequest->getVal( 'diff' ) ) ) {
193 return '';
194 }
195
196 if ( !$wgOut->isArticle() || !$this->getSkin()->getTitle()->exists() ) {
197 return '';
198 }
199
200 $article = new Article( $this->getSkin()->getTitle(), 0 );
201
202 $s = '';
203
204 if ( !$wgDisableCounters ) {
205 $count = $wgLang->formatNum( $article->getCount() );
206
207 if ( $count ) {
208 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
209 }
210 }
211
212 if ( $wgMaxCredits != 0 ) {
213 $s .= ' ' . Credits::getCredits( $article, $wgMaxCredits, $wgShowCreditsIfMax );
214 } else {
215 $s .= $this->data['lastmod'];
216 }
217
218 if ( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
219 $dbr = wfGetDB( DB_SLAVE );
220 $res = $dbr->select(
221 'watchlist',
222 array( 'COUNT(*) AS n' ),
223 array(
224 'wl_title' => $dbr->strencode( $this->getSkin()->getTitle()->getDBkey() ),
225 'wl_namespace' => $this->getSkin()->getTitle()->getNamespace()
226 ),
227 __METHOD__
228 );
229 $x = $dbr->fetchObject( $res );
230
231 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
232 array( 'parseinline' ), $wgLang->formatNum( $x->n )
233 );
234 }
235
236 return $s . ' ' . $this->getSkin()->getCopyright();
237 }
238
239 function topLinks() {
240 global $wgOut;
241
242 $s = array(
243 $this->getSkin()->mainPageLink(),
244 $this->getSkin()->specialLink( 'Recentchanges' )
245 );
246
247 if ( $wgOut->isArticleRelated() ) {
248 $s[] = $this->editThisPage();
249 $s[] = $this->historyLink();
250 }
251
252 # Many people don't like this dropdown box
253 # $s[] = $this->specialPagesList();
254
255 if ( $this->variantLinks() ) {
256 $s[] = $this->variantLinks();
257 }
258
259 if ( $this->extensionTabLinks() ) {
260 $s[] = $this->extensionTabLinks();
261 }
262
263 // @todo FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
264 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
265 }
266
267 /**
268 * Language/charset variant links for classic-style skins
269 * @return string
270 */
271 function variantLinks() {
272 $s = '';
273
274 /* show links to different language variants */
275 global $wgDisableLangConversion, $wgLang, $wgContLang;
276
277 $variants = $wgContLang->getVariants();
278
279 if ( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
280 foreach ( $variants as $code ) {
281 $varname = $wgContLang->getVariantname( $code );
282
283 if ( $varname == 'disable' ) {
284 continue;
285 }
286 $s = $wgLang->pipeList( array(
287 $s,
288 '<a href="' . $this->getSkin()->getTitle()->escapeLocalURL( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
289 ) );
290 }
291 }
292
293 return $s;
294 }
295
296 /**
297 * Compatibility for extensions adding functionality through tabs.
298 * Eventually these old skins should be replaced with SkinTemplate-based
299 * versions, sigh...
300 * @return string
301 * @todo Exterminate! ...that, and replace it with normal SkinTemplate stuff
302 */
303 function extensionTabLinks() {
304 $tabs = array();
305 $out = '';
306 $s = array();
307 wfRunHooks( 'SkinTemplateTabs', array( $this->getSkin(), &$tabs ) );
308 foreach ( $tabs as $tab ) {
309 $s[] = Xml::element( 'a',
310 array( 'href' => $tab['href'] ),
311 $tab['text'] );
312 }
313
314 if ( count( $s ) ) {
315 global $wgLang;
316
317 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
318 $out .= $wgLang->pipeList( $s );
319 }
320
321 return $out;
322 }
323
324 function bottomLinks() {
325 global $wgOut, $wgUser, $wgUseTrackbacks;
326 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
327
328 $s = '';
329 if ( $wgOut->isArticleRelated() ) {
330 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
331
332 if ( $wgUser->isLoggedIn() ) {
333 $element[] = $this->watchThisPage();
334 }
335
336 $element[] = $this->talkLink();
337 $element[] = $this->historyLink();
338 $element[] = $this->whatLinksHere();
339 $element[] = $this->watchPageLinksLink();
340
341 if ( $wgUseTrackbacks ) {
342 $element[] = $this->trackbackLink();
343 }
344
345 if (
346 $this->getSkin()->getTitle()->getNamespace() == NS_USER ||
347 $this->getSkin()->getTitle()->getNamespace() == NS_USER_TALK
348 ) {
349 $id = User::idFromName( $this->getSkin()->getTitle()->getText() );
350 $ip = User::isIP( $this->getSkin()->getTitle()->getText() );
351
352 # Both anons and non-anons have contributions list
353 if ( $id || $ip ) {
354 $element[] = $this->userContribsLink();
355 }
356
357 if ( $this->getSkin()->showEmailUser( $id ) ) {
358 $element[] = $this->emailUserLink();
359 }
360 }
361
362 $s = implode( $element, $sep );
363
364 if ( $this->getSkin()->getTitle()->getArticleId() ) {
365 $s .= "\n<br />";
366
367 // Delete/protect/move links for privileged users
368 if ( $wgUser->isAllowed( 'delete' ) ) {
369 $s .= $this->deleteThisPage();
370 }
371
372 if ( $wgUser->isAllowed( 'protect' ) ) {
373 $s .= $sep . $this->protectThisPage();
374 }
375
376 if ( $wgUser->isAllowed( 'move' ) ) {
377 $s .= $sep . $this->moveThisPage();
378 }
379 }
380
381 $s .= "<br />\n" . $this->otherLanguages();
382 }
383
384 return $s;
385 }
386
387 function otherLanguages() {
388 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
389
390 if ( $wgHideInterlanguageLinks ) {
391 return '';
392 }
393
394 $a = $wgOut->getLanguageLinks();
395
396 if ( 0 == count( $a ) ) {
397 return '';
398 }
399
400 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
401 $first = true;
402
403 if ( $wgContLang->isRTL() ) {
404 $s .= '<span dir="LTR">';
405 }
406
407 foreach ( $a as $l ) {
408 if ( !$first ) {
409 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
410 }
411
412 $first = false;
413
414 $nt = Title::newFromText( $l );
415 $url = $nt->escapeFullURL();
416 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
417 $title = htmlspecialchars( $nt->getText() );
418
419 if ( $text == '' ) {
420 $text = $l;
421 }
422
423 $style = $this->getExternalLinkAttributes();
424 $s .= "<a href=\"{$url}\" title=\"{$title}\"{$style}>{$text}</a>";
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 = array_merge( SpecialPage::getRegularPages(), SpecialPage::getRestrictedPages() );
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, $wgFeedClasses, $wgRequest, $wgLang;
575
576 $s = array();
577
578 if ( !$wgOut->isPrintable() ) {
579 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
580 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
581 }
582
583 if ( $wgOut->isSyndicated() ) {
584 foreach ( $wgFeedClasses as $format => $class ) {
585 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
586 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
587 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
588 }
589 }
590 return $wgLang->pipeList( $s );
591 }
592
593 function getQuickbarCompensator( $rows = 1 ) {
594 return "<td width='152' rowspan='{$rows}'>&#160;</td>";
595 }
596
597 function editThisPage() {
598 global $wgOut;
599
600 if ( !$wgOut->isArticleRelated() ) {
601 $s = wfMsg( 'protectedpage' );
602 } else {
603 if ( $this->getSkin()->getTitle()->quickUserCan( 'edit' ) && $this->getSkin()->getTitle()->exists() ) {
604 $t = wfMsg( 'editthispage' );
605 } elseif ( $this->getSkin()->getTitle()->quickUserCan( 'create' ) && !$this->getSkin()->getTitle()->exists() ) {
606 $t = wfMsg( 'create-this-page' );
607 } else {
608 $t = wfMsg( 'viewsource' );
609 }
610
611 $s = $this->getSkin()->link(
612 $this->getSkin()->getTitle(),
613 $t,
614 array(),
615 $this->getSkin()->editUrlOptions(),
616 array( 'known', 'noclasses' )
617 );
618 }
619
620 return $s;
621 }
622
623 function deleteThisPage() {
624 global $wgUser, $wgRequest;
625
626 $diff = $wgRequest->getVal( 'diff' );
627
628 if ( $this->getSkin()->getTitle()->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
629 $t = wfMsg( 'deletethispage' );
630
631 $s = $this->getSkin()->link(
632 $this->getSkin()->getTitle(),
633 $t,
634 array(),
635 array( 'action' => 'delete' ),
636 array( 'known', 'noclasses' )
637 );
638 } else {
639 $s = '';
640 }
641
642 return $s;
643 }
644
645 function protectThisPage() {
646 global $wgUser, $wgRequest;
647
648 $diff = $wgRequest->getVal( 'diff' );
649
650 if ( $this->getSkin()->getTitle()->getArticleId() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
651 if ( $this->getSkin()->getTitle()->isProtected() ) {
652 $text = wfMsg( 'unprotectthispage' );
653 $query = array( 'action' => 'unprotect' );
654 } else {
655 $text = wfMsg( 'protectthispage' );
656 $query = array( 'action' => 'protect' );
657 }
658
659 $s = $this->getSkin()->link(
660 $this->getSkin()->getTitle(),
661 $text,
662 array(),
663 $query,
664 array( 'known', 'noclasses' )
665 );
666 } else {
667 $s = '';
668 }
669
670 return $s;
671 }
672
673 function watchThisPage() {
674 global $wgOut;
675 ++$this->mWatchLinkNum;
676
677 if ( $wgOut->isArticleRelated() ) {
678 if ( $this->getSkin()->getTitle()->userIsWatching() ) {
679 $text = wfMsg( 'unwatchthispage' );
680 $query = array( 'action' => 'unwatch' );
681 $id = 'mw-unwatch-link' . $this->mWatchLinkNum;
682 } else {
683 $text = wfMsg( 'watchthispage' );
684 $query = array( 'action' => 'watch' );
685 $id = 'mw-watch-link' . $this->mWatchLinkNum;
686 }
687
688 $s = $this->getSkin()->link(
689 $this->getSkin()->getTitle(),
690 $text,
691 array( 'id' => $id ),
692 $query,
693 array( 'known', 'noclasses' )
694 );
695 } else {
696 $s = wfMsg( 'notanarticle' );
697 }
698
699 return $s;
700 }
701
702 function moveThisPage() {
703 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
704 return $this->getSkin()->link(
705 SpecialPage::getTitleFor( 'Movepage' ),
706 wfMsg( 'movethispage' ),
707 array(),
708 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() ),
709 array( 'known', 'noclasses' )
710 );
711 } else {
712 // no message if page is protected - would be redundant
713 return '';
714 }
715 }
716
717 function historyLink() {
718 return $this->getSkin()->link(
719 $this->getSkin()->getTitle(),
720 wfMsgHtml( 'history' ),
721 array( 'rel' => 'archives' ),
722 array( 'action' => 'history' )
723 );
724 }
725
726 function whatLinksHere() {
727 return $this->getSkin()->link(
728 SpecialPage::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
729 wfMsgHtml( 'whatlinkshere' ),
730 array(),
731 array(),
732 array( 'known', 'noclasses' )
733 );
734 }
735
736 function userContribsLink() {
737 return $this->getSkin()->link(
738 SpecialPage::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
739 wfMsgHtml( 'contributions' ),
740 array(),
741 array(),
742 array( 'known', 'noclasses' )
743 );
744 }
745
746 function emailUserLink() {
747 return $this->getSkin()->link(
748 SpecialPage::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
749 wfMsg( 'emailuser' ),
750 array(),
751 array(),
752 array( 'known', 'noclasses' )
753 );
754 }
755
756 function watchPageLinksLink() {
757 global $wgOut;
758
759 if ( !$wgOut->isArticleRelated() ) {
760 return '(' . wfMsg( 'notanarticle' ) . ')';
761 } else {
762 return $this->getSkin()->link(
763 SpecialPage::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
764 wfMsg( 'recentchangeslinked-toolbox' ),
765 array(),
766 array(),
767 array( 'known', 'noclasses' )
768 );
769 }
770 }
771
772 function trackbackLink() {
773 return '<a href="' . $this->getSkin()->getTitle()->trackbackURL() . '">'
774 . wfMsg( 'trackbacklink' ) . '</a>';
775 }
776
777 function talkLink() {
778 if ( NS_SPECIAL == $this->getSkin()->getTitle()->getNamespace() ) {
779 # No discussion links for special pages
780 return '';
781 }
782
783 $linkOptions = array();
784
785 if ( $this->getSkin()->getTitle()->isTalkPage() ) {
786 $link = $this->getSkin()->getTitle()->getSubjectPage();
787 switch( $link->getNamespace() ) {
788 case NS_MAIN:
789 $text = wfMsg( 'articlepage' );
790 break;
791 case NS_USER:
792 $text = wfMsg( 'userpage' );
793 break;
794 case NS_PROJECT:
795 $text = wfMsg( 'projectpage' );
796 break;
797 case NS_FILE:
798 $text = wfMsg( 'imagepage' );
799 # Make link known if image exists, even if the desc. page doesn't.
800 if ( wfFindFile( $link ) )
801 $linkOptions[] = 'known';
802 break;
803 case NS_MEDIAWIKI:
804 $text = wfMsg( 'mediawikipage' );
805 break;
806 case NS_TEMPLATE:
807 $text = wfMsg( 'templatepage' );
808 break;
809 case NS_HELP:
810 $text = wfMsg( 'viewhelppage' );
811 break;
812 case NS_CATEGORY:
813 $text = wfMsg( 'categorypage' );
814 break;
815 default:
816 $text = wfMsg( 'articlepage' );
817 }
818 } else {
819 $link = $this->getSkin()->getTitle()->getTalkPage();
820 $text = wfMsg( 'talkpage' );
821 }
822
823 $s = $this->getSkin()->link( $link, $text, array(), array(), $linkOptions );
824
825 return $s;
826 }
827
828 function commentLink() {
829 global $wgOut;
830
831 if ( $this->getSkin()->getTitle()->getNamespace() == NS_SPECIAL ) {
832 return '';
833 }
834
835 # __NEWSECTIONLINK___ changes behaviour here
836 # If it is present, the link points to this page, otherwise
837 # it points to the talk page
838 if ( $this->getSkin()->getTitle()->isTalkPage() ) {
839 $title = $this->getSkin()->getTitle();
840 } elseif ( $wgOut->showNewSectionLink() ) {
841 $title = $this->getSkin()->getTitle();
842 } else {
843 $title = $this->getSkin()->getTitle()->getTalkPage();
844 }
845
846 return $this->getSkin()->link(
847 $title,
848 wfMsg( 'postcomment' ),
849 array(),
850 array(
851 'action' => 'edit',
852 'section' => 'new'
853 ),
854 array( 'known', 'noclasses' )
855 );
856 }
857
858 function getUploadLink() {
859 global $wgUploadNavigationUrl;
860
861 if ( $wgUploadNavigationUrl ) {
862 # Using an empty class attribute to avoid automatic setting of "external" class
863 return $this->makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '' ) );
864 } else {
865 return $this->getSkin()->link(
866 SpecialPage::getTitleFor( 'Upload' ),
867 wfMsgHtml( 'upload' ),
868 array(),
869 array(),
870 array( 'known', 'noclasses' )
871 );
872 }
873 }
874
875 function nameAndLogin() {
876 global $wgUser, $wgLang, $wgContLang;
877
878 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
879
880 $ret = '';
881
882 if ( $wgUser->isAnon() ) {
883 if ( $this->getSkin()->showIPinHeader() ) {
884 $name = wfGetIP();
885
886 $talkLink = $this->getSkin()->link( $wgUser->getTalkPage(),
887 $wgLang->getNsText( NS_TALK ) );
888
889 $ret .= "$name ($talkLink)";
890 } else {
891 $ret .= wfMsg( 'notloggedin' );
892 }
893
894 $returnTo = $this->getSkin()->getTitle()->getPrefixedDBkey();
895 $query = array();
896
897 if ( $logoutPage != $returnTo ) {
898 $query['returnto'] = $returnTo;
899 }
900
901 $loginlink = $wgUser->isAllowed( 'createaccount' )
902 ? 'nav-login-createaccount'
903 : 'login';
904 $ret .= "\n<br />" . $this->getSkin()->link(
905 SpecialPage::getTitleFor( 'Userlogin' ),
906 wfMsg( $loginlink ), array(), $query
907 );
908 } else {
909 $returnTo = $this->getSkin()->getTitle()->getPrefixedDBkey();
910 $talkLink = $this->getSkin()->link( $wgUser->getTalkPage(),
911 $wgLang->getNsText( NS_TALK ) );
912
913 $ret .= $this->getSkin()->link( $wgUser->getUserPage(),
914 htmlspecialchars( $wgUser->getName() ) );
915 $ret .= " ($talkLink)<br />";
916 $ret .= $wgLang->pipeList( array(
917 $this->getSkin()->link(
918 SpecialPage::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
919 array(), array( 'returnto' => $returnTo )
920 ),
921 $this->getSkin()->specialLink( 'Preferences' ),
922 ) );
923 }
924
925 $ret = $wgLang->pipeList( array(
926 $ret,
927 $this->getSkin()->link(
928 Title::newFromText( wfMsgForContent( 'helppage' ) ),
929 wfMsg( 'help' )
930 ),
931 ) );
932
933 return $ret;
934 }
935
936 }
937