MediaWiki REL1_33
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
177 protected function setupTemplateForOutput() {
178 $request = $this->getRequest();
179 $user = $this->getUser();
180 $title = $this->getTitle();
181
182 $tpl = $this->setupTemplate( $this->template, 'skins' );
183
184 $this->thispage = $title->getPrefixedDBkey();
185 $this->titletxt = $title->getPrefixedText();
186 $this->userpage = $user->getUserPage()->getPrefixedText();
187 $query = [];
188 if ( !$request->wasPosted() ) {
189 $query = $request->getValues();
190 unset( $query['title'] );
191 unset( $query['returnto'] );
192 unset( $query['returntoquery'] );
193 }
194 $this->thisquery = wfArrayToCgi( $query );
195 $this->loggedin = $user->isLoggedIn();
196 $this->username = $user->getName();
197
198 if ( $this->loggedin ) {
199 $this->userpageUrlDetails = self::makeUrlDetails( $this->userpage );
200 } else {
201 # This won't be used in the standard skins, but we define it to preserve the interface
202 # To save time, we check for existence
203 $this->userpageUrlDetails = self::makeKnownUrlDetails( $this->userpage );
204 }
205
206 return $tpl;
207 }
208
214 function outputPage( OutputPage $out = null ) {
215 Profiler::instance()->setTemplated( true );
216
217 $oldContext = null;
218 if ( $out !== null ) {
219 // Deprecated since 1.20, note added in 1.25
220 wfDeprecated( __METHOD__, '1.25' );
221 $oldContext = $this->getContext();
222 $this->setContext( $out->getContext() );
223 }
224
225 $out = $this->getOutput();
226
227 $this->initPage( $out );
228 $tpl = $this->prepareQuickTemplate();
229 // execute template
230 $res = $tpl->execute();
231
232 // result may be an error
233 $this->printOrError( $res );
234
235 if ( $oldContext ) {
236 $this->setContext( $oldContext );
237 }
238 }
239
247 protected function wrapHTML( $title, $html ) {
248 # An ID that includes the actual body text; without categories, contentSub, ...
249 $realBodyAttribs = [ 'id' => 'mw-content-text' ];
250
251 # Add a mw-content-ltr/rtl class to be able to style based on text
252 # direction when the content is different from the UI language (only
253 # when viewing)
254 # Most information on special pages and file pages is in user language,
255 # rather than content language, so those will not get this
256 if ( Action::getActionName( $this ) === 'view' &&
257 ( !$title->inNamespaces( NS_SPECIAL, NS_FILE ) || $title->isRedirect() ) ) {
258 $pageLang = $title->getPageViewLanguage();
259 $realBodyAttribs['lang'] = $pageLang->getHtmlCode();
260 $realBodyAttribs['dir'] = $pageLang->getDir();
261 $realBodyAttribs['class'] = 'mw-content-' . $pageLang->getDir();
262 }
263
264 return Html::rawElement( 'div', $realBodyAttribs, $html );
265 }
266
273 protected function prepareQuickTemplate() {
278
279 $title = $this->getTitle();
280 $request = $this->getRequest();
281 $out = $this->getOutput();
282 $tpl = $this->setupTemplateForOutput();
283
284 $tpl->set( 'title', $out->getPageTitle() );
285 $tpl->set( 'pagetitle', $out->getHTMLTitle() );
286 $tpl->set( 'displaytitle', $out->mPageLinkTitle );
287
288 $tpl->set( 'thispage', $this->thispage );
289 $tpl->set( 'titleprefixeddbkey', $this->thispage );
290 $tpl->set( 'titletext', $title->getText() );
291 $tpl->set( 'articleid', $title->getArticleID() );
292
293 $tpl->set( 'isarticle', $out->isArticle() );
294
295 $subpagestr = $this->subPageSubtitle();
296 if ( $subpagestr !== '' ) {
297 $subpagestr = '<span class="subpages">' . $subpagestr . '</span>';
298 }
299 $tpl->set( 'subtitle', $subpagestr . $out->getSubtitle() );
300
301 $undelete = $this->getUndeleteLink();
302 if ( $undelete === '' ) {
303 $tpl->set( 'undelete', '' );
304 } else {
305 $tpl->set( 'undelete', '<span class="subpages">' . $undelete . '</span>' );
306 }
307
308 $tpl->set( 'catlinks', $this->getCategories() );
309 if ( $out->isSyndicated() ) {
310 $feeds = [];
311 foreach ( $out->getSyndicationLinks() as $format => $link ) {
312 $feeds[$format] = [
313 // Messages: feed-atom, feed-rss
314 'text' => $this->msg( "feed-$format" )->text(),
315 'href' => $link
316 ];
317 }
318 $tpl->set( 'feeds', $feeds );
319 } else {
320 $tpl->set( 'feeds', false );
321 }
322
323 $tpl->set( 'mimetype', $wgMimeType );
324 $tpl->set( 'jsmimetype', $wgJsMimeType );
325 $tpl->set( 'charset', 'UTF-8' );
326 $tpl->set( 'wgScript', $wgScript );
327 $tpl->set( 'skinname', $this->skinname );
328 $tpl->set( 'skinclass', static::class );
329 $tpl->set( 'skin', $this );
330 $tpl->set( 'stylename', $this->stylename );
331 $tpl->set( 'printable', $out->isPrintable() );
332 $tpl->set( 'handheld', $request->getBool( 'handheld' ) );
333 $tpl->set( 'loggedin', $this->loggedin );
334 $tpl->set( 'notspecialpage', !$title->isSpecialPage() );
335 $tpl->set( 'searchaction', $this->escapeSearchLink() );
336 $tpl->set( 'searchtitle', SpecialPage::getTitleFor( 'Search' )->getPrefixedDBkey() );
337 $tpl->set( 'search', trim( $request->getVal( 'search' ) ) );
338 $tpl->set( 'stylepath', $wgStylePath );
339 $tpl->set( 'articlepath', $wgArticlePath );
340 $tpl->set( 'scriptpath', $wgScriptPath );
341 $tpl->set( 'serverurl', $wgServer );
342 $tpl->set( 'logopath', $wgLogo );
343 $tpl->set( 'sitename', $wgSitename );
344
345 $userLang = $this->getLanguage();
346 $userLangCode = $userLang->getHtmlCode();
347 $userLangDir = $userLang->getDir();
348
349 $tpl->set( 'lang', $userLangCode );
350 $tpl->set( 'dir', $userLangDir );
351 $tpl->set( 'rtl', $userLang->isRTL() );
352
353 $tpl->set( 'capitalizeallnouns', $userLang->capitalizeAllNouns() ? ' capitalize-all-nouns' : '' );
354 $tpl->set( 'showjumplinks', true ); // showjumplinks preference has been removed
355 $tpl->set( 'username', $this->loggedin ? $this->username : null );
356 $tpl->set( 'userpage', $this->userpage );
357 $tpl->set( 'userpageurl', $this->userpageUrlDetails['href'] );
358 $tpl->set( 'userlang', $userLangCode );
359
360 // Users can have their language set differently than the
361 // content of the wiki. For these users, tell the web browser
362 // that interface elements are in a different language.
363 $tpl->set( 'userlangattributes', '' );
364 $tpl->set( 'specialpageattributes', '' ); # obsolete
365 // Used by VectorBeta to insert HTML before content but after the
366 // heading for the page title. Defaults to empty string.
367 $tpl->set( 'prebodyhtml', '' );
368
369 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
370 if (
371 $userLangCode !== $contLang->getHtmlCode() ||
372 $userLangDir !== $contLang->getDir()
373 ) {
374 $escUserlang = htmlspecialchars( $userLangCode );
375 $escUserdir = htmlspecialchars( $userLangDir );
376 // Attributes must be in double quotes because htmlspecialchars() doesn't
377 // escape single quotes
378 $attrs = " lang=\"$escUserlang\" dir=\"$escUserdir\"";
379 $tpl->set( 'userlangattributes', $attrs );
380 }
381
382 $tpl->set( 'newtalk', $this->getNewtalks() );
383 $tpl->set( 'logo', $this->logoText() );
384
385 $tpl->set( 'copyright', false );
386 // No longer used
387 $tpl->set( 'viewcount', false );
388 $tpl->set( 'lastmod', false );
389 $tpl->set( 'credits', false );
390 $tpl->set( 'numberofwatchingusers', false );
391 if ( $title->exists() ) {
392 if ( $out->isArticle() && $this->isRevisionCurrent() ) {
393 if ( $wgMaxCredits != 0 ) {
395 $action = Action::factory(
396 'credits', $this->getWikiPage(), $this->getContext() );
397 $tpl->set( 'credits',
398 $action->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ) );
399 } else {
400 $tpl->set( 'lastmod', $this->lastModified() );
401 }
402 }
403 if ( $out->showsCopyright() ) {
404 $tpl->set( 'copyright', $this->getCopyright() );
405 }
406 }
407
408 $tpl->set( 'copyrightico', $this->getCopyrightIcon() );
409 $tpl->set( 'poweredbyico', $this->getPoweredBy() );
410 $tpl->set( 'disclaimer', $this->disclaimerLink() );
411 $tpl->set( 'privacy', $this->privacyLink() );
412 $tpl->set( 'about', $this->aboutLink() );
413
414 $tpl->set( 'footerlinks', [
415 'info' => [
416 'lastmod',
417 'numberofwatchingusers',
418 'credits',
419 'copyright',
420 ],
421 'places' => [
422 'privacy',
423 'about',
424 'disclaimer',
425 ],
426 ] );
427
428 global $wgFooterIcons;
429 $tpl->set( 'footericons', $wgFooterIcons );
430 foreach ( $tpl->data['footericons'] as $footerIconsKey => &$footerIconsBlock ) {
431 if ( count( $footerIconsBlock ) > 0 ) {
432 foreach ( $footerIconsBlock as &$footerIcon ) {
433 if ( isset( $footerIcon['src'] ) ) {
434 if ( !isset( $footerIcon['width'] ) ) {
435 $footerIcon['width'] = 88;
436 }
437 if ( !isset( $footerIcon['height'] ) ) {
438 $footerIcon['height'] = 31;
439 }
440 }
441 }
442 } else {
443 unset( $tpl->data['footericons'][$footerIconsKey] );
444 }
445 }
446
447 $tpl->set( 'indicators', $out->getIndicators() );
448
449 $tpl->set( 'sitenotice', $this->getSiteNotice() );
450 $tpl->set( 'printfooter', $this->printSource() );
451 // Wrap the bodyText with #mw-content-text element
452 $out->mBodytext = $this->wrapHTML( $title, $out->mBodytext );
453 $tpl->set( 'bodytext', $out->mBodytext );
454
455 $language_urls = $this->getLanguages();
456 if ( count( $language_urls ) ) {
457 $tpl->set( 'language_urls', $language_urls );
458 } else {
459 $tpl->set( 'language_urls', false );
460 }
461
462 # Personal toolbar
463 $tpl->set( 'personal_urls', $this->buildPersonalUrls() );
464 $content_navigation = $this->buildContentNavigationUrls();
465 $content_actions = $this->buildContentActionUrls( $content_navigation );
466 $tpl->set( 'content_navigation', $content_navigation );
467 $tpl->set( 'content_actions', $content_actions );
468
469 $tpl->set( 'sidebar', $this->buildSidebar() );
470 $tpl->set( 'nav_urls', $this->buildNavUrls() );
471
472 // Do this last in case hooks above add bottom scripts
473 $tpl->set( 'bottomscripts', $this->bottomScripts() );
474
475 // Set the head scripts near the end, in case the above actions resulted in added scripts
476 $tpl->set( 'headelement', $out->headElement( $this ) );
477
478 $tpl->set( 'debug', '' );
479 $tpl->set( 'debughtml', $this->generateDebugHTML() );
480 $tpl->set( 'reporttime', wfReportTime( $out->getCSPNonce() ) );
481
482 // Avoid PHP 7.1 warning of passing $this by reference
483 $skinTemplate = $this;
484 // original version by hansm
485 if ( !Hooks::run( 'SkinTemplateOutputPageBeforeExec', [ &$skinTemplate, &$tpl ] ) ) {
486 wfDebug( __METHOD__ . ": Hook SkinTemplateOutputPageBeforeExec broke outputPage execution!\n" );
487 }
488
489 // Set the bodytext to another key so that skins can just output it on its own
490 // and output printfooter and debughtml separately
491 $tpl->set( 'bodycontent', $tpl->data['bodytext'] );
492
493 // Append printfooter and debughtml onto bodytext so that skins that
494 // were already using bodytext before they were split out don't suddenly
495 // start not outputting information.
496 $tpl->data['bodytext'] .= Html::rawElement(
497 'div',
498 [ 'class' => 'printfooter' ],
499 "\n{$tpl->data['printfooter']}"
500 ) . "\n";
501 $tpl->data['bodytext'] .= $tpl->data['debughtml'];
502
503 // allow extensions adding stuff after the page content.
504 // See Skin::afterContentHook() for further documentation.
505 $tpl->set( 'dataAfterContent', $this->afterContentHook() );
506
507 return $tpl;
508 }
509
514 public function getPersonalToolsList() {
515 return $this->makePersonalToolsList();
516 }
517
527 public function makePersonalToolsList( $personalTools = null, $options = [] ) {
528 $tpl = $this->setupTemplateForOutput();
529 $tpl->set( 'personal_urls', $this->buildPersonalUrls() );
530 $html = '';
531
532 if ( $personalTools === null ) {
533 $personalTools = ( $tpl instanceof BaseTemplate )
534 ? $tpl->getPersonalTools()
535 : [];
536 }
537
538 foreach ( $personalTools as $key => $item ) {
539 $html .= $tpl->makeListItem( $key, $item, $options );
540 }
541
542 return $html;
543 }
544
552 public function getStructuredPersonalTools() {
553 $tpl = $this->setupTemplateForOutput();
554 $tpl->set( 'personal_urls', $this->buildPersonalUrls() );
555
556 return ( $tpl instanceof BaseTemplate ) ? $tpl->getPersonalTools() : [];
557 }
558
567 function formatLanguageName( $name ) {
568 return $this->getLanguage()->ucfirst( $name );
569 }
570
579 function printOrError( $str ) {
580 echo $str;
581 }
582
595 }
596
601 protected function buildPersonalUrls() {
602 $title = $this->getTitle();
603 $request = $this->getRequest();
604 $pageurl = $title->getLocalURL();
605 $authManager = AuthManager::singleton();
606
607 /* set up the default links for the personal toolbar */
608 $personal_urls = [];
609
610 # Due to T34276, if a user does not have read permissions,
611 # $this->getTitle() will just give Special:Badtitle, which is
612 # not especially useful as a returnto parameter. Use the title
613 # from the request instead, if there was one.
614 if ( $this->getUser()->isAllowed( 'read' ) ) {
615 $page = $this->getTitle();
616 } else {
617 $page = Title::newFromText( $request->getVal( 'title', '' ) );
618 }
619 $page = $request->getVal( 'returnto', $page );
620 $returnto = [];
621 if ( strval( $page ) !== '' ) {
622 $returnto['returnto'] = $page;
623 $query = $request->getVal( 'returntoquery', $this->thisquery );
624 $paramsArray = wfCgiToArray( $query );
625 unset( $paramsArray['logoutToken'] );
626 $query = wfArrayToCgi( $paramsArray );
627 if ( $query != '' ) {
628 $returnto['returntoquery'] = $query;
629 }
630 }
631
632 if ( $this->loggedin ) {
633 $personal_urls['userpage'] = [
634 'text' => $this->username,
635 'href' => &$this->userpageUrlDetails['href'],
636 'class' => $this->userpageUrlDetails['exists'] ? false : 'new',
637 'exists' => $this->userpageUrlDetails['exists'],
638 'active' => ( $this->userpageUrlDetails['href'] == $pageurl ),
639 'dir' => 'auto'
640 ];
641 $usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage );
642 $personal_urls['mytalk'] = [
643 'text' => $this->msg( 'mytalk' )->text(),
644 'href' => &$usertalkUrlDetails['href'],
645 'class' => $usertalkUrlDetails['exists'] ? false : 'new',
646 'exists' => $usertalkUrlDetails['exists'],
647 'active' => ( $usertalkUrlDetails['href'] == $pageurl )
648 ];
649 $href = self::makeSpecialUrl( 'Preferences' );
650 $personal_urls['preferences'] = [
651 'text' => $this->msg( 'mypreferences' )->text(),
652 'href' => $href,
653 'active' => ( $href == $pageurl )
654 ];
655
656 if ( $this->getUser()->isAllowed( 'viewmywatchlist' ) ) {
657 $href = self::makeSpecialUrl( 'Watchlist' );
658 $personal_urls['watchlist'] = [
659 'text' => $this->msg( 'mywatchlist' )->text(),
660 'href' => $href,
661 'active' => ( $href == $pageurl )
662 ];
663 }
664
665 # We need to do an explicit check for Special:Contributions, as we
666 # have to match both the title, and the target, which could come
667 # from request values (Special:Contributions?target=Jimbo_Wales)
668 # or be specified in "sub page" form
669 # (Special:Contributions/Jimbo_Wales). The plot
670 # thickens, because the Title object is altered for special pages,
671 # so it doesn't contain the original alias-with-subpage.
672 $origTitle = Title::newFromText( $request->getText( 'title' ) );
673 if ( $origTitle instanceof Title && $origTitle->isSpecialPage() ) {
674 list( $spName, $spPar ) =
675 MediaWikiServices::getInstance()->getSpecialPageFactory()->
676 resolveAlias( $origTitle->getText() );
677 $active = $spName == 'Contributions'
678 && ( ( $spPar && $spPar == $this->username )
679 || $request->getText( 'target' ) == $this->username );
680 } else {
681 $active = false;
682 }
683
684 $href = self::makeSpecialUrlSubpage( 'Contributions', $this->username );
685 $personal_urls['mycontris'] = [
686 'text' => $this->msg( 'mycontris' )->text(),
687 'href' => $href,
688 'active' => $active
689 ];
690
691 // if we can't set the user, we can't unset it either
692 if ( $request->getSession()->canSetUser() ) {
693 $personal_urls['logout'] = [
694 'text' => $this->msg( 'pt-userlogout' )->text(),
695 'href' => self::makeSpecialUrl( 'Userlogout',
696 // Note: userlogout link must always contain an & character, otherwise we might not be able
697 // to detect a buggy precaching proxy (T19790)
698 ( $title->isSpecial( 'Preferences' ) ? [] : $returnto )
699 + [ 'logoutToken' => $this->getUser()->getEditToken( 'logoutToken', $this->getRequest() ) ] ),
700 'active' => false
701 ];
702 }
703 } else {
704 $useCombinedLoginLink = $this->useCombinedLoginLink();
705 if ( !$authManager->canCreateAccounts() || !$authManager->canAuthenticateNow() ) {
706 // don't show combined login/signup link if one of those is actually not available
707 $useCombinedLoginLink = false;
708 }
709
710 $loginlink = $this->getUser()->isAllowed( 'createaccount' ) && $useCombinedLoginLink
711 ? 'nav-login-createaccount'
712 : 'pt-login';
713
714 $login_url = [
715 'text' => $this->msg( $loginlink )->text(),
716 'href' => self::makeSpecialUrl( 'Userlogin', $returnto ),
717 'active' => $title->isSpecial( 'Userlogin' )
718 || $title->isSpecial( 'CreateAccount' ) && $useCombinedLoginLink,
719 ];
720 $createaccount_url = [
721 'text' => $this->msg( 'pt-createaccount' )->text(),
722 'href' => self::makeSpecialUrl( 'CreateAccount', $returnto ),
723 'active' => $title->isSpecial( 'CreateAccount' ),
724 ];
725
726 // No need to show Talk and Contributions to anons if they can't contribute!
727 if ( User::groupHasPermission( '*', 'edit' ) ) {
728 // Because of caching, we can't link directly to the IP talk and
729 // contributions pages. Instead we use the special page shortcuts
730 // (which work correctly regardless of caching). This means we can't
731 // determine whether these links are active or not, but since major
732 // skins (MonoBook, Vector) don't use this information, it's not a
733 // huge loss.
734 $personal_urls['anontalk'] = [
735 'text' => $this->msg( 'anontalk' )->text(),
736 'href' => self::makeSpecialUrlSubpage( 'Mytalk', false ),
737 'active' => false
738 ];
739 $personal_urls['anoncontribs'] = [
740 'text' => $this->msg( 'anoncontribs' )->text(),
741 'href' => self::makeSpecialUrlSubpage( 'Mycontributions', false ),
742 'active' => false
743 ];
744 }
745
746 if (
747 $authManager->canCreateAccounts()
748 && $this->getUser()->isAllowed( 'createaccount' )
749 && !$useCombinedLoginLink
750 ) {
751 $personal_urls['createaccount'] = $createaccount_url;
752 }
753
754 if ( $authManager->canAuthenticateNow() ) {
755 $key = User::groupHasPermission( '*', 'read' )
756 ? 'login'
757 : 'login-private';
758 $personal_urls[$key] = $login_url;
759 }
760 }
761
762 Hooks::runWithoutAbort( 'PersonalUrls', [ &$personal_urls, &$title, $this ] );
763 return $personal_urls;
764 }
765
777 function tabAction( $title, $message, $selected, $query = '', $checkEdit = false ) {
778 $classes = [];
779 if ( $selected ) {
780 $classes[] = 'selected';
781 }
782 $exists = true;
783 if ( $checkEdit && !$title->isKnown() ) {
784 $classes[] = 'new';
785 $exists = false;
786 if ( $query !== '' ) {
787 $query = 'action=edit&redlink=1&' . $query;
788 } else {
789 $query = 'action=edit&redlink=1';
790 }
791 }
792
793 $linkClass = MediaWikiServices::getInstance()->getLinkRenderer()->getLinkClasses( $title );
794
795 // wfMessageFallback will nicely accept $message as an array of fallbacks
796 // or just a single key
797 $msg = wfMessageFallback( $message )->setContext( $this->getContext() );
798 if ( is_array( $message ) ) {
799 // for hook compatibility just keep the last message name
800 $message = end( $message );
801 }
802 if ( $msg->exists() ) {
803 $text = $msg->text();
804 } else {
805 $text = MediaWikiServices::getInstance()->getContentLanguage()->getConverter()->
806 convertNamespace( MWNamespace::getSubject( $title->getNamespace() ) );
807 }
808
809 // Avoid PHP 7.1 warning of passing $this by reference
810 $skinTemplate = $this;
811 $result = [];
812 if ( !Hooks::run( 'SkinTemplateTabAction', [ &$skinTemplate,
813 $title, $message, $selected, $checkEdit,
814 &$classes, &$query, &$text, &$result ] ) ) {
815 return $result;
816 }
817
818 $result = [
819 'class' => implode( ' ', $classes ),
820 'text' => $text,
821 'href' => $title->getLocalURL( $query ),
822 'exists' => $exists,
823 'primary' => true ];
824 if ( $linkClass !== '' ) {
825 $result['link-class'] = $linkClass;
826 }
827
828 return $result;
829 }
830
831 function makeTalkUrlDetails( $name, $urlaction = '' ) {
832 $title = Title::newFromText( $name );
833 if ( !is_object( $title ) ) {
834 throw new MWException( __METHOD__ . " given invalid pagename $name" );
835 }
836 $title = $title->getTalkPage();
838 return [
839 'href' => $title->getLocalURL( $urlaction ),
840 'exists' => $title->isKnown(),
841 ];
842 }
843
850 function makeArticleUrlDetails( $name, $urlaction = '' ) {
851 $title = Title::newFromText( $name );
852 $title = $title->getSubjectPage();
854 return [
855 'href' => $title->getLocalURL( $urlaction ),
856 'exists' => $title->exists(),
857 ];
858 }
859
894 protected function buildContentNavigationUrls() {
896
897 // Display tabs for the relevant title rather than always the title itself
898 $title = $this->getRelevantTitle();
899 $onPage = $title->equals( $this->getTitle() );
900
901 $out = $this->getOutput();
902 $request = $this->getRequest();
903 $user = $this->getUser();
904
905 $content_navigation = [
906 'namespaces' => [],
907 'views' => [],
908 'actions' => [],
909 'variants' => []
910 ];
911
912 // parameters
913 $action = $request->getVal( 'action', 'view' );
914
915 $userCanRead = $title->quickUserCan( 'read', $user );
916
917 // Avoid PHP 7.1 warning of passing $this by reference
918 $skinTemplate = $this;
919 $preventActiveTabs = false;
920 Hooks::run( 'SkinTemplatePreventOtherActiveTabs', [ &$skinTemplate, &$preventActiveTabs ] );
921
922 // Checks if page is some kind of content
923 if ( $title->canExist() ) {
924 // Gets page objects for the related namespaces
925 $subjectPage = $title->getSubjectPage();
926 $talkPage = $title->getTalkPage();
927
928 // Determines if this is a talk page
929 $isTalk = $title->isTalkPage();
930
931 // Generates XML IDs from namespace names
932 $subjectId = $title->getNamespaceKey( '' );
933
934 if ( $subjectId == 'main' ) {
935 $talkId = 'talk';
936 } else {
937 $talkId = "{$subjectId}_talk";
938 }
939
940 $skname = $this->skinname;
941
942 // Adds namespace links
943 $subjectMsg = [ "nstab-$subjectId" ];
944 if ( $subjectPage->isMainPage() ) {
945 array_unshift( $subjectMsg, 'mainpage-nstab' );
946 }
947 $content_navigation['namespaces'][$subjectId] = $this->tabAction(
948 $subjectPage, $subjectMsg, !$isTalk && !$preventActiveTabs, '', $userCanRead
949 );
950 $content_navigation['namespaces'][$subjectId]['context'] = 'subject';
951 $content_navigation['namespaces'][$talkId] = $this->tabAction(
952 $talkPage, [ "nstab-$talkId", 'talk' ], $isTalk && !$preventActiveTabs, '', $userCanRead
953 );
954 $content_navigation['namespaces'][$talkId]['context'] = 'talk';
955
956 if ( $userCanRead ) {
957 // Adds "view" view link
958 if ( $title->isKnown() ) {
959 $content_navigation['views']['view'] = $this->tabAction(
960 $isTalk ? $talkPage : $subjectPage,
961 [ "$skname-view-view", 'view' ],
962 ( $onPage && ( $action == 'view' || $action == 'purge' ) ), '', true
963 );
964 // signal to hide this from simple content_actions
965 $content_navigation['views']['view']['redundant'] = true;
966 }
967
968 $page = $this->canUseWikiPage() ? $this->getWikiPage() : false;
969 $isRemoteContent = $page && !$page->isLocal();
970
971 // If it is a non-local file, show a link to the file in its own repository
972 // @todo abstract this for remote content that isn't a file
973 if ( $isRemoteContent ) {
974 $content_navigation['views']['view-foreign'] = [
975 'class' => '',
976 'text' => wfMessageFallback( "$skname-view-foreign", 'view-foreign' )->
977 setContext( $this->getContext() )->
978 params( $page->getWikiDisplayName() )->text(),
979 'href' => $page->getSourceURL(),
980 'primary' => false,
981 ];
982 }
983
984 // Checks if user can edit the current page if it exists or create it otherwise
985 if ( $title->quickUserCan( 'edit', $user )
986 && ( $title->exists() || $title->quickUserCan( 'create', $user ) )
987 ) {
988 // Builds CSS class for talk page links
989 $isTalkClass = $isTalk ? ' istalk' : '';
990 // Whether the user is editing the page
991 $isEditing = $onPage && ( $action == 'edit' || $action == 'submit' );
992 // Whether to show the "Add a new section" tab
993 // Checks if this is a current rev of talk page and is not forced to be hidden
994 $showNewSection = !$out->forceHideNewSectionLink()
995 && ( ( $isTalk && $this->isRevisionCurrent() ) || $out->showNewSectionLink() );
996 $section = $request->getVal( 'section' );
997
998 if ( $title->exists()
999 || ( $title->getNamespace() == NS_MEDIAWIKI
1000 && $title->getDefaultMessageText() !== false
1001 )
1002 ) {
1003 $msgKey = $isRemoteContent ? 'edit-local' : 'edit';
1004 } else {
1005 $msgKey = $isRemoteContent ? 'create-local' : 'create';
1006 }
1007 $content_navigation['views']['edit'] = [
1008 'class' => ( $isEditing && ( $section !== 'new' || !$showNewSection )
1009 ? 'selected'
1010 : ''
1011 ) . $isTalkClass,
1012 'text' => wfMessageFallback( "$skname-view-$msgKey", $msgKey )
1013 ->setContext( $this->getContext() )->text(),
1014 'href' => $title->getLocalURL( $this->editUrlOptions() ),
1015 'primary' => !$isRemoteContent, // don't collapse this in vector
1016 ];
1017
1018 // section link
1019 if ( $showNewSection ) {
1020 // Adds new section link
1021 // $content_navigation['actions']['addsection']
1022 $content_navigation['views']['addsection'] = [
1023 'class' => ( $isEditing && $section == 'new' ) ? 'selected' : false,
1024 'text' => wfMessageFallback( "$skname-action-addsection", 'addsection' )
1025 ->setContext( $this->getContext() )->text(),
1026 'href' => $title->getLocalURL( 'action=edit&section=new' )
1027 ];
1028 }
1029 // Checks if the page has some kind of viewable source content
1030 } elseif ( $title->hasSourceText() ) {
1031 // Adds view source view link
1032 $content_navigation['views']['viewsource'] = [
1033 'class' => ( $onPage && $action == 'edit' ) ? 'selected' : false,
1034 'text' => wfMessageFallback( "$skname-action-viewsource", 'viewsource' )
1035 ->setContext( $this->getContext() )->text(),
1036 'href' => $title->getLocalURL( $this->editUrlOptions() ),
1037 'primary' => true, // don't collapse this in vector
1038 ];
1039 }
1040
1041 // Checks if the page exists
1042 if ( $title->exists() ) {
1043 // Adds history view link
1044 $content_navigation['views']['history'] = [
1045 'class' => ( $onPage && $action == 'history' ) ? 'selected' : false,
1046 'text' => wfMessageFallback( "$skname-view-history", 'history_short' )
1047 ->setContext( $this->getContext() )->text(),
1048 'href' => $title->getLocalURL( 'action=history' ),
1049 ];
1050
1051 if ( $title->quickUserCan( 'delete', $user ) ) {
1052 $content_navigation['actions']['delete'] = [
1053 'class' => ( $onPage && $action == 'delete' ) ? 'selected' : false,
1054 'text' => wfMessageFallback( "$skname-action-delete", 'delete' )
1055 ->setContext( $this->getContext() )->text(),
1056 'href' => $title->getLocalURL( 'action=delete' )
1057 ];
1058 }
1059
1060 if ( $title->quickUserCan( 'move', $user ) ) {
1061 $moveTitle = SpecialPage::getTitleFor( 'Movepage', $title->getPrefixedDBkey() );
1062 $content_navigation['actions']['move'] = [
1063 'class' => $this->getTitle()->isSpecial( 'Movepage' ) ? 'selected' : false,
1064 'text' => wfMessageFallback( "$skname-action-move", 'move' )
1065 ->setContext( $this->getContext() )->text(),
1066 'href' => $moveTitle->getLocalURL()
1067 ];
1068 }
1069 } else {
1070 // article doesn't exist or is deleted
1071 if ( $title->quickUserCan( 'deletedhistory', $user ) ) {
1072 $n = $title->isDeleted();
1073 if ( $n ) {
1074 $undelTitle = SpecialPage::getTitleFor( 'Undelete', $title->getPrefixedDBkey() );
1075 // If the user can't undelete but can view deleted
1076 // history show them a "View .. deleted" tab instead.
1077 $msgKey = $title->quickUserCan( 'undelete', $user ) ? 'undelete' : 'viewdeleted';
1078 $content_navigation['actions']['undelete'] = [
1079 'class' => $this->getTitle()->isSpecial( 'Undelete' ) ? 'selected' : false,
1080 'text' => wfMessageFallback( "$skname-action-$msgKey", "{$msgKey}_short" )
1081 ->setContext( $this->getContext() )->numParams( $n )->text(),
1082 'href' => $undelTitle->getLocalURL()
1083 ];
1084 }
1085 }
1086 }
1087
1088 if ( $title->quickUserCan( 'protect', $user ) && $title->getRestrictionTypes() &&
1089 MWNamespace::getRestrictionLevels( $title->getNamespace(), $user ) !== [ '' ]
1090 ) {
1091 $mode = $title->isProtected() ? 'unprotect' : 'protect';
1092 $content_navigation['actions'][$mode] = [
1093 'class' => ( $onPage && $action == $mode ) ? 'selected' : false,
1094 'text' => wfMessageFallback( "$skname-action-$mode", $mode )
1095 ->setContext( $this->getContext() )->text(),
1096 'href' => $title->getLocalURL( "action=$mode" )
1097 ];
1098 }
1099
1100 // Checks if the user is logged in
1101 if ( $this->loggedin && $user->isAllowedAll( 'viewmywatchlist', 'editmywatchlist' ) ) {
1111 $mode = $user->isWatched( $title ) ? 'unwatch' : 'watch';
1112 $content_navigation['actions'][$mode] = [
1113 'class' => 'mw-watchlink ' . (
1114 $onPage && ( $action == 'watch' || $action == 'unwatch' ) ? 'selected' : ''
1115 ),
1116 // uses 'watch' or 'unwatch' message
1117 'text' => $this->msg( $mode )->text(),
1118 'href' => $title->getLocalURL( [ 'action' => $mode ] ),
1119 // Set a data-mw=interface attribute, which the mediawiki.page.ajax
1120 // module will look for to make sure it's a trusted link
1121 'data' => [
1122 'mw' => 'interface',
1123 ],
1124 ];
1125 }
1126 }
1127
1128 // Avoid PHP 7.1 warning of passing $this by reference
1129 $skinTemplate = $this;
1130 Hooks::runWithoutAbort(
1131 'SkinTemplateNavigation',
1132 [ &$skinTemplate, &$content_navigation ]
1133 );
1134
1135 if ( $userCanRead && !$wgDisableLangConversion ) {
1136 $pageLang = $title->getPageLanguage();
1137 // Checks that language conversion is enabled and variants exist
1138 // And if it is not in the special namespace
1139 if ( $pageLang->hasVariants() ) {
1140 // Gets list of language variants
1141 $variants = $pageLang->getVariants();
1142 // Gets preferred variant (note that user preference is
1143 // only possible for wiki content language variant)
1144 $preferred = $pageLang->getPreferredVariant();
1145 if ( Action::getActionName( $this ) === 'view' ) {
1146 $params = $request->getQueryValues();
1147 unset( $params['title'] );
1148 } else {
1149 $params = [];
1150 }
1151 // Loops over each variant
1152 foreach ( $variants as $code ) {
1153 // Gets variant name from language code
1154 $varname = $pageLang->getVariantname( $code );
1155 // Appends variant link
1156 $content_navigation['variants'][] = [
1157 'class' => ( $code == $preferred ) ? 'selected' : false,
1158 'text' => $varname,
1159 'href' => $title->getLocalURL( [ 'variant' => $code ] + $params ),
1160 'lang' => LanguageCode::bcp47( $code ),
1161 'hreflang' => LanguageCode::bcp47( $code ),
1162 ];
1163 }
1164 }
1165 }
1166 } else {
1167 // If it's not content, it's got to be a special page
1168 $content_navigation['namespaces']['special'] = [
1169 'class' => 'selected',
1170 'text' => $this->msg( 'nstab-special' )->text(),
1171 'href' => $request->getRequestURL(), // @see: T4457, T4510
1172 'context' => 'subject'
1173 ];
1174
1175 // Avoid PHP 7.1 warning of passing $this by reference
1176 $skinTemplate = $this;
1177 Hooks::runWithoutAbort( 'SkinTemplateNavigation::SpecialPage',
1178 [ &$skinTemplate, &$content_navigation ] );
1179 }
1180
1181 // Avoid PHP 7.1 warning of passing $this by reference
1182 $skinTemplate = $this;
1183 // Equiv to SkinTemplateContentActions
1184 Hooks::runWithoutAbort( 'SkinTemplateNavigation::Universal',
1185 [ &$skinTemplate, &$content_navigation ] );
1186
1187 // Setup xml ids and tooltip info
1188 foreach ( $content_navigation as $section => &$links ) {
1189 foreach ( $links as $key => &$link ) {
1190 $xmlID = $key;
1191 if ( isset( $link['context'] ) && $link['context'] == 'subject' ) {
1192 $xmlID = 'ca-nstab-' . $xmlID;
1193 } elseif ( isset( $link['context'] ) && $link['context'] == 'talk' ) {
1194 $xmlID = 'ca-talk';
1195 $link['rel'] = 'discussion';
1196 } elseif ( $section == 'variants' ) {
1197 $xmlID = 'ca-varlang-' . $xmlID;
1198 } else {
1199 $xmlID = 'ca-' . $xmlID;
1200 }
1201 $link['id'] = $xmlID;
1202 }
1203 }
1204
1205 # We don't want to give the watch tab an accesskey if the
1206 # page is being edited, because that conflicts with the
1207 # accesskey on the watch checkbox. We also don't want to
1208 # give the edit tab an accesskey, because that's fairly
1209 # superfluous and conflicts with an accesskey (Ctrl-E) often
1210 # used for editing in Safari.
1211 if ( in_array( $action, [ 'edit', 'submit' ] ) ) {
1212 if ( isset( $content_navigation['views']['edit'] ) ) {
1213 $content_navigation['views']['edit']['tooltiponly'] = true;
1214 }
1215 if ( isset( $content_navigation['actions']['watch'] ) ) {
1216 $content_navigation['actions']['watch']['tooltiponly'] = true;
1217 }
1218 if ( isset( $content_navigation['actions']['unwatch'] ) ) {
1219 $content_navigation['actions']['unwatch']['tooltiponly'] = true;
1220 }
1221 }
1222
1223 return $content_navigation;
1224 }
1225
1231 private function buildContentActionUrls( $content_navigation ) {
1232 // content_actions has been replaced with content_navigation for backwards
1233 // compatibility and also for skins that just want simple tabs content_actions
1234 // is now built by flattening the content_navigation arrays into one
1235
1236 $content_actions = [];
1237
1238 foreach ( $content_navigation as $links ) {
1239 foreach ( $links as $key => $value ) {
1240 if ( isset( $value['redundant'] ) && $value['redundant'] ) {
1241 // Redundant tabs are dropped from content_actions
1242 continue;
1243 }
1244
1245 // content_actions used to have ids built using the "ca-$key" pattern
1246 // so the xmlID based id is much closer to the actual $key that we want
1247 // for that reason we'll just strip out the ca- if present and use
1248 // the latter potion of the "id" as the $key
1249 if ( isset( $value['id'] ) && substr( $value['id'], 0, 3 ) == 'ca-' ) {
1250 $key = substr( $value['id'], 3 );
1251 }
1252
1253 if ( isset( $content_actions[$key] ) ) {
1254 wfDebug( __METHOD__ . ": Found a duplicate key for $key while flattening " .
1255 "content_navigation into content_actions.\n" );
1256 continue;
1257 }
1258
1259 $content_actions[$key] = $value;
1260 }
1261 }
1262
1263 return $content_actions;
1264 }
1265
1270 protected function buildNavUrls() {
1272
1273 $out = $this->getOutput();
1274 $request = $this->getRequest();
1275
1276 $nav_urls = [];
1277 $nav_urls['mainpage'] = [ 'href' => self::makeMainPageUrl() ];
1278 if ( $wgUploadNavigationUrl ) {
1279 $nav_urls['upload'] = [ 'href' => $wgUploadNavigationUrl ];
1280 } elseif ( UploadBase::isEnabled() && UploadBase::isAllowed( $this->getUser() ) === true ) {
1281 $nav_urls['upload'] = [ 'href' => self::makeSpecialUrl( 'Upload' ) ];
1282 } else {
1283 $nav_urls['upload'] = false;
1284 }
1285 $nav_urls['specialpages'] = [ 'href' => self::makeSpecialUrl( 'Specialpages' ) ];
1286
1287 $nav_urls['print'] = false;
1288 $nav_urls['permalink'] = false;
1289 $nav_urls['info'] = false;
1290 $nav_urls['whatlinkshere'] = false;
1291 $nav_urls['recentchangeslinked'] = false;
1292 $nav_urls['contributions'] = false;
1293 $nav_urls['log'] = false;
1294 $nav_urls['blockip'] = false;
1295 $nav_urls['emailuser'] = false;
1296 $nav_urls['userrights'] = false;
1297
1298 // A print stylesheet is attached to all pages, but nobody ever
1299 // figures that out. :) Add a link...
1300 if ( !$out->isPrintable() && ( $out->isArticle() || $this->getTitle()->isSpecialPage() ) ) {
1301 $nav_urls['print'] = [
1302 'text' => $this->msg( 'printableversion' )->text(),
1303 'href' => $this->getTitle()->getLocalURL(
1304 $request->appendQueryValue( 'printable', 'yes' ) )
1305 ];
1306 }
1307
1308 if ( $out->isArticle() ) {
1309 // Also add a "permalink" while we're at it
1310 $revid = $this->getRevisionId();
1311 if ( $revid ) {
1312 $nav_urls['permalink'] = [
1313 'text' => $this->msg( 'permalink' )->text(),
1314 'href' => $this->getTitle()->getLocalURL( "oldid=$revid" )
1315 ];
1316 }
1317
1318 // Avoid PHP 7.1 warning of passing $this by reference
1319 $skinTemplate = $this;
1320 // Use the copy of revision ID in case this undocumented, shady hook tries to mess with internals
1321 Hooks::run( 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink',
1322 [ &$skinTemplate, &$nav_urls, &$revid, &$revid ] );
1323 }
1324
1325 if ( $out->isArticleRelated() ) {
1326 $nav_urls['whatlinkshere'] = [
1327 'href' => SpecialPage::getTitleFor( 'Whatlinkshere', $this->thispage )->getLocalURL()
1328 ];
1329
1330 $nav_urls['info'] = [
1331 'text' => $this->msg( 'pageinfo-toolboxlink' )->text(),
1332 'href' => $this->getTitle()->getLocalURL( "action=info" )
1333 ];
1334
1335 if ( $this->getTitle()->exists() || $this->getTitle()->inNamespace( NS_CATEGORY ) ) {
1336 $nav_urls['recentchangeslinked'] = [
1337 'href' => SpecialPage::getTitleFor( 'Recentchangeslinked', $this->thispage )->getLocalURL()
1338 ];
1339 }
1340 }
1341
1342 $user = $this->getRelevantUser();
1343 if ( $user ) {
1344 $rootUser = $user->getName();
1345
1346 $nav_urls['contributions'] = [
1347 'text' => $this->msg( 'contributions', $rootUser )->text(),
1348 'href' => self::makeSpecialUrlSubpage( 'Contributions', $rootUser ),
1349 'tooltip-params' => [ $rootUser ],
1350 ];
1351
1352 $nav_urls['log'] = [
1353 'href' => self::makeSpecialUrlSubpage( 'Log', $rootUser )
1354 ];
1355
1356 if ( $this->getUser()->isAllowed( 'block' ) ) {
1357 $nav_urls['blockip'] = [
1358 'text' => $this->msg( 'blockip', $rootUser )->text(),
1359 'href' => self::makeSpecialUrlSubpage( 'Block', $rootUser )
1360 ];
1361 }
1362
1363 if ( $this->showEmailUser( $user ) ) {
1364 $nav_urls['emailuser'] = [
1365 'text' => $this->msg( 'tool-link-emailuser', $rootUser )->text(),
1366 'href' => self::makeSpecialUrlSubpage( 'Emailuser', $rootUser ),
1367 'tooltip-params' => [ $rootUser ],
1368 ];
1369 }
1370
1371 if ( !$user->isAnon() ) {
1372 $sur = new UserrightsPage;
1373 $sur->setContext( $this->getContext() );
1374 $canChange = $sur->userCanChangeRights( $user );
1375 $nav_urls['userrights'] = [
1376 'text' => $this->msg(
1377 $canChange ? 'tool-link-userrights' : 'tool-link-userrights-readonly',
1378 $rootUser
1379 )->text(),
1380 'href' => self::makeSpecialUrlSubpage( 'Userrights', $rootUser )
1381 ];
1382 }
1383 }
1384
1385 return $nav_urls;
1386 }
1387
1392 protected function getNameSpaceKey() {
1393 return $this->getTitle()->getNamespaceKey();
1394 }
1395}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
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.
New base template for a skin's template extended from QuickTemplate this class features helper method...
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.
getContext()
Get the base IContextSource 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.
string $template
For QuickTemplate, the name of the subclass which will actually fill the template.
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:1053
isRevisionCurrent()
Whether the revision displayed is the latest revision of the page.
Definition Skin.php:318
afterContentHook()
This runs a hook to allow extensions placing their stuff after content and article metadata (e....
Definition Skin.php:641
getNewtalks()
Gets new talk page messages for the current user and returns an appropriate alert message (or an empt...
Definition Skin.php:1433
static makeMainPageUrl( $urlaction='')
Definition Skin.php:1125
static makeKnownUrlDetails( $name, $urlaction='')
Make URL details where the article exists (or at least it's convenient to think so)
Definition Skin.php:1236
generateDebugHTML()
Generate debug data HTML for displaying at the bottom of the main content area.
Definition Skin.php:667
getCopyrightIcon()
Definition Skin.php:865
privacyLink()
Gets the link to the wiki's privacy policy page.
Definition Skin.php:1045
getSiteNotice()
Get the site notice.
Definition Skin.php:1575
getUndeleteLink()
Definition Skin.php:716
getPoweredBy()
Gets the powered by MediaWiki icon.
Definition Skin.php:895
escapeSearchLink()
Definition Skin.php:811
static makeUrlDetails( $name, $urlaction='')
these return an array with the 'href' and boolean 'exists'
Definition Skin.php:1220
static makeSpecialUrlSubpage( $name, $subpage, $urlaction='')
Definition Skin.php:1158
getRelevantUser()
Return the "relevant" user.
Definition Skin.php:363
logoText( $align='')
Definition Skin.php:945
static checkTitle(&$title, $name)
make sure we have some title to operate on
Definition Skin.php:1252
editUrlOptions()
Return URL options for the 'edit page' link.
Definition Skin.php:1072
showEmailUser( $id)
Definition Skin.php:1086
buildSidebar()
Build an array that represents the sidebar(s), the navigation bar among them.
Definition Skin.php:1282
getCopyright( $type='detect')
Definition Skin.php:819
printSource()
Text with the permalink to the source page, usually shown on the footer of a printed page.
Definition Skin.php:698
getRevisionId()
Get the current revision ID.
Definition Skin.php:309
bottomScripts()
This gets called shortly before the "</body>" tag.
Definition Skin.php:676
disclaimerLink()
Gets the link to the wiki's general disclaimers page.
Definition Skin.php:1061
static makeSpecialUrl( $name, $urlaction='', $proto=null)
Make a URL for a Special Page using the given query and protocol.
Definition Skin.php:1143
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:747
getRelevantTitle()
Return the "relevant" title.
Definition Skin.php:342
getCategories()
Definition Skin.php:606
setContext( $context)
Sets the context this SpecialPage is executed in.
Represents a title within MediaWiki.
Definition Title.php:40
isSpecialPage()
Returns true if this is a special page.
Definition Title.php:1128
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:5062
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
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
const NS_FILE
Definition Defines.php:79
const NS_MEDIAWIKI
Definition Defines.php:81
const NS_SPECIAL
Definition Defines.php:62
const NS_CATEGORY
Definition Defines.php:87
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:2843
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImgAuthModifyHeaders':Executed just before a file is streamed to a user via img_auth.php, allowing headers to be modified beforehand. $title:LinkTarget object & $headers:HTTP headers(name=> value, names are case insensitive). Two headers get special handling:If-Modified-Since(value must be a valid HTTP date) and Range(must be of the form "bytes=(\d*-\d*)") will be honored when streaming the file. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED since 1.28! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition hooks.txt:1991
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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:855
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:1999
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:955
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
Definition hooks.txt:783
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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:856
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:2004
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
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:2011
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition hooks.txt:3069
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:271
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:1617
return true to allow those checks to and false if checking is done & $user
Definition hooks.txt:1510
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:3070
processing should stop and the error should be shown to the user * false
Definition hooks.txt:187
$wgArticlePath
Definition img_auth.php:46
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
$params