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