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