* Follow-up r84610: don't assume a Parser object is attached
[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 $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->getSkin()->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 = $this->getSkin()->getSiteNotice();
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 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
416
417 $s .= Html::element( 'a',
418 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
419 $text == '' ? $l : $text );
420 }
421
422 if ( $wgContLang->isRTL() ) {
423 $s .= '</span>';
424 }
425
426 return $s;
427 }
428
429 /**
430 * Show a drop-down box of special pages
431 */
432 function specialPagesList() {
433 global $wgContLang, $wgServer, $wgRedirectScript;
434
435 $pages = array_merge( SpecialPage::getRegularPages(), SpecialPage::getRestrictedPages() );
436
437 foreach ( $pages as $name => $page ) {
438 $pages[$name] = $page->getDescription();
439 }
440
441 $go = wfMsg( 'go' );
442 $sp = wfMsg( 'specialpages' );
443 $spp = $wgContLang->specialPage( 'Specialpages' );
444
445 $s = '<form id="specialpages" method="get" ' .
446 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
447 $s .= "<select name=\"wpDropdown\">\n";
448 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
449
450
451 foreach ( $pages as $name => $desc ) {
452 $p = $wgContLang->specialPage( $name );
453 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
454 }
455
456 $s .= "</select>\n";
457 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
458 $s .= "</form>\n";
459
460 return $s;
461 }
462
463 function pageTitleLinks() {
464 global $wgOut, $wgUser, $wgRequest, $wgLang;
465
466 $oldid = $wgRequest->getVal( 'oldid' );
467 $diff = $wgRequest->getVal( 'diff' );
468 $action = $wgRequest->getText( 'action' );
469
470 $s[] = $this->printableLink();
471 $disclaimer = $this->getSkin()->disclaimerLink(); # may be empty
472
473 if ( $disclaimer ) {
474 $s[] = $disclaimer;
475 }
476
477 $privacy = $this->getSkin()->privacyLink(); # may be empty too
478
479 if ( $privacy ) {
480 $s[] = $privacy;
481 }
482
483 if ( $wgOut->isArticleRelated() ) {
484 if ( $this->getSkin()->getTitle()->getNamespace() == NS_FILE ) {
485 $name = $this->getSkin()->getTitle()->getDBkey();
486 $image = wfFindFile( $this->getSkin()->getTitle() );
487
488 if ( $image ) {
489 $link = htmlspecialchars( $image->getURL() );
490 $style = $this->getInternalLinkAttributes( $link, $name );
491 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
492 }
493 }
494 }
495
496 if ( 'history' == $action || isset( $diff ) || isset( $oldid ) ) {
497 $s[] .= $this->getSkin()->link(
498 $this->getSkin()->getTitle(),
499 wfMsg( 'currentrev' ),
500 array(),
501 array(),
502 array( 'known', 'noclasses' )
503 );
504 }
505
506 if ( $wgUser->getNewtalk() ) {
507 # do not show "You have new messages" text when we are viewing our
508 # own talk page
509 if ( !$this->getSkin()->getTitle()->equals( $wgUser->getTalkPage() ) ) {
510 $tl = $this->getSkin()->link(
511 $wgUser->getTalkPage(),
512 wfMsgHtml( 'newmessageslink' ),
513 array(),
514 array( 'redirect' => 'no' ),
515 array( 'known', 'noclasses' )
516 );
517
518 $dl = $this->getSkin()->link(
519 $wgUser->getTalkPage(),
520 wfMsgHtml( 'newmessagesdifflink' ),
521 array(),
522 array( 'diff' => 'cur' ),
523 array( 'known', 'noclasses' )
524 );
525 $s[] = '<strong>' . wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
526 # disable caching
527 $wgOut->setSquidMaxage( 0 );
528 $wgOut->enableClientCache( false );
529 }
530 }
531
532 $undelete = $this->getSkin()->getUndeleteLink();
533
534 if ( !empty( $undelete ) ) {
535 $s[] = $undelete;
536 }
537
538 return $wgLang->pipeList( $s );
539 }
540
541 /**
542 * Gets the h1 element with the page title.
543 * @return string
544 */
545 function pageTitle() {
546 global $wgOut;
547 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
548 return $s;
549 }
550
551 function pageSubtitle() {
552 global $wgOut;
553
554 $sub = $wgOut->getSubtitle();
555
556 if ( $sub == '' ) {
557 global $wgExtraSubtitle;
558 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
559 }
560
561 $subpages = $this->getSkin()->subPageSubtitle();
562 $sub .= !empty( $subpages ) ? "</p><p class='subpages'>$subpages" : '';
563 $s = "<p class='subtitle'>{$sub}</p>\n";
564
565 return $s;
566 }
567
568 function printableLink() {
569 global $wgOut, $wgRequest, $wgLang;
570
571 $s = array();
572
573 if ( !$wgOut->isPrintable() ) {
574 $printurl = htmlspecialchars( $this->getSkin()->getTitle()->getLocalUrl(
575 $wgRequest->appendQueryValue( 'printable', 'yes', true ) ) );
576 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
577 }
578
579 if ( $wgOut->isSyndicated() ) {
580 foreach ( $wgOut->getSyndicationLinks() as $format => $link ) {
581 $feedurl = htmlspecialchars( $link );
582 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
583 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
584 }
585 }
586 return $wgLang->pipeList( $s );
587 }
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 = $this->getSkin()->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 = $this->getSkin()->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 = $this->getSkin()->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;
671 ++$this->mWatchLinkNum;
672
673 if ( $wgOut->isArticleRelated() ) {
674 if ( $this->getSkin()->getTitle()->userIsWatching() ) {
675 $text = wfMsg( 'unwatchthispage' );
676 $query = array( 'action' => 'unwatch' );
677 $id = 'mw-unwatch-link' . $this->mWatchLinkNum;
678 } else {
679 $text = wfMsg( 'watchthispage' );
680 $query = array( 'action' => 'watch' );
681 $id = 'mw-watch-link' . $this->mWatchLinkNum;
682 }
683
684 $s = $this->getSkin()->link(
685 $this->getSkin()->getTitle(),
686 $text,
687 array( 'id' => $id ),
688 $query,
689 array( 'known', 'noclasses' )
690 );
691 } else {
692 $s = wfMsg( 'notanarticle' );
693 }
694
695 return $s;
696 }
697
698 function moveThisPage() {
699 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
700 return $this->getSkin()->link(
701 SpecialPage::getTitleFor( 'Movepage' ),
702 wfMsg( 'movethispage' ),
703 array(),
704 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() ),
705 array( 'known', 'noclasses' )
706 );
707 } else {
708 // no message if page is protected - would be redundant
709 return '';
710 }
711 }
712
713 function historyLink() {
714 return $this->getSkin()->link(
715 $this->getSkin()->getTitle(),
716 wfMsgHtml( 'history' ),
717 array( 'rel' => 'archives' ),
718 array( 'action' => 'history' )
719 );
720 }
721
722 function whatLinksHere() {
723 return $this->getSkin()->link(
724 SpecialPage::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
725 wfMsgHtml( 'whatlinkshere' ),
726 array(),
727 array(),
728 array( 'known', 'noclasses' )
729 );
730 }
731
732 function userContribsLink() {
733 return $this->getSkin()->link(
734 SpecialPage::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
735 wfMsgHtml( 'contributions' ),
736 array(),
737 array(),
738 array( 'known', 'noclasses' )
739 );
740 }
741
742 function emailUserLink() {
743 return $this->getSkin()->link(
744 SpecialPage::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
745 wfMsg( 'emailuser' ),
746 array(),
747 array(),
748 array( 'known', 'noclasses' )
749 );
750 }
751
752 function watchPageLinksLink() {
753 global $wgOut;
754
755 if ( !$wgOut->isArticleRelated() ) {
756 return '(' . wfMsg( 'notanarticle' ) . ')';
757 } else {
758 return $this->getSkin()->link(
759 SpecialPage::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
760 wfMsg( 'recentchangeslinked-toolbox' ),
761 array(),
762 array(),
763 array( 'known', 'noclasses' )
764 );
765 }
766 }
767
768 function trackbackLink() {
769 return '<a href="' . $this->getSkin()->getTitle()->trackbackURL() . '">'
770 . wfMsg( 'trackbacklink' ) . '</a>';
771 }
772
773 function talkLink() {
774 if ( NS_SPECIAL == $this->getSkin()->getTitle()->getNamespace() ) {
775 # No discussion links for special pages
776 return '';
777 }
778
779 $linkOptions = array();
780
781 if ( $this->getSkin()->getTitle()->isTalkPage() ) {
782 $link = $this->getSkin()->getTitle()->getSubjectPage();
783 switch( $link->getNamespace() ) {
784 case NS_MAIN:
785 $text = wfMsg( 'articlepage' );
786 break;
787 case NS_USER:
788 $text = wfMsg( 'userpage' );
789 break;
790 case NS_PROJECT:
791 $text = wfMsg( 'projectpage' );
792 break;
793 case NS_FILE:
794 $text = wfMsg( 'imagepage' );
795 # Make link known if image exists, even if the desc. page doesn't.
796 if ( wfFindFile( $link ) )
797 $linkOptions[] = 'known';
798 break;
799 case NS_MEDIAWIKI:
800 $text = wfMsg( 'mediawikipage' );
801 break;
802 case NS_TEMPLATE:
803 $text = wfMsg( 'templatepage' );
804 break;
805 case NS_HELP:
806 $text = wfMsg( 'viewhelppage' );
807 break;
808 case NS_CATEGORY:
809 $text = wfMsg( 'categorypage' );
810 break;
811 default:
812 $text = wfMsg( 'articlepage' );
813 }
814 } else {
815 $link = $this->getSkin()->getTitle()->getTalkPage();
816 $text = wfMsg( 'talkpage' );
817 }
818
819 $s = $this->getSkin()->link( $link, $text, array(), array(), $linkOptions );
820
821 return $s;
822 }
823
824 function commentLink() {
825 global $wgOut;
826
827 if ( $this->getSkin()->getTitle()->getNamespace() == NS_SPECIAL ) {
828 return '';
829 }
830
831 # __NEWSECTIONLINK___ changes behaviour here
832 # If it is present, the link points to this page, otherwise
833 # it points to the talk page
834 if ( $this->getSkin()->getTitle()->isTalkPage() ) {
835 $title = $this->getSkin()->getTitle();
836 } elseif ( $wgOut->showNewSectionLink() ) {
837 $title = $this->getSkin()->getTitle();
838 } else {
839 $title = $this->getSkin()->getTitle()->getTalkPage();
840 }
841
842 return $this->getSkin()->link(
843 $title,
844 wfMsg( 'postcomment' ),
845 array(),
846 array(
847 'action' => 'edit',
848 'section' => 'new'
849 ),
850 array( 'known', 'noclasses' )
851 );
852 }
853
854 function getUploadLink() {
855 global $wgUploadNavigationUrl;
856
857 if ( $wgUploadNavigationUrl ) {
858 # Using an empty class attribute to avoid automatic setting of "external" class
859 return $this->makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '' ) );
860 } else {
861 return $this->getSkin()->link(
862 SpecialPage::getTitleFor( 'Upload' ),
863 wfMsgHtml( 'upload' ),
864 array(),
865 array(),
866 array( 'known', 'noclasses' )
867 );
868 }
869 }
870
871 function nameAndLogin() {
872 global $wgUser, $wgLang, $wgContLang;
873
874 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
875
876 $ret = '';
877
878 if ( $wgUser->isAnon() ) {
879 if ( $this->getSkin()->showIPinHeader() ) {
880 $name = wfGetIP();
881
882 $talkLink = $this->getSkin()->link( $wgUser->getTalkPage(),
883 $wgLang->getNsText( NS_TALK ) );
884
885 $ret .= "$name ($talkLink)";
886 } else {
887 $ret .= wfMsg( 'notloggedin' );
888 }
889
890 $returnTo = $this->getSkin()->getTitle()->getPrefixedDBkey();
891 $query = array();
892
893 if ( $logoutPage != $returnTo ) {
894 $query['returnto'] = $returnTo;
895 }
896
897 $loginlink = $wgUser->isAllowed( 'createaccount' )
898 ? 'nav-login-createaccount'
899 : 'login';
900 $ret .= "\n<br />" . $this->getSkin()->link(
901 SpecialPage::getTitleFor( 'Userlogin' ),
902 wfMsg( $loginlink ), array(), $query
903 );
904 } else {
905 $returnTo = $this->getSkin()->getTitle()->getPrefixedDBkey();
906 $talkLink = $this->getSkin()->link( $wgUser->getTalkPage(),
907 $wgLang->getNsText( NS_TALK ) );
908
909 $ret .= $this->getSkin()->link( $wgUser->getUserPage(),
910 htmlspecialchars( $wgUser->getName() ) );
911 $ret .= " ($talkLink)<br />";
912 $ret .= $wgLang->pipeList( array(
913 $this->getSkin()->link(
914 SpecialPage::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
915 array(), array( 'returnto' => $returnTo )
916 ),
917 $this->getSkin()->specialLink( 'Preferences' ),
918 ) );
919 }
920
921 $ret = $wgLang->pipeList( array(
922 $ret,
923 $this->getSkin()->link(
924 Title::newFromText( wfMsgForContent( 'helppage' ) ),
925 wfMsg( 'help' )
926 ),
927 ) );
928
929 return $ret;
930 }
931
932 }
933