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