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