mediawiki-extensions-CiteTh.../CiteThisPage.hooks.php
Kunal Mehta a7fc55d07d build: Updating mediawiki/mediawiki-codesniffer to 0.7.1
Also added "composer fix" command.

Change-Id: Ib4160f107ae6ac2bea84ee3e1ccaf6de47372c2b
2016-05-09 16:36:56 -07:00

49 lines
1.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
class CiteThisPageHooks {
/**
* @param SkinTemplate $skintemplate
* @param $nav_urls
* @param $oldid
* @param $revid
* @return bool
*/
public static function onSkinTemplateBuildNavUrlsNav_urlsAfterPermalink(
&$skintemplate, &$nav_urls, &$oldid, &$revid
) {
// check whether were in the right namespace, the $revid has the correct type and is not empty
// (which would mean that the current page doesnt exist)
$title = $skintemplate->getTitle();
if ( $title->isContentPage() && $revid !== 0 && !empty( $revid ) ) {
$nav_urls['citeThisPage'] = [
'args' => [ 'page' => $title->getPrefixedDBkey(), 'id' => $revid ]
];
}
return true;
}
/**
* @param Skin $skin
* @return bool
*/
public static function onSkinTemplateToolboxEnd( &$skin ) {
if ( isset( $skin->data['nav_urls']['citeThisPage'] ) ) {
echo Html::rawElement(
'li',
[ 'id' => 't-cite' ],
Linker::link(
SpecialPage::getTitleFor( 'CiteThisPage' ),
wfMessage( 'citethispage-link' )->escaped(),
# Used message keys: 'tooltip-citethispage', 'accesskey-citethispage'
Linker::tooltipAndAccessKeyAttribs( 'citethispage' ),
$skin->data['nav_urls']['citeThisPage']['args']
)
);
}
return true;
}
}