Merge "Implement namespace inversion on WhatLinksHere"
[lhc/web/wiklou.git] / includes / skins / SkinTemplate.php
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 */
20
21 /**
22 * Base class for template-based skins.
23 *
24 * Template-filler skin base class
25 * Formerly generic PHPTal (http://phptal.sourceforge.net/) skin
26 * Based on Brion's smarty skin
27 * @copyright Copyright © Gabriel Wicke -- http://www.aulinx.de/
28 *
29 * @todo Needs some serious refactoring into functions that correspond
30 * to the computations individual esi snippets need. Most importantly no body
31 * parsing for most of those of course.
32 *
33 * @ingroup Skins
34 */
35 class SkinTemplate extends Skin {
36 /**
37 * @var string Name of our skin, it probably needs to be all lower case.
38 * Child classes should override the default.
39 */
40 public $skinname = 'monobook';
41
42 /**
43 * @var string For QuickTemplate, the name of the subclass which will
44 * actually fill the template. Child classes should override the default.
45 */
46 public $template = 'QuickTemplate';
47
48 /**
49 * Add specific styles for this skin
50 *
51 * @param OutputPage $out
52 */
53 function setupSkinUserCss( OutputPage $out ) {
54 $out->addModuleStyles( array(
55 'mediawiki.legacy.shared',
56 'mediawiki.legacy.commonPrint',
57 'mediawiki.ui.button'
58 ) );
59 }
60
61 /**
62 * Create the template engine object; we feed it a bunch of data
63 * and eventually it spits out some HTML. Should have interface
64 * roughly equivalent to PHPTAL 0.7.
65 *
66 * @param string $classname
67 * @param bool|string $repository Subdirectory where we keep template files
68 * @param bool|string $cache_dir
69 * @return QuickTemplate
70 * @private
71 */
72 function setupTemplate( $classname, $repository = false, $cache_dir = false ) {
73 return new $classname( $this->getConfig() );
74 }
75
76 /**
77 * Generates array of language links for the current page
78 *
79 * @return array
80 */
81 public function getLanguages() {
82 global $wgHideInterlanguageLinks;
83 if ( $wgHideInterlanguageLinks ) {
84 return array();
85 }
86
87 $userLang = $this->getLanguage();
88 $languageLinks = array();
89
90 foreach ( $this->getOutput()->getLanguageLinks() as $languageLinkText ) {
91 $languageLinkParts = explode( ':', $languageLinkText, 2 );
92 $class = 'interlanguage-link interwiki-' . $languageLinkParts[0];
93 unset( $languageLinkParts );
94
95 $languageLinkTitle = Title::newFromText( $languageLinkText );
96 if ( $languageLinkTitle ) {
97 $ilInterwikiCode = $languageLinkTitle->getInterwiki();
98 $ilLangName = Language::fetchLanguageName( $ilInterwikiCode );
99
100 if ( strval( $ilLangName ) === '' ) {
101 $ilDisplayTextMsg = wfMessage( "interlanguage-link-$ilInterwikiCode" );
102 if ( !$ilDisplayTextMsg->isDisabled() ) {
103 // Use custom MW message for the display text
104 $ilLangName = $ilDisplayTextMsg->text();
105 } else {
106 // Last resort: fallback to the language link target
107 $ilLangName = $languageLinkText;
108 }
109 } else {
110 // Use the language autonym as display text
111 $ilLangName = $this->formatLanguageName( $ilLangName );
112 }
113
114 // CLDR extension or similar is required to localize the language name;
115 // otherwise we'll end up with the autonym again.
116 $ilLangLocalName = Language::fetchLanguageName(
117 $ilInterwikiCode,
118 $userLang->getCode()
119 );
120
121 $languageLinkTitleText = $languageLinkTitle->getText();
122 if ( $ilLangLocalName === '' ) {
123 $ilFriendlySiteName = wfMessage( "interlanguage-link-sitename-$ilInterwikiCode" );
124 if ( !$ilFriendlySiteName->isDisabled() ) {
125 if ( $languageLinkTitleText === '' ) {
126 $ilTitle = wfMessage(
127 'interlanguage-link-title-nonlangonly',
128 $ilFriendlySiteName->text()
129 )->text();
130 } else {
131 $ilTitle = wfMessage(
132 'interlanguage-link-title-nonlang',
133 $languageLinkTitleText,
134 $ilFriendlySiteName->text()
135 )->text();
136 }
137 } else {
138 // we have nothing friendly to put in the title, so fall back to
139 // displaying the interlanguage link itself in the title text
140 // (similar to what is done in page content)
141 $ilTitle = $languageLinkTitle->getInterwiki() .
142 ":$languageLinkTitleText";
143 }
144 } elseif ( $languageLinkTitleText === '' ) {
145 $ilTitle = wfMessage(
146 'interlanguage-link-title-langonly',
147 $ilLangLocalName
148 )->text();
149 } else {
150 $ilTitle = wfMessage(
151 'interlanguage-link-title',
152 $languageLinkTitleText,
153 $ilLangLocalName
154 )->text();
155 }
156
157 $ilInterwikiCodeBCP47 = wfBCP47( $ilInterwikiCode );
158 $languageLink = array(
159 'href' => $languageLinkTitle->getFullURL(),
160 'text' => $ilLangName,
161 'title' => $ilTitle,
162 'class' => $class,
163 'lang' => $ilInterwikiCodeBCP47,
164 'hreflang' => $ilInterwikiCodeBCP47,
165 );
166 Hooks::run(
167 'SkinTemplateGetLanguageLink',
168 array( &$languageLink, $languageLinkTitle, $this->getTitle(), $this->getOutput() )
169 );
170 $languageLinks[] = $languageLink;
171 }
172 }
173
174 return $languageLinks;
175 }
176
177 protected function setupTemplateForOutput() {
178
179 $request = $this->getRequest();
180 $user = $this->getUser();
181 $title = $this->getTitle();
182
183 $tpl = $this->setupTemplate( $this->template, 'skins' );
184
185 $this->thispage = $title->getPrefixedDBkey();
186 $this->titletxt = $title->getPrefixedText();
187 $this->userpage = $user->getUserPage()->getPrefixedText();
188 $query = array();
189 if ( !$request->wasPosted() ) {
190 $query = $request->getValues();
191 unset( $query['title'] );
192 unset( $query['returnto'] );
193 unset( $query['returntoquery'] );
194 }
195 $this->thisquery = wfArrayToCgi( $query );
196 $this->loggedin = $user->isLoggedIn();
197 $this->username = $user->getName();
198
199 if ( $this->loggedin || $this->showIPinHeader() ) {
200 $this->userpageUrlDetails = self::makeUrlDetails( $this->userpage );
201 } else {
202 # This won't be used in the standard skins, but we define it to preserve the interface
203 # To save time, we check for existence
204 $this->userpageUrlDetails = self::makeKnownUrlDetails( $this->userpage );
205 }
206
207 return $tpl;
208 }
209
210 /**
211 * initialize various variables and generate the template
212 *
213 * @param OutputPage $out
214 */
215 function outputPage( OutputPage $out = null ) {
216 Profiler::instance()->setTemplated( true );
217
218 $oldContext = null;
219 if ( $out !== null ) {
220 // Deprecated since 1.20, note added in 1.25
221 wfDeprecated( __METHOD__, '1.25' );
222 $oldContext = $this->getContext();
223 $this->setContext( $out->getContext() );
224 }
225
226 $out = $this->getOutput();
227
228 $this->initPage( $out );
229 $tpl = $this->prepareQuickTemplate( $out );
230 // execute template
231 $res = $tpl->execute();
232
233 // result may be an error
234 $this->printOrError( $res );
235
236 if ( $oldContext ) {
237 $this->setContext( $oldContext );
238 }
239
240 }
241
242 /**
243 * initialize various variables and generate the template
244 *
245 * @since 1.23
246 * @return QuickTemplate The template to be executed by outputPage
247 */
248 protected function prepareQuickTemplate() {
249 global $wgContLang, $wgScript, $wgStylePath, $wgMimeType, $wgJsMimeType,
250 $wgSitename, $wgLogo, $wgMaxCredits,
251 $wgShowCreditsIfMax, $wgArticlePath,
252 $wgScriptPath, $wgServer;
253
254 $title = $this->getTitle();
255 $request = $this->getRequest();
256 $out = $this->getOutput();
257 $tpl = $this->setupTemplateForOutput();
258
259 $tpl->set( 'title', $out->getPageTitle() );
260 $tpl->set( 'pagetitle', $out->getHTMLTitle() );
261 $tpl->set( 'displaytitle', $out->mPageLinkTitle );
262
263 $tpl->setRef( 'thispage', $this->thispage );
264 $tpl->setRef( 'titleprefixeddbkey', $this->thispage );
265 $tpl->set( 'titletext', $title->getText() );
266 $tpl->set( 'articleid', $title->getArticleID() );
267
268 $tpl->set( 'isarticle', $out->isArticle() );
269
270 $subpagestr = $this->subPageSubtitle();
271 if ( $subpagestr !== '' ) {
272 $subpagestr = '<span class="subpages">' . $subpagestr . '</span>';
273 }
274 $tpl->set( 'subtitle', $subpagestr . $out->getSubtitle() );
275
276 $undelete = $this->getUndeleteLink();
277 if ( $undelete === '' ) {
278 $tpl->set( 'undelete', '' );
279 } else {
280 $tpl->set( 'undelete', '<span class="subpages">' . $undelete . '</span>' );
281 }
282
283 $tpl->set( 'catlinks', $this->getCategories() );
284 if ( $out->isSyndicated() ) {
285 $feeds = array();
286 foreach ( $out->getSyndicationLinks() as $format => $link ) {
287 $feeds[$format] = array(
288 // Messages: feed-atom, feed-rss
289 'text' => $this->msg( "feed-$format" )->text(),
290 'href' => $link
291 );
292 }
293 $tpl->setRef( 'feeds', $feeds );
294 } else {
295 $tpl->set( 'feeds', false );
296 }
297
298 $tpl->setRef( 'mimetype', $wgMimeType );
299 $tpl->setRef( 'jsmimetype', $wgJsMimeType );
300 $tpl->set( 'charset', 'UTF-8' );
301 $tpl->setRef( 'wgScript', $wgScript );
302 $tpl->setRef( 'skinname', $this->skinname );
303 $tpl->set( 'skinclass', get_class( $this ) );
304 $tpl->setRef( 'skin', $this );
305 $tpl->setRef( 'stylename', $this->stylename );
306 $tpl->set( 'printable', $out->isPrintable() );
307 $tpl->set( 'handheld', $request->getBool( 'handheld' ) );
308 $tpl->setRef( 'loggedin', $this->loggedin );
309 $tpl->set( 'notspecialpage', !$title->isSpecialPage() );
310 $tpl->set( 'searchaction', $this->escapeSearchLink() );
311 $tpl->set( 'searchtitle', SpecialPage::getTitleFor( 'Search' )->getPrefixedDBkey() );
312 $tpl->set( 'search', trim( $request->getVal( 'search' ) ) );
313 $tpl->setRef( 'stylepath', $wgStylePath );
314 $tpl->setRef( 'articlepath', $wgArticlePath );
315 $tpl->setRef( 'scriptpath', $wgScriptPath );
316 $tpl->setRef( 'serverurl', $wgServer );
317 $tpl->setRef( 'logopath', $wgLogo );
318 $tpl->setRef( 'sitename', $wgSitename );
319
320 $userLang = $this->getLanguage();
321 $userLangCode = $userLang->getHtmlCode();
322 $userLangDir = $userLang->getDir();
323
324 $tpl->set( 'lang', $userLangCode );
325 $tpl->set( 'dir', $userLangDir );
326 $tpl->set( 'rtl', $userLang->isRTL() );
327
328 $tpl->set( 'capitalizeallnouns', $userLang->capitalizeAllNouns() ? ' capitalize-all-nouns' : '' );
329 $tpl->set( 'showjumplinks', true ); // showjumplinks preference has been removed
330 $tpl->set( 'username', $this->loggedin ? $this->username : null );
331 $tpl->setRef( 'userpage', $this->userpage );
332 $tpl->setRef( 'userpageurl', $this->userpageUrlDetails['href'] );
333 $tpl->set( 'userlang', $userLangCode );
334
335 // Users can have their language set differently than the
336 // content of the wiki. For these users, tell the web browser
337 // that interface elements are in a different language.
338 $tpl->set( 'userlangattributes', '' );
339 $tpl->set( 'specialpageattributes', '' ); # obsolete
340 // Used by VectorBeta to insert HTML before content but after the
341 // heading for the page title. Defaults to empty string.
342 $tpl->set( 'prebodyhtml', '' );
343
344 if ( $userLangCode !== $wgContLang->getHtmlCode() || $userLangDir !== $wgContLang->getDir() ) {
345 $escUserlang = htmlspecialchars( $userLangCode );
346 $escUserdir = htmlspecialchars( $userLangDir );
347 // Attributes must be in double quotes because htmlspecialchars() doesn't
348 // escape single quotes
349 $attrs = " lang=\"$escUserlang\" dir=\"$escUserdir\"";
350 $tpl->set( 'userlangattributes', $attrs );
351 }
352
353 $tpl->set( 'newtalk', $this->getNewtalks() );
354 $tpl->set( 'logo', $this->logoText() );
355
356 $tpl->set( 'copyright', false );
357 // No longer used
358 $tpl->set( 'viewcount', false );
359 $tpl->set( 'lastmod', false );
360 $tpl->set( 'credits', false );
361 $tpl->set( 'numberofwatchingusers', false );
362 if ( $out->isArticle() && $title->exists() ) {
363 if ( $this->isRevisionCurrent() ) {
364 if ( $wgMaxCredits != 0 ) {
365 $tpl->set( 'credits', Action::factory( 'credits', $this->getWikiPage(),
366 $this->getContext() )->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ) );
367 } else {
368 $tpl->set( 'lastmod', $this->lastModified() );
369 }
370 }
371 $tpl->set( 'copyright', $this->getCopyright() );
372 }
373
374 $tpl->set( 'copyrightico', $this->getCopyrightIcon() );
375 $tpl->set( 'poweredbyico', $this->getPoweredBy() );
376 $tpl->set( 'disclaimer', $this->disclaimerLink() );
377 $tpl->set( 'privacy', $this->privacyLink() );
378 $tpl->set( 'about', $this->aboutLink() );
379
380 $tpl->set( 'footerlinks', array(
381 'info' => array(
382 'lastmod',
383 'numberofwatchingusers',
384 'credits',
385 'copyright',
386 ),
387 'places' => array(
388 'privacy',
389 'about',
390 'disclaimer',
391 ),
392 ) );
393
394 global $wgFooterIcons;
395 $tpl->set( 'footericons', $wgFooterIcons );
396 foreach ( $tpl->data['footericons'] as $footerIconsKey => &$footerIconsBlock ) {
397 if ( count( $footerIconsBlock ) > 0 ) {
398 foreach ( $footerIconsBlock as &$footerIcon ) {
399 if ( isset( $footerIcon['src'] ) ) {
400 if ( !isset( $footerIcon['width'] ) ) {
401 $footerIcon['width'] = 88;
402 }
403 if ( !isset( $footerIcon['height'] ) ) {
404 $footerIcon['height'] = 31;
405 }
406 }
407 }
408 } else {
409 unset( $tpl->data['footericons'][$footerIconsKey] );
410 }
411 }
412
413 $tpl->set( 'indicators', $out->getIndicators() );
414
415 $tpl->set( 'sitenotice', $this->getSiteNotice() );
416 $tpl->set( 'bottomscripts', $this->bottomScripts() );
417 $tpl->set( 'printfooter', $this->printSource() );
418
419 # An ID that includes the actual body text; without categories, contentSub, ...
420 $realBodyAttribs = array( 'id' => 'mw-content-text' );
421
422 # Add a mw-content-ltr/rtl class to be able to style based on text direction
423 # when the content is different from the UI language, i.e.:
424 # not for special pages or file pages AND only when viewing AND if the page exists
425 # (or is in MW namespace, because that has default content)
426 if ( !in_array( $title->getNamespace(), array( NS_SPECIAL, NS_FILE ) ) &&
427 Action::getActionName( $this ) === 'view' &&
428 ( $title->exists() || $title->getNamespace() == NS_MEDIAWIKI ) ) {
429 $pageLang = $title->getPageViewLanguage();
430 $realBodyAttribs['lang'] = $pageLang->getHtmlCode();
431 $realBodyAttribs['dir'] = $pageLang->getDir();
432 $realBodyAttribs['class'] = 'mw-content-' . $pageLang->getDir();
433 }
434
435 $out->mBodytext = Html::rawElement( 'div', $realBodyAttribs, $out->mBodytext );
436 $tpl->setRef( 'bodytext', $out->mBodytext );
437
438 $language_urls = $this->getLanguages();
439 if ( count( $language_urls ) ) {
440 $tpl->setRef( 'language_urls', $language_urls );
441 } else {
442 $tpl->set( 'language_urls', false );
443 }
444
445 # Personal toolbar
446 $tpl->set( 'personal_urls', $this->buildPersonalUrls() );
447 $content_navigation = $this->buildContentNavigationUrls();
448 $content_actions = $this->buildContentActionUrls( $content_navigation );
449 $tpl->setRef( 'content_navigation', $content_navigation );
450 $tpl->setRef( 'content_actions', $content_actions );
451
452 $tpl->set( 'sidebar', $this->buildSidebar() );
453 $tpl->set( 'nav_urls', $this->buildNavUrls() );
454
455 // Set the head scripts near the end, in case the above actions resulted in added scripts
456 $tpl->set( 'headelement', $out->headElement( $this ) );
457
458 $tpl->set( 'debug', '' );
459 $tpl->set( 'debughtml', $this->generateDebugHTML() );
460 $tpl->set( 'reporttime', wfReportTime() );
461
462 // original version by hansm
463 if ( !Hooks::run( 'SkinTemplateOutputPageBeforeExec', array( &$this, &$tpl ) ) ) {
464 wfDebug( __METHOD__ . ": Hook SkinTemplateOutputPageBeforeExec broke outputPage execution!\n" );
465 }
466
467 // Set the bodytext to another key so that skins can just output it on its own
468 // and output printfooter and debughtml separately
469 $tpl->set( 'bodycontent', $tpl->data['bodytext'] );
470
471 // Append printfooter and debughtml onto bodytext so that skins that
472 // were already using bodytext before they were split out don't suddenly
473 // start not outputting information.
474 $tpl->data['bodytext'] .= Html::rawElement(
475 'div',
476 array( 'class' => 'printfooter' ),
477 "\n{$tpl->data['printfooter']}"
478 ) . "\n";
479 $tpl->data['bodytext'] .= $tpl->data['debughtml'];
480
481 // allow extensions adding stuff after the page content.
482 // See Skin::afterContentHook() for further documentation.
483 $tpl->set( 'dataAfterContent', $this->afterContentHook() );
484
485 return $tpl;
486 }
487
488 /**
489 * Get the HTML for the p-personal list
490 * @return string
491 */
492 public function getPersonalToolsList() {
493 $tpl = $this->setupTemplateForOutput();
494 $tpl->set( 'personal_urls', $this->buildPersonalUrls() );
495 $html = '';
496 foreach ( $tpl->getPersonalTools() as $key => $item ) {
497 $html .= $tpl->makeListItem( $key, $item );
498 }
499 return $html;
500 }
501
502 /**
503 * Format language name for use in sidebar interlanguage links list.
504 * By default it is capitalized.
505 *
506 * @param string $name Language name, e.g. "English" or "español"
507 * @return string
508 * @private
509 */
510 function formatLanguageName( $name ) {
511 return $this->getLanguage()->ucfirst( $name );
512 }
513
514 /**
515 * Output the string, or print error message if it's
516 * an error object of the appropriate type.
517 * For the base class, assume strings all around.
518 *
519 * @param string $str
520 * @private
521 */
522 function printOrError( $str ) {
523 echo $str;
524 }
525
526 /**
527 * Output a boolean indicating if buildPersonalUrls should output separate
528 * login and create account links or output a combined link
529 * By default we simply return a global config setting that affects most skins
530 * This is setup as a method so that like with $wgLogo and getLogo() a skin
531 * can override this setting and always output one or the other if it has
532 * a reason it can't output one of the two modes.
533 * @return bool
534 */
535 function useCombinedLoginLink() {
536 global $wgUseCombinedLoginLink;
537 return $wgUseCombinedLoginLink;
538 }
539
540 /**
541 * build array of urls for personal toolbar
542 * @return array
543 */
544 protected function buildPersonalUrls() {
545 $title = $this->getTitle();
546 $request = $this->getRequest();
547 $pageurl = $title->getLocalURL();
548
549 /* set up the default links for the personal toolbar */
550 $personal_urls = array();
551
552 # Due to bug 32276, if a user does not have read permissions,
553 # $this->getTitle() will just give Special:Badtitle, which is
554 # not especially useful as a returnto parameter. Use the title
555 # from the request instead, if there was one.
556 if ( $this->getUser()->isAllowed( 'read' ) ) {
557 $page = $this->getTitle();
558 } else {
559 $page = Title::newFromText( $request->getVal( 'title', '' ) );
560 }
561 $page = $request->getVal( 'returnto', $page );
562 $a = array();
563 if ( strval( $page ) !== '' ) {
564 $a['returnto'] = $page;
565 $query = $request->getVal( 'returntoquery', $this->thisquery );
566 if ( $query != '' ) {
567 $a['returntoquery'] = $query;
568 }
569 }
570
571 $returnto = wfArrayToCgi( $a );
572 if ( $this->loggedin ) {
573 $personal_urls['userpage'] = array(
574 'text' => $this->username,
575 'href' => &$this->userpageUrlDetails['href'],
576 'class' => $this->userpageUrlDetails['exists'] ? false : 'new',
577 'active' => ( $this->userpageUrlDetails['href'] == $pageurl ),
578 'dir' => 'auto'
579 );
580 $usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage );
581 $personal_urls['mytalk'] = array(
582 'text' => $this->msg( 'mytalk' )->text(),
583 'href' => &$usertalkUrlDetails['href'],
584 'class' => $usertalkUrlDetails['exists'] ? false : 'new',
585 'active' => ( $usertalkUrlDetails['href'] == $pageurl )
586 );
587 $href = self::makeSpecialUrl( 'Preferences' );
588 $personal_urls['preferences'] = array(
589 'text' => $this->msg( 'mypreferences' )->text(),
590 'href' => $href,
591 'active' => ( $href == $pageurl )
592 );
593
594 if ( $this->getUser()->isAllowed( 'viewmywatchlist' ) ) {
595 $href = self::makeSpecialUrl( 'Watchlist' );
596 $personal_urls['watchlist'] = array(
597 'text' => $this->msg( 'mywatchlist' )->text(),
598 'href' => $href,
599 'active' => ( $href == $pageurl )
600 );
601 }
602
603 # We need to do an explicit check for Special:Contributions, as we
604 # have to match both the title, and the target, which could come
605 # from request values (Special:Contributions?target=Jimbo_Wales)
606 # or be specified in "sub page" form
607 # (Special:Contributions/Jimbo_Wales). The plot
608 # thickens, because the Title object is altered for special pages,
609 # so it doesn't contain the original alias-with-subpage.
610 $origTitle = Title::newFromText( $request->getText( 'title' ) );
611 if ( $origTitle instanceof Title && $origTitle->isSpecialPage() ) {
612 list( $spName, $spPar ) = SpecialPageFactory::resolveAlias( $origTitle->getText() );
613 $active = $spName == 'Contributions'
614 && ( ( $spPar && $spPar == $this->username )
615 || $request->getText( 'target' ) == $this->username );
616 } else {
617 $active = false;
618 }
619
620 $href = self::makeSpecialUrlSubpage( 'Contributions', $this->username );
621 $personal_urls['mycontris'] = array(
622 'text' => $this->msg( 'mycontris' )->text(),
623 'href' => $href,
624 'active' => $active
625 );
626 $personal_urls['logout'] = array(
627 'text' => $this->msg( 'pt-userlogout' )->text(),
628 'href' => self::makeSpecialUrl( 'Userlogout',
629 // userlogout link must always contain an & character, otherwise we might not be able
630 // to detect a buggy precaching proxy (bug 17790)
631 $title->isSpecial( 'Preferences' ) ? 'noreturnto' : $returnto
632 ),
633 'active' => false
634 );
635 } else {
636 $useCombinedLoginLink = $this->useCombinedLoginLink();
637 $loginlink = $this->getUser()->isAllowed( 'createaccount' ) && $useCombinedLoginLink
638 ? 'nav-login-createaccount'
639 : 'pt-login';
640 $is_signup = $request->getText( 'type' ) == 'signup';
641
642 $login_url = array(
643 'text' => $this->msg( $loginlink )->text(),
644 'href' => self::makeSpecialUrl( 'Userlogin', $returnto ),
645 'active' => $title->isSpecial( 'Userlogin' )
646 && ( $loginlink == 'nav-login-createaccount' || !$is_signup ),
647 );
648 $createaccount_url = array(
649 'text' => $this->msg( 'pt-createaccount' )->text(),
650 'href' => self::makeSpecialUrl( 'Userlogin', "$returnto&type=signup" ),
651 'active' => $title->isSpecial( 'Userlogin' ) && $is_signup,
652 );
653
654 if ( $this->showIPinHeader() ) {
655 $href = &$this->userpageUrlDetails['href'];
656 $personal_urls['anonuserpage'] = array(
657 'text' => $this->username,
658 'href' => $href,
659 'class' => $this->userpageUrlDetails['exists'] ? false : 'new',
660 'active' => ( $pageurl == $href )
661 );
662 $usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage );
663 $href = &$usertalkUrlDetails['href'];
664 $personal_urls['anontalk'] = array(
665 'text' => $this->msg( 'anontalk' )->text(),
666 'href' => $href,
667 'class' => $usertalkUrlDetails['exists'] ? false : 'new',
668 'active' => ( $pageurl == $href )
669 );
670 }
671
672 if ( $this->getUser()->isAllowed( 'createaccount' ) && !$useCombinedLoginLink ) {
673 $personal_urls['createaccount'] = $createaccount_url;
674 }
675
676 $personal_urls['login'] = $login_url;
677 }
678
679 Hooks::run( 'PersonalUrls', array( &$personal_urls, &$title, $this ) );
680 return $personal_urls;
681 }
682
683 /**
684 * Builds an array with tab definition
685 *
686 * @param Title $title Page Where the tab links to
687 * @param string|array $message Message key or an array of message keys (will fall back)
688 * @param bool $selected Display the tab as selected
689 * @param string $query Query string attached to tab URL
690 * @param bool $checkEdit Check if $title exists and mark with .new if one doesn't
691 *
692 * @return array
693 */
694 function tabAction( $title, $message, $selected, $query = '', $checkEdit = false ) {
695 $classes = array();
696 if ( $selected ) {
697 $classes[] = 'selected';
698 }
699 if ( $checkEdit && !$title->isKnown() ) {
700 $classes[] = 'new';
701 if ( $query !== '' ) {
702 $query = 'action=edit&redlink=1&' . $query;
703 } else {
704 $query = 'action=edit&redlink=1';
705 }
706 }
707
708 // wfMessageFallback will nicely accept $message as an array of fallbacks
709 // or just a single key
710 $msg = wfMessageFallback( $message )->setContext( $this->getContext() );
711 if ( is_array( $message ) ) {
712 // for hook compatibility just keep the last message name
713 $message = end( $message );
714 }
715 if ( $msg->exists() ) {
716 $text = $msg->text();
717 } else {
718 global $wgContLang;
719 $text = $wgContLang->getFormattedNsText(
720 MWNamespace::getSubject( $title->getNamespace() ) );
721 }
722
723 $result = array();
724 if ( !Hooks::run( 'SkinTemplateTabAction', array( &$this,
725 $title, $message, $selected, $checkEdit,
726 &$classes, &$query, &$text, &$result ) ) ) {
727 return $result;
728 }
729
730 return array(
731 'class' => implode( ' ', $classes ),
732 'text' => $text,
733 'href' => $title->getLocalURL( $query ),
734 'primary' => true );
735 }
736
737 function makeTalkUrlDetails( $name, $urlaction = '' ) {
738 $title = Title::newFromText( $name );
739 if ( !is_object( $title ) ) {
740 throw new MWException( __METHOD__ . " given invalid pagename $name" );
741 }
742 $title = $title->getTalkPage();
743 self::checkTitle( $title, $name );
744 return array(
745 'href' => $title->getLocalURL( $urlaction ),
746 'exists' => $title->getArticleID() != 0,
747 );
748 }
749
750 function makeArticleUrlDetails( $name, $urlaction = '' ) {
751 $title = Title::newFromText( $name );
752 $title = $title->getSubjectPage();
753 self::checkTitle( $title, $name );
754 return array(
755 'href' => $title->getLocalURL( $urlaction ),
756 'exists' => $title->getArticleID() != 0,
757 );
758 }
759
760 /**
761 * a structured array of links usually used for the tabs in a skin
762 *
763 * There are 4 standard sections
764 * namespaces: Used for namespace tabs like special, page, and talk namespaces
765 * views: Used for primary page views like read, edit, history
766 * actions: Used for most extra page actions like deletion, protection, etc...
767 * variants: Used to list the language variants for the page
768 *
769 * Each section's value is a key/value array of links for that section.
770 * The links themselves have these common keys:
771 * - class: The css classes to apply to the tab
772 * - text: The text to display on the tab
773 * - href: The href for the tab to point to
774 * - rel: An optional rel= for the tab's link
775 * - redundant: If true the tab will be dropped in skins using content_actions
776 * this is useful for tabs like "Read" which only have meaning in skins that
777 * take special meaning from the grouped structure of content_navigation
778 *
779 * Views also have an extra key which can be used:
780 * - primary: If this is not true skins like vector may try to hide the tab
781 * when the user has limited space in their browser window
782 *
783 * content_navigation using code also expects these ids to be present on the
784 * links, however these are usually automatically generated by SkinTemplate
785 * itself and are not necessary when using a hook. The only things these may
786 * matter to are people modifying content_navigation after it's initial creation:
787 * - id: A "preferred" id, most skins are best off outputting this preferred
788 * id for best compatibility.
789 * - tooltiponly: This is set to true for some tabs in cases where the system
790 * believes that the accesskey should not be added to the tab.
791 *
792 * @return array
793 */
794 protected function buildContentNavigationUrls() {
795 global $wgDisableLangConversion;
796
797 // Display tabs for the relevant title rather than always the title itself
798 $title = $this->getRelevantTitle();
799 $onPage = $title->equals( $this->getTitle() );
800
801 $out = $this->getOutput();
802 $request = $this->getRequest();
803 $user = $this->getUser();
804
805 $content_navigation = array(
806 'namespaces' => array(),
807 'views' => array(),
808 'actions' => array(),
809 'variants' => array()
810 );
811
812 // parameters
813 $action = $request->getVal( 'action', 'view' );
814
815 $userCanRead = $title->quickUserCan( 'read', $user );
816
817 $preventActiveTabs = false;
818 Hooks::run( 'SkinTemplatePreventOtherActiveTabs', array( &$this, &$preventActiveTabs ) );
819
820 // Checks if page is some kind of content
821 if ( $title->canExist() ) {
822 // Gets page objects for the related namespaces
823 $subjectPage = $title->getSubjectPage();
824 $talkPage = $title->getTalkPage();
825
826 // Determines if this is a talk page
827 $isTalk = $title->isTalkPage();
828
829 // Generates XML IDs from namespace names
830 $subjectId = $title->getNamespaceKey( '' );
831
832 if ( $subjectId == 'main' ) {
833 $talkId = 'talk';
834 } else {
835 $talkId = "{$subjectId}_talk";
836 }
837
838 $skname = $this->skinname;
839
840 // Adds namespace links
841 $subjectMsg = array( "nstab-$subjectId" );
842 if ( $subjectPage->isMainPage() ) {
843 array_unshift( $subjectMsg, 'mainpage-nstab' );
844 }
845 $content_navigation['namespaces'][$subjectId] = $this->tabAction(
846 $subjectPage, $subjectMsg, !$isTalk && !$preventActiveTabs, '', $userCanRead
847 );
848 $content_navigation['namespaces'][$subjectId]['context'] = 'subject';
849 $content_navigation['namespaces'][$talkId] = $this->tabAction(
850 $talkPage, array( "nstab-$talkId", 'talk' ), $isTalk && !$preventActiveTabs, '', $userCanRead
851 );
852 $content_navigation['namespaces'][$talkId]['context'] = 'talk';
853
854 if ( $userCanRead ) {
855 $isForeignFile = $title->inNamespace( NS_FILE ) && $this->canUseWikiPage() &&
856 $this->getWikiPage() instanceof WikiFilePage && !$this->getWikiPage()->isLocal();
857
858 // Adds view view link
859 if ( $title->exists() || $isForeignFile ) {
860 $content_navigation['views']['view'] = $this->tabAction(
861 $isTalk ? $talkPage : $subjectPage,
862 array( "$skname-view-view", 'view' ),
863 ( $onPage && ( $action == 'view' || $action == 'purge' ) ), '', true
864 );
865 // signal to hide this from simple content_actions
866 $content_navigation['views']['view']['redundant'] = true;
867 }
868
869 // If it is a non-local file, show a link to the file in its own repository
870 if ( $isForeignFile ) {
871 $file = $this->getWikiPage()->getFile();
872 $content_navigation['views']['view-foreign'] = array(
873 'class' => '',
874 'text' => wfMessageFallback( "$skname-view-foreign", 'view-foreign' )->
875 setContext( $this->getContext() )->
876 params( $file->getRepo()->getDisplayName() )->text(),
877 'href' => $file->getDescriptionUrl(),
878 'primary' => false,
879 );
880 }
881
882 // Checks if user can edit the current page if it exists or create it otherwise
883 if ( $title->quickUserCan( 'edit', $user )
884 && ( $title->exists() || $title->quickUserCan( 'create', $user ) )
885 ) {
886 // Builds CSS class for talk page links
887 $isTalkClass = $isTalk ? ' istalk' : '';
888 // Whether the user is editing the page
889 $isEditing = $onPage && ( $action == 'edit' || $action == 'submit' );
890 // Whether to show the "Add a new section" tab
891 // Checks if this is a current rev of talk page and is not forced to be hidden
892 $showNewSection = !$out->forceHideNewSectionLink()
893 && ( ( $isTalk && $this->isRevisionCurrent() ) || $out->showNewSectionLink() );
894 $section = $request->getVal( 'section' );
895
896 if ( $title->exists()
897 || ( $title->getNamespace() == NS_MEDIAWIKI
898 && $title->getDefaultMessageText() !== false
899 )
900 ) {
901 $msgKey = $isForeignFile ? 'edit-local' : 'edit';
902 } else {
903 $msgKey = $isForeignFile ? 'create-local' : 'create';
904 }
905 $content_navigation['views']['edit'] = array(
906 'class' => ( $isEditing && ( $section !== 'new' || !$showNewSection )
907 ? 'selected'
908 : ''
909 ) . $isTalkClass,
910 'text' => wfMessageFallback( "$skname-view-$msgKey", $msgKey )
911 ->setContext( $this->getContext() )->text(),
912 'href' => $title->getLocalURL( $this->editUrlOptions() ),
913 'primary' => !$isForeignFile, // don't collapse this in vector
914 );
915
916 // section link
917 if ( $showNewSection ) {
918 // Adds new section link
919 //$content_navigation['actions']['addsection']
920 $content_navigation['views']['addsection'] = array(
921 'class' => ( $isEditing && $section == 'new' ) ? 'selected' : false,
922 'text' => wfMessageFallback( "$skname-action-addsection", 'addsection' )
923 ->setContext( $this->getContext() )->text(),
924 'href' => $title->getLocalURL( 'action=edit&section=new' )
925 );
926 }
927 // Checks if the page has some kind of viewable content
928 } elseif ( $title->hasSourceText() ) {
929 // Adds view source view link
930 $content_navigation['views']['viewsource'] = array(
931 'class' => ( $onPage && $action == 'edit' ) ? 'selected' : false,
932 'text' => wfMessageFallback( "$skname-action-viewsource", 'viewsource' )
933 ->setContext( $this->getContext() )->text(),
934 'href' => $title->getLocalURL( $this->editUrlOptions() ),
935 'primary' => true, // don't collapse this in vector
936 );
937 }
938
939 // Checks if the page exists
940 if ( $title->exists() ) {
941 // Adds history view link
942 $content_navigation['views']['history'] = array(
943 'class' => ( $onPage && $action == 'history' ) ? 'selected' : false,
944 'text' => wfMessageFallback( "$skname-view-history", 'history_short' )
945 ->setContext( $this->getContext() )->text(),
946 'href' => $title->getLocalURL( 'action=history' ),
947 'rel' => 'archives',
948 );
949
950 if ( $title->quickUserCan( 'delete', $user ) ) {
951 $content_navigation['actions']['delete'] = array(
952 'class' => ( $onPage && $action == 'delete' ) ? 'selected' : false,
953 'text' => wfMessageFallback( "$skname-action-delete", 'delete' )
954 ->setContext( $this->getContext() )->text(),
955 'href' => $title->getLocalURL( 'action=delete' )
956 );
957 }
958
959 if ( $title->quickUserCan( 'move', $user ) ) {
960 $moveTitle = SpecialPage::getTitleFor( 'Movepage', $title->getPrefixedDBkey() );
961 $content_navigation['actions']['move'] = array(
962 'class' => $this->getTitle()->isSpecial( 'Movepage' ) ? 'selected' : false,
963 'text' => wfMessageFallback( "$skname-action-move", 'move' )
964 ->setContext( $this->getContext() )->text(),
965 'href' => $moveTitle->getLocalURL()
966 );
967 }
968 } else {
969 // article doesn't exist or is deleted
970 if ( $user->isAllowed( 'deletedhistory' ) ) {
971 $n = $title->isDeleted();
972 if ( $n ) {
973 $undelTitle = SpecialPage::getTitleFor( 'Undelete', $title->getPrefixedDBkey() );
974 // If the user can't undelete but can view deleted
975 // history show them a "View .. deleted" tab instead.
976 $msgKey = $user->isAllowed( 'undelete' ) ? 'undelete' : 'viewdeleted';
977 $content_navigation['actions']['undelete'] = array(
978 'class' => $this->getTitle()->isSpecial( 'Undelete' ) ? 'selected' : false,
979 'text' => wfMessageFallback( "$skname-action-$msgKey", "{$msgKey}_short" )
980 ->setContext( $this->getContext() )->numParams( $n )->text(),
981 'href' => $undelTitle->getLocalURL()
982 );
983 }
984 }
985 }
986
987 if ( $title->quickUserCan( 'protect', $user ) && $title->getRestrictionTypes() &&
988 MWNamespace::getRestrictionLevels( $title->getNamespace(), $user ) !== array( '' )
989 ) {
990 $mode = $title->isProtected() ? 'unprotect' : 'protect';
991 $content_navigation['actions'][$mode] = array(
992 'class' => ( $onPage && $action == $mode ) ? 'selected' : false,
993 'text' => wfMessageFallback( "$skname-action-$mode", $mode )
994 ->setContext( $this->getContext() )->text(),
995 'href' => $title->getLocalURL( "action=$mode" )
996 );
997 }
998
999 // Checks if the user is logged in
1000 if ( $this->loggedin && $user->isAllowedAll( 'viewmywatchlist', 'editmywatchlist' ) ) {
1001 /**
1002 * The following actions use messages which, if made particular to
1003 * the any specific skins, would break the Ajax code which makes this
1004 * action happen entirely inline. OutputPage::getJSVars
1005 * defines a set of messages in a javascript object - and these
1006 * messages are assumed to be global for all skins. Without making
1007 * a change to that procedure these messages will have to remain as
1008 * the global versions.
1009 */
1010 $mode = $user->isWatched( $title ) ? 'unwatch' : 'watch';
1011 $token = WatchAction::getWatchToken( $title, $user, $mode );
1012 $content_navigation['actions'][$mode] = array(
1013 'class' => $onPage && ( $action == 'watch' || $action == 'unwatch' ) ? 'selected' : false,
1014 // uses 'watch' or 'unwatch' message
1015 'text' => $this->msg( $mode )->text(),
1016 'href' => $title->getLocalURL( array( 'action' => $mode, 'token' => $token ) )
1017 );
1018 }
1019 }
1020
1021 Hooks::run( 'SkinTemplateNavigation', array( &$this, &$content_navigation ) );
1022
1023 if ( $userCanRead && !$wgDisableLangConversion ) {
1024 $pageLang = $title->getPageLanguage();
1025 // Gets list of language variants
1026 $variants = $pageLang->getVariants();
1027 // Checks that language conversion is enabled and variants exist
1028 // And if it is not in the special namespace
1029 if ( count( $variants ) > 1 ) {
1030 // Gets preferred variant (note that user preference is
1031 // only possible for wiki content language variant)
1032 $preferred = $pageLang->getPreferredVariant();
1033 if ( Action::getActionName( $this ) === 'view' ) {
1034 $params = $request->getQueryValues();
1035 unset( $params['title'] );
1036 } else {
1037 $params = array();
1038 }
1039 // Loops over each variant
1040 foreach ( $variants as $code ) {
1041 // Gets variant name from language code
1042 $varname = $pageLang->getVariantname( $code );
1043 // Appends variant link
1044 $content_navigation['variants'][] = array(
1045 'class' => ( $code == $preferred ) ? 'selected' : false,
1046 'text' => $varname,
1047 'href' => $title->getLocalURL( array( 'variant' => $code ) + $params ),
1048 'lang' => wfBCP47( $code ),
1049 'hreflang' => wfBCP47( $code ),
1050 );
1051 }
1052 }
1053 }
1054 } else {
1055 // If it's not content, it's got to be a special page
1056 $content_navigation['namespaces']['special'] = array(
1057 'class' => 'selected',
1058 'text' => $this->msg( 'nstab-special' )->text(),
1059 'href' => $request->getRequestURL(), // @see: bug 2457, bug 2510
1060 'context' => 'subject'
1061 );
1062
1063 Hooks::run( 'SkinTemplateNavigation::SpecialPage',
1064 array( &$this, &$content_navigation ) );
1065 }
1066
1067 // Equiv to SkinTemplateContentActions
1068 Hooks::run( 'SkinTemplateNavigation::Universal', array( &$this, &$content_navigation ) );
1069
1070 // Setup xml ids and tooltip info
1071 foreach ( $content_navigation as $section => &$links ) {
1072 foreach ( $links as $key => &$link ) {
1073 $xmlID = $key;
1074 if ( isset( $link['context'] ) && $link['context'] == 'subject' ) {
1075 $xmlID = 'ca-nstab-' . $xmlID;
1076 } elseif ( isset( $link['context'] ) && $link['context'] == 'talk' ) {
1077 $xmlID = 'ca-talk';
1078 } elseif ( $section == 'variants' ) {
1079 $xmlID = 'ca-varlang-' . $xmlID;
1080 } else {
1081 $xmlID = 'ca-' . $xmlID;
1082 }
1083 $link['id'] = $xmlID;
1084 }
1085 }
1086
1087 # We don't want to give the watch tab an accesskey if the
1088 # page is being edited, because that conflicts with the
1089 # accesskey on the watch checkbox. We also don't want to
1090 # give the edit tab an accesskey, because that's fairly
1091 # superfluous and conflicts with an accesskey (Ctrl-E) often
1092 # used for editing in Safari.
1093 if ( in_array( $action, array( 'edit', 'submit' ) ) ) {
1094 if ( isset( $content_navigation['views']['edit'] ) ) {
1095 $content_navigation['views']['edit']['tooltiponly'] = true;
1096 }
1097 if ( isset( $content_navigation['actions']['watch'] ) ) {
1098 $content_navigation['actions']['watch']['tooltiponly'] = true;
1099 }
1100 if ( isset( $content_navigation['actions']['unwatch'] ) ) {
1101 $content_navigation['actions']['unwatch']['tooltiponly'] = true;
1102 }
1103 }
1104
1105 return $content_navigation;
1106 }
1107
1108 /**
1109 * an array of edit links by default used for the tabs
1110 * @param array $content_navigation
1111 * @return array
1112 */
1113 private function buildContentActionUrls( $content_navigation ) {
1114
1115 // content_actions has been replaced with content_navigation for backwards
1116 // compatibility and also for skins that just want simple tabs content_actions
1117 // is now built by flattening the content_navigation arrays into one
1118
1119 $content_actions = array();
1120
1121 foreach ( $content_navigation as $links ) {
1122 foreach ( $links as $key => $value ) {
1123 if ( isset( $value['redundant'] ) && $value['redundant'] ) {
1124 // Redundant tabs are dropped from content_actions
1125 continue;
1126 }
1127
1128 // content_actions used to have ids built using the "ca-$key" pattern
1129 // so the xmlID based id is much closer to the actual $key that we want
1130 // for that reason we'll just strip out the ca- if present and use
1131 // the latter potion of the "id" as the $key
1132 if ( isset( $value['id'] ) && substr( $value['id'], 0, 3 ) == 'ca-' ) {
1133 $key = substr( $value['id'], 3 );
1134 }
1135
1136 if ( isset( $content_actions[$key] ) ) {
1137 wfDebug( __METHOD__ . ": Found a duplicate key for $key while flattening " .
1138 "content_navigation into content_actions.\n" );
1139 continue;
1140 }
1141
1142 $content_actions[$key] = $value;
1143 }
1144 }
1145
1146 return $content_actions;
1147 }
1148
1149 /**
1150 * build array of common navigation links
1151 * @return array
1152 */
1153 protected function buildNavUrls() {
1154 global $wgUploadNavigationUrl;
1155
1156 $out = $this->getOutput();
1157 $request = $this->getRequest();
1158
1159 $nav_urls = array();
1160 $nav_urls['mainpage'] = array( 'href' => self::makeMainPageUrl() );
1161 if ( $wgUploadNavigationUrl ) {
1162 $nav_urls['upload'] = array( 'href' => $wgUploadNavigationUrl );
1163 } elseif ( UploadBase::isEnabled() && UploadBase::isAllowed( $this->getUser() ) === true ) {
1164 $nav_urls['upload'] = array( 'href' => self::makeSpecialUrl( 'Upload' ) );
1165 } else {
1166 $nav_urls['upload'] = false;
1167 }
1168 $nav_urls['specialpages'] = array( 'href' => self::makeSpecialUrl( 'Specialpages' ) );
1169
1170 $nav_urls['print'] = false;
1171 $nav_urls['permalink'] = false;
1172 $nav_urls['info'] = false;
1173 $nav_urls['whatlinkshere'] = false;
1174 $nav_urls['recentchangeslinked'] = false;
1175 $nav_urls['contributions'] = false;
1176 $nav_urls['log'] = false;
1177 $nav_urls['blockip'] = false;
1178 $nav_urls['emailuser'] = false;
1179 $nav_urls['userrights'] = false;
1180
1181 // A print stylesheet is attached to all pages, but nobody ever
1182 // figures that out. :) Add a link...
1183 if ( !$out->isPrintable() && ( $out->isArticle() || $this->getTitle()->isSpecialPage() ) ) {
1184 $nav_urls['print'] = array(
1185 'text' => $this->msg( 'printableversion' )->text(),
1186 'href' => $this->getTitle()->getLocalURL(
1187 $request->appendQueryValue( 'printable', 'yes', true ) )
1188 );
1189 }
1190
1191 if ( $out->isArticle() ) {
1192 // Also add a "permalink" while we're at it
1193 $revid = $this->getRevisionId();
1194 if ( $revid ) {
1195 $nav_urls['permalink'] = array(
1196 'text' => $this->msg( 'permalink' )->text(),
1197 'href' => $this->getTitle()->getLocalURL( "oldid=$revid" )
1198 );
1199 }
1200
1201 // Use the copy of revision ID in case this undocumented, shady hook tries to mess with internals
1202 Hooks::run( 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink',
1203 array( &$this, &$nav_urls, &$revid, &$revid ) );
1204 }
1205
1206 if ( $out->isArticleRelated() ) {
1207 $nav_urls['whatlinkshere'] = array(
1208 'href' => SpecialPage::getTitleFor( 'Whatlinkshere', $this->thispage )->getLocalURL()
1209 );
1210
1211 $nav_urls['info'] = array(
1212 'text' => $this->msg( 'pageinfo-toolboxlink' )->text(),
1213 'href' => $this->getTitle()->getLocalURL( "action=info" )
1214 );
1215
1216 if ( $this->getTitle()->getArticleID() ) {
1217 $nav_urls['recentchangeslinked'] = array(
1218 'href' => SpecialPage::getTitleFor( 'Recentchangeslinked', $this->thispage )->getLocalURL()
1219 );
1220 }
1221 }
1222
1223 $user = $this->getRelevantUser();
1224 if ( $user ) {
1225 $rootUser = $user->getName();
1226
1227 $nav_urls['contributions'] = array(
1228 'text' => $this->msg( 'contributions', $rootUser )->text(),
1229 'href' => self::makeSpecialUrlSubpage( 'Contributions', $rootUser )
1230 );
1231
1232 $nav_urls['log'] = array(
1233 'href' => self::makeSpecialUrlSubpage( 'Log', $rootUser )
1234 );
1235
1236 if ( $this->getUser()->isAllowed( 'block' ) ) {
1237 $nav_urls['blockip'] = array(
1238 'text' => $this->msg( 'blockip', $rootUser )->text(),
1239 'href' => self::makeSpecialUrlSubpage( 'Block', $rootUser )
1240 );
1241 }
1242
1243 if ( $this->showEmailUser( $user ) ) {
1244 $nav_urls['emailuser'] = array(
1245 'href' => self::makeSpecialUrlSubpage( 'Emailuser', $rootUser )
1246 );
1247 }
1248
1249 if ( !$user->isAnon() ) {
1250 $sur = new UserrightsPage;
1251 $sur->setContext( $this->getContext() );
1252 if ( $sur->userCanExecute( $this->getUser() ) ) {
1253 $nav_urls['userrights'] = array(
1254 'href' => self::makeSpecialUrlSubpage( 'Userrights', $rootUser )
1255 );
1256 }
1257 }
1258 }
1259
1260 return $nav_urls;
1261 }
1262
1263 /**
1264 * Generate strings used for xml 'id' names
1265 * @return string
1266 */
1267 protected function getNameSpaceKey() {
1268 return $this->getTitle()->getNamespaceKey();
1269 }
1270 }