mediawiki-extensions-CiteTh.../CiteThisPage.hooks.php
Kunal Mehta d4ebe024e8 Move hooks to static class
Change-Id: Idad4cda047ae64fc955775f0de5f538e6d9aff15
2015-01-26 21:34:04 -08:00

46 lines
1.2 KiB
PHP
Raw Permalink 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'] = array(
'args' => array( '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',
array( '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;
}
}