MediaWiki  1.34.0
CiteThisPageHooks.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: CiteThisPageHooks.php:40
CiteThisPageHooks\onBaseTemplateToolbox
static onBaseTemplateToolbox(BaseTemplate $baseTemplate, array &$toolbox)
Definition: CiteThisPageHooks.php:55
CiteThisPageHooks\onSkinTemplateBuildNavUrlsNav_urlsAfterPermalink
static onSkinTemplateBuildNavUrlsNav_urlsAfterPermalink(&$skintemplate, &$nav_urls, &$oldid, &$revid)
Definition: CiteThisPageHooks.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:83
$title
$title
Definition: testCompression.php:34
Title
Represents a title within MediaWiki.
Definition: Title.php:42
CiteThisPageHooks
Definition: CiteThisPageHooks.php:3
BaseTemplate
New base template for a skin's template extended from QuickTemplate this class features helper method...
Definition: BaseTemplate.php:29