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