MediaWiki  1.27.3
SkinTemplate.php
Go to the documentation of this file.
1 <?php
35 class SkinTemplate extends Skin {
40  public $skinname = 'monobook';
41 
46  public $template = 'QuickTemplate';
47 
48  public $thispage;
49  public $titletxt;
50  public $userpage;
51  public $thisquery;
52  public $loggedin;
53  public $username;
55 
62  $moduleStyles = [
63  'mediawiki.legacy.shared',
64  'mediawiki.legacy.commonPrint',
65  'mediawiki.sectionAnchor'
66  ];
67  if ( $out->isSyndicated() ) {
68  $moduleStyles[] = 'mediawiki.feedlink';
69  }
70 
71  // Deprecated since 1.26: Unconditional loading of mediawiki.ui.button
72  // on every page is deprecated. Express a dependency instead.
73  if ( strpos( $out->getHTML(), 'mw-ui-button' ) !== false ) {
74  $moduleStyles[] = 'mediawiki.ui.button';
75  }
76 
77  $out->addModuleStyles( $moduleStyles );
78  }
79 
91  function setupTemplate( $classname, $repository = false, $cache_dir = false ) {
92  return new $classname( $this->getConfig() );
93  }
94 
100  public function getLanguages() {
102  if ( $wgHideInterlanguageLinks ) {
103  return [];
104  }
105 
106  $userLang = $this->getLanguage();
107  $languageLinks = [];
108 
109  foreach ( $this->getOutput()->getLanguageLinks() as $languageLinkText ) {
110  $class = 'interlanguage-link interwiki-' . explode( ':', $languageLinkText, 2 )[0];
111 
112  $languageLinkTitle = Title::newFromText( $languageLinkText );
113  if ( $languageLinkTitle ) {
114  $ilInterwikiCode = $languageLinkTitle->getInterwiki();
115  $ilLangName = Language::fetchLanguageName( $ilInterwikiCode );
116 
117  if ( strval( $ilLangName ) === '' ) {
118  $ilDisplayTextMsg = wfMessage( "interlanguage-link-$ilInterwikiCode" );
119  if ( !$ilDisplayTextMsg->isDisabled() ) {
120  // Use custom MW message for the display text
121  $ilLangName = $ilDisplayTextMsg->text();
122  } else {
123  // Last resort: fallback to the language link target
124  $ilLangName = $languageLinkText;
125  }
126  } else {
127  // Use the language autonym as display text
128  $ilLangName = $this->formatLanguageName( $ilLangName );
129  }
130 
131  // CLDR extension or similar is required to localize the language name;
132  // otherwise we'll end up with the autonym again.
133  $ilLangLocalName = Language::fetchLanguageName(
134  $ilInterwikiCode,
135  $userLang->getCode()
136  );
137 
138  $languageLinkTitleText = $languageLinkTitle->getText();
139  if ( $ilLangLocalName === '' ) {
140  $ilFriendlySiteName = wfMessage( "interlanguage-link-sitename-$ilInterwikiCode" );
141  if ( !$ilFriendlySiteName->isDisabled() ) {
142  if ( $languageLinkTitleText === '' ) {
143  $ilTitle = wfMessage(
144  'interlanguage-link-title-nonlangonly',
145  $ilFriendlySiteName->text()
146  )->text();
147  } else {
148  $ilTitle = wfMessage(
149  'interlanguage-link-title-nonlang',
150  $languageLinkTitleText,
151  $ilFriendlySiteName->text()
152  )->text();
153  }
154  } else {
155  // we have nothing friendly to put in the title, so fall back to
156  // displaying the interlanguage link itself in the title text
157  // (similar to what is done in page content)
158  $ilTitle = $languageLinkTitle->getInterwiki() .
159  ":$languageLinkTitleText";
160  }
161  } elseif ( $languageLinkTitleText === '' ) {
162  $ilTitle = wfMessage(
163  'interlanguage-link-title-langonly',
164  $ilLangLocalName
165  )->text();
166  } else {
167  $ilTitle = wfMessage(
168  'interlanguage-link-title',
169  $languageLinkTitleText,
170  $ilLangLocalName
171  )->text();
172  }
173 
174  $ilInterwikiCodeBCP47 = wfBCP47( $ilInterwikiCode );
175  $languageLink = [
176  'href' => $languageLinkTitle->getFullURL(),
177  'text' => $ilLangName,
178  'title' => $ilTitle,
179  'class' => $class,
180  'lang' => $ilInterwikiCodeBCP47,
181  'hreflang' => $ilInterwikiCodeBCP47,
182  ];
183  Hooks::run(
184  'SkinTemplateGetLanguageLink',
185  [ &$languageLink, $languageLinkTitle, $this->getTitle(), $this->getOutput() ]
186  );
187  $languageLinks[] = $languageLink;
188  }
189  }
190 
191  return $languageLinks;
192  }
193 
194  protected function setupTemplateForOutput() {
195 
196  $request = $this->getRequest();
197  $user = $this->getUser();
198  $title = $this->getTitle();
199 
200  $tpl = $this->setupTemplate( $this->template, 'skins' );
201 
202  $this->thispage = $title->getPrefixedDBkey();
203  $this->titletxt = $title->getPrefixedText();
204  $this->userpage = $user->getUserPage()->getPrefixedText();
205  $query = [];
206  if ( !$request->wasPosted() ) {
207  $query = $request->getValues();
208  unset( $query['title'] );
209  unset( $query['returnto'] );
210  unset( $query['returntoquery'] );
211  }
212  $this->thisquery = wfArrayToCgi( $query );
213  $this->loggedin = $user->isLoggedIn();
214  $this->username = $user->getName();
215 
216  if ( $this->loggedin ) {
217  $this->userpageUrlDetails = self::makeUrlDetails( $this->userpage );
218  } else {
219  # This won't be used in the standard skins, but we define it to preserve the interface
220  # To save time, we check for existence
221  $this->userpageUrlDetails = self::makeKnownUrlDetails( $this->userpage );
222  }
223 
224  return $tpl;
225  }
226 
232  function outputPage( OutputPage $out = null ) {
233  Profiler::instance()->setTemplated( true );
234 
235  $oldContext = null;
236  if ( $out !== null ) {
237  // Deprecated since 1.20, note added in 1.25
238  wfDeprecated( __METHOD__, '1.25' );
239  $oldContext = $this->getContext();
240  $this->setContext( $out->getContext() );
241  }
242 
243  $out = $this->getOutput();
244 
245  $this->initPage( $out );
246  $tpl = $this->prepareQuickTemplate( $out );
247  // execute template
248  $res = $tpl->execute();
249 
250  // result may be an error
251  $this->printOrError( $res );
252 
253  if ( $oldContext ) {
254  $this->setContext( $oldContext );
255  }
256 
257  }
258 
266  protected function wrapHTML( $title, $html ) {
267  # An ID that includes the actual body text; without categories, contentSub, ...
268  $realBodyAttribs = [ 'id' => 'mw-content-text' ];
269 
270  # Add a mw-content-ltr/rtl class to be able to style based on text direction
271  # when the content is different from the UI language, i.e.:
272  # not for special pages or file pages AND only when viewing
273  if ( !in_array( $title->getNamespace(), [ NS_SPECIAL, NS_FILE ] ) &&
274  Action::getActionName( $this ) === 'view' ) {
275  $pageLang = $title->getPageViewLanguage();
276  $realBodyAttribs['lang'] = $pageLang->getHtmlCode();
277  $realBodyAttribs['dir'] = $pageLang->getDir();
278  $realBodyAttribs['class'] = 'mw-content-' . $pageLang->getDir();
279  }
280 
281  return Html::rawElement( 'div', $realBodyAttribs, $html );
282  }
283 
290  protected function prepareQuickTemplate() {
292  $wgSitename, $wgLogo, $wgMaxCredits,
293  $wgShowCreditsIfMax, $wgArticlePath,
295 
296  $title = $this->getTitle();
297  $request = $this->getRequest();
298  $out = $this->getOutput();
299  $tpl = $this->setupTemplateForOutput();
300 
301  $tpl->set( 'title', $out->getPageTitle() );
302  $tpl->set( 'pagetitle', $out->getHTMLTitle() );
303  $tpl->set( 'displaytitle', $out->mPageLinkTitle );
304 
305  $tpl->setRef( 'thispage', $this->thispage );
306  $tpl->setRef( 'titleprefixeddbkey', $this->thispage );
307  $tpl->set( 'titletext', $title->getText() );
308  $tpl->set( 'articleid', $title->getArticleID() );
309 
310  $tpl->set( 'isarticle', $out->isArticle() );
311 
312  $subpagestr = $this->subPageSubtitle();
313  if ( $subpagestr !== '' ) {
314  $subpagestr = '<span class="subpages">' . $subpagestr . '</span>';
315  }
316  $tpl->set( 'subtitle', $subpagestr . $out->getSubtitle() );
317 
318  $undelete = $this->getUndeleteLink();
319  if ( $undelete === '' ) {
320  $tpl->set( 'undelete', '' );
321  } else {
322  $tpl->set( 'undelete', '<span class="subpages">' . $undelete . '</span>' );
323  }
324 
325  $tpl->set( 'catlinks', $this->getCategories() );
326  if ( $out->isSyndicated() ) {
327  $feeds = [];
328  foreach ( $out->getSyndicationLinks() as $format => $link ) {
329  $feeds[$format] = [
330  // Messages: feed-atom, feed-rss
331  'text' => $this->msg( "feed-$format" )->text(),
332  'href' => $link
333  ];
334  }
335  $tpl->setRef( 'feeds', $feeds );
336  } else {
337  $tpl->set( 'feeds', false );
338  }
339 
340  $tpl->setRef( 'mimetype', $wgMimeType );
341  $tpl->setRef( 'jsmimetype', $wgJsMimeType );
342  $tpl->set( 'charset', 'UTF-8' );
343  $tpl->setRef( 'wgScript', $wgScript );
344  $tpl->setRef( 'skinname', $this->skinname );
345  $tpl->set( 'skinclass', get_class( $this ) );
346  $tpl->setRef( 'skin', $this );
347  $tpl->setRef( 'stylename', $this->stylename );
348  $tpl->set( 'printable', $out->isPrintable() );
349  $tpl->set( 'handheld', $request->getBool( 'handheld' ) );
350  $tpl->setRef( 'loggedin', $this->loggedin );
351  $tpl->set( 'notspecialpage', !$title->isSpecialPage() );
352  $tpl->set( 'searchaction', $this->escapeSearchLink() );
353  $tpl->set( 'searchtitle', SpecialPage::getTitleFor( 'Search' )->getPrefixedDBkey() );
354  $tpl->set( 'search', trim( $request->getVal( 'search' ) ) );
355  $tpl->setRef( 'stylepath', $wgStylePath );
356  $tpl->setRef( 'articlepath', $wgArticlePath );
357  $tpl->setRef( 'scriptpath', $wgScriptPath );
358  $tpl->setRef( 'serverurl', $wgServer );
359  $tpl->setRef( 'logopath', $wgLogo );
360  $tpl->setRef( 'sitename', $wgSitename );
361 
362  $userLang = $this->getLanguage();
363  $userLangCode = $userLang->getHtmlCode();
364  $userLangDir = $userLang->getDir();
365 
366  $tpl->set( 'lang', $userLangCode );
367  $tpl->set( 'dir', $userLangDir );
368  $tpl->set( 'rtl', $userLang->isRTL() );
369 
370  $tpl->set( 'capitalizeallnouns', $userLang->capitalizeAllNouns() ? ' capitalize-all-nouns' : '' );
371  $tpl->set( 'showjumplinks', true ); // showjumplinks preference has been removed
372  $tpl->set( 'username', $this->loggedin ? $this->username : null );
373  $tpl->setRef( 'userpage', $this->userpage );
374  $tpl->setRef( 'userpageurl', $this->userpageUrlDetails['href'] );
375  $tpl->set( 'userlang', $userLangCode );
376 
377  // Users can have their language set differently than the
378  // content of the wiki. For these users, tell the web browser
379  // that interface elements are in a different language.
380  $tpl->set( 'userlangattributes', '' );
381  $tpl->set( 'specialpageattributes', '' ); # obsolete
382  // Used by VectorBeta to insert HTML before content but after the
383  // heading for the page title. Defaults to empty string.
384  $tpl->set( 'prebodyhtml', '' );
385 
386  if ( $userLangCode !== $wgContLang->getHtmlCode() || $userLangDir !== $wgContLang->getDir() ) {
387  $escUserlang = htmlspecialchars( $userLangCode );
388  $escUserdir = htmlspecialchars( $userLangDir );
389  // Attributes must be in double quotes because htmlspecialchars() doesn't
390  // escape single quotes
391  $attrs = " lang=\"$escUserlang\" dir=\"$escUserdir\"";
392  $tpl->set( 'userlangattributes', $attrs );
393  }
394 
395  $tpl->set( 'newtalk', $this->getNewtalks() );
396  $tpl->set( 'logo', $this->logoText() );
397 
398  $tpl->set( 'copyright', false );
399  // No longer used
400  $tpl->set( 'viewcount', false );
401  $tpl->set( 'lastmod', false );
402  $tpl->set( 'credits', false );
403  $tpl->set( 'numberofwatchingusers', false );
404  if ( $out->isArticle() && $title->exists() ) {
405  if ( $this->isRevisionCurrent() ) {
406  if ( $wgMaxCredits != 0 ) {
407  $tpl->set( 'credits', Action::factory( 'credits', $this->getWikiPage(),
408  $this->getContext() )->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ) );
409  } else {
410  $tpl->set( 'lastmod', $this->lastModified() );
411  }
412  }
413  $tpl->set( 'copyright', $this->getCopyright() );
414  }
415 
416  $tpl->set( 'copyrightico', $this->getCopyrightIcon() );
417  $tpl->set( 'poweredbyico', $this->getPoweredBy() );
418  $tpl->set( 'disclaimer', $this->disclaimerLink() );
419  $tpl->set( 'privacy', $this->privacyLink() );
420  $tpl->set( 'about', $this->aboutLink() );
421 
422  $tpl->set( 'footerlinks', [
423  'info' => [
424  'lastmod',
425  'numberofwatchingusers',
426  'credits',
427  'copyright',
428  ],
429  'places' => [
430  'privacy',
431  'about',
432  'disclaimer',
433  ],
434  ] );
435 
437  $tpl->set( 'footericons', $wgFooterIcons );
438  foreach ( $tpl->data['footericons'] as $footerIconsKey => &$footerIconsBlock ) {
439  if ( count( $footerIconsBlock ) > 0 ) {
440  foreach ( $footerIconsBlock as &$footerIcon ) {
441  if ( isset( $footerIcon['src'] ) ) {
442  if ( !isset( $footerIcon['width'] ) ) {
443  $footerIcon['width'] = 88;
444  }
445  if ( !isset( $footerIcon['height'] ) ) {
446  $footerIcon['height'] = 31;
447  }
448  }
449  }
450  } else {
451  unset( $tpl->data['footericons'][$footerIconsKey] );
452  }
453  }
454 
455  $tpl->set( 'indicators', $out->getIndicators() );
456 
457  $tpl->set( 'sitenotice', $this->getSiteNotice() );
458  $tpl->set( 'bottomscripts', $this->bottomScripts() );
459  $tpl->set( 'printfooter', $this->printSource() );
460  // Wrap the bodyText with #mw-content-text element
461  $out->mBodytext = $this->wrapHTML( $title, $out->mBodytext );
462  $tpl->setRef( 'bodytext', $out->mBodytext );
463 
464  $language_urls = $this->getLanguages();
465  if ( count( $language_urls ) ) {
466  $tpl->setRef( 'language_urls', $language_urls );
467  } else {
468  $tpl->set( 'language_urls', false );
469  }
470 
471  # Personal toolbar
472  $tpl->set( 'personal_urls', $this->buildPersonalUrls() );
473  $content_navigation = $this->buildContentNavigationUrls();
474  $content_actions = $this->buildContentActionUrls( $content_navigation );
475  $tpl->setRef( 'content_navigation', $content_navigation );
476  $tpl->setRef( 'content_actions', $content_actions );
477 
478  $tpl->set( 'sidebar', $this->buildSidebar() );
479  $tpl->set( 'nav_urls', $this->buildNavUrls() );
480 
481  // Set the head scripts near the end, in case the above actions resulted in added scripts
482  $tpl->set( 'headelement', $out->headElement( $this ) );
483 
484  $tpl->set( 'debug', '' );
485  $tpl->set( 'debughtml', $this->generateDebugHTML() );
486  $tpl->set( 'reporttime', wfReportTime() );
487 
488  // Avoid PHP 7.1 warning of passing $this by reference
489  $skinTemplate = $this;
490  // original version by hansm
491  if ( !Hooks::run( 'SkinTemplateOutputPageBeforeExec', [ &$skinTemplate, &$tpl ] ) ) {
492  wfDebug( __METHOD__ . ": Hook SkinTemplateOutputPageBeforeExec broke outputPage execution!\n" );
493  }
494 
495  // Set the bodytext to another key so that skins can just output it on its own
496  // and output printfooter and debughtml separately
497  $tpl->set( 'bodycontent', $tpl->data['bodytext'] );
498 
499  // Append printfooter and debughtml onto bodytext so that skins that
500  // were already using bodytext before they were split out don't suddenly
501  // start not outputting information.
502  $tpl->data['bodytext'] .= Html::rawElement(
503  'div',
504  [ 'class' => 'printfooter' ],
505  "\n{$tpl->data['printfooter']}"
506  ) . "\n";
507  $tpl->data['bodytext'] .= $tpl->data['debughtml'];
508 
509  // allow extensions adding stuff after the page content.
510  // See Skin::afterContentHook() for further documentation.
511  $tpl->set( 'dataAfterContent', $this->afterContentHook() );
512 
513  return $tpl;
514  }
515 
520  public function getPersonalToolsList() {
521  $tpl = $this->setupTemplateForOutput();
522  $tpl->set( 'personal_urls', $this->buildPersonalUrls() );
523  $html = '';
524  foreach ( $tpl->getPersonalTools() as $key => $item ) {
525  $html .= $tpl->makeListItem( $key, $item );
526  }
527  return $html;
528  }
529 
538  function formatLanguageName( $name ) {
539  return $this->getLanguage()->ucfirst( $name );
540  }
541 
550  function printOrError( $str ) {
551  echo $str;
552  }
553 
563  function useCombinedLoginLink() {
566  }
567 
572  protected function buildPersonalUrls() {
573  $title = $this->getTitle();
574  $request = $this->getRequest();
575  $pageurl = $title->getLocalURL();
576 
577  /* set up the default links for the personal toolbar */
578  $personal_urls = [];
579 
580  # Due to bug 32276, if a user does not have read permissions,
581  # $this->getTitle() will just give Special:Badtitle, which is
582  # not especially useful as a returnto parameter. Use the title
583  # from the request instead, if there was one.
584  if ( $this->getUser()->isAllowed( 'read' ) ) {
585  $page = $this->getTitle();
586  } else {
587  $page = Title::newFromText( $request->getVal( 'title', '' ) );
588  }
589  $page = $request->getVal( 'returnto', $page );
590  $a = [];
591  if ( strval( $page ) !== '' ) {
592  $a['returnto'] = $page;
593  $query = $request->getVal( 'returntoquery', $this->thisquery );
594  if ( $query != '' ) {
595  $a['returntoquery'] = $query;
596  }
597  }
598 
599  $returnto = wfArrayToCgi( $a );
600  if ( $this->loggedin ) {
601  $personal_urls['userpage'] = [
602  'text' => $this->username,
603  'href' => &$this->userpageUrlDetails['href'],
604  'class' => $this->userpageUrlDetails['exists'] ? false : 'new',
605  'active' => ( $this->userpageUrlDetails['href'] == $pageurl ),
606  'dir' => 'auto'
607  ];
608  $usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage );
609  $personal_urls['mytalk'] = [
610  'text' => $this->msg( 'mytalk' )->text(),
611  'href' => &$usertalkUrlDetails['href'],
612  'class' => $usertalkUrlDetails['exists'] ? false : 'new',
613  'active' => ( $usertalkUrlDetails['href'] == $pageurl )
614  ];
615  $href = self::makeSpecialUrl( 'Preferences' );
616  $personal_urls['preferences'] = [
617  'text' => $this->msg( 'mypreferences' )->text(),
618  'href' => $href,
619  'active' => ( $href == $pageurl )
620  ];
621 
622  if ( $this->getUser()->isAllowed( 'viewmywatchlist' ) ) {
623  $href = self::makeSpecialUrl( 'Watchlist' );
624  $personal_urls['watchlist'] = [
625  'text' => $this->msg( 'mywatchlist' )->text(),
626  'href' => $href,
627  'active' => ( $href == $pageurl )
628  ];
629  }
630 
631  # We need to do an explicit check for Special:Contributions, as we
632  # have to match both the title, and the target, which could come
633  # from request values (Special:Contributions?target=Jimbo_Wales)
634  # or be specified in "sub page" form
635  # (Special:Contributions/Jimbo_Wales). The plot
636  # thickens, because the Title object is altered for special pages,
637  # so it doesn't contain the original alias-with-subpage.
638  $origTitle = Title::newFromText( $request->getText( 'title' ) );
639  if ( $origTitle instanceof Title && $origTitle->isSpecialPage() ) {
640  list( $spName, $spPar ) = SpecialPageFactory::resolveAlias( $origTitle->getText() );
641  $active = $spName == 'Contributions'
642  && ( ( $spPar && $spPar == $this->username )
643  || $request->getText( 'target' ) == $this->username );
644  } else {
645  $active = false;
646  }
647 
648  $href = self::makeSpecialUrlSubpage( 'Contributions', $this->username );
649  $personal_urls['mycontris'] = [
650  'text' => $this->msg( 'mycontris' )->text(),
651  'href' => $href,
652  'active' => $active
653  ];
654  $personal_urls['logout'] = [
655  'text' => $this->msg( 'pt-userlogout' )->text(),
656  'href' => self::makeSpecialUrl( 'Userlogout',
657  // userlogout link must always contain an & character, otherwise we might not be able
658  // to detect a buggy precaching proxy (bug 17790)
659  $title->isSpecial( 'Preferences' ) ? 'noreturnto' : $returnto
660  ),
661  'active' => false
662  ];
663  } else {
664  $useCombinedLoginLink = $this->useCombinedLoginLink();
665  $loginlink = $this->getUser()->isAllowed( 'createaccount' ) && $useCombinedLoginLink
666  ? 'nav-login-createaccount'
667  : 'pt-login';
668 
669  $login_url = [
670  'text' => $this->msg( $loginlink )->text(),
671  'href' => self::makeSpecialUrl( 'Userlogin', $returnto ),
672  'active' => $title->isSpecial( 'Userlogin' )
673  || $title->isSpecial( 'CreateAccount' ) && $useCombinedLoginLink,
674  ];
675  $createaccount_url = [
676  'text' => $this->msg( 'pt-createaccount' )->text(),
677  'href' => self::makeSpecialUrl( 'CreateAccount', $returnto ),
678  'active' => $title->isSpecial( 'CreateAccount' ),
679  ];
680 
681  // No need to show Talk and Contributions to anons if they can't contribute!
682  if ( User::groupHasPermission( '*', 'edit' ) ) {
683  // Because of caching, we can't link directly to the IP talk and
684  // contributions pages. Instead we use the special page shortcuts
685  // (which work correctly regardless of caching). This means we can't
686  // determine whether these links are active or not, but since major
687  // skins (MonoBook, Vector) don't use this information, it's not a
688  // huge loss.
689  $personal_urls['anontalk'] = [
690  'text' => $this->msg( 'anontalk' )->text(),
691  'href' => self::makeSpecialUrlSubpage( 'Mytalk', false ),
692  'active' => false
693  ];
694  $personal_urls['anoncontribs'] = [
695  'text' => $this->msg( 'anoncontribs' )->text(),
696  'href' => self::makeSpecialUrlSubpage( 'Mycontributions', false ),
697  'active' => false
698  ];
699  }
700 
701  if ( $this->getUser()->isAllowed( 'createaccount' ) && !$useCombinedLoginLink ) {
702  $personal_urls['createaccount'] = $createaccount_url;
703  }
704 
705  $personal_urls['login'] = $login_url;
706  }
707 
708  Hooks::run( 'PersonalUrls', [ &$personal_urls, &$title, $this ] );
709  return $personal_urls;
710  }
711 
723  function tabAction( $title, $message, $selected, $query = '', $checkEdit = false ) {
724  $classes = [];
725  if ( $selected ) {
726  $classes[] = 'selected';
727  }
728  if ( $checkEdit && !$title->isKnown() ) {
729  $classes[] = 'new';
730  if ( $query !== '' ) {
731  $query = 'action=edit&redlink=1&' . $query;
732  } else {
733  $query = 'action=edit&redlink=1';
734  }
735  }
736 
737  // wfMessageFallback will nicely accept $message as an array of fallbacks
738  // or just a single key
739  $msg = wfMessageFallback( $message )->setContext( $this->getContext() );
740  if ( is_array( $message ) ) {
741  // for hook compatibility just keep the last message name
742  $message = end( $message );
743  }
744  if ( $msg->exists() ) {
745  $text = $msg->text();
746  } else {
748  $text = $wgContLang->getConverter()->convertNamespace(
749  MWNamespace::getSubject( $title->getNamespace() ) );
750  }
751 
752  // Avoid PHP 7.1 warning of passing $this by reference
753  $skinTemplate = $this;
754  $result = [];
755  if ( !Hooks::run( 'SkinTemplateTabAction', [ &$skinTemplate,
756  $title, $message, $selected, $checkEdit,
757  &$classes, &$query, &$text, &$result ] ) ) {
758  return $result;
759  }
760 
761  return [
762  'class' => implode( ' ', $classes ),
763  'text' => $text,
764  'href' => $title->getLocalURL( $query ),
765  'primary' => true ];
766  }
767 
768  function makeTalkUrlDetails( $name, $urlaction = '' ) {
770  if ( !is_object( $title ) ) {
771  throw new MWException( __METHOD__ . " given invalid pagename $name" );
772  }
773  $title = $title->getTalkPage();
774  self::checkTitle( $title, $name );
775  return [
776  'href' => $title->getLocalURL( $urlaction ),
777  'exists' => $title->isKnown(),
778  ];
779  }
780 
784  function makeArticleUrlDetails( $name, $urlaction = '' ) {
786  $title = $title->getSubjectPage();
787  self::checkTitle( $title, $name );
788  return [
789  'href' => $title->getLocalURL( $urlaction ),
790  'exists' => $title->exists(),
791  ];
792  }
793 
828  protected function buildContentNavigationUrls() {
830 
831  // Display tabs for the relevant title rather than always the title itself
832  $title = $this->getRelevantTitle();
833  $onPage = $title->equals( $this->getTitle() );
834 
835  $out = $this->getOutput();
836  $request = $this->getRequest();
837  $user = $this->getUser();
838 
839  $content_navigation = [
840  'namespaces' => [],
841  'views' => [],
842  'actions' => [],
843  'variants' => []
844  ];
845 
846  // parameters
847  $action = $request->getVal( 'action', 'view' );
848 
849  $userCanRead = $title->quickUserCan( 'read', $user );
850 
851  // Avoid PHP 7.1 warning of passing $this by reference
852  $skinTemplate = $this;
853  $preventActiveTabs = false;
854  Hooks::run( 'SkinTemplatePreventOtherActiveTabs', [ &$skinTemplate, &$preventActiveTabs ] );
855 
856  // Checks if page is some kind of content
857  if ( $title->canExist() ) {
858  // Gets page objects for the related namespaces
859  $subjectPage = $title->getSubjectPage();
860  $talkPage = $title->getTalkPage();
861 
862  // Determines if this is a talk page
863  $isTalk = $title->isTalkPage();
864 
865  // Generates XML IDs from namespace names
866  $subjectId = $title->getNamespaceKey( '' );
867 
868  if ( $subjectId == 'main' ) {
869  $talkId = 'talk';
870  } else {
871  $talkId = "{$subjectId}_talk";
872  }
873 
874  $skname = $this->skinname;
875 
876  // Adds namespace links
877  $subjectMsg = [ "nstab-$subjectId" ];
878  if ( $subjectPage->isMainPage() ) {
879  array_unshift( $subjectMsg, 'mainpage-nstab' );
880  }
881  $content_navigation['namespaces'][$subjectId] = $this->tabAction(
882  $subjectPage, $subjectMsg, !$isTalk && !$preventActiveTabs, '', $userCanRead
883  );
884  $content_navigation['namespaces'][$subjectId]['context'] = 'subject';
885  $content_navigation['namespaces'][$talkId] = $this->tabAction(
886  $talkPage, [ "nstab-$talkId", 'talk' ], $isTalk && !$preventActiveTabs, '', $userCanRead
887  );
888  $content_navigation['namespaces'][$talkId]['context'] = 'talk';
889 
890  if ( $userCanRead ) {
891  $isForeignFile = $title->inNamespace( NS_FILE ) && $this->canUseWikiPage() &&
892  $this->getWikiPage() instanceof WikiFilePage && !$this->getWikiPage()->isLocal();
893 
894  // Adds view view link
895  if ( $title->exists() || $isForeignFile ) {
896  $content_navigation['views']['view'] = $this->tabAction(
897  $isTalk ? $talkPage : $subjectPage,
898  [ "$skname-view-view", 'view' ],
899  ( $onPage && ( $action == 'view' || $action == 'purge' ) ), '', true
900  );
901  // signal to hide this from simple content_actions
902  $content_navigation['views']['view']['redundant'] = true;
903  }
904 
905  // If it is a non-local file, show a link to the file in its own repository
906  if ( $isForeignFile ) {
907  $file = $this->getWikiPage()->getFile();
908  $content_navigation['views']['view-foreign'] = [
909  'class' => '',
910  'text' => wfMessageFallback( "$skname-view-foreign", 'view-foreign' )->
911  setContext( $this->getContext() )->
912  params( $file->getRepo()->getDisplayName() )->text(),
913  'href' => $file->getDescriptionUrl(),
914  'primary' => false,
915  ];
916  }
917 
918  // Checks if user can edit the current page if it exists or create it otherwise
919  if ( $title->quickUserCan( 'edit', $user )
920  && ( $title->exists() || $title->quickUserCan( 'create', $user ) )
921  ) {
922  // Builds CSS class for talk page links
923  $isTalkClass = $isTalk ? ' istalk' : '';
924  // Whether the user is editing the page
925  $isEditing = $onPage && ( $action == 'edit' || $action == 'submit' );
926  // Whether to show the "Add a new section" tab
927  // Checks if this is a current rev of talk page and is not forced to be hidden
928  $showNewSection = !$out->forceHideNewSectionLink()
929  && ( ( $isTalk && $this->isRevisionCurrent() ) || $out->showNewSectionLink() );
930  $section = $request->getVal( 'section' );
931 
932  if ( $title->exists()
933  || ( $title->getNamespace() == NS_MEDIAWIKI
934  && $title->getDefaultMessageText() !== false
935  )
936  ) {
937  $msgKey = $isForeignFile ? 'edit-local' : 'edit';
938  } else {
939  $msgKey = $isForeignFile ? 'create-local' : 'create';
940  }
941  $content_navigation['views']['edit'] = [
942  'class' => ( $isEditing && ( $section !== 'new' || !$showNewSection )
943  ? 'selected'
944  : ''
945  ) . $isTalkClass,
946  'text' => wfMessageFallback( "$skname-view-$msgKey", $msgKey )
947  ->setContext( $this->getContext() )->text(),
948  'href' => $title->getLocalURL( $this->editUrlOptions() ),
949  'primary' => !$isForeignFile, // don't collapse this in vector
950  ];
951 
952  // section link
953  if ( $showNewSection ) {
954  // Adds new section link
955  // $content_navigation['actions']['addsection']
956  $content_navigation['views']['addsection'] = [
957  'class' => ( $isEditing && $section == 'new' ) ? 'selected' : false,
958  'text' => wfMessageFallback( "$skname-action-addsection", 'addsection' )
959  ->setContext( $this->getContext() )->text(),
960  'href' => $title->getLocalURL( 'action=edit&section=new' )
961  ];
962  }
963  // Checks if the page has some kind of viewable content
964  } elseif ( $title->hasSourceText() ) {
965  // Adds view source view link
966  $content_navigation['views']['viewsource'] = [
967  'class' => ( $onPage && $action == 'edit' ) ? 'selected' : false,
968  'text' => wfMessageFallback( "$skname-action-viewsource", 'viewsource' )
969  ->setContext( $this->getContext() )->text(),
970  'href' => $title->getLocalURL( $this->editUrlOptions() ),
971  'primary' => true, // don't collapse this in vector
972  ];
973  }
974 
975  // Checks if the page exists
976  if ( $title->exists() ) {
977  // Adds history view link
978  $content_navigation['views']['history'] = [
979  'class' => ( $onPage && $action == 'history' ) ? 'selected' : false,
980  'text' => wfMessageFallback( "$skname-view-history", 'history_short' )
981  ->setContext( $this->getContext() )->text(),
982  'href' => $title->getLocalURL( 'action=history' ),
983  ];
984 
985  if ( $title->quickUserCan( 'delete', $user ) ) {
986  $content_navigation['actions']['delete'] = [
987  'class' => ( $onPage && $action == 'delete' ) ? 'selected' : false,
988  'text' => wfMessageFallback( "$skname-action-delete", 'delete' )
989  ->setContext( $this->getContext() )->text(),
990  'href' => $title->getLocalURL( 'action=delete' )
991  ];
992  }
993 
994  if ( $title->quickUserCan( 'move', $user ) ) {
995  $moveTitle = SpecialPage::getTitleFor( 'Movepage', $title->getPrefixedDBkey() );
996  $content_navigation['actions']['move'] = [
997  'class' => $this->getTitle()->isSpecial( 'Movepage' ) ? 'selected' : false,
998  'text' => wfMessageFallback( "$skname-action-move", 'move' )
999  ->setContext( $this->getContext() )->text(),
1000  'href' => $moveTitle->getLocalURL()
1001  ];
1002  }
1003  } else {
1004  // article doesn't exist or is deleted
1005  if ( $user->isAllowed( 'deletedhistory' ) ) {
1006  $n = $title->isDeleted();
1007  if ( $n ) {
1008  $undelTitle = SpecialPage::getTitleFor( 'Undelete', $title->getPrefixedDBkey() );
1009  // If the user can't undelete but can view deleted
1010  // history show them a "View .. deleted" tab instead.
1011  $msgKey = $user->isAllowed( 'undelete' ) ? 'undelete' : 'viewdeleted';
1012  $content_navigation['actions']['undelete'] = [
1013  'class' => $this->getTitle()->isSpecial( 'Undelete' ) ? 'selected' : false,
1014  'text' => wfMessageFallback( "$skname-action-$msgKey", "{$msgKey}_short" )
1015  ->setContext( $this->getContext() )->numParams( $n )->text(),
1016  'href' => $undelTitle->getLocalURL()
1017  ];
1018  }
1019  }
1020  }
1021 
1022  if ( $title->quickUserCan( 'protect', $user ) && $title->getRestrictionTypes() &&
1023  MWNamespace::getRestrictionLevels( $title->getNamespace(), $user ) !== [ '' ]
1024  ) {
1025  $mode = $title->isProtected() ? 'unprotect' : 'protect';
1026  $content_navigation['actions'][$mode] = [
1027  'class' => ( $onPage && $action == $mode ) ? 'selected' : false,
1028  'text' => wfMessageFallback( "$skname-action-$mode", $mode )
1029  ->setContext( $this->getContext() )->text(),
1030  'href' => $title->getLocalURL( "action=$mode" )
1031  ];
1032  }
1033 
1034  // Checks if the user is logged in
1035  if ( $this->loggedin && $user->isAllowedAll( 'viewmywatchlist', 'editmywatchlist' ) ) {
1045  $mode = $user->isWatched( $title ) ? 'unwatch' : 'watch';
1046  $content_navigation['actions'][$mode] = [
1047  'class' => 'mw-watchlink ' . (
1048  $onPage && ( $action == 'watch' || $action == 'unwatch' ) ? 'selected' : ''
1049  ),
1050  // uses 'watch' or 'unwatch' message
1051  'text' => $this->msg( $mode )->text(),
1052  'href' => $title->getLocalURL( [ 'action' => $mode ] )
1053  ];
1054  }
1055  }
1056 
1057  // Avoid PHP 7.1 warning of passing $this by reference
1058  $skinTemplate = $this;
1059  Hooks::run( 'SkinTemplateNavigation', [ &$skinTemplate, &$content_navigation ] );
1060 
1061  if ( $userCanRead && !$wgDisableLangConversion ) {
1062  $pageLang = $title->getPageLanguage();
1063  // Gets list of language variants
1064  $variants = $pageLang->getVariants();
1065  // Checks that language conversion is enabled and variants exist
1066  // And if it is not in the special namespace
1067  if ( count( $variants ) > 1 ) {
1068  // Gets preferred variant (note that user preference is
1069  // only possible for wiki content language variant)
1070  $preferred = $pageLang->getPreferredVariant();
1071  if ( Action::getActionName( $this ) === 'view' ) {
1072  $params = $request->getQueryValues();
1073  unset( $params['title'] );
1074  } else {
1075  $params = [];
1076  }
1077  // Loops over each variant
1078  foreach ( $variants as $code ) {
1079  // Gets variant name from language code
1080  $varname = $pageLang->getVariantname( $code );
1081  // Appends variant link
1082  $content_navigation['variants'][] = [
1083  'class' => ( $code == $preferred ) ? 'selected' : false,
1084  'text' => $varname,
1085  'href' => $title->getLocalURL( [ 'variant' => $code ] + $params ),
1086  'lang' => wfBCP47( $code ),
1087  'hreflang' => wfBCP47( $code ),
1088  ];
1089  }
1090  }
1091  }
1092  } else {
1093  // If it's not content, it's got to be a special page
1094  $content_navigation['namespaces']['special'] = [
1095  'class' => 'selected',
1096  'text' => $this->msg( 'nstab-special' )->text(),
1097  'href' => $request->getRequestURL(), // @see: bug 2457, bug 2510
1098  'context' => 'subject'
1099  ];
1100 
1101  // Avoid PHP 7.1 warning of passing $this by reference
1102  $skinTemplate = $this;
1103  Hooks::run( 'SkinTemplateNavigation::SpecialPage',
1104  [ &$skinTemplate, &$content_navigation ] );
1105  }
1106 
1107  // Avoid PHP 7.1 warning of passing $this by reference
1108  $skinTemplate = $this;
1109  // Equiv to SkinTemplateContentActions
1110  Hooks::run( 'SkinTemplateNavigation::Universal', [ &$skinTemplate, &$content_navigation ] );
1111 
1112  // Setup xml ids and tooltip info
1113  foreach ( $content_navigation as $section => &$links ) {
1114  foreach ( $links as $key => &$link ) {
1115  $xmlID = $key;
1116  if ( isset( $link['context'] ) && $link['context'] == 'subject' ) {
1117  $xmlID = 'ca-nstab-' . $xmlID;
1118  } elseif ( isset( $link['context'] ) && $link['context'] == 'talk' ) {
1119  $xmlID = 'ca-talk';
1120  $link['rel'] = 'discussion';
1121  } elseif ( $section == 'variants' ) {
1122  $xmlID = 'ca-varlang-' . $xmlID;
1123  } else {
1124  $xmlID = 'ca-' . $xmlID;
1125  }
1126  $link['id'] = $xmlID;
1127  }
1128  }
1129 
1130  # We don't want to give the watch tab an accesskey if the
1131  # page is being edited, because that conflicts with the
1132  # accesskey on the watch checkbox. We also don't want to
1133  # give the edit tab an accesskey, because that's fairly
1134  # superfluous and conflicts with an accesskey (Ctrl-E) often
1135  # used for editing in Safari.
1136  if ( in_array( $action, [ 'edit', 'submit' ] ) ) {
1137  if ( isset( $content_navigation['views']['edit'] ) ) {
1138  $content_navigation['views']['edit']['tooltiponly'] = true;
1139  }
1140  if ( isset( $content_navigation['actions']['watch'] ) ) {
1141  $content_navigation['actions']['watch']['tooltiponly'] = true;
1142  }
1143  if ( isset( $content_navigation['actions']['unwatch'] ) ) {
1144  $content_navigation['actions']['unwatch']['tooltiponly'] = true;
1145  }
1146  }
1147 
1148  return $content_navigation;
1149  }
1150 
1156  private function buildContentActionUrls( $content_navigation ) {
1157 
1158  // content_actions has been replaced with content_navigation for backwards
1159  // compatibility and also for skins that just want simple tabs content_actions
1160  // is now built by flattening the content_navigation arrays into one
1161 
1162  $content_actions = [];
1163 
1164  foreach ( $content_navigation as $links ) {
1165  foreach ( $links as $key => $value ) {
1166  if ( isset( $value['redundant'] ) && $value['redundant'] ) {
1167  // Redundant tabs are dropped from content_actions
1168  continue;
1169  }
1170 
1171  // content_actions used to have ids built using the "ca-$key" pattern
1172  // so the xmlID based id is much closer to the actual $key that we want
1173  // for that reason we'll just strip out the ca- if present and use
1174  // the latter potion of the "id" as the $key
1175  if ( isset( $value['id'] ) && substr( $value['id'], 0, 3 ) == 'ca-' ) {
1176  $key = substr( $value['id'], 3 );
1177  }
1178 
1179  if ( isset( $content_actions[$key] ) ) {
1180  wfDebug( __METHOD__ . ": Found a duplicate key for $key while flattening " .
1181  "content_navigation into content_actions.\n" );
1182  continue;
1183  }
1184 
1185  $content_actions[$key] = $value;
1186  }
1187  }
1188 
1189  return $content_actions;
1190  }
1191 
1196  protected function buildNavUrls() {
1198 
1199  $out = $this->getOutput();
1200  $request = $this->getRequest();
1201 
1202  $nav_urls = [];
1203  $nav_urls['mainpage'] = [ 'href' => self::makeMainPageUrl() ];
1204  if ( $wgUploadNavigationUrl ) {
1205  $nav_urls['upload'] = [ 'href' => $wgUploadNavigationUrl ];
1206  } elseif ( UploadBase::isEnabled() && UploadBase::isAllowed( $this->getUser() ) === true ) {
1207  $nav_urls['upload'] = [ 'href' => self::makeSpecialUrl( 'Upload' ) ];
1208  } else {
1209  $nav_urls['upload'] = false;
1210  }
1211  $nav_urls['specialpages'] = [ 'href' => self::makeSpecialUrl( 'Specialpages' ) ];
1212 
1213  $nav_urls['print'] = false;
1214  $nav_urls['permalink'] = false;
1215  $nav_urls['info'] = false;
1216  $nav_urls['whatlinkshere'] = false;
1217  $nav_urls['recentchangeslinked'] = false;
1218  $nav_urls['contributions'] = false;
1219  $nav_urls['log'] = false;
1220  $nav_urls['blockip'] = false;
1221  $nav_urls['emailuser'] = false;
1222  $nav_urls['userrights'] = false;
1223 
1224  // A print stylesheet is attached to all pages, but nobody ever
1225  // figures that out. :) Add a link...
1226  if ( !$out->isPrintable() && ( $out->isArticle() || $this->getTitle()->isSpecialPage() ) ) {
1227  $nav_urls['print'] = [
1228  'text' => $this->msg( 'printableversion' )->text(),
1229  'href' => $this->getTitle()->getLocalURL(
1230  $request->appendQueryValue( 'printable', 'yes' ) )
1231  ];
1232  }
1233 
1234  if ( $out->isArticle() ) {
1235  // Also add a "permalink" while we're at it
1236  $revid = $this->getRevisionId();
1237  if ( $revid ) {
1238  $nav_urls['permalink'] = [
1239  'text' => $this->msg( 'permalink' )->text(),
1240  'href' => $this->getTitle()->getLocalURL( "oldid=$revid" )
1241  ];
1242  }
1243 
1244  // Avoid PHP 7.1 warning of passing $this by reference
1245  $skinTemplate = $this;
1246  // Use the copy of revision ID in case this undocumented, shady hook tries to mess with internals
1247  Hooks::run( 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink',
1248  [ &$skinTemplate, &$nav_urls, &$revid, &$revid ] );
1249  }
1250 
1251  if ( $out->isArticleRelated() ) {
1252  $nav_urls['whatlinkshere'] = [
1253  'href' => SpecialPage::getTitleFor( 'Whatlinkshere', $this->thispage )->getLocalURL()
1254  ];
1255 
1256  $nav_urls['info'] = [
1257  'text' => $this->msg( 'pageinfo-toolboxlink' )->text(),
1258  'href' => $this->getTitle()->getLocalURL( "action=info" )
1259  ];
1260 
1261  if ( $this->getTitle()->exists() ) {
1262  $nav_urls['recentchangeslinked'] = [
1263  'href' => SpecialPage::getTitleFor( 'Recentchangeslinked', $this->thispage )->getLocalURL()
1264  ];
1265  }
1266  }
1267 
1268  $user = $this->getRelevantUser();
1269  if ( $user ) {
1270  $rootUser = $user->getName();
1271 
1272  $nav_urls['contributions'] = [
1273  'text' => $this->msg( 'contributions', $rootUser )->text(),
1274  'href' => self::makeSpecialUrlSubpage( 'Contributions', $rootUser ),
1275  'tooltip-params' => [ $rootUser ],
1276  ];
1277 
1278  $nav_urls['log'] = [
1279  'href' => self::makeSpecialUrlSubpage( 'Log', $rootUser )
1280  ];
1281 
1282  if ( $this->getUser()->isAllowed( 'block' ) ) {
1283  $nav_urls['blockip'] = [
1284  'text' => $this->msg( 'blockip', $rootUser )->text(),
1285  'href' => self::makeSpecialUrlSubpage( 'Block', $rootUser )
1286  ];
1287  }
1288 
1289  if ( $this->showEmailUser( $user ) ) {
1290  $nav_urls['emailuser'] = [
1291  'href' => self::makeSpecialUrlSubpage( 'Emailuser', $rootUser ),
1292  'tooltip-params' => [ $rootUser ],
1293  ];
1294  }
1295 
1296  if ( !$user->isAnon() ) {
1297  $sur = new UserrightsPage;
1298  $sur->setContext( $this->getContext() );
1299  if ( $sur->userCanExecute( $this->getUser() ) ) {
1300  $nav_urls['userrights'] = [
1301  'href' => self::makeSpecialUrlSubpage( 'Userrights', $rootUser )
1302  ];
1303  }
1304  }
1305  }
1306 
1307  return $nav_urls;
1308  }
1309 
1314  protected function getNameSpaceKey() {
1315  return $this->getTitle()->getNamespaceKey();
1316  }
1317 }
setContext(IContextSource $context)
Set the IContextSource object.
$wgFooterIcons
Abstract list of footer icons for skins in place of old copyrightico and poweredbyico code You can ad...
lastModified()
Get the timestamp of the latest revision, formatted in user language.
Definition: Skin.php:832
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:1802
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
logoText($align= '')
Definition: Skin.php:859
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:766
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:1422
getLanguage()
Get the Language object.
$wgScript
The URL path to index.php.
afterContentHook()
This runs a hook to allow extensions placing their stuff after content and article metadata (e...
Definition: Skin.php:557
magic word the default is to use $key to get the and $key value or $key value text $key value html to format the value $key
Definition: hooks.txt:2325
The main skin class which provides methods and properties for all other skins.
Definition: Skin.php:34
subPageSubtitle()
Definition: Skin.php:654
getPoweredBy()
Gets the powered by MediaWiki icon.
Definition: Skin.php:808
getNewtalks()
Gets new talk page messages for the current user and returns an appropriate alert message (or an empt...
Definition: Skin.php:1329
getLanguages()
Generates array of language links for the current page.
$wgSitename
Name of the site.
outputPage(OutputPage $out=null)
initialize various variables and generate the template
static isAllowed($user)
Returns true if the user can use this upload module or else a string identifying the missing permissi...
Definition: UploadBase.php:122
$wgJsMimeType
Previously used as content type in HTML script tags.
static getTitleFor($name, $subpage=false, $fragment= '')
Get a localised Title object for a specified special page name.
Definition: SpecialPage.php:75
buildSidebar()
Build an array that represents the sidebar(s), the navigation bar among them.
Definition: Skin.php:1187
$wgMimeType
The default Content-Type header.
static instance()
Singleton.
Definition: Profiler.php:60
privacyLink()
Gets the link to the wiki's privacy policy page.
Definition: Skin.php:948
static rawElement($element, $attribs=[], $contents= '')
Returns an HTML element in a string.
Definition: Html.php:210
string $template
For QuickTemplate, the name of the subclass which will actually fill the template.
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:189
initPage(OutputPage $out)
Definition: Skin.php:144
editUrlOptions()
Return URL options for the 'edit page' link.
Definition: Skin.php:975
buildContentNavigationUrls()
a structured array of links usually used for the tabs in a skin
setupSkinUserCss(OutputPage $out)
Add specific styles for this skin.
$value
const NS_SPECIAL
Definition: Defines.php:58
wfMessageFallback()
This function accepts multiple message keys and returns a message instance for the first message whic...
getCopyrightIcon()
Definition: Skin.php:778
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:277
Represents a title within MediaWiki.
Definition: Title.php:34
when a variable name is used in a it is silently declared as a new local masking the global
Definition: design.txt:93
$wgArticlePath
Definition: img_auth.php:45
wfReportTime()
Returns a script tag that stores the amount of time it took MediaWiki to handle the request in millis...
getCategories()
Definition: Skin.php:522
isSyndicated()
Should we output feed links for this page?
static getRestrictionLevels($index, User $user=null)
Determine which restriction levels it makes sense to use in a namespace, optionally filtered by a use...
getTitle()
Get the Title object.
getSiteNotice()
Get the site notice.
Definition: Skin.php:1474
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
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. '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 '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. 'LanguageGetMagic':DEPRECATED!Use $magicWords in a file listed in $wgExtensionMessagesFiles instead.Use this to define synonyms of magic words depending of the language &$magicExtensions:associative array of magic words synonyms $lang:language code(string) '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 'LanguageGetSpecialPageAliases':DEPRECATED!Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead.Use to define aliases of special pages names depending of the language &$specialPageAliases:associative array of magic words synonyms $lang:language code(string) '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:Associative array mapping language codes to prefixed links of the form"language:title".&$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':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:1800
the value to return A Title object or null for latest to be modified or replaced by the hook handler or if authentication is not possible after cache objects are set for highlighting & $link
Definition: hooks.txt:2585
static factory($action, Page $page, IContextSource $context=null)
Get an appropriate Action subclass for the given action.
Definition: Action.php:95
getRequest()
Get the WebRequest object.
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:1802
canUseWikiPage()
Check whether a WikiPage object can be get with getWikiPage().
msg()
Get a Message object with context set Parameters are the same as wfMessage()
getCopyright($type= 'detect')
Definition: Skin.php:732
getHTML()
Get the body HTML.
$wgStylePath
The URL path of the skins directory.
printOrError($str)
Output the string, or print error message if it's an error object of the appropriate type...
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc & $personal_urls
Definition: hooks.txt:2342
static groupHasPermission($group, $role)
Check, if the given group has the given permission.
Definition: User.php:4552
useCombinedLoginLink()
Output a boolean indicating if buildPersonalUrls should output separate login and create account link...
Base class for template-based skins.
getRelevantTitle()
Return the "relevant" title.
Definition: Skin.php:270
$res
Definition: database.txt:21
getConfig()
Get the Config object.
disclaimerLink()
Gets the link to the wiki's general disclaimers page.
Definition: Skin.php:964
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 after processing 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 unsetoffset-wrap String Wrap the message in html(usually something like"&lt
getContext()
Get the base IContextSource object.
$params
wfDeprecated($function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
generateDebugHTML()
Generate debug data HTML for displaying at the bottom of the main content area.
Definition: Skin.php:583
wfBCP47($code)
Get the normalised IETF language tag See unit test for examples.
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:916
showEmailUser($id)
Definition: Skin.php:989
getRelevantUser()
Return the "relevant" user.
Definition: Skin.php:294
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:131
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:12
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
aboutLink()
Gets the link to the wiki's about page.
Definition: Skin.php:956
const NS_FILE
Definition: Defines.php:75
makeTalkUrlDetails($name, $urlaction= '')
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
Definition: distributors.txt:9
$wgDisableLangConversion
Whether to enable language variant conversion.
Special handling for file pages.
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:766
This class should be covered by a general architecture document which does not exist as of January 20...
Definition: OutputPage.php:42
const NS_MEDIAWIKI
Definition: Defines.php:77
static fetchLanguageName($code, $inLanguage=null, $include= 'all')
Definition: Language.php:886
static isEnabled()
Returns true if uploads are enabled.
Definition: UploadBase.php:103
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:2719
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
Definition: hooks.txt:246
isSpecialPage()
Returns true if this is a special page.
Definition: Title.php:1045
makeArticleUrlDetails($name, $urlaction= '')
printSource()
Text with the permalink to the source page, usually shown on the footer of a printed page...
Definition: Skin.php:608
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:35
tabAction($title, $message, $selected, $query= '', $checkEdit=false)
Builds an array with tab definition.
error also a ContextSource you ll probably need to make sure the header is varied on $request
Definition: hooks.txt:2422
$wgHideInterlanguageLinks
Hide interlanguage links from the sidebar.
buildPersonalUrls()
build array of urls for personal toolbar
static resolveAlias($alias)
Given a special page name with a possible subpage, return an array where the first element is the spe...
isRevisionCurrent()
Whether the revision displayed is the latest revision of the page.
Definition: Skin.php:246
$wgScriptPath
The path we should point to.
wfArrayToCgi($array1, $array2=null, $prefix= '')
This function takes one or two arrays as input, and returns a CGI-style string, e.g.
string $skinname
Name of our skin, it probably needs to be all lower case.
getNameSpaceKey()
Generate strings used for xml 'id' names.
wrapHTML($title, $html)
Wrap the body text with language information and identifiable element.
buildContentActionUrls($content_navigation)
an array of edit links by default used for the tabs
prepareQuickTemplate()
initialize various variables and generate the template
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:56
$wgLogo
The URL path of the wiki logo.
Special page to allow managing user group membership.
getUndeleteLink()
Definition: Skin.php:626
$wgServer
URL of the server.
$wgUseCombinedLoginLink
Login / create account link behavior when it's possible for anonymous users to create an account...
getRevisionId()
Get the current revision ID.
Definition: Skin.php:237
$wgUploadNavigationUrl
Point the upload navigation link to an external URL Useful if you want to use a shared repository by ...
escapeSearchLink()
Definition: Skin.php:724
getWikiPage()
Get the WikiPage object.
static getSubject($index)
Get the subject namespace index for a given namespace Special namespaces (NS_MEDIA, NS_SPECIAL) are always the subject.
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...
getUser()
Get the User object.
setContext($context)
Sets the context this SpecialPage is executed in.
bottomScripts()
This gets called shortly before the "" tag.
Definition: Skin.php:592
addModuleStyles($modules)
Add only CSS of one or more modules recognized by ResourceLoader.
Definition: OutputPage.php:618
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
Definition: hooks.txt:2342
formatLanguageName($name)
Format language name for use in sidebar interlanguage links list.
buildNavUrls()
build array of common navigation links
getOutput()
Get the OutputPage object.
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:314
getPersonalToolsList()
Get the HTML for the p-personal list.