* (bug 31435) Fix raw watchlist edit regression from r84718.
[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 $wgLang;
94 wfProfileIn( __METHOD__ );
95
96 $s = '';
97
98 $langlinks = $this->otherLanguages();
99 if ( $langlinks ) {
100 $rows = 2;
101 $borderhack = '';
102 } else {
103 $rows = 1;
104 $langlinks = false;
105 $borderhack = 'class="top"';
106 }
107
108 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
109 "<table border='0' cellspacing='0' width='100%'>\n<tr>\n";
110
111 if ( $this->getSkin()->qbSetting() == 0 ) {
112 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
113 $this->getSkin()->logoText( $wgLang->alignStart() ) . '</td>';
114 }
115
116 $l = $wgLang->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 = $wgLang->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 $s .= "</tr>\n</table>\n</div>\n";
132 $s .= "\n<div id='article'>\n";
133
134 $notice = $this->getSkin()->getSiteNotice();
135
136 if ( $notice ) {
137 $s .= "\n<div id='siteNotice'>$notice</div>\n";
138 }
139 $s .= $this->pageTitle();
140 $s .= $this->pageSubtitle();
141 $s .= $this->getSkin()->getCategories();
142
143 wfProfileOut( __METHOD__ );
144 return $s;
145 }
146
147 /**
148 * This gets called shortly before the </body> tag.
149 * @return String HTML to be put before </body>
150 */
151 function afterContent() {
152 return $this->doAfterContent();
153 }
154
155 /** overloaded by derived classes */
156 function doAfterContent() {
157 return '</div></div>';
158 }
159
160 function searchForm() {
161 global $wgRequest, $wgUseTwoButtonsSearchForm;
162
163 $search = $wgRequest->getText( 'search' );
164
165 $s = '<form id="searchform' . $this->searchboxes . '" name="search" class="inline" method="post" action="'
166 . $this->getSkin()->escapeSearchLink() . "\">\n"
167 . '<input type="text" id="searchInput' . $this->searchboxes . '" name="search" size="19" value="'
168 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
169 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
170
171 if ( $wgUseTwoButtonsSearchForm ) {
172 $s .= '&#160;<input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
173 } else {
174 $s .= ' <a href="' . $this->getSkin()->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
175 }
176
177 $s .= '</form>';
178
179 // Ensure unique id's for search boxes made after the first
180 $this->searchboxes = $this->searchboxes == '' ? 2 : $this->searchboxes + 1;
181
182 return $s;
183 }
184
185 function pageStats() {
186 global $wgOut, $wgLang, $wgRequest, $wgUser;
187 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
188
189 if ( !is_null( $wgRequest->getVal( 'oldid' ) ) || !is_null( $wgRequest->getVal( 'diff' ) ) ) {
190 return '';
191 }
192
193 if ( !$wgOut->isArticle() || !$this->getSkin()->getTitle()->exists() ) {
194 return '';
195 }
196
197 $article = new Article( $this->getSkin()->getTitle(), 0 );
198
199 $s = '';
200
201 if ( !$wgDisableCounters ) {
202 $count = $wgLang->formatNum( $article->getCount() );
203
204 if ( $count ) {
205 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
206 }
207 }
208
209 if ( $wgMaxCredits != 0 ) {
210 $s .= ' ' . Action::factory( 'credits', $article )->getCredits( $wgMaxCredits, $wgShowCreditsIfMax );
211 } else {
212 $s .= $this->data['lastmod'];
213 }
214
215 if ( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
216 $dbr = wfGetDB( DB_SLAVE );
217 $res = $dbr->select(
218 'watchlist',
219 array( 'COUNT(*) AS n' ),
220 array(
221 'wl_title' => $dbr->strencode( $this->getSkin()->getTitle()->getDBkey() ),
222 'wl_namespace' => $this->getSkin()->getTitle()->getNamespace()
223 ),
224 __METHOD__
225 );
226 $x = $dbr->fetchObject( $res );
227
228 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
229 array( 'parseinline' ), $wgLang->formatNum( $x->n )
230 );
231 }
232
233 return $s . ' ' . $this->getSkin()->getCopyright();
234 }
235
236 function topLinks() {
237 global $wgOut;
238
239 $s = array(
240 $this->getSkin()->mainPageLink(),
241 Linker::specialLink( 'Recentchanges' )
242 );
243
244 if ( $wgOut->isArticleRelated() ) {
245 $s[] = $this->editThisPage();
246 $s[] = $this->historyLink();
247 }
248
249 # Many people don't like this dropdown box
250 # $s[] = $this->specialPagesList();
251
252 if ( $this->variantLinks() ) {
253 $s[] = $this->variantLinks();
254 }
255
256 if ( $this->extensionTabLinks() ) {
257 $s[] = $this->extensionTabLinks();
258 }
259
260 // @todo FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
261 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
262 }
263
264 /**
265 * Language/charset variant links for classic-style skins
266 * @return string
267 */
268 function variantLinks() {
269 $s = '';
270
271 /* show links to different language variants */
272 global $wgDisableLangConversion, $wgLang;
273
274 $title = $this->getSkin()->getTitle();
275 $lang = $title->getPageLanguage();
276 $variants = $lang->getVariants();
277
278 if ( !$wgDisableLangConversion && sizeof( $variants ) > 1
279 && $title->getNamespace() != NS_SPECIAL ) {
280 foreach ( $variants as $code ) {
281 $varname = $lang->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 = SpecialPageFactory::getUsablePages();
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 = Linker::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[] .= Linker::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 = Linker::link(
511 $wgUser->getTalkPage(),
512 wfMsgHtml( 'newmessageslink' ),
513 array(),
514 array( 'redirect' => 'no' ),
515 array( 'known', 'noclasses' )
516 );
517
518 $dl = Linker::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 /**
590 * @deprecated in 1.19
591 */
592 function getQuickbarCompensator( $rows = 1 ) {
593 return "<td width='152' rowspan='{$rows}'>&#160;</td>";
594 }
595
596 function editThisPage() {
597 global $wgOut;
598
599 if ( !$wgOut->isArticleRelated() ) {
600 $s = wfMsg( 'protectedpage' );
601 } else {
602 if ( $this->getSkin()->getTitle()->quickUserCan( 'edit' ) && $this->getSkin()->getTitle()->exists() ) {
603 $t = wfMsg( 'editthispage' );
604 } elseif ( $this->getSkin()->getTitle()->quickUserCan( 'create' ) && !$this->getSkin()->getTitle()->exists() ) {
605 $t = wfMsg( 'create-this-page' );
606 } else {
607 $t = wfMsg( 'viewsource' );
608 }
609
610 $s = Linker::link(
611 $this->getSkin()->getTitle(),
612 $t,
613 array(),
614 $this->getSkin()->editUrlOptions(),
615 array( 'known', 'noclasses' )
616 );
617 }
618
619 return $s;
620 }
621
622 function deleteThisPage() {
623 global $wgUser, $wgRequest;
624
625 $diff = $wgRequest->getVal( 'diff' );
626
627 if ( $this->getSkin()->getTitle()->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
628 $t = wfMsg( 'deletethispage' );
629
630 $s = Linker::link(
631 $this->getSkin()->getTitle(),
632 $t,
633 array(),
634 array( 'action' => 'delete' ),
635 array( 'known', 'noclasses' )
636 );
637 } else {
638 $s = '';
639 }
640
641 return $s;
642 }
643
644 function protectThisPage() {
645 global $wgUser, $wgRequest;
646
647 $diff = $wgRequest->getVal( 'diff' );
648
649 if ( $this->getSkin()->getTitle()->getArticleId() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
650 if ( $this->getSkin()->getTitle()->isProtected() ) {
651 $text = wfMsg( 'unprotectthispage' );
652 $query = array( 'action' => 'unprotect' );
653 } else {
654 $text = wfMsg( 'protectthispage' );
655 $query = array( 'action' => 'protect' );
656 }
657
658 $s = Linker::link(
659 $this->getSkin()->getTitle(),
660 $text,
661 array(),
662 $query,
663 array( 'known', 'noclasses' )
664 );
665 } else {
666 $s = '';
667 }
668
669 return $s;
670 }
671
672 function watchThisPage() {
673 global $wgOut, $wgUser;
674 ++$this->mWatchLinkNum;
675
676 // Cache
677 $title = $this->getSkin()->getTitle();
678
679 if ( $wgOut->isArticleRelated() ) {
680 if ( $title->userIsWatching() ) {
681 $text = wfMsg( 'unwatchthispage' );
682 $query = array(
683 'action' => 'unwatch',
684 'token' => UnwatchAction::getUnwatchToken( $title, $wgUser ),
685 );
686 $id = 'mw-unwatch-link' . $this->mWatchLinkNum;
687 } else {
688 $text = wfMsg( 'watchthispage' );
689 $query = array(
690 'action' => 'watch',
691 'token' => WatchAction::getWatchToken( $title, $wgUser ),
692 );
693 $id = 'mw-watch-link' . $this->mWatchLinkNum;
694 }
695
696 $s = Linker::link(
697 $title,
698 $text,
699 array( 'id' => $id ),
700 $query,
701 array( 'known', 'noclasses' )
702 );
703 } else {
704 $s = wfMsg( 'notanarticle' );
705 }
706
707 return $s;
708 }
709
710 function moveThisPage() {
711 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
712 return Linker::link(
713 SpecialPage::getTitleFor( 'Movepage' ),
714 wfMsg( 'movethispage' ),
715 array(),
716 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() ),
717 array( 'known', 'noclasses' )
718 );
719 } else {
720 // no message if page is protected - would be redundant
721 return '';
722 }
723 }
724
725 function historyLink() {
726 return Linker::link(
727 $this->getSkin()->getTitle(),
728 wfMsgHtml( 'history' ),
729 array( 'rel' => 'archives' ),
730 array( 'action' => 'history' )
731 );
732 }
733
734 function whatLinksHere() {
735 return Linker::link(
736 SpecialPage::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
737 wfMsgHtml( 'whatlinkshere' ),
738 array(),
739 array(),
740 array( 'known', 'noclasses' )
741 );
742 }
743
744 function userContribsLink() {
745 return Linker::link(
746 SpecialPage::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
747 wfMsgHtml( 'contributions' ),
748 array(),
749 array(),
750 array( 'known', 'noclasses' )
751 );
752 }
753
754 function emailUserLink() {
755 return Linker::link(
756 SpecialPage::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
757 wfMsg( 'emailuser' ),
758 array(),
759 array(),
760 array( 'known', 'noclasses' )
761 );
762 }
763
764 function watchPageLinksLink() {
765 global $wgOut;
766
767 if ( !$wgOut->isArticleRelated() ) {
768 return '(' . wfMsg( 'notanarticle' ) . ')';
769 } else {
770 return Linker::link(
771 SpecialPage::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
772 wfMsg( 'recentchangeslinked-toolbox' ),
773 array(),
774 array(),
775 array( 'known', 'noclasses' )
776 );
777 }
778 }
779
780 function trackbackLink() {
781 return '<a href="' . $this->getSkin()->getTitle()->trackbackURL() . '">'
782 . wfMsg( 'trackbacklink' ) . '</a>';
783 }
784
785 function talkLink() {
786 if ( NS_SPECIAL == $this->getSkin()->getTitle()->getNamespace() ) {
787 # No discussion links for special pages
788 return '';
789 }
790
791 $linkOptions = array();
792
793 if ( $this->getSkin()->getTitle()->isTalkPage() ) {
794 $link = $this->getSkin()->getTitle()->getSubjectPage();
795 switch( $link->getNamespace() ) {
796 case NS_MAIN:
797 $text = wfMsg( 'articlepage' );
798 break;
799 case NS_USER:
800 $text = wfMsg( 'userpage' );
801 break;
802 case NS_PROJECT:
803 $text = wfMsg( 'projectpage' );
804 break;
805 case NS_FILE:
806 $text = wfMsg( 'imagepage' );
807 # Make link known if image exists, even if the desc. page doesn't.
808 if ( wfFindFile( $link ) )
809 $linkOptions[] = 'known';
810 break;
811 case NS_MEDIAWIKI:
812 $text = wfMsg( 'mediawikipage' );
813 break;
814 case NS_TEMPLATE:
815 $text = wfMsg( 'templatepage' );
816 break;
817 case NS_HELP:
818 $text = wfMsg( 'viewhelppage' );
819 break;
820 case NS_CATEGORY:
821 $text = wfMsg( 'categorypage' );
822 break;
823 default:
824 $text = wfMsg( 'articlepage' );
825 }
826 } else {
827 $link = $this->getSkin()->getTitle()->getTalkPage();
828 $text = wfMsg( 'talkpage' );
829 }
830
831 $s = Linker::link( $link, $text, array(), array(), $linkOptions );
832
833 return $s;
834 }
835
836 function commentLink() {
837 global $wgOut;
838
839 if ( $this->getSkin()->getTitle()->getNamespace() == NS_SPECIAL ) {
840 return '';
841 }
842
843 # __NEWSECTIONLINK___ changes behaviour here
844 # If it is present, the link points to this page, otherwise
845 # it points to the talk page
846 if ( $this->getSkin()->getTitle()->isTalkPage() ) {
847 $title = $this->getSkin()->getTitle();
848 } elseif ( $wgOut->showNewSectionLink() ) {
849 $title = $this->getSkin()->getTitle();
850 } else {
851 $title = $this->getSkin()->getTitle()->getTalkPage();
852 }
853
854 return Linker::link(
855 $title,
856 wfMsg( 'postcomment' ),
857 array(),
858 array(
859 'action' => 'edit',
860 'section' => 'new'
861 ),
862 array( 'known', 'noclasses' )
863 );
864 }
865
866 function getUploadLink() {
867 global $wgUploadNavigationUrl;
868
869 if ( $wgUploadNavigationUrl ) {
870 # Using an empty class attribute to avoid automatic setting of "external" class
871 return Linker::makeExternalLink( $wgUploadNavigationUrl, wfMsgHtml( 'upload' ), false, null, array( 'class' => '' ) );
872 } else {
873 return Linker::link(
874 SpecialPage::getTitleFor( 'Upload' ),
875 wfMsgHtml( 'upload' ),
876 array(),
877 array(),
878 array( 'known', 'noclasses' )
879 );
880 }
881 }
882
883 function nameAndLogin() {
884 global $wgUser, $wgLang, $wgRequest, $wgContLang;
885
886 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
887
888 $ret = '';
889
890 if ( $wgUser->isAnon() ) {
891 if ( $this->getSkin()->showIPinHeader() ) {
892 $name = $wgRequest->getIP();
893
894 $talkLink = Linker::link( $wgUser->getTalkPage(),
895 $wgLang->getNsText( NS_TALK ) );
896
897 $ret .= "$name ($talkLink)";
898 } else {
899 $ret .= wfMsg( 'notloggedin' );
900 }
901
902 $returnTo = $this->getSkin()->getTitle()->getPrefixedDBkey();
903 $query = array();
904
905 if ( $logoutPage != $returnTo ) {
906 $query['returnto'] = $returnTo;
907 }
908
909 $loginlink = $wgUser->isAllowed( 'createaccount' )
910 ? 'nav-login-createaccount'
911 : 'login';
912 $ret .= "\n<br />" . Linker::link(
913 SpecialPage::getTitleFor( 'Userlogin' ),
914 wfMsg( $loginlink ), array(), $query
915 );
916 } else {
917 $returnTo = $this->getSkin()->getTitle()->getPrefixedDBkey();
918 $talkLink = Linker::link( $wgUser->getTalkPage(),
919 $wgLang->getNsText( NS_TALK ) );
920
921 $ret .= Linker::link( $wgUser->getUserPage(),
922 htmlspecialchars( $wgUser->getName() ) );
923 $ret .= " ($talkLink)<br />";
924 $ret .= $wgLang->pipeList( array(
925 Linker::link(
926 SpecialPage::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
927 array(), array( 'returnto' => $returnTo )
928 ),
929 Linker::specialLink( 'Preferences' ),
930 ) );
931 }
932
933 $ret = $wgLang->pipeList( array(
934 $ret,
935 Linker::link(
936 Title::newFromText( wfMsgForContent( 'helppage' ) ),
937 wfMsg( 'help' )
938 ),
939 ) );
940
941 return $ret;
942 }
943
944 }
945