MediaWiki REL1_30
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';
50
51 public $thispage;
52 public $titletxt;
53 public $userpage;
54 public $thisquery;
55 public $loggedin;
56 public $username;
58
64 public function setupSkinUserCss( OutputPage $out ) {
65 $moduleStyles = [
66 'mediawiki.legacy.shared',
67 'mediawiki.legacy.commonPrint',
68 'mediawiki.sectionAnchor'
69 ];
70 if ( $out->isSyndicated() ) {
71 $moduleStyles[] = 'mediawiki.feedlink';
72 }
73
74 // Deprecated since 1.26: Unconditional loading of mediawiki.ui.button
75 // on every page is deprecated. Express a dependency instead.
76 if ( strpos( $out->getHTML(), 'mw-ui-button' ) !== false ) {
77 $moduleStyles[] = 'mediawiki.ui.button';
78 }
79
80 $out->addModuleStyles( $moduleStyles );
81 }
82
94 function setupTemplate( $classname, $repository = false, $cache_dir = false ) {
95 return new $classname( $this->getConfig() );
96 }
97
103 public function getLanguages() {
106 return [];
107 }
108
109 $userLang = $this->getLanguage();
110 $languageLinks = [];
111
112 foreach ( $this->getOutput()->getLanguageLinks() as $languageLinkText ) {
113 $class = 'interlanguage-link interwiki-' . explode( ':', $languageLinkText, 2 )[0];
114
115 $languageLinkTitle = Title::newFromText( $languageLinkText );
116 if ( $languageLinkTitle ) {
117 $ilInterwikiCode = $languageLinkTitle->getInterwiki();
118 $ilLangName = Language::fetchLanguageName( $ilInterwikiCode );
119
120 if ( strval( $ilLangName ) === '' ) {
121 $ilDisplayTextMsg = wfMessage( "interlanguage-link-$ilInterwikiCode" );
122 if ( !$ilDisplayTextMsg->isDisabled() ) {
123 // Use custom MW message for the display text
124 $ilLangName = $ilDisplayTextMsg->text();
125 } else {
126 // Last resort: fallback to the language link target
127 $ilLangName = $languageLinkText;
128 }
129 } else {
130 // Use the language autonym as display text
131 $ilLangName = $this->formatLanguageName( $ilLangName );
132 }
133
134 // CLDR extension or similar is required to localize the language name;
135 // otherwise we'll end up with the autonym again.
136 $ilLangLocalName = Language::fetchLanguageName(
137 $ilInterwikiCode,
138 $userLang->getCode()
139 );
140
141 $languageLinkTitleText = $languageLinkTitle->getText();
142 if ( $ilLangLocalName === '' ) {
143 $ilFriendlySiteName = wfMessage( "interlanguage-link-sitename-$ilInterwikiCode" );
144 if ( !$ilFriendlySiteName->isDisabled() ) {
145 if ( $languageLinkTitleText === '' ) {
146 $ilTitle = wfMessage(
147 'interlanguage-link-title-nonlangonly',
148 $ilFriendlySiteName->text()
149 )->text();
150 } else {
151 $ilTitle = wfMessage(
152 'interlanguage-link-title-nonlang',
153 $languageLinkTitleText,
154 $ilFriendlySiteName->text()
155 )->text();
156 }
157 } else {
158 // we have nothing friendly to put in the title, so fall back to
159 // displaying the interlanguage link itself in the title text
160 // (similar to what is done in page content)
161 $ilTitle = $languageLinkTitle->getInterwiki() .
162 ":$languageLinkTitleText";
163 }
164 } elseif ( $languageLinkTitleText === '' ) {
165 $ilTitle = wfMessage(
166 'interlanguage-link-title-langonly',
167 $ilLangLocalName
168 )->text();
169 } else {
170 $ilTitle = wfMessage(
171 'interlanguage-link-title',
172 $languageLinkTitleText,
173 $ilLangLocalName
174 )->text();
175 }
176
177 $ilInterwikiCodeBCP47 = wfBCP47( $ilInterwikiCode );
178 $languageLink = [
179 'href' => $languageLinkTitle->getFullURL(),
180 'text' => $ilLangName,
181 'title' => $ilTitle,
182 'class' => $class,
183 'link-class' => 'interlanguage-link-target',
184 'lang' => $ilInterwikiCodeBCP47,
185 'hreflang' => $ilInterwikiCodeBCP47,
186 ];
187 Hooks::run(
188 'SkinTemplateGetLanguageLink',
189 [ &$languageLink, $languageLinkTitle, $this->getTitle(), $this->getOutput() ]
190 );
191 $languageLinks[] = $languageLink;
192 }
193 }
194
195 return $languageLinks;
196 }
197
198 protected function setupTemplateForOutput() {
199 $request = $this->getRequest();
200 $user = $this->getUser();
201 $title = $this->getTitle();
202
203 $tpl = $this->setupTemplate( $this->template, 'skins' );
204
205 $this->thispage = $title->getPrefixedDBkey();
206 $this->titletxt = $title->getPrefixedText();
207 $this->userpage = $user->getUserPage()->getPrefixedText();
208 $query = [];
209 if ( !$request->wasPosted() ) {
210 $query = $request->getValues();
211 unset( $query['title'] );
212 unset( $query['returnto'] );
213 unset( $query['returntoquery'] );
214 }
215 $this->thisquery = wfArrayToCgi( $query );
216 $this->loggedin = $user->isLoggedIn();
217 $this->username = $user->getName();
218
219 if ( $this->loggedin ) {
220 $this->userpageUrlDetails = self::makeUrlDetails( $this->userpage );
221 } else {
222 # This won't be used in the standard skins, but we define it to preserve the interface
223 # To save time, we check for existence
224 $this->userpageUrlDetails = self::makeKnownUrlDetails( $this->userpage );
225 }
226
227 return $tpl;
228 }
229
235 function outputPage( OutputPage $out = null ) {
236 Profiler::instance()->setTemplated( true );
237
238 $oldContext = null;
239 if ( $out !== null ) {
240 // Deprecated since 1.20, note added in 1.25
241 wfDeprecated( __METHOD__, '1.25' );
242 $oldContext = $this->getContext();
243 $this->setContext( $out->getContext() );
244 }
245
246 $out = $this->getOutput();
247
248 $this->initPage( $out );
249 $tpl = $this->prepareQuickTemplate();
250 // execute template
251 $res = $tpl->execute();
252
253 // result may be an error
254 $this->printOrError( $res );
255
256 if ( $oldContext ) {
257 $this->setContext( $oldContext );
258 }
259 }
260
268 protected function wrapHTML( $title, $html ) {
269 # An ID that includes the actual body text; without categories, contentSub, ...
270 $realBodyAttribs = [ 'id' => 'mw-content-text' ];
271
272 # Add a mw-content-ltr/rtl class to be able to style based on text
273 # direction when the content is different from the UI language (only
274 # when viewing)
275 # Most information on special pages and file pages is in user language,
276 # rather than content language, so those will not get this
277 if ( Action::getActionName( $this ) === 'view' &&
278 ( !$title->inNamespaces( NS_SPECIAL, NS_FILE ) || $title->isRedirect() ) ) {
279 $pageLang = $title->getPageViewLanguage();
280 $realBodyAttribs['lang'] = $pageLang->getHtmlCode();
281 $realBodyAttribs['dir'] = $pageLang->getDir();
282 $realBodyAttribs['class'] = 'mw-content-' . $pageLang->getDir();
283 }
284
285 return Html::rawElement( 'div', $realBodyAttribs, $html );
286 }
287
294 protected function prepareQuickTemplate() {
299
300 $title = $this->getTitle();
301 $request = $this->getRequest();
302 $out = $this->getOutput();
303 $tpl = $this->setupTemplateForOutput();
304
305 $tpl->set( 'title', $out->getPageTitle() );
306 $tpl->set( 'pagetitle', $out->getHTMLTitle() );
307 $tpl->set( 'displaytitle', $out->mPageLinkTitle );
308
309 $tpl->set( 'thispage', $this->thispage );
310 $tpl->set( 'titleprefixeddbkey', $this->thispage );
311 $tpl->set( 'titletext', $title->getText() );
312 $tpl->set( 'articleid', $title->getArticleID() );
313
314 $tpl->set( 'isarticle', $out->isArticle() );
315
316 $subpagestr = $this->subPageSubtitle();
317 if ( $subpagestr !== '' ) {
318 $subpagestr = '<span class="subpages">' . $subpagestr . '</span>';
319 }
320 $tpl->set( 'subtitle', $subpagestr . $out->getSubtitle() );
321
322 $undelete = $this->getUndeleteLink();
323 if ( $undelete === '' ) {
324 $tpl->set( 'undelete', '' );
325 } else {
326 $tpl->set( 'undelete', '<span class="subpages">' . $undelete . '</span>' );
327 }
328
329 $tpl->set( 'catlinks', $this->getCategories() );
330 if ( $out->isSyndicated() ) {
331 $feeds = [];
332 foreach ( $out->getSyndicationLinks() as $format => $link ) {
333 $feeds[$format] = [
334 // Messages: feed-atom, feed-rss
335 'text' => $this->msg( "feed-$format" )->text(),
336 'href' => $link
337 ];
338 }
339 $tpl->set( 'feeds', $feeds );
340 } else {
341 $tpl->set( 'feeds', false );
342 }
343
344 $tpl->set( 'mimetype', $wgMimeType );
345 $tpl->set( 'jsmimetype', $wgJsMimeType );
346 $tpl->set( 'charset', 'UTF-8' );
347 $tpl->set( 'wgScript', $wgScript );
348 $tpl->set( 'skinname', $this->skinname );
349 $tpl->set( 'skinclass', static::class );
350 $tpl->set( 'skin', $this );
351 $tpl->set( 'stylename', $this->stylename );
352 $tpl->set( 'printable', $out->isPrintable() );
353 $tpl->set( 'handheld', $request->getBool( 'handheld' ) );
354 $tpl->set( 'loggedin', $this->loggedin );
355 $tpl->set( 'notspecialpage', !$title->isSpecialPage() );
356 $tpl->set( 'searchaction', $this->escapeSearchLink() );
357 $tpl->set( 'searchtitle', SpecialPage::getTitleFor( 'Search' )->getPrefixedDBkey() );
358 $tpl->set( 'search', trim( $request->getVal( 'search' ) ) );
359 $tpl->set( 'stylepath', $wgStylePath );
360 $tpl->set( 'articlepath', $wgArticlePath );
361 $tpl->set( 'scriptpath', $wgScriptPath );
362 $tpl->set( 'serverurl', $wgServer );
363 $tpl->set( 'logopath', $wgLogo );
364 $tpl->set( 'sitename', $wgSitename );
365
366 $userLang = $this->getLanguage();
367 $userLangCode = $userLang->getHtmlCode();
368 $userLangDir = $userLang->getDir();
369
370 $tpl->set( 'lang', $userLangCode );
371 $tpl->set( 'dir', $userLangDir );
372 $tpl->set( 'rtl', $userLang->isRTL() );
373
374 $tpl->set( 'capitalizeallnouns', $userLang->capitalizeAllNouns() ? ' capitalize-all-nouns' : '' );
375 $tpl->set( 'showjumplinks', true ); // showjumplinks preference has been removed
376 $tpl->set( 'username', $this->loggedin ? $this->username : null );
377 $tpl->set( 'userpage', $this->userpage );
378 $tpl->set( 'userpageurl', $this->userpageUrlDetails['href'] );
379 $tpl->set( 'userlang', $userLangCode );
380
381 // Users can have their language set differently than the
382 // content of the wiki. For these users, tell the web browser
383 // that interface elements are in a different language.
384 $tpl->set( 'userlangattributes', '' );
385 $tpl->set( 'specialpageattributes', '' ); # obsolete
386 // Used by VectorBeta to insert HTML before content but after the
387 // heading for the page title. Defaults to empty string.
388 $tpl->set( 'prebodyhtml', '' );
389
390 if ( $userLangCode !== $wgContLang->getHtmlCode() || $userLangDir !== $wgContLang->getDir() ) {
391 $escUserlang = htmlspecialchars( $userLangCode );
392 $escUserdir = htmlspecialchars( $userLangDir );
393 // Attributes must be in double quotes because htmlspecialchars() doesn't
394 // escape single quotes
395 $attrs = " lang=\"$escUserlang\" dir=\"$escUserdir\"";
396 $tpl->set( 'userlangattributes', $attrs );
397 }
398
399 $tpl->set( 'newtalk', $this->getNewtalks() );
400 $tpl->set( 'logo', $this->logoText() );
401
402 $tpl->set( 'copyright', false );
403 // No longer used
404 $tpl->set( 'viewcount', false );
405 $tpl->set( 'lastmod', false );
406 $tpl->set( 'credits', false );
407 $tpl->set( 'numberofwatchingusers', false );
408 if ( $out->isArticle() && $title->exists() ) {
409 if ( $this->isRevisionCurrent() ) {
410 if ( $wgMaxCredits != 0 ) {
411 $tpl->set( 'credits', Action::factory( 'credits', $this->getWikiPage(),
412 $this->getContext() )->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ) );
413 } else {
414 $tpl->set( 'lastmod', $this->lastModified() );
415 }
416 }
417 $tpl->set( 'copyright', $this->getCopyright() );
418 }
419
420 $tpl->set( 'copyrightico', $this->getCopyrightIcon() );
421 $tpl->set( 'poweredbyico', $this->getPoweredBy() );
422 $tpl->set( 'disclaimer', $this->disclaimerLink() );
423 $tpl->set( 'privacy', $this->privacyLink() );
424 $tpl->set( 'about', $this->aboutLink() );
425
426 $tpl->set( 'footerlinks', [
427 'info' => [
428 'lastmod',
429 'numberofwatchingusers',
430 'credits',
431 'copyright',
432 ],
433 'places' => [
434 'privacy',
435 'about',
436 'disclaimer',
437 ],
438 ] );
439
440 global $wgFooterIcons;
441 $tpl->set( 'footericons', $wgFooterIcons );
442 foreach ( $tpl->data['footericons'] as $footerIconsKey => &$footerIconsBlock ) {
443 if ( count( $footerIconsBlock ) > 0 ) {
444 foreach ( $footerIconsBlock as &$footerIcon ) {
445 if ( isset( $footerIcon['src'] ) ) {
446 if ( !isset( $footerIcon['width'] ) ) {
447 $footerIcon['width'] = 88;
448 }
449 if ( !isset( $footerIcon['height'] ) ) {
450 $footerIcon['height'] = 31;
451 }
452 }
453 }
454 } else {
455 unset( $tpl->data['footericons'][$footerIconsKey] );
456 }
457 }
458
459 $tpl->set( 'indicators', $out->getIndicators() );
460
461 $tpl->set( 'sitenotice', $this->getSiteNotice() );
462 $tpl->set( 'printfooter', $this->printSource() );
463 // Wrap the bodyText with #mw-content-text element
464 $out->mBodytext = $this->wrapHTML( $title, $out->mBodytext );
465 $tpl->set( 'bodytext', $out->mBodytext );
466
467 $language_urls = $this->getLanguages();
468 if ( count( $language_urls ) ) {
469 $tpl->set( 'language_urls', $language_urls );
470 } else {
471 $tpl->set( 'language_urls', false );
472 }
473
474 # Personal toolbar
475 $tpl->set( 'personal_urls', $this->buildPersonalUrls() );
476 $content_navigation = $this->buildContentNavigationUrls();
477 $content_actions = $this->buildContentActionUrls( $content_navigation );
478 $tpl->set( 'content_navigation', $content_navigation );
479 $tpl->set( 'content_actions', $content_actions );
480
481 $tpl->set( 'sidebar', $this->buildSidebar() );
482 $tpl->set( 'nav_urls', $this->buildNavUrls() );
483
484 // Do this last in case hooks above add bottom scripts
485 $tpl->set( 'bottomscripts', $this->bottomScripts() );
486
487 // Set the head scripts near the end, in case the above actions resulted in added scripts
488 $tpl->set( 'headelement', $out->headElement( $this ) );
489
490 $tpl->set( 'debug', '' );
491 $tpl->set( 'debughtml', $this->generateDebugHTML() );
492 $tpl->set( 'reporttime', wfReportTime() );
493
494 // Avoid PHP 7.1 warning of passing $this by reference
495 $skinTemplate = $this;
496 // original version by hansm
497 if ( !Hooks::run( 'SkinTemplateOutputPageBeforeExec', [ &$skinTemplate, &$tpl ] ) ) {
498 wfDebug( __METHOD__ . ": Hook SkinTemplateOutputPageBeforeExec broke outputPage execution!\n" );
499 }
500
501 // Set the bodytext to another key so that skins can just output it on its own
502 // and output printfooter and debughtml separately
503 $tpl->set( 'bodycontent', $tpl->data['bodytext'] );
504
505 // Append printfooter and debughtml onto bodytext so that skins that
506 // were already using bodytext before they were split out don't suddenly
507 // start not outputting information.
508 $tpl->data['bodytext'] .= Html::rawElement(
509 'div',
510 [ 'class' => 'printfooter' ],
511 "\n{$tpl->data['printfooter']}"
512 ) . "\n";
513 $tpl->data['bodytext'] .= $tpl->data['debughtml'];
514
515 // allow extensions adding stuff after the page content.
516 // See Skin::afterContentHook() for further documentation.
517 $tpl->set( 'dataAfterContent', $this->afterContentHook() );
518
519 return $tpl;
520 }
521
526 public function getPersonalToolsList() {
527 $tpl = $this->setupTemplateForOutput();
528 $tpl->set( 'personal_urls', $this->buildPersonalUrls() );
529 $html = '';
530 foreach ( $tpl->getPersonalTools() as $key => $item ) {
531 $html .= $tpl->makeListItem( $key, $item );
532 }
533 return $html;
534 }
535
544 function formatLanguageName( $name ) {
545 return $this->getLanguage()->ucfirst( $name );
546 }
547
556 function printOrError( $str ) {
557 echo $str;
558 }
559
572 }
573
578 protected function buildPersonalUrls() {
579 $title = $this->getTitle();
580 $request = $this->getRequest();
581 $pageurl = $title->getLocalURL();
582 $authManager = AuthManager::singleton();
583
584 /* set up the default links for the personal toolbar */
585 $personal_urls = [];
586
587 # Due to T34276, if a user does not have read permissions,
588 # $this->getTitle() will just give Special:Badtitle, which is
589 # not especially useful as a returnto parameter. Use the title
590 # from the request instead, if there was one.
591 if ( $this->getUser()->isAllowed( 'read' ) ) {
592 $page = $this->getTitle();
593 } else {
594 $page = Title::newFromText( $request->getVal( 'title', '' ) );
595 }
596 $page = $request->getVal( 'returnto', $page );
597 $returnto = [];
598 if ( strval( $page ) !== '' ) {
599 $returnto['returnto'] = $page;
600 $query = $request->getVal( 'returntoquery', $this->thisquery );
601 $paramsArray = wfCgiToArray( $query );
602 unset( $paramsArray['logoutToken'] );
603 $query = wfArrayToCgi( $paramsArray );
604 if ( $query != '' ) {
605 $returnto['returntoquery'] = $query;
606 }
607 }
608
609 if ( $this->loggedin ) {
610 $personal_urls['userpage'] = [
611 'text' => $this->username,
612 'href' => &$this->userpageUrlDetails['href'],
613 'class' => $this->userpageUrlDetails['exists'] ? false : 'new',
614 'active' => ( $this->userpageUrlDetails['href'] == $pageurl ),
615 'dir' => 'auto'
616 ];
617 $usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage );
618 $personal_urls['mytalk'] = [
619 'text' => $this->msg( 'mytalk' )->text(),
620 'href' => &$usertalkUrlDetails['href'],
621 'class' => $usertalkUrlDetails['exists'] ? false : 'new',
622 'active' => ( $usertalkUrlDetails['href'] == $pageurl )
623 ];
624 $href = self::makeSpecialUrl( 'Preferences' );
625 $personal_urls['preferences'] = [
626 'text' => $this->msg( 'mypreferences' )->text(),
627 'href' => $href,
628 'active' => ( $href == $pageurl )
629 ];
630
631 if ( $this->getUser()->isAllowed( 'viewmywatchlist' ) ) {
632 $href = self::makeSpecialUrl( 'Watchlist' );
633 $personal_urls['watchlist'] = [
634 'text' => $this->msg( 'mywatchlist' )->text(),
635 'href' => $href,
636 'active' => ( $href == $pageurl )
637 ];
638 }
639
640 # We need to do an explicit check for Special:Contributions, as we
641 # have to match both the title, and the target, which could come
642 # from request values (Special:Contributions?target=Jimbo_Wales)
643 # or be specified in "sub page" form
644 # (Special:Contributions/Jimbo_Wales). The plot
645 # thickens, because the Title object is altered for special pages,
646 # so it doesn't contain the original alias-with-subpage.
647 $origTitle = Title::newFromText( $request->getText( 'title' ) );
648 if ( $origTitle instanceof Title && $origTitle->isSpecialPage() ) {
649 list( $spName, $spPar ) = SpecialPageFactory::resolveAlias( $origTitle->getText() );
650 $active = $spName == 'Contributions'
651 && ( ( $spPar && $spPar == $this->username )
652 || $request->getText( 'target' ) == $this->username );
653 } else {
654 $active = false;
655 }
656
657 $href = self::makeSpecialUrlSubpage( 'Contributions', $this->username );
658 $personal_urls['mycontris'] = [
659 'text' => $this->msg( 'mycontris' )->text(),
660 'href' => $href,
661 'active' => $active
662 ];
663
664 // if we can't set the user, we can't unset it either
665 if ( $request->getSession()->canSetUser() ) {
666 $personal_urls['logout'] = [
667 'text' => $this->msg( 'pt-userlogout' )->text(),
668 'href' => self::makeSpecialUrl( 'Userlogout',
669 // Note: userlogout link must always contain an & character, otherwise we might not be able
670 // to detect a buggy precaching proxy (T19790)
671 ( $title->isSpecial( 'Preferences' ) ? [] : $returnto )
672 + [ 'logoutToken' => $this->getUser()->getEditToken( 'logoutToken', $this->getRequest() ) ] ),
673 'active' => false
674 ];
675 }
676 } else {
677 $useCombinedLoginLink = $this->useCombinedLoginLink();
678 if ( !$authManager->canCreateAccounts() || !$authManager->canAuthenticateNow() ) {
679 // don't show combined login/signup link if one of those is actually not available
680 $useCombinedLoginLink = false;
681 }
682
683 $loginlink = $this->getUser()->isAllowed( 'createaccount' ) && $useCombinedLoginLink
684 ? 'nav-login-createaccount'
685 : 'pt-login';
686
687 $login_url = [
688 'text' => $this->msg( $loginlink )->text(),
689 'href' => self::makeSpecialUrl( 'Userlogin', $returnto ),
690 'active' => $title->isSpecial( 'Userlogin' )
691 || $title->isSpecial( 'CreateAccount' ) && $useCombinedLoginLink,
692 ];
693 $createaccount_url = [
694 'text' => $this->msg( 'pt-createaccount' )->text(),
695 'href' => self::makeSpecialUrl( 'CreateAccount', $returnto ),
696 'active' => $title->isSpecial( 'CreateAccount' ),
697 ];
698
699 // No need to show Talk and Contributions to anons if they can't contribute!
700 if ( User::groupHasPermission( '*', 'edit' ) ) {
701 // Because of caching, we can't link directly to the IP talk and
702 // contributions pages. Instead we use the special page shortcuts
703 // (which work correctly regardless of caching). This means we can't
704 // determine whether these links are active or not, but since major
705 // skins (MonoBook, Vector) don't use this information, it's not a
706 // huge loss.
707 $personal_urls['anontalk'] = [
708 'text' => $this->msg( 'anontalk' )->text(),
709 'href' => self::makeSpecialUrlSubpage( 'Mytalk', false ),
710 'active' => false
711 ];
712 $personal_urls['anoncontribs'] = [
713 'text' => $this->msg( 'anoncontribs' )->text(),
714 'href' => self::makeSpecialUrlSubpage( 'Mycontributions', false ),
715 'active' => false
716 ];
717 }
718
719 if (
720 $authManager->canCreateAccounts()
721 && $this->getUser()->isAllowed( 'createaccount' )
722 && !$useCombinedLoginLink
723 ) {
724 $personal_urls['createaccount'] = $createaccount_url;
725 }
726
727 if ( $authManager->canAuthenticateNow() ) {
728 $key = User::groupHasPermission( '*', 'read' )
729 ? 'login'
730 : 'login-private';
731 $personal_urls[$key] = $login_url;
732 }
733 }
734
735 Hooks::run( 'PersonalUrls', [ &$personal_urls, &$title, $this ] );
736 return $personal_urls;
737 }
738
750 function tabAction( $title, $message, $selected, $query = '', $checkEdit = false ) {
751 $classes = [];
752 if ( $selected ) {
753 $classes[] = 'selected';
754 }
755 if ( $checkEdit && !$title->isKnown() ) {
756 $classes[] = 'new';
757 if ( $query !== '' ) {
758 $query = 'action=edit&redlink=1&' . $query;
759 } else {
760 $query = 'action=edit&redlink=1';
761 }
762 }
763
764 $linkClass = MediaWikiServices::getInstance()->getLinkRenderer()->getLinkClasses( $title );
765
766 // wfMessageFallback will nicely accept $message as an array of fallbacks
767 // or just a single key
768 $msg = wfMessageFallback( $message )->setContext( $this->getContext() );
769 if ( is_array( $message ) ) {
770 // for hook compatibility just keep the last message name
771 $message = end( $message );
772 }
773 if ( $msg->exists() ) {
774 $text = $msg->text();
775 } else {
776 global $wgContLang;
777 $text = $wgContLang->getConverter()->convertNamespace(
778 MWNamespace::getSubject( $title->getNamespace() ) );
779 }
780
781 // Avoid PHP 7.1 warning of passing $this by reference
782 $skinTemplate = $this;
783 $result = [];
784 if ( !Hooks::run( 'SkinTemplateTabAction', [ &$skinTemplate,
785 $title, $message, $selected, $checkEdit,
786 &$classes, &$query, &$text, &$result ] ) ) {
787 return $result;
788 }
789
790 $result = [
791 'class' => implode( ' ', $classes ),
792 'text' => $text,
793 'href' => $title->getLocalURL( $query ),
794 'primary' => true ];
795 if ( $linkClass !== '' ) {
796 $result['link-class'] = $linkClass;
797 }
798
799 return $result;
800 }
801
802 function makeTalkUrlDetails( $name, $urlaction = '' ) {
803 $title = Title::newFromText( $name );
804 if ( !is_object( $title ) ) {
805 throw new MWException( __METHOD__ . " given invalid pagename $name" );
806 }
807 $title = $title->getTalkPage();
808 self::checkTitle( $title, $name );
809 return [
810 'href' => $title->getLocalURL( $urlaction ),
811 'exists' => $title->isKnown(),
812 ];
813 }
814
821 function makeArticleUrlDetails( $name, $urlaction = '' ) {
822 $title = Title::newFromText( $name );
823 $title = $title->getSubjectPage();
824 self::checkTitle( $title, $name );
825 return [
826 'href' => $title->getLocalURL( $urlaction ),
827 'exists' => $title->exists(),
828 ];
829 }
830
865 protected function buildContentNavigationUrls() {
867
868 // Display tabs for the relevant title rather than always the title itself
869 $title = $this->getRelevantTitle();
870 $onPage = $title->equals( $this->getTitle() );
871
872 $out = $this->getOutput();
873 $request = $this->getRequest();
874 $user = $this->getUser();
875
876 $content_navigation = [
877 'namespaces' => [],
878 'views' => [],
879 'actions' => [],
880 'variants' => []
881 ];
882
883 // parameters
884 $action = $request->getVal( 'action', 'view' );
885
886 $userCanRead = $title->quickUserCan( 'read', $user );
887
888 // Avoid PHP 7.1 warning of passing $this by reference
889 $skinTemplate = $this;
890 $preventActiveTabs = false;
891 Hooks::run( 'SkinTemplatePreventOtherActiveTabs', [ &$skinTemplate, &$preventActiveTabs ] );
892
893 // Checks if page is some kind of content
894 if ( $title->canExist() ) {
895 // Gets page objects for the related namespaces
896 $subjectPage = $title->getSubjectPage();
897 $talkPage = $title->getTalkPage();
898
899 // Determines if this is a talk page
900 $isTalk = $title->isTalkPage();
901
902 // Generates XML IDs from namespace names
903 $subjectId = $title->getNamespaceKey( '' );
904
905 if ( $subjectId == 'main' ) {
906 $talkId = 'talk';
907 } else {
908 $talkId = "{$subjectId}_talk";
909 }
910
911 $skname = $this->skinname;
912
913 // Adds namespace links
914 $subjectMsg = [ "nstab-$subjectId" ];
915 if ( $subjectPage->isMainPage() ) {
916 array_unshift( $subjectMsg, 'mainpage-nstab' );
917 }
918 $content_navigation['namespaces'][$subjectId] = $this->tabAction(
919 $subjectPage, $subjectMsg, !$isTalk && !$preventActiveTabs, '', $userCanRead
920 );
921 $content_navigation['namespaces'][$subjectId]['context'] = 'subject';
922 $content_navigation['namespaces'][$talkId] = $this->tabAction(
923 $talkPage, [ "nstab-$talkId", 'talk' ], $isTalk && !$preventActiveTabs, '', $userCanRead
924 );
925 $content_navigation['namespaces'][$talkId]['context'] = 'talk';
926
927 if ( $userCanRead ) {
928 // Adds "view" view link
929 if ( $title->isKnown() ) {
930 $content_navigation['views']['view'] = $this->tabAction(
931 $isTalk ? $talkPage : $subjectPage,
932 [ "$skname-view-view", 'view' ],
933 ( $onPage && ( $action == 'view' || $action == 'purge' ) ), '', true
934 );
935 // signal to hide this from simple content_actions
936 $content_navigation['views']['view']['redundant'] = true;
937 }
938
939 $page = $this->canUseWikiPage() ? $this->getWikiPage() : false;
940 $isRemoteContent = $page && !$page->isLocal();
941
942 // If it is a non-local file, show a link to the file in its own repository
943 // @todo abstract this for remote content that isn't a file
944 if ( $isRemoteContent ) {
945 $content_navigation['views']['view-foreign'] = [
946 'class' => '',
947 'text' => wfMessageFallback( "$skname-view-foreign", 'view-foreign' )->
948 setContext( $this->getContext() )->
949 params( $page->getWikiDisplayName() )->text(),
950 'href' => $page->getSourceURL(),
951 'primary' => false,
952 ];
953 }
954
955 // Checks if user can edit the current page if it exists or create it otherwise
956 if ( $title->quickUserCan( 'edit', $user )
957 && ( $title->exists() || $title->quickUserCan( 'create', $user ) )
958 ) {
959 // Builds CSS class for talk page links
960 $isTalkClass = $isTalk ? ' istalk' : '';
961 // Whether the user is editing the page
962 $isEditing = $onPage && ( $action == 'edit' || $action == 'submit' );
963 // Whether to show the "Add a new section" tab
964 // Checks if this is a current rev of talk page and is not forced to be hidden
965 $showNewSection = !$out->forceHideNewSectionLink()
966 && ( ( $isTalk && $this->isRevisionCurrent() ) || $out->showNewSectionLink() );
967 $section = $request->getVal( 'section' );
968
969 if ( $title->exists()
970 || ( $title->getNamespace() == NS_MEDIAWIKI
971 && $title->getDefaultMessageText() !== false
972 )
973 ) {
974 $msgKey = $isRemoteContent ? 'edit-local' : 'edit';
975 } else {
976 $msgKey = $isRemoteContent ? 'create-local' : 'create';
977 }
978 $content_navigation['views']['edit'] = [
979 'class' => ( $isEditing && ( $section !== 'new' || !$showNewSection )
980 ? 'selected'
981 : ''
982 ) . $isTalkClass,
983 'text' => wfMessageFallback( "$skname-view-$msgKey", $msgKey )
984 ->setContext( $this->getContext() )->text(),
985 'href' => $title->getLocalURL( $this->editUrlOptions() ),
986 'primary' => !$isRemoteContent, // don't collapse this in vector
987 ];
988
989 // section link
990 if ( $showNewSection ) {
991 // Adds new section link
992 // $content_navigation['actions']['addsection']
993 $content_navigation['views']['addsection'] = [
994 'class' => ( $isEditing && $section == 'new' ) ? 'selected' : false,
995 'text' => wfMessageFallback( "$skname-action-addsection", 'addsection' )
996 ->setContext( $this->getContext() )->text(),
997 'href' => $title->getLocalURL( 'action=edit&section=new' )
998 ];
999 }
1000 // Checks if the page has some kind of viewable source content
1001 } elseif ( $title->hasSourceText() ) {
1002 // Adds view source view link
1003 $content_navigation['views']['viewsource'] = [
1004 'class' => ( $onPage && $action == 'edit' ) ? 'selected' : false,
1005 'text' => wfMessageFallback( "$skname-action-viewsource", 'viewsource' )
1006 ->setContext( $this->getContext() )->text(),
1007 'href' => $title->getLocalURL( $this->editUrlOptions() ),
1008 'primary' => true, // don't collapse this in vector
1009 ];
1010 }
1011
1012 // Checks if the page exists
1013 if ( $title->exists() ) {
1014 // Adds history view link
1015 $content_navigation['views']['history'] = [
1016 'class' => ( $onPage && $action == 'history' ) ? 'selected' : false,
1017 'text' => wfMessageFallback( "$skname-view-history", 'history_short' )
1018 ->setContext( $this->getContext() )->text(),
1019 'href' => $title->getLocalURL( 'action=history' ),
1020 ];
1021
1022 if ( $title->quickUserCan( 'delete', $user ) ) {
1023 $content_navigation['actions']['delete'] = [
1024 'class' => ( $onPage && $action == 'delete' ) ? 'selected' : false,
1025 'text' => wfMessageFallback( "$skname-action-delete", 'delete' )
1026 ->setContext( $this->getContext() )->text(),
1027 'href' => $title->getLocalURL( 'action=delete' )
1028 ];
1029 }
1030
1031 if ( $title->quickUserCan( 'move', $user ) ) {
1032 $moveTitle = SpecialPage::getTitleFor( 'Movepage', $title->getPrefixedDBkey() );
1033 $content_navigation['actions']['move'] = [
1034 'class' => $this->getTitle()->isSpecial( 'Movepage' ) ? 'selected' : false,
1035 'text' => wfMessageFallback( "$skname-action-move", 'move' )
1036 ->setContext( $this->getContext() )->text(),
1037 'href' => $moveTitle->getLocalURL()
1038 ];
1039 }
1040 } else {
1041 // article doesn't exist or is deleted
1042 if ( $user->isAllowed( 'deletedhistory' ) ) {
1043 $n = $title->isDeleted();
1044 if ( $n ) {
1045 $undelTitle = SpecialPage::getTitleFor( 'Undelete', $title->getPrefixedDBkey() );
1046 // If the user can't undelete but can view deleted
1047 // history show them a "View .. deleted" tab instead.
1048 $msgKey = $user->isAllowed( 'undelete' ) ? 'undelete' : 'viewdeleted';
1049 $content_navigation['actions']['undelete'] = [
1050 'class' => $this->getTitle()->isSpecial( 'Undelete' ) ? 'selected' : false,
1051 'text' => wfMessageFallback( "$skname-action-$msgKey", "{$msgKey}_short" )
1052 ->setContext( $this->getContext() )->numParams( $n )->text(),
1053 'href' => $undelTitle->getLocalURL()
1054 ];
1055 }
1056 }
1057 }
1058
1059 if ( $title->quickUserCan( 'protect', $user ) && $title->getRestrictionTypes() &&
1060 MWNamespace::getRestrictionLevels( $title->getNamespace(), $user ) !== [ '' ]
1061 ) {
1062 $mode = $title->isProtected() ? 'unprotect' : 'protect';
1063 $content_navigation['actions'][$mode] = [
1064 'class' => ( $onPage && $action == $mode ) ? 'selected' : false,
1065 'text' => wfMessageFallback( "$skname-action-$mode", $mode )
1066 ->setContext( $this->getContext() )->text(),
1067 'href' => $title->getLocalURL( "action=$mode" )
1068 ];
1069 }
1070
1071 // Checks if the user is logged in
1072 if ( $this->loggedin && $user->isAllowedAll( 'viewmywatchlist', 'editmywatchlist' ) ) {
1082 $mode = $user->isWatched( $title ) ? 'unwatch' : 'watch';
1083 $content_navigation['actions'][$mode] = [
1084 'class' => 'mw-watchlink ' . (
1085 $onPage && ( $action == 'watch' || $action == 'unwatch' ) ? 'selected' : ''
1086 ),
1087 // uses 'watch' or 'unwatch' message
1088 'text' => $this->msg( $mode )->text(),
1089 'href' => $title->getLocalURL( [ 'action' => $mode ] ),
1090 // Set a data-mw=interface attribute, which the mediawiki.page.ajax
1091 // module will look for to make sure it's a trusted link
1092 'data' => [
1093 'mw' => 'interface',
1094 ],
1095 ];
1096 }
1097 }
1098
1099 // Avoid PHP 7.1 warning of passing $this by reference
1100 $skinTemplate = $this;
1101 Hooks::run( 'SkinTemplateNavigation', [ &$skinTemplate, &$content_navigation ] );
1102
1103 if ( $userCanRead && !$wgDisableLangConversion ) {
1104 $pageLang = $title->getPageLanguage();
1105 // Gets list of language variants
1106 $variants = $pageLang->getVariants();
1107 // Checks that language conversion is enabled and variants exist
1108 // And if it is not in the special namespace
1109 if ( count( $variants ) > 1 ) {
1110 // Gets preferred variant (note that user preference is
1111 // only possible for wiki content language variant)
1112 $preferred = $pageLang->getPreferredVariant();
1113 if ( Action::getActionName( $this ) === 'view' ) {
1114 $params = $request->getQueryValues();
1115 unset( $params['title'] );
1116 } else {
1117 $params = [];
1118 }
1119 // Loops over each variant
1120 foreach ( $variants as $code ) {
1121 // Gets variant name from language code
1122 $varname = $pageLang->getVariantname( $code );
1123 // Appends variant link
1124 $content_navigation['variants'][] = [
1125 'class' => ( $code == $preferred ) ? 'selected' : false,
1126 'text' => $varname,
1127 'href' => $title->getLocalURL( [ 'variant' => $code ] + $params ),
1128 'lang' => wfBCP47( $code ),
1129 'hreflang' => wfBCP47( $code ),
1130 ];
1131 }
1132 }
1133 }
1134 } else {
1135 // If it's not content, it's got to be a special page
1136 $content_navigation['namespaces']['special'] = [
1137 'class' => 'selected',
1138 'text' => $this->msg( 'nstab-special' )->text(),
1139 'href' => $request->getRequestURL(), // @see: T4457, T4510
1140 'context' => 'subject'
1141 ];
1142
1143 // Avoid PHP 7.1 warning of passing $this by reference
1144 $skinTemplate = $this;
1145 Hooks::run( 'SkinTemplateNavigation::SpecialPage',
1146 [ &$skinTemplate, &$content_navigation ] );
1147 }
1148
1149 // Avoid PHP 7.1 warning of passing $this by reference
1150 $skinTemplate = $this;
1151 // Equiv to SkinTemplateContentActions
1152 Hooks::run( 'SkinTemplateNavigation::Universal', [ &$skinTemplate, &$content_navigation ] );
1153
1154 // Setup xml ids and tooltip info
1155 foreach ( $content_navigation as $section => &$links ) {
1156 foreach ( $links as $key => &$link ) {
1157 $xmlID = $key;
1158 if ( isset( $link['context'] ) && $link['context'] == 'subject' ) {
1159 $xmlID = 'ca-nstab-' . $xmlID;
1160 } elseif ( isset( $link['context'] ) && $link['context'] == 'talk' ) {
1161 $xmlID = 'ca-talk';
1162 $link['rel'] = 'discussion';
1163 } elseif ( $section == 'variants' ) {
1164 $xmlID = 'ca-varlang-' . $xmlID;
1165 } else {
1166 $xmlID = 'ca-' . $xmlID;
1167 }
1168 $link['id'] = $xmlID;
1169 }
1170 }
1171
1172 # We don't want to give the watch tab an accesskey if the
1173 # page is being edited, because that conflicts with the
1174 # accesskey on the watch checkbox. We also don't want to
1175 # give the edit tab an accesskey, because that's fairly
1176 # superfluous and conflicts with an accesskey (Ctrl-E) often
1177 # used for editing in Safari.
1178 if ( in_array( $action, [ 'edit', 'submit' ] ) ) {
1179 if ( isset( $content_navigation['views']['edit'] ) ) {
1180 $content_navigation['views']['edit']['tooltiponly'] = true;
1181 }
1182 if ( isset( $content_navigation['actions']['watch'] ) ) {
1183 $content_navigation['actions']['watch']['tooltiponly'] = true;
1184 }
1185 if ( isset( $content_navigation['actions']['unwatch'] ) ) {
1186 $content_navigation['actions']['unwatch']['tooltiponly'] = true;
1187 }
1188 }
1189
1190 return $content_navigation;
1191 }
1192
1198 private function buildContentActionUrls( $content_navigation ) {
1199 // content_actions has been replaced with content_navigation for backwards
1200 // compatibility and also for skins that just want simple tabs content_actions
1201 // is now built by flattening the content_navigation arrays into one
1202
1203 $content_actions = [];
1204
1205 foreach ( $content_navigation as $links ) {
1206 foreach ( $links as $key => $value ) {
1207 if ( isset( $value['redundant'] ) && $value['redundant'] ) {
1208 // Redundant tabs are dropped from content_actions
1209 continue;
1210 }
1211
1212 // content_actions used to have ids built using the "ca-$key" pattern
1213 // so the xmlID based id is much closer to the actual $key that we want
1214 // for that reason we'll just strip out the ca- if present and use
1215 // the latter potion of the "id" as the $key
1216 if ( isset( $value['id'] ) && substr( $value['id'], 0, 3 ) == 'ca-' ) {
1217 $key = substr( $value['id'], 3 );
1218 }
1219
1220 if ( isset( $content_actions[$key] ) ) {
1221 wfDebug( __METHOD__ . ": Found a duplicate key for $key while flattening " .
1222 "content_navigation into content_actions.\n" );
1223 continue;
1224 }
1225
1226 $content_actions[$key] = $value;
1227 }
1228 }
1229
1230 return $content_actions;
1231 }
1232
1237 protected function buildNavUrls() {
1239
1240 $out = $this->getOutput();
1241 $request = $this->getRequest();
1242
1243 $nav_urls = [];
1244 $nav_urls['mainpage'] = [ 'href' => self::makeMainPageUrl() ];
1245 if ( $wgUploadNavigationUrl ) {
1246 $nav_urls['upload'] = [ 'href' => $wgUploadNavigationUrl ];
1247 } elseif ( UploadBase::isEnabled() && UploadBase::isAllowed( $this->getUser() ) === true ) {
1248 $nav_urls['upload'] = [ 'href' => self::makeSpecialUrl( 'Upload' ) ];
1249 } else {
1250 $nav_urls['upload'] = false;
1251 }
1252 $nav_urls['specialpages'] = [ 'href' => self::makeSpecialUrl( 'Specialpages' ) ];
1253
1254 $nav_urls['print'] = false;
1255 $nav_urls['permalink'] = false;
1256 $nav_urls['info'] = false;
1257 $nav_urls['whatlinkshere'] = false;
1258 $nav_urls['recentchangeslinked'] = false;
1259 $nav_urls['contributions'] = false;
1260 $nav_urls['log'] = false;
1261 $nav_urls['blockip'] = false;
1262 $nav_urls['emailuser'] = false;
1263 $nav_urls['userrights'] = false;
1264
1265 // A print stylesheet is attached to all pages, but nobody ever
1266 // figures that out. :) Add a link...
1267 if ( !$out->isPrintable() && ( $out->isArticle() || $this->getTitle()->isSpecialPage() ) ) {
1268 $nav_urls['print'] = [
1269 'text' => $this->msg( 'printableversion' )->text(),
1270 'href' => $this->getTitle()->getLocalURL(
1271 $request->appendQueryValue( 'printable', 'yes' ) )
1272 ];
1273 }
1274
1275 if ( $out->isArticle() ) {
1276 // Also add a "permalink" while we're at it
1277 $revid = $this->getRevisionId();
1278 if ( $revid ) {
1279 $nav_urls['permalink'] = [
1280 'text' => $this->msg( 'permalink' )->text(),
1281 'href' => $this->getTitle()->getLocalURL( "oldid=$revid" )
1282 ];
1283 }
1284
1285 // Avoid PHP 7.1 warning of passing $this by reference
1286 $skinTemplate = $this;
1287 // Use the copy of revision ID in case this undocumented, shady hook tries to mess with internals
1288 Hooks::run( 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink',
1289 [ &$skinTemplate, &$nav_urls, &$revid, &$revid ] );
1290 }
1291
1292 if ( $out->isArticleRelated() ) {
1293 $nav_urls['whatlinkshere'] = [
1294 'href' => SpecialPage::getTitleFor( 'Whatlinkshere', $this->thispage )->getLocalURL()
1295 ];
1296
1297 $nav_urls['info'] = [
1298 'text' => $this->msg( 'pageinfo-toolboxlink' )->text(),
1299 'href' => $this->getTitle()->getLocalURL( "action=info" )
1300 ];
1301
1302 if ( $this->getTitle()->exists() || $this->getTitle()->inNamespace( NS_CATEGORY ) ) {
1303 $nav_urls['recentchangeslinked'] = [
1304 'href' => SpecialPage::getTitleFor( 'Recentchangeslinked', $this->thispage )->getLocalURL()
1305 ];
1306 }
1307 }
1308
1309 $user = $this->getRelevantUser();
1310 if ( $user ) {
1311 $rootUser = $user->getName();
1312
1313 $nav_urls['contributions'] = [
1314 'text' => $this->msg( 'contributions', $rootUser )->text(),
1315 'href' => self::makeSpecialUrlSubpage( 'Contributions', $rootUser ),
1316 'tooltip-params' => [ $rootUser ],
1317 ];
1318
1319 $nav_urls['log'] = [
1320 'href' => self::makeSpecialUrlSubpage( 'Log', $rootUser )
1321 ];
1322
1323 if ( $this->getUser()->isAllowed( 'block' ) ) {
1324 $nav_urls['blockip'] = [
1325 'text' => $this->msg( 'blockip', $rootUser )->text(),
1326 'href' => self::makeSpecialUrlSubpage( 'Block', $rootUser )
1327 ];
1328 }
1329
1330 if ( $this->showEmailUser( $user ) ) {
1331 $nav_urls['emailuser'] = [
1332 'text' => $this->msg( 'tool-link-emailuser', $rootUser )->text(),
1333 'href' => self::makeSpecialUrlSubpage( 'Emailuser', $rootUser ),
1334 'tooltip-params' => [ $rootUser ],
1335 ];
1336 }
1337
1338 if ( !$user->isAnon() ) {
1339 $sur = new UserrightsPage;
1340 $sur->setContext( $this->getContext() );
1341 $canChange = $sur->userCanChangeRights( $user );
1342 $nav_urls['userrights'] = [
1343 'text' => $this->msg(
1344 $canChange ? 'tool-link-userrights' : 'tool-link-userrights-readonly',
1345 $rootUser
1346 )->text(),
1347 'href' => self::makeSpecialUrlSubpage( 'Userrights', $rootUser )
1348 ];
1349 }
1350 }
1351
1352 return $nav_urls;
1353 }
1354
1359 protected function getNameSpaceKey() {
1360 return $this->getTitle()->getNamespaceKey();
1361 }
1362}
$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.
wfBCP47( $code)
Get the normalised IETF language tag See unit test for examples.
wfReportTime()
Returns a script tag that stores the amount of time it took MediaWiki to handle the request in millis...
wfMessageFallback()
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.
static factory( $action, Page $page, IContextSource $context=null)
Get an appropriate Action subclass for the given action.
Definition Action.php:95
static getActionName(IContextSource $context)
Get the action that will be executed, not necessarily the one passed passed through the "action" requ...
Definition Action.php:122
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
getUser()
Get the User object.
getRequest()
Get the WebRequest object.
canUseWikiPage()
Check whether a WikiPage object can be get with getWikiPage().
getConfig()
Get the Config object.
getTitle()
Get the Title object.
getOutput()
Get the OutputPage object.
getWikiPage()
Get the WikiPage object.
getLanguage()
Get the Language object.
getContext()
Get the base IContextSource object.
setContext(IContextSource $context)
Set the IContextSource object.
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...
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='')
setupSkinUserCss(OutputPage $out)
Add specific styles for this skin.
outputPage(OutputPage $out=null)
initialize various variables and generate the template
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:36
aboutLink()
Gets the link to the wiki's about page.
Definition Skin.php:1020
isRevisionCurrent()
Whether the revision displayed is the latest revision of the page.
Definition Skin.php:285
afterContentHook()
This runs a hook to allow extensions placing their stuff after content and article metadata (e....
Definition Skin.php:605
getNewtalks()
Gets new talk page messages for the current user and returns an appropriate alert message (or an empt...
Definition Skin.php:1394
static makeMainPageUrl( $urlaction='')
Definition Skin.php:1094
static makeKnownUrlDetails( $name, $urlaction='')
Make URL details where the article exists (or at least it's convenient to think so)
Definition Skin.php:1205
generateDebugHTML()
Generate debug data HTML for displaying at the bottom of the main content area.
Definition Skin.php:631
getCopyrightIcon()
Definition Skin.php:830
privacyLink()
Gets the link to the wiki's privacy policy page.
Definition Skin.php:1012
getSiteNotice()
Get the site notice.
Definition Skin.php:1537
getUndeleteLink()
Definition Skin.php:674
getPoweredBy()
Gets the powered by MediaWiki icon.
Definition Skin.php:860
escapeSearchLink()
Definition Skin.php:776
static makeUrlDetails( $name, $urlaction='')
these return an array with the 'href' and boolean 'exists'
Definition Skin.php:1189
static makeSpecialUrlSubpage( $name, $subpage, $urlaction='')
Definition Skin.php:1127
getRelevantUser()
Return the "relevant" user.
Definition Skin.php:333
logoText( $align='')
Definition Skin.php:911
static checkTitle(&$title, $name)
make sure we have some title to operate on
Definition Skin.php:1221
editUrlOptions()
Return URL options for the 'edit page' link.
Definition Skin.php:1039
showEmailUser( $id)
Definition Skin.php:1053
buildSidebar()
Build an array that represents the sidebar(s), the navigation bar among them.
Definition Skin.php:1251
getCopyright( $type='detect')
Definition Skin.php:784
printSource()
Text with the permalink to the source page, usually shown on the footer of a printed page.
Definition Skin.php:656
getRevisionId()
Get the current revision ID.
Definition Skin.php:276
bottomScripts()
This gets called shortly before the "</body>" tag.
Definition Skin.php:640
disclaimerLink()
Gets the link to the wiki's general disclaimers page.
Definition Skin.php:1028
static makeSpecialUrl( $name, $urlaction='', $proto=null)
Make a URL for a Special Page using the given query and protocol.
Definition Skin.php:1112
lastModified()
Get the timestamp of the latest revision, formatted in user language.
Definition Skin.php:884
initPage(OutputPage $out)
Definition Skin.php:146
subPageSubtitle( $out=null)
Definition Skin.php:703
getRelevantTitle()
Return the "relevant" title.
Definition Skin.php:309
getCategories()
Definition Skin.php:570
static resolveAlias( $alias)
Given a special page name with a possible subpage, return an array where the first element is the spe...
setContext( $context)
Sets the context this SpecialPage is executed in.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Represents a title within MediaWiki.
Definition Title.php:39
isSpecialPage()
Returns true if this is a special page.
Definition Title.php:1122
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...
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 class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
Definition design.txt:57
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition design.txt:18
namespace being checked & $result
Definition hooks.txt:2293
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:2775
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:863
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 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 true
Definition hooks.txt:1976
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:862
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:1983
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition hooks.txt:2989
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:1610
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:2990
processing should stop and the error should be shown to the user * false
Definition hooks.txt:187
const NS_FILE
Definition Defines.php:71
const NS_SPECIAL
Definition Defines.php:54
const NS_CATEGORY
Definition Defines.php:79
$wgArticlePath
Definition img_auth.php:45
$params