MediaWiki  1.29.1
CiteThisPage.hooks.php
Go to the documentation of this file.
1 <?php
2 
4 
13  &$skintemplate, &$nav_urls, &$oldid, &$revid
14  ) {
15  // check whether we’re in the right namespace, the $revid has the correct type and is not empty
16  // (which would mean that the current page doesn’t exist)
17  $title = $skintemplate->getTitle();
18  if ( self::shouldAddLink( $title ) && $revid !== 0 && !empty( $revid ) ) {
19  $nav_urls['citethispage'] = [
20  'text' => $skintemplate->msg( 'citethispage-link' )->text(),
21  'href' => SpecialPage::getTitleFor( 'CiteThisPage' )
22  ->getLocalURL( [ 'page' => $title->getPrefixedDBkey(), 'id' => $revid ] ),
23  'id' => 't-cite',
24  # Used message keys: 'tooltip-citethispage', 'accesskey-citethispage'
25  'single-id' => 'citethispage',
26  ];
27  }
28 
29  return true;
30  }
31 
40  private static function shouldAddLink( Title $title ) {
41  global $wgCiteThisPageAdditionalNamespaces;
42 
43  return $title->isContentPage() ||
44  (
45  isset( $wgCiteThisPageAdditionalNamespaces[$title->getNamespace()] ) &&
46  $wgCiteThisPageAdditionalNamespaces[$title->getNamespace()]
47  );
48  }
49 
55  public static function onBaseTemplateToolbox( BaseTemplate $baseTemplate, array &$toolbox ) {
56  if ( isset( $baseTemplate->data['nav_urls']['citethispage'] ) ) {
57  $toolbox['citethispage'] = $baseTemplate->data['nav_urls']['citethispage'];
58  }
59 
60  return true;
61  }
62 }
CiteThisPageHooks::shouldAddLink
static shouldAddLink(Title $title)
Checks, if the "cite this page" link should be added.
Definition: CiteThisPage.hooks.php:40
CiteThisPageHooks::onBaseTemplateToolbox
static onBaseTemplateToolbox(BaseTemplate $baseTemplate, array &$toolbox)
Definition: CiteThisPage.hooks.php:55
CiteThisPageHooks::onSkinTemplateBuildNavUrlsNav_urlsAfterPermalink
static onSkinTemplateBuildNavUrlsNav_urlsAfterPermalink(&$skintemplate, &$nav_urls, &$oldid, &$revid)
Definition: CiteThisPage.hooks.php:12
SpecialPage\getTitleFor
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Definition: SpecialPage.php:82
php
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
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:934
message
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a message
Definition: hooks.txt:2114
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
Title
Represents a title within MediaWiki.
Definition: Title.php:39
CiteThisPageHooks
Definition: CiteThisPage.hooks.php:3
BaseTemplate
New base template for a skin's template extended from QuickTemplate this class features helper method...
Definition: BaseTemplate.php:26
array
the array() calling protocol came about after MediaWiki 1.4rc1.