MediaWiki REL1_30
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}
New base template for a skin's template extended from QuickTemplate this class features helper method...
static onBaseTemplateToolbox(BaseTemplate $baseTemplate, array &$toolbox)
static shouldAddLink(Title $title)
Checks, if the "cite this page" link should be added.
static onSkinTemplateBuildNavUrlsNav_urlsAfterPermalink(&$skintemplate, &$nav_urls, &$oldid, &$revid)
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Represents a title within MediaWiki.
Definition Title.php:39