2015-01-27 05:34:04 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
class CiteThisPageHooks {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param SkinTemplate $skintemplate
|
|
|
|
|
* @param $nav_urls
|
|
|
|
|
* @param $oldid
|
|
|
|
|
* @param $revid
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
2016-01-16 12:41:27 +00:00
|
|
|
|
public static function onSkinTemplateBuildNavUrlsNav_urlsAfterPermalink(
|
|
|
|
|
&$skintemplate, &$nav_urls, &$oldid, &$revid
|
|
|
|
|
) {
|
2015-01-27 05:34:04 +00:00
|
|
|
|
// check whether we’re in the right namespace, the $revid has the correct type and is not empty
|
|
|
|
|
// (which would mean that the current page doesn’t exist)
|
|
|
|
|
$title = $skintemplate->getTitle();
|
2016-01-16 12:41:27 +00:00
|
|
|
|
if ( $title->isContentPage() && $revid !== 0 && !empty( $revid ) ) {
|
2016-07-13 19:44:33 +00:00
|
|
|
|
$nav_urls['citethispage'] = [
|
|
|
|
|
'text' => $skintemplate->msg( 'citethispage-link' )->text(),
|
|
|
|
|
'href' => SpecialPage::getTitleFor( 'CiteThisPage' )
|
|
|
|
|
->getLocalURL( [ 'page' => $title->getPrefixedDBkey(), 'id' => $revid ] ),
|
|
|
|
|
'id' => 't-cite',
|
|
|
|
|
# Used message keys: 'tooltip-citethispage', 'accesskey-citethispage'
|
|
|
|
|
'single-id' => 'citethispage',
|
2016-05-09 23:36:56 +00:00
|
|
|
|
];
|
2016-01-16 12:41:27 +00:00
|
|
|
|
}
|
2015-01-27 05:34:04 +00:00
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2016-07-13 19:44:33 +00:00
|
|
|
|
* @param BaseTemplate $baseTemplate
|
|
|
|
|
* @param array $toolbox
|
2015-01-27 05:34:04 +00:00
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
2016-07-13 19:44:33 +00:00
|
|
|
|
public static function onBaseTemplateToolbox( BaseTemplate $baseTemplate, array &$toolbox ) {
|
|
|
|
|
if ( isset( $baseTemplate->data['nav_urls']['citethispage'] ) ) {
|
|
|
|
|
$toolbox['citethispage'] = $baseTemplate->data['nav_urls']['citethispage'];
|
2015-01-27 05:34:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|