MediaWiki REL1_32
SkinTemplate.php
Go to the documentation of this file.
1<?php
23
38class SkinTemplate extends Skin {
43 public $skinname = 'monobook';
44
49 public $template = QuickTemplate::class;
50
51 public $thispage;
52 public $titletxt;
53 public $userpage;
54 public $thisquery;
55 public $loggedin;
56 public $username;
58
70 function setupTemplate( $classname, $repository = false, $cache_dir = false ) {
71 return new $classname( $this->getConfig() );
72 }
73
79 public function getLanguages() {
82 return [];
83 }
84
85 $userLang = $this->getLanguage();
86 $languageLinks = [];
87
88 foreach ( $this->getOutput()->getLanguageLinks() as $languageLinkText ) {
89 $class = 'interlanguage-link interwiki-' . explode( ':', $languageLinkText, 2 )[0];
90
91 $languageLinkTitle = Title::newFromText( $languageLinkText );
92 if ( $languageLinkTitle ) {
93 $ilInterwikiCode = $languageLinkTitle->getInterwiki();
94 $ilLangName = Language::fetchLanguageName( $ilInterwikiCode );
95
96 if ( strval( $ilLangName ) === '' ) {
97 $ilDisplayTextMsg = wfMessage( "interlanguage-link-$ilInterwikiCode" );
98 if ( !$ilDisplayTextMsg->isDisabled() ) {
99 // Use custom MW message for the display text
100 $ilLangName = $ilDisplayTextMsg->text();
101 } else {
102 // Last resort: fallback to the language link target
103 $ilLangName = $languageLinkText;
104 }
105 } else {
106 // Use the language autonym as display text
107 $ilLangName = $this->formatLanguageName( $ilLangName );
108 }
109
110 // CLDR extension or similar is required to localize the language name;
111 // otherwise we'll end up with the autonym again.
112 $ilLangLocalName = Language::fetchLanguageName(
113 $ilInterwikiCode,
114 $userLang->getCode()
115 );
116
117 $languageLinkTitleText = $languageLinkTitle->getText();
118 if ( $ilLangLocalName === '' ) {
119 $ilFriendlySiteName = wfMessage( "interlanguage-link-sitename-$ilInterwikiCode" );
120 if ( !$ilFriendlySiteName->isDisabled() ) {
121 if ( $languageLinkTitleText === '' ) {
122 $ilTitle = wfMessage(
123 'interlanguage-link-title-nonlangonly',
124 $ilFriendlySiteName->text()
125 )->text();
126 } else {
127 $ilTitle = wfMessage(
128 'interlanguage-link-title-nonlang',
129 $languageLinkTitleText,
130 $ilFriendlySiteName->text()
131 )->text();
132 }
133 } else {
134 // we have nothing friendly to put in the title, so fall back to
135 // displaying the interlanguage link itself in the title text
136 // (similar to what is done in page content)
137 $ilTitle = $languageLinkTitle->getInterwiki() .
138 ":$languageLinkTitleText";
139 }
140 } elseif ( $languageLinkTitleText === '' ) {
141 $ilTitle = wfMessage(
142 'interlanguage-link-title-langonly',
143 $ilLangLocalName
144 )->text();
145 } else {
146 $ilTitle = wfMessage(
147 'interlanguage-link-title',
148 $languageLinkTitleText,
149 $ilLangLocalName
150 )->text();
151 }
152
153 $ilInterwikiCodeBCP47 = LanguageCode::bcp47( $ilInterwikiCode );
154 $languageLink = [
155 'href' => $languageLinkTitle->getFullURL(),
156 'text' => $ilLangName,
157 'title' => $ilTitle,
158 'class' => $class,
159 'link-class' => 'interlanguage-link-target',
160 'lang' => $ilInterwikiCodeBCP47,
161 'hreflang' => $ilInterwikiCodeBCP47,
162 ];
163 Hooks::run(
164 'SkinTemplateGetLanguageLink',
165 [ &$languageLink, $languageLinkTitle, $this->getTitle(), $this->getOutput() ]
166 );
167 $languageLinks[] = $languageLink;
168 }
169 }
170
171 return $languageLinks;
172 }
173
174 protected function setupTemplateForOutput() {
175 $request = $this->getRequest();
176 $user = $this->getUser();
177 $title = $this->getTitle();
178
179 $tpl = $this->setupTemplate( $this->template, 'skins' );
180
181 $this->thispage = $title->getPrefixedDBkey();
182 $this->titletxt = $title->getPrefixedText();
183 $this->userpage = $user->getUserPage()->getPrefixedText();
184 $query = [];
185 if ( !$request->wasPosted() ) {
186 $query = $request->getValues();
187 unset( $query['title'] );
188 unset( $query['returnto'] );
189 unset( $query['returntoquery'] );
190 }
191 $this->thisquery = wfArrayToCgi( $query );
192 $this->loggedin = $user->isLoggedIn();
193 $this->username = $user->getName();
194
195 if ( $this->loggedin ) {
196 $this->userpageUrlDetails = self::makeUrlDetails( $this->userpage );
197 } else {
198 # This won't be used in the standard skins, but we define it to preserve the interface
199 # To save time, we check for existence
200 $this->userpageUrlDetails = self::makeKnownUrlDetails( $this->userpage );
201 }
202
203 return $tpl;
204 }
205
211 function outputPage( OutputPage $out = null ) {
212 Profiler::instance()->setTemplated( true );
213
214 $oldContext = null;
215 if ( $out !== null ) {
216 // Deprecated since 1.20, note added in 1.25
217 wfDeprecated( __METHOD__, '1.25' );
218 $oldContext = $this->getContext();
219 $this->setContext( $out->getContext() );
220 }
221
222 $out = $this->getOutput();
223
224 $this->initPage( $out );
225 $tpl = $this->prepareQuickTemplate();
226 // execute template
227 $res = $tpl->execute();
228
229 // result may be an error
230 $this->printOrError( $res );
231
232 if ( $oldContext ) {
233 $this->setContext( $oldContext );
234 }
235 }
236
244 protected function wrapHTML( $title, $html ) {
245 # An ID that includes the actual body text; without categories, contentSub, ...
246 $realBodyAttribs = [ 'id' => 'mw-content-text' ];
247
248 # Add a mw-content-ltr/rtl class to be able to style based on text
249 # direction when the content is different from the UI language (only
250 # when viewing)
251 # Most information on special pages and file pages is in user language,
252 # rather than content language, so those will not get this
253 if ( Action::getActionName( $this ) === 'view' &&
254 ( !$title->inNamespaces( NS_SPECIAL, NS_FILE ) || $title->isRedirect() ) ) {
255 $pageLang = $title->getPageViewLanguage();
256 $realBodyAttribs['lang'] = $pageLang->getHtmlCode();
257 $realBodyAttribs['dir'] = $pageLang->getDir();
258 $realBodyAttribs['class'] = 'mw-content-' . $pageLang->getDir();
259 }
260
261 return Html::rawElement( 'div', $realBodyAttribs, $html );
262 }
263
270 protected function prepareQuickTemplate() {
275
276 $title = $this->getTitle();
277 $request = $this->getRequest();
278 $out = $this->getOutput();
279 $tpl = $this->setupTemplateForOutput();
280
281 $tpl->set( 'title', $out->getPageTitle() );
282 $tpl->set( 'pagetitle', $out->getHTMLTitle() );
283 $tpl->set( 'displaytitle', $out->mPageLinkTitle );
284
285 $tpl->set( 'thispage', $this->thispage );
286 $tpl->set( 'titleprefixeddbkey', $this->thispage );
287 $tpl->set( 'titletext', $title->getText() );
288 $tpl->set( 'articleid', $title->getArticleID() );
289
290 $tpl->set( 'isarticle', $out->isArticle() );
291
292 $subpagestr = $this->subPageSubtitle();
293 if ( $subpagestr !== '' ) {
294 $subpagestr = '<span class="subpages">' . $subpagestr . '</span>';
295 }
296 $tpl->set( 'subtitle', $subpagestr . $out->getSubtitle() );
297
298 $undelete = $this->getUndeleteLink();
299 if ( $undelete === '' ) {
300 $tpl->set( 'undelete', '' );
301 } else {
302 $tpl->set( 'undelete', '<span class="subpages">' . $undelete . '</span>' );
303 }
304
305 $tpl->set( 'catlinks', $this->getCategories() );
306 if ( $out->isSyndicated() ) {
307 $feeds = [];
308 foreach ( $out->getSyndicationLinks() as $format => $link ) {
309 $feeds[$format] = [
310 // Messages: feed-atom, feed-rss
311 'text' => $this->msg( "feed-$format" )->text(),
312 'href' => $link
313 ];
314 }
315 $tpl->set( 'feeds', $feeds );
316 } else {
317 $tpl->set( 'feeds', false );
318 }
319
320 $tpl->set( 'mimetype', $wgMimeType );
321 $tpl->set( 'jsmimetype', $wgJsMimeType );
322 $tpl->set( 'charset', 'UTF-8' );
323 $tpl->set( 'wgScript', $wgScript );
324 $tpl->set( 'skinname', $this->skinname );
325 $tpl->set( 'skinclass', static::class );
326 $tpl->set( 'skin', $this );
327 $tpl->set( 'stylename', $this->stylename );
328 $tpl->set( 'printable', $out->isPrintable() );
329 $tpl->set( 'handheld', $request->getBool( 'handheld' ) );
330 $tpl->set( 'loggedin', $this->loggedin );
331 $tpl->set( 'notspecialpage', !$title->isSpecialPage() );
332 $tpl->set( 'searchaction', $this->escapeSearchLink() );
333 $tpl->set( 'searchtitle', SpecialPage::getTitleFor( 'Search' )->getPrefixedDBkey() );
334 $tpl->set( 'search', trim( $request->getVal( 'search' ) ) );
335 $tpl->set( 'stylepath', $wgStylePath );
336 $tpl->set( 'articlepath', $wgArticlePath );
337 $tpl->set( 'scriptpath', $wgScriptPath );
338 $tpl->set( 'serverurl', $wgServer );
339 $tpl->set( 'logopath', $wgLogo );
340 $tpl->set( 'sitename', $wgSitename );
341
342 $userLang = $this->getLanguage();
343 $userLangCode = $userLang->getHtmlCode();
344 $userLangDir = $userLang->getDir();
345
346 $tpl->set( 'lang', $userLangCode );
347 $tpl->set( 'dir', $userLangDir );
348 $tpl->set( 'rtl', $userLang->isRTL() );
349
350 $tpl->set( 'capitalizeallnouns', $userLang->capitalizeAllNouns() ? ' capitalize-all-nouns' : '' );
351 $tpl->set( 'showjumplinks', true ); // showjumplinks preference has been removed
352 $tpl->set( 'username', $this->loggedin ? $this->username : null );
353 $tpl->set( 'userpage', $this->userpage );
354 $tpl->set( 'userpageurl', $this->userpageUrlDetails['href'] );
355 $tpl->set( 'userlang', $userLangCode );
356
357 // Users can have their language set differently than the
358 // content of the wiki. For these users, tell the web browser
359 // that interface elements are in a different language.
360 $tpl->set( 'userlangattributes', '' );
361 $tpl->set( 'specialpageattributes', '' ); # obsolete
362 // Used by VectorBeta to insert HTML before content but after the
363 // heading for the page title. Defaults to empty string.
364 $tpl->set( 'prebodyhtml', '' );
365
366 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
367 if (
368 $userLangCode !== $contLang->getHtmlCode() ||
369 $userLangDir !== $contLang->getDir()
370 ) {
371 $escUserlang = htmlspecialchars( $userLangCode );
372 $escUserdir = htmlspecialchars( $userLangDir );
373 // Attributes must be in double quotes because htmlspecialchars() doesn't
374 // escape single quotes
375 $attrs = " lang=\"$escUserlang\" dir=\"$escUserdir\"";
376 $tpl->set( 'userlangattributes', $attrs );
377 }
378
379 $tpl->set( 'newtalk', $this->getNewtalks() );
380 $tpl->set( 'logo', $this->logoText() );
381
382 $tpl->set( 'copyright', false );
383 // No longer used
384 $tpl->set( 'viewcount', false );
385 $tpl->set( 'lastmod', false );
386 $tpl->set( 'credits', false );
387 $tpl->set( 'numberofwatchingusers', false );
388 if ( $title->exists() ) {
389 if ( $out->isArticle() ) {
390 if ( $this->isRevisionCurrent() ) {
391 if ( $wgMaxCredits != 0 ) {
392 $tpl->set( 'credits', Action::factory( 'credits', $this->getWikiPage(),
393 $this->getContext() )->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ) );
394 } else {
395 $tpl->set( 'lastmod', $this->lastModified() );
396 }
397 }
398 }
399 if ( $out->showsCopyright() ) {
400 $tpl->set( 'copyright', $this->getCopyright() );
401 }
402 }
403
404 $tpl->set( 'copyrightico', $this->getCopyrightIcon() );
405 $tpl->set( 'poweredbyico', $this->getPoweredBy() );
406 $tpl->set( 'disclaimer', $this->disclaimerLink() );
407 $tpl->set( 'privacy', $this->privacyLink() );
408 $tpl->set( 'about', $this->aboutLink() );
409
410 $tpl->set( 'footerlinks', [
411 'info' => [
412 'lastmod',
413 'numberofwatchingusers',
414 'credits',
415 'copyright',
416 ],
417 'places' => [
418 'privacy',
419 'about',
420 'disclaimer',
421 ],
422 ] );
423
424 global $wgFooterIcons;
425 $tpl->set( 'footericons', $wgFooterIcons );
426 foreach ( $tpl->data['footericons'] as $footerIconsKey => &$footerIconsBlock ) {
427 if ( count( $footerIconsBlock ) > 0 ) {
428 foreach ( $footerIconsBlock as &$footerIcon ) {
429 if ( isset( $footerIcon['src'] ) ) {
430 if ( !isset( $footerIcon['width'] ) ) {
431 $footerIcon['width'] = 88;
432 }
433 if ( !isset( $footerIcon['height'] ) ) {
434 $footerIcon['height'] = 31;
435 }
436 }
437 }
438 } else {
439 unset( $tpl->data['footericons'][$footerIconsKey] );
440 }
441 }
442
443 $tpl->set( 'indicators', $out->getIndicators() );
444
445 $tpl->set( 'sitenotice', $this->getSiteNotice() );
446 $tpl->set( 'printfooter', $this->printSource() );
447 // Wrap the bodyText with #mw-content-text element
448 $out->mBodytext = $this->wrapHTML( $title, $out->mBodytext );
449 $tpl->set( 'bodytext', $out->mBodytext );
450
451 $language_urls = $this->getLanguages();
452 if ( count( $language_urls ) ) {
453 $tpl->set( 'language_urls', $language_urls );
454 } else {
455 $tpl->set( 'language_urls', false );
456 }
457
458 # Personal toolbar
459 $tpl->set( 'personal_urls', $this->buildPersonalUrls() );
460 $content_navigation = $this->buildContentNavigationUrls();
461 $content_actions = $this->buildContentActionUrls( $content_navigation );
462 $tpl->set( 'content_navigation', $content_navigation );
463 $tpl->set( 'content_actions', $content_actions );
464
465 $tpl->set( 'sidebar', $this->buildSidebar() );
466 $tpl->set( 'nav_urls', $this->buildNavUrls() );
467
468 // Do this last in case hooks above add bottom scripts
469 $tpl->set( 'bottomscripts', $this->bottomScripts() );
470
471 // Set the head scripts near the end, in case the above actions resulted in added scripts
472 $tpl->set( 'headelement', $out->headElement( $this ) );
473
474 $tpl->set( 'debug', '' );
475 $tpl->set( 'debughtml', $this->generateDebugHTML() );
476 $tpl->set( 'reporttime', wfReportTime( $out->getCSPNonce() ) );
477
478 // Avoid PHP 7.1 warning of passing $this by reference
479 $skinTemplate = $this;
480 // original version by hansm
481 if ( !Hooks::run( 'SkinTemplateOutputPageBeforeExec', [ &$skinTemplate, &$tpl ] ) ) {
482 wfDebug( __METHOD__ . ": Hook SkinTemplateOutputPageBeforeExec broke outputPage execution!\n" );
483 }
484
485 // Set the bodytext to another key so that skins can just output it on its own
486 // and output printfooter and debughtml separately
487 $tpl->set( 'bodycontent', $tpl->data['bodytext'] );
488
489 // Append printfooter and debughtml onto bodytext so that skins that
490 // were already using bodytext before they were split out don't suddenly
491 // start not outputting information.
492 $tpl->data['bodytext'] .= Html::rawElement(
493 'div',
494 [ 'class' => 'printfooter' ],
495 "\n{$tpl->data['printfooter']}"
496 ) . "\n";
497 $tpl->data['bodytext'] .= $tpl->data['debughtml'];
498
499 // allow extensions adding stuff after the page content.
500 // See Skin::afterContentHook() for further documentation.
501 $tpl->set( 'dataAfterContent', $this->afterContentHook() );
502
503 return $tpl;
504 }
505
510 public function getPersonalToolsList() {
511 return $this->makePersonalToolsList();
512 }
513
523 public function makePersonalToolsList( $personalTools = null, $options = [] ) {
524 $tpl = $this->setupTemplateForOutput();
525 $tpl->set( 'personal_urls', $this->buildPersonalUrls() );
526 $html = '';
527
528 if ( $personalTools === null ) {
529 $personalTools = $tpl->getPersonalTools();
530 }
531
532 foreach ( $personalTools as $key => $item ) {
533 $html .= $tpl->makeListItem( $key, $item, $options );
534 }
535
536 return $html;
537 }
538
546 public function getStructuredPersonalTools() {
547 $tpl = $this->setupTemplateForOutput();
548 $tpl->set( 'personal_urls', $this->buildPersonalUrls() );
549
550 return $tpl->getPersonalTools();
551 }
552
561 function formatLanguageName( $name ) {
562 return $this->getLanguage()->ucfirst( $name );
563 }
564
573 function printOrError( $str ) {
574 echo $str;
575 }
576
589 }
590
595 protected function buildPersonalUrls() {
596 $title = $this->getTitle();
597 $request = $this->getRequest();
598 $pageurl = $title->getLocalURL();
599 $authManager = AuthManager::singleton();
600
601 /* set up the default links for the personal toolbar */
602 $personal_urls = [];
603
604 # Due to T34276, if a user does not have read permissions,
605 # $this->getTitle() will just give Special:Badtitle, which is
606 # not especially useful as a returnto parameter. Use the title
607 # from the request instead, if there was one.
608 if ( $this->getUser()->isAllowed( 'read' ) ) {
609 $page = $this->getTitle();
610 } else {
611 $page = Title::newFromText( $request->getVal( 'title', '' ) );
612 }
613 $page = $request->getVal( 'returnto', $page );
614 $returnto = [];
615 if ( strval( $page ) !== '' ) {
616 $returnto['returnto'] = $page;
617 $query = $request->getVal( 'returntoquery', $this->thisquery );
618 $paramsArray = wfCgiToArray( $query );
619 unset( $paramsArray['logoutToken'] );
620 $query = wfArrayToCgi( $paramsArray );
621 if ( $query != '' ) {
622 $returnto['returntoquery'] = $query;
623 }
624 }
625
626 if ( $this->loggedin ) {
627 $personal_urls['userpage'] = [
628 'text' => $this->username,
629 'href' => &$this->userpageUrlDetails['href'],
630 'class' => $this->userpageUrlDetails['exists'] ? false : 'new',
631 'exists' => $this->userpageUrlDetails['exists'],
632 'active' => ( $this->userpageUrlDetails['href'] == $pageurl ),
633 'dir' => 'auto'
634 ];
635 $usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage );
636 $personal_urls['mytalk'] = [
637 'text' => $this->msg( 'mytalk' )->text(),
638 'href' => &$usertalkUrlDetails['href'],
639 'class' => $usertalkUrlDetails['exists'] ? false : 'new',
640 'exists' => $usertalkUrlDetails['exists'],
641 'active' => ( $usertalkUrlDetails['href'] == $pageurl )
642 ];
643 $href = self::makeSpecialUrl( 'Preferences' );
644 $personal_urls['preferences'] = [
645 'text' => $this->msg( 'mypreferences' )->text(),
646 'href' => $href,
647 'active' => ( $href == $pageurl )
648 ];
649
650 if ( $this->getUser()->isAllowed( 'viewmywatchlist' ) ) {
651 $href = self::makeSpecialUrl( 'Watchlist' );
652 $personal_urls['watchlist'] = [
653 'text' => $this->msg( 'mywatchlist' )->text(),
654 'href' => $href,
655 'active' => ( $href == $pageurl )
656 ];
657 }
658
659 # We need to do an explicit check for Special:Contributions, as we
660 # have to match both the title, and the target, which could come
661 # from request values (Special:Contributions?target=Jimbo_Wales)
662 # or be specified in "sub page" form
663 # (Special:Contributions/Jimbo_Wales). The plot
664 # thickens, because the Title object is altered for special pages,
665 # so it doesn't contain the original alias-with-subpage.
666 $origTitle = Title::newFromText( $request->getText( 'title' ) );
667 if ( $origTitle instanceof Title && $origTitle->isSpecialPage() ) {
668 list( $spName, $spPar ) =
669 MediaWikiServices::getInstance()->getSpecialPageFactory()->
670 resolveAlias( $origTitle->getText() );
671 $active = $spName == 'Contributions'
672 && ( ( $spPar && $spPar == $this->username )
673 || $request->getText( 'target' ) == $this->username );
674 } else {
675 $active = false;
676 }
677
678 $href = self::makeSpecialUrlSubpage( 'Contributions', $this->username );
679 $personal_urls['mycontris'] = [
680 'text' => $this->msg( 'mycontris' )->text(),
681 'href' => $href,
682 'active' => $active
683 ];
684
685 // if we can't set the user, we can't unset it either
686 if ( $request->getSession()->canSetUser() ) {
687 $personal_urls['logout'] = [
688 'text' => $this->msg( 'pt-userlogout' )->text(),
689 'href' => self::makeSpecialUrl( 'Userlogout',
690 // Note: userlogout link must always contain an & character, otherwise we might not be able
691 // to detect a buggy precaching proxy (T19790)
692 ( $title->isSpecial( 'Preferences' ) ? [] : $returnto )
693 + [ 'logoutToken' => $this->getUser()->getEditToken( 'logoutToken', $this->getRequest() ) ] ),
694 'active' => false
695 ];
696 }
697 } else {
698 $useCombinedLoginLink = $this->useCombinedLoginLink();
699 if ( !$authManager->canCreateAccounts() || !$authManager->canAuthenticateNow() ) {
700 // don't show combined login/signup link if one of those is actually not available
701 $useCombinedLoginLink = false;
702 }
703
704 $loginlink = $this->getUser()->isAllowed( 'createaccount' ) && $useCombinedLoginLink
705 ? 'nav-login-createaccount'
706 : 'pt-login';
707
708 $login_url = [
709 'text' => $this->msg( $loginlink )->text(),
710 'href' => self::makeSpecialUrl( 'Userlogin', $returnto ),
711 'active' => $title->isSpecial( 'Userlogin' )
712 || $title->isSpecial( 'CreateAccount' ) && $useCombinedLoginLink,
713 ];
714 $createaccount_url = [
715 'text' => $this->msg( 'pt-createaccount' )->text(),
716 'href' => self::makeSpecialUrl( 'CreateAccount', $returnto ),
717 'active' => $title->isSpecial( 'CreateAccount' ),
718 ];
719
720 // No need to show Talk and Contributions to anons if they can't contribute!
721 if ( User::groupHasPermission( '*', 'edit' ) ) {
722 // Because of caching, we can't link directly to the IP talk and
723 // contributions pages. Instead we use the special page shortcuts
724 // (which work correctly regardless of caching). This means we can't
725 // determine whether these links are active or not, but since major
726 // skins (MonoBook, Vector) don't use this information, it's not a
727 // huge loss.
728 $personal_urls['anontalk'] = [
729 'text' => $this->msg( 'anontalk' )->text(),
730 'href' => self::makeSpecialUrlSubpage( 'Mytalk', false ),
731 'active' => false
732 ];
733 $personal_urls['anoncontribs'] = [
734 'text' => $this->msg( 'anoncontribs' )->text(),
735 'href' => self::makeSpecialUrlSubpage( 'Mycontributions', false ),
736 'active' => false
737 ];
738 }
739
740 if (
741 $authManager->canCreateAccounts()
742 && $this->getUser()->isAllowed( 'createaccount' )
743 && !$useCombinedLoginLink
744 ) {
745 $personal_urls['createaccount'] = $createaccount_url;
746 }
747
748 if ( $authManager->canAuthenticateNow() ) {
749 $key = User::groupHasPermission( '*', 'read' )
750 ? 'login'
751 : 'login-private';
752 $personal_urls[$key] = $login_url;
753 }
754 }
755
756 Hooks::runWithoutAbort( 'PersonalUrls', [ &$personal_urls, &$title, $this ] );
757 return $personal_urls;
758 }
759
771 function tabAction( $title, $message, $selected, $query = '', $checkEdit = false ) {
772 $classes = [];
773 if ( $selected ) {
774 $classes[] = 'selected';
775 }
776 $exists = true;
777 if ( $checkEdit && !$title->isKnown() ) {
778 $classes[] = 'new';
779 $exists = false;
780 if ( $query !== '' ) {
781 $query = 'action=edit&redlink=1&' . $query;
782 } else {
783 $query = 'action=edit&redlink=1';
784 }
785 }
786
787 $linkClass = MediaWikiServices::getInstance()->getLinkRenderer()->getLinkClasses( $title );
788
789 // wfMessageFallback will nicely accept $message as an array of fallbacks
790 // or just a single key
791 $msg = wfMessageFallback( $message )->setContext( $this->getContext() );
792 if ( is_array( $message ) ) {
793 // for hook compatibility just keep the last message name
794 $message = end( $message );
795 }
796 if ( $msg->exists() ) {
797 $text = $msg->text();
798 } else {
799 $text = MediaWikiServices::getInstance()->getContentLanguage()->getConverter()->
800 convertNamespace( MWNamespace::getSubject( $title->getNamespace() ) );
801 }
802
803 // Avoid PHP 7.1 warning of passing $this by reference
804 $skinTemplate = $this;
805 $result = [];
806 if ( !Hooks::run( 'SkinTemplateTabAction', [ &$skinTemplate,
807 $title, $message, $selected, $checkEdit,
808 &$classes, &$query, &$text, &$result ] ) ) {
809 return $result;
810 }
811
812 $result = [
813 'class' => implode( ' ', $classes ),
814 'text' => $text,
815 'href' => $title->getLocalURL( $query ),
816 'exists' => $exists,
817 'primary' => true ];
818 if ( $linkClass !== '' ) {
819 $result['link-class'] = $linkClass;
820 }
821
822 return $result;
823 }
824
825 function makeTalkUrlDetails( $name, $urlaction = '' ) {
826 $title = Title::newFromText( $name );
827 if ( !is_object( $title ) ) {
828 throw new MWException( __METHOD__ . " given invalid pagename $name" );
829 }
830 $title = $title->getTalkPage();
831 self::checkTitle( $title, $name );
832 return [
833 'href' => $title->getLocalURL( $urlaction ),
834 'exists' => $title->isKnown(),
835 ];
836 }
837
844 function makeArticleUrlDetails( $name, $urlaction = '' ) {
845 $title = Title::newFromText( $name );
846 $title = $title->getSubjectPage();
847 self::checkTitle( $title, $name );
848 return [
849 'href' => $title->getLocalURL( $urlaction ),
850 'exists' => $title->exists(),
851 ];
852 }
853
888 protected function buildContentNavigationUrls() {
890
891 // Display tabs for the relevant title rather than always the title itself
892 $title = $this->getRelevantTitle();
893 $onPage = $title->equals( $this->getTitle() );
894
895 $out = $this->getOutput();
896 $request = $this->getRequest();
897 $user = $this->getUser();
898
899 $content_navigation = [
900 'namespaces' => [],
901 'views' => [],
902 'actions' => [],
903 'variants' => []
904 ];
905
906 // parameters
907 $action = $request->getVal( 'action', 'view' );
908
909 $userCanRead = $title->quickUserCan( 'read', $user );
910
911 // Avoid PHP 7.1 warning of passing $this by reference
912 $skinTemplate = $this;
913 $preventActiveTabs = false;
914 Hooks::run( 'SkinTemplatePreventOtherActiveTabs', [ &$skinTemplate, &$preventActiveTabs ] );
915
916 // Checks if page is some kind of content
917 if ( $title->canExist() ) {
918 // Gets page objects for the related namespaces
919 $subjectPage = $title->getSubjectPage();
920 $talkPage = $title->getTalkPage();
921
922 // Determines if this is a talk page
923 $isTalk = $title->isTalkPage();
924
925 // Generates XML IDs from namespace names
926 $subjectId = $title->getNamespaceKey( '' );
927
928 if ( $subjectId == 'main' ) {
929 $talkId = 'talk';
930 } else {
931 $talkId = "{$subjectId}_talk";
932 }
933
934 $skname = $this->skinname;
935
936 // Adds namespace links
937 $subjectMsg = [ "nstab-$subjectId" ];
938 if ( $subjectPage->isMainPage() ) {
939 array_unshift( $subjectMsg, 'mainpage-nstab' );
940 }
941 $content_navigation['namespaces'][$subjectId] = $this->tabAction(
942 $subjectPage, $subjectMsg, !$isTalk && !$preventActiveTabs, '', $userCanRead
943 );
944 $content_navigation['namespaces'][$subjectId]['context'] = 'subject';
945 $content_navigation['namespaces'][$talkId] = $this->tabAction(
946 $talkPage, [ "nstab-$talkId", 'talk' ], $isTalk && !$preventActiveTabs, '', $userCanRead
947 );
948 $content_navigation['namespaces'][$talkId]['context'] = 'talk';
949
950 if ( $userCanRead ) {
951 // Adds "view" view link
952 if ( $title->isKnown() ) {
953 $content_navigation['views']['view'] = $this->tabAction(
954 $isTalk ? $talkPage : $subjectPage,
955 [ "$skname-view-view", 'view' ],
956 ( $onPage && ( $action == 'view' || $action == 'purge' ) ), '', true
957 );
958 // signal to hide this from simple content_actions
959 $content_navigation['views']['view']['redundant'] = true;
960 }
961
962 $page = $this->canUseWikiPage() ? $this->getWikiPage() : false;
963 $isRemoteContent = $page && !$page->isLocal();
964
965 // If it is a non-local file, show a link to the file in its own repository
966 // @todo abstract this for remote content that isn't a file
967 if ( $isRemoteContent ) {
968 $content_navigation['views']['view-foreign'] = [
969 'class' => '',
970 'text' => wfMessageFallback( "$skname-view-foreign", 'view-foreign' )->
971 setContext( $this->getContext() )->
972 params( $page->getWikiDisplayName() )->text(),
973 'href' => $page->getSourceURL(),
974 'primary' => false,
975 ];
976 }
977
978 // Checks if user can edit the current page if it exists or create it otherwise
979 if ( $title->quickUserCan( 'edit', $user )
980 && ( $title->exists() || $title->quickUserCan( 'create', $user ) )
981 ) {
982 // Builds CSS class for talk page links
983 $isTalkClass = $isTalk ? ' istalk' : '';
984 // Whether the user is editing the page
985 $isEditing = $onPage && ( $action == 'edit' || $action == 'submit' );
986 // Whether to show the "Add a new section" tab
987 // Checks if this is a current rev of talk page and is not forced to be hidden
988 $showNewSection = !$out->forceHideNewSectionLink()
989 && ( ( $isTalk && $this->isRevisionCurrent() ) || $out->showNewSectionLink() );
990 $section = $request->getVal( 'section' );
991
992 if ( $title->exists()
993 || ( $title->getNamespace() == NS_MEDIAWIKI
994 && $title->getDefaultMessageText() !== false
995 )
996 ) {
997 $msgKey = $isRemoteContent ? 'edit-local' : 'edit';
998 } else {
999 $msgKey = $isRemoteContent ? 'create-local' : 'create';
1000 }
1001 $content_navigation['views']['edit'] = [
1002 'class' => ( $isEditing && ( $section !== 'new' || !$showNewSection )
1003 ? 'selected'
1004 : ''
1005 ) . $isTalkClass,
1006 'text' => wfMessageFallback( "$skname-view-$msgKey", $msgKey )
1007 ->setContext( $this->getContext() )->text(),
1008 'href' => $title->getLocalURL( $this->editUrlOptions() ),
1009 'primary' => !$isRemoteContent, // don't collapse this in vector
1010 ];
1011
1012 // section link
1013 if ( $showNewSection ) {
1014 // Adds new section link
1015 // $content_navigation['actions']['addsection']
1016 $content_navigation['views']['addsection'] = [
1017 'class' => ( $isEditing && $section == 'new' ) ? 'selected' : false,
1018 'text' => wfMessageFallback( "$skname-action-addsection", 'addsection' )
1019 ->setContext( $this->getContext() )->text(),
1020 'href' => $title->getLocalURL( 'action=edit&section=new' )
1021 ];
1022 }
1023 // Checks if the page has some kind of viewable source content
1024 } elseif ( $title->hasSourceText() ) {
1025 // Adds view source view link
1026 $content_navigation['views']['viewsource'] = [
1027 'class' => ( $onPage && $action == 'edit' ) ? 'selected' : false,
1028 'text' => wfMessageFallback( "$skname-action-viewsource", 'viewsource' )
1029 ->setContext( $this->getContext() )->text(),
1030 'href' => $title->getLocalURL( $this->editUrlOptions() ),
1031 'primary' => true, // don't collapse this in vector
1032 ];
1033 }
1034
1035 // Checks if the page exists
1036 if ( $title->exists() ) {
1037 // Adds history view link
1038 $content_navigation['views']['history'] = [
1039 'class' => ( $onPage && $action == 'history' ) ? 'selected' : false,
1040 'text' => wfMessageFallback( "$skname-view-history", 'history_short' )
1041 ->setContext( $this->getContext() )->text(),
1042 'href' => $title->getLocalURL( 'action=history' ),
1043 ];
1044
1045 if ( $title->quickUserCan( 'delete', $user ) ) {
1046 $content_navigation['actions']['delete'] = [
1047 'class' => ( $onPage && $action == 'delete' ) ? 'selected' : false,
1048 'text' => wfMessageFallback( "$skname-action-delete", 'delete' )
1049 ->setContext( $this->getContext() )->text(),
1050 'href' => $title->getLocalURL( 'action=delete' )
1051 ];
1052 }
1053
1054 if ( $title->quickUserCan( 'move', $user ) ) {
1055 $moveTitle = SpecialPage::getTitleFor( 'Movepage', $title->getPrefixedDBkey() );
1056 $content_navigation['actions']['move'] = [
1057 'class' => $this->getTitle()->isSpecial( 'Movepage' ) ? 'selected' : false,
1058 'text' => wfMessageFallback( "$skname-action-move", 'move' )
1059 ->setContext( $this->getContext() )->text(),
1060 'href' => $moveTitle->getLocalURL()
1061 ];
1062 }
1063 } else {
1064 // article doesn't exist or is deleted
1065 if ( $title->quickUserCan( 'deletedhistory', $user ) ) {
1066 $n = $title->isDeleted();
1067 if ( $n ) {
1068 $undelTitle = SpecialPage::getTitleFor( 'Undelete', $title->getPrefixedDBkey() );
1069 // If the user can't undelete but can view deleted
1070 // history show them a "View .. deleted" tab instead.
1071 $msgKey = $title->quickUserCan( 'undelete', $user ) ? 'undelete' : 'viewdeleted';
1072 $content_navigation['actions']['undelete'] = [
1073 'class' => $this->getTitle()->isSpecial( 'Undelete' ) ? 'selected' : false,
1074 'text' => wfMessageFallback( "$skname-action-$msgKey", "{$msgKey}_short" )
1075 ->setContext( $this->getContext() )->numParams( $n )->text(),
1076 'href' => $undelTitle->getLocalURL()
1077 ];
1078 }
1079 }
1080 }
1081
1082 if ( $title->quickUserCan( 'protect', $user ) && $title->getRestrictionTypes() &&
1083 MWNamespace::getRestrictionLevels( $title->getNamespace(), $user ) !== [ '' ]
1084 ) {
1085 $mode = $title->isProtected() ? 'unprotect' : 'protect';
1086 $content_navigation['actions'][$mode] = [
1087 'class' => ( $onPage && $action == $mode ) ? 'selected' : false,
1088 'text' => wfMessageFallback( "$skname-action-$mode", $mode )
1089 ->setContext( $this->getContext() )->text(),
1090 'href' => $title->getLocalURL( "action=$mode" )
1091 ];
1092 }
1093
1094 // Checks if the user is logged in
1095 if ( $this->loggedin && $user->isAllowedAll( 'viewmywatchlist', 'editmywatchlist' ) ) {
1105 $mode = $user->isWatched( $title ) ? 'unwatch' : 'watch';
1106 $content_navigation['actions'][$mode] = [
1107 'class' => 'mw-watchlink ' . (
1108 $onPage && ( $action == 'watch' || $action == 'unwatch' ) ? 'selected' : ''
1109 ),
1110 // uses 'watch' or 'unwatch' message
1111 'text' => $this->msg( $mode )->text(),
1112 'href' => $title->getLocalURL( [ 'action' => $mode ] ),
1113 // Set a data-mw=interface attribute, which the mediawiki.page.ajax
1114 // module will look for to make sure it's a trusted link
1115 'data' => [
1116 'mw' => 'interface',
1117 ],
1118 ];
1119 }
1120 }
1121
1122 // Avoid PHP 7.1 warning of passing $this by reference
1123 $skinTemplate = $this;
1124 Hooks::runWithoutAbort(
1125 'SkinTemplateNavigation',
1126 [ &$skinTemplate, &$content_navigation ]
1127 );
1128
1129 if ( $userCanRead && !$wgDisableLangConversion ) {
1130 $pageLang = $title->getPageLanguage();
1131 // Checks that language conversion is enabled and variants exist
1132 // And if it is not in the special namespace
1133 if ( $pageLang->hasVariants() ) {
1134 // Gets list of language variants
1135 $variants = $pageLang->getVariants();
1136 // Gets preferred variant (note that user preference is
1137 // only possible for wiki content language variant)
1138 $preferred = $pageLang->getPreferredVariant();
1139 if ( Action::getActionName( $this ) === 'view' ) {
1140 $params = $request->getQueryValues();
1141 unset( $params['title'] );
1142 } else {
1143 $params = [];
1144 }
1145 // Loops over each variant
1146 foreach ( $variants as $code ) {
1147 // Gets variant name from language code
1148 $varname = $pageLang->getVariantname( $code );
1149 // Appends variant link
1150 $content_navigation['variants'][] = [
1151 'class' => ( $code == $preferred ) ? 'selected' : false,
1152 'text' => $varname,
1153 'href' => $title->getLocalURL( [ 'variant' => $code ] + $params ),
1154 'lang' => LanguageCode::bcp47( $code ),
1155 'hreflang' => LanguageCode::bcp47( $code ),
1156 ];
1157 }
1158 }
1159 }
1160 } else {
1161 // If it's not content, it's got to be a special page
1162 $content_navigation['namespaces']['special'] = [
1163 'class' => 'selected',
1164 'text' => $this->msg( 'nstab-special' )->text(),
1165 'href' => $request->getRequestURL(), // @see: T4457, T4510
1166 'context' => 'subject'
1167 ];
1168
1169 // Avoid PHP 7.1 warning of passing $this by reference
1170 $skinTemplate = $this;
1171 Hooks::runWithoutAbort( 'SkinTemplateNavigation::SpecialPage',
1172 [ &$skinTemplate, &$content_navigation ] );
1173 }
1174
1175 // Avoid PHP 7.1 warning of passing $this by reference
1176 $skinTemplate = $this;
1177 // Equiv to SkinTemplateContentActions
1178 Hooks::runWithoutAbort( 'SkinTemplateNavigation::Universal',
1179 [ &$skinTemplate, &$content_navigation ] );
1180
1181 // Setup xml ids and tooltip info
1182 foreach ( $content_navigation as $section => &$links ) {
1183 foreach ( $links as $key => &$link ) {
1184 $xmlID = $key;
1185 if ( isset( $link['context'] ) && $link['context'] == 'subject' ) {
1186 $xmlID = 'ca-nstab-' . $xmlID;
1187 } elseif ( isset( $link['context'] ) && $link['context'] == 'talk' ) {
1188 $xmlID = 'ca-talk';
1189 $link['rel'] = 'discussion';
1190 } elseif ( $section == 'variants' ) {
1191 $xmlID = 'ca-varlang-' . $xmlID;
1192 } else {
1193 $xmlID = 'ca-' . $xmlID;
1194 }
1195 $link['id'] = $xmlID;
1196 }
1197 }
1198
1199 # We don't want to give the watch tab an accesskey if the
1200 # page is being edited, because that conflicts with the
1201 # accesskey on the watch checkbox. We also don't want to
1202 # give the edit tab an accesskey, because that's fairly
1203 # superfluous and conflicts with an accesskey (Ctrl-E) often
1204 # used for editing in Safari.
1205 if ( in_array( $action, [ 'edit', 'submit' ] ) ) {
1206 if ( isset( $content_navigation['views']['edit'] ) ) {
1207 $content_navigation['views']['edit']['tooltiponly'] = true;
1208 }
1209 if ( isset( $content_navigation['actions']['watch'] ) ) {
1210 $content_navigation['actions']['watch']['tooltiponly'] = true;
1211 }
1212 if ( isset( $content_navigation['actions']['unwatch'] ) ) {
1213 $content_navigation['actions']['unwatch']['tooltiponly'] = true;
1214 }
1215 }
1216
1217 return $content_navigation;
1218 }
1219
1225 private function buildContentActionUrls( $content_navigation ) {
1226 // content_actions has been replaced with content_navigation for backwards
1227 // compatibility and also for skins that just want simple tabs content_actions
1228 // is now built by flattening the content_navigation arrays into one
1229
1230 $content_actions = [];
1231
1232 foreach ( $content_navigation as $links ) {
1233 foreach ( $links as $key => $value ) {
1234 if ( isset( $value['redundant'] ) && $value['redundant'] ) {
1235 // Redundant tabs are dropped from content_actions
1236 continue;
1237 }
1238
1239 // content_actions used to have ids built using the "ca-$key" pattern
1240 // so the xmlID based id is much closer to the actual $key that we want
1241 // for that reason we'll just strip out the ca- if present and use
1242 // the latter potion of the "id" as the $key
1243 if ( isset( $value['id'] ) && substr( $value['id'], 0, 3 ) == 'ca-' ) {
1244 $key = substr( $value['id'], 3 );
1245 }
1246
1247 if ( isset( $content_actions[$key] ) ) {
1248 wfDebug( __METHOD__ . ": Found a duplicate key for $key while flattening " .
1249 "content_navigation into content_actions.\n" );
1250 continue;
1251 }
1252
1253 $content_actions[$key] = $value;
1254 }
1255 }
1256
1257 return $content_actions;
1258 }
1259
1264 protected function buildNavUrls() {
1266
1267 $out = $this->getOutput();
1268 $request = $this->getRequest();
1269
1270 $nav_urls = [];
1271 $nav_urls['mainpage'] = [ 'href' => self::makeMainPageUrl() ];
1272 if ( $wgUploadNavigationUrl ) {
1273 $nav_urls['upload'] = [ 'href' => $wgUploadNavigationUrl ];
1274 } elseif ( UploadBase::isEnabled() && UploadBase::isAllowed( $this->getUser() ) === true ) {
1275 $nav_urls['upload'] = [ 'href' => self::makeSpecialUrl( 'Upload' ) ];
1276 } else {
1277 $nav_urls['upload'] = false;
1278 }
1279 $nav_urls['specialpages'] = [ 'href' => self::makeSpecialUrl( 'Specialpages' ) ];
1280
1281 $nav_urls['print'] = false;
1282 $nav_urls['permalink'] = false;
1283 $nav_urls['info'] = false;
1284 $nav_urls['whatlinkshere'] = false;
1285 $nav_urls['recentchangeslinked'] = false;
1286 $nav_urls['contributions'] = false;
1287 $nav_urls['log'] = false;
1288 $nav_urls['blockip'] = false;
1289 $nav_urls['emailuser'] = false;
1290 $nav_urls['userrights'] = false;
1291
1292 // A print stylesheet is attached to all pages, but nobody ever
1293 // figures that out. :) Add a link...
1294 if ( !$out->isPrintable() && ( $out->isArticle() || $this->getTitle()->isSpecialPage() ) ) {
1295 $nav_urls['print'] = [
1296 'text' => $this->msg( 'printableversion' )->text(),
1297 'href' => $this->getTitle()->getLocalURL(
1298 $request->appendQueryValue( 'printable', 'yes' ) )
1299 ];
1300 }
1301
1302 if ( $out->isArticle() ) {
1303 // Also add a "permalink" while we're at it
1304 $revid = $this->getRevisionId();
1305 if ( $revid ) {
1306 $nav_urls['permalink'] = [
1307 'text' => $this->msg( 'permalink' )->text(),
1308 'href' => $this->getTitle()->getLocalURL( "oldid=$revid" )
1309 ];
1310 }
1311
1312 // Avoid PHP 7.1 warning of passing $this by reference
1313 $skinTemplate = $this;
1314 // Use the copy of revision ID in case this undocumented, shady hook tries to mess with internals
1315 Hooks::run( 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink',
1316 [ &$skinTemplate, &$nav_urls, &$revid, &$revid ] );
1317 }
1318
1319 if ( $out->isArticleRelated() ) {
1320 $nav_urls['whatlinkshere'] = [
1321 'href' => SpecialPage::getTitleFor( 'Whatlinkshere', $this->thispage )->getLocalURL()
1322 ];
1323
1324 $nav_urls['info'] = [
1325 'text' => $this->msg( 'pageinfo-toolboxlink' )->text(),
1326 'href' => $this->getTitle()->getLocalURL( "action=info" )
1327 ];
1328
1329 if ( $this->getTitle()->exists() || $this->getTitle()->inNamespace( NS_CATEGORY ) ) {
1330 $nav_urls['recentchangeslinked'] = [
1331 'href' => SpecialPage::getTitleFor( 'Recentchangeslinked', $this->thispage )->getLocalURL()
1332 ];
1333 }
1334 }
1335
1336 $user = $this->getRelevantUser();
1337 if ( $user ) {
1338 $rootUser = $user->getName();
1339
1340 $nav_urls['contributions'] = [
1341 'text' => $this->msg( 'contributions', $rootUser )->text(),
1342 'href' => self::makeSpecialUrlSubpage( 'Contributions', $rootUser ),
1343 'tooltip-params' => [ $rootUser ],
1344 ];
1345
1346 $nav_urls['log'] = [
1347 'href' => self::makeSpecialUrlSubpage( 'Log', $rootUser )
1348 ];
1349
1350 if ( $this->getUser()->isAllowed( 'block' ) ) {
1351 $nav_urls['blockip'] = [
1352 'text' => $this->msg( 'blockip', $rootUser )->text(),
1353 'href' => self::makeSpecialUrlSubpage( 'Block', $rootUser )
1354 ];
1355 }
1356
1357 if ( $this->showEmailUser( $user ) ) {
1358 $nav_urls['emailuser'] = [
1359 'text' => $this->msg( 'tool-link-emailuser', $rootUser )->text(),
1360 'href' => self::makeSpecialUrlSubpage( 'Emailuser', $rootUser ),
1361 'tooltip-params' => [ $rootUser ],
1362 ];
1363 }
1364
1365 if ( !$user->isAnon() ) {
1366 $sur = new UserrightsPage;
1367 $sur->setContext( $this->getContext() );
1368 $canChange = $sur->userCanChangeRights( $user );
1369 $nav_urls['userrights'] = [
1370 'text' => $this->msg(
1371 $canChange ? 'tool-link-userrights' : 'tool-link-userrights-readonly',
1372 $rootUser
1373 )->text(),
1374 'href' => self::makeSpecialUrlSubpage( 'Userrights', $rootUser )
1375 ];
1376 }
1377 }
1378
1379 return $nav_urls;
1380 }
1381
1386 protected function getNameSpaceKey() {
1387 return $this->getTitle()->getNamespaceKey();
1388 }
1389}
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
$wgScript
The URL path to index.php.
$wgMimeType
The default Content-Type header.
$wgDisableLangConversion
Whether to enable language variant conversion.
$wgSitename
Name of the site.
$wgUseCombinedLoginLink
Login / create account link behavior when it's possible for anonymous users to create an account.
$wgHideInterlanguageLinks
Hide interlanguage links from the sidebar.
$wgShowCreditsIfMax
If there are more than $wgMaxCredits authors, show $wgMaxCredits of them.
$wgJsMimeType
Previously used as content type in HTML script tags.
$wgFooterIcons
Abstract list of footer icons for skins in place of old copyrightico and poweredbyico code You can ad...
$wgUploadNavigationUrl
Point the upload navigation link to an external URL Useful if you want to use a shared repository by ...
$wgScriptPath
The path we should point to.
$wgStylePath
The URL path of the skins directory.
$wgServer
URL of the server.
$wgLogo
The URL path of the wiki logo.
$wgMaxCredits
Set this to the number of authors that you want to be credited below an article text.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfReportTime( $nonce=null)
Returns a script tag that stores the amount of time it took MediaWiki to handle the request in millis...
wfMessageFallback(... $keys)
This function accepts multiple message keys and returns a message instance for the first message whic...
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....
wfCgiToArray( $query)
This is the logical opposite of wfArrayToCgi(): it accepts a query string as its argument and returns...
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
getContext()
static factory( $action, Page $page, IContextSource $context=null)
Get an appropriate Action subclass for the given action.
Definition Action.php:97
static getActionName(IContextSource $context)
Get the action that will be executed, not necessarily the one passed passed through the "action" requ...
Definition Action.php:124
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
canUseWikiPage()
Check whether a WikiPage object can be get with getWikiPage().
getWikiPage()
Get the WikiPage object.
setContext(IContextSource $context)
MediaWiki exception.
This serves as the entry point to the authentication system.
MediaWikiServices is the service locator for the application scope of MediaWiki.
This class should be covered by a general architecture document which does not exist as of January 20...
Base class for template-based skins.
setupTemplate( $classname, $repository=false, $cache_dir=false)
Create the template engine object; we feed it a bunch of data and eventually it spits out some HTML.
formatLanguageName( $name)
Format language name for use in sidebar interlanguage links list.
prepareQuickTemplate()
initialize various variables and generate the template
getPersonalToolsList()
Get the HTML for the p-personal list.
buildPersonalUrls()
build array of urls for personal toolbar
buildContentNavigationUrls()
a structured array of links usually used for the tabs in a skin
useCombinedLoginLink()
Output a boolean indicating if buildPersonalUrls should output separate login and create account link...
getStructuredPersonalTools()
Get personal tools for the user.
getLanguages()
Generates array of language links for the current page.
wrapHTML( $title, $html)
Wrap the body text with language information and identifiable element.
makeTalkUrlDetails( $name, $urlaction='')
outputPage(OutputPage $out=null)
initialize various variables and generate the template
makePersonalToolsList( $personalTools=null, $options=[])
Get the HTML for the personal tools list.
buildNavUrls()
build array of common navigation links
string $skinname
Name of our skin, it probably needs to be all lower case.
buildContentActionUrls( $content_navigation)
an array of edit links by default used for the tabs
makeArticleUrlDetails( $name, $urlaction='')
tabAction( $title, $message, $selected, $query='', $checkEdit=false)
Builds an array with tab definition.
getNameSpaceKey()
Generate strings used for xml 'id' names.
printOrError( $str)
Output the string, or print error message if it's an error object of the appropriate type.
The main skin class which provides methods and properties for all other skins.
Definition Skin.php:38
aboutLink()
Gets the link to the wiki's about page.
Definition Skin.php:1054
isRevisionCurrent()
Whether the revision displayed is the latest revision of the page.
Definition Skin.php:320
afterContentHook()
This runs a hook to allow extensions placing their stuff after content and article metadata (e....
Definition Skin.php:642
getNewtalks()
Gets new talk page messages for the current user and returns an appropriate alert message (or an empt...
Definition Skin.php:1436
generateDebugHTML()
Generate debug data HTML for displaying at the bottom of the main content area.
Definition Skin.php:668
getCopyrightIcon()
Definition Skin.php:864
privacyLink()
Gets the link to the wiki's privacy policy page.
Definition Skin.php:1046
getSiteNotice()
Get the site notice.
Definition Skin.php:1581
getUndeleteLink()
Definition Skin.php:717
getPoweredBy()
Gets the powered by MediaWiki icon.
Definition Skin.php:894
escapeSearchLink()
Definition Skin.php:810
getRelevantUser()
Return the "relevant" user.
Definition Skin.php:368
logoText( $align='')
Definition Skin.php:945
editUrlOptions()
Return URL options for the 'edit page' link.
Definition Skin.php:1073
showEmailUser( $id)
Definition Skin.php:1087
buildSidebar()
Build an array that represents the sidebar(s), the navigation bar among them.
Definition Skin.php:1285
getCopyright( $type='detect')
Definition Skin.php:818
printSource()
Text with the permalink to the source page, usually shown on the footer of a printed page.
Definition Skin.php:699
getRevisionId()
Get the current revision ID.
Definition Skin.php:311
bottomScripts()
This gets called shortly before the "</body>" tag.
Definition Skin.php:677
disclaimerLink()
Gets the link to the wiki's general disclaimers page.
Definition Skin.php:1062
lastModified()
Get the timestamp of the latest revision, formatted in user language.
Definition Skin.php:918
initPage(OutputPage $out)
Definition Skin.php:162
subPageSubtitle( $out=null)
Definition Skin.php:746
getRelevantTitle()
Return the "relevant" title.
Definition Skin.php:344
getCategories()
Definition Skin.php:607
setContext( $context)
Sets the context this SpecialPage is executed in.
Represents a title within MediaWiki.
Definition Title.php:39
isSpecialPage()
Returns true if this is a special page.
Definition Title.php:1117
static isEnabled()
Returns true if uploads are enabled.
static isAllowed( $user)
Returns true if the user can use this upload module or else a string identifying the missing permissi...
static groupHasPermission( $group, $role)
Check, if the given group has the given permission.
Definition User.php:5013
Special page to allow managing user group membership.
$res
Definition database.txt:21
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition deferred.txt:11
namespace being checked & $result
Definition hooks.txt:2385
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
Definition hooks.txt:2880
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping $template
Definition hooks.txt:861
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition hooks.txt:2050
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
Definition hooks.txt:895
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition hooks.txt:2055
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt;div ...>$1&lt;/div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition hooks.txt:894
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
Definition hooks.txt:2062
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition hooks.txt:3106
this hook is for auditing only or null if authentication failed before getting that far $username
Definition hooks.txt:815
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition hooks.txt:1656
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
Definition hooks.txt:3107
processing should stop and the error should be shown to the user * false
Definition hooks.txt:187
const NS_FILE
Definition Defines.php:70
const NS_SPECIAL
Definition Defines.php:53
const NS_CATEGORY
Definition Defines.php:78
$wgArticlePath
Definition img_auth.php:46
$params