mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CiteThisPage
synced 2024-11-15 11:45:23 +00:00
a7fc55d07d
Also added "composer fix" command. Change-Id: Ib4160f107ae6ac2bea84ee3e1ccaf6de47372c2b
49 lines
1.2 KiB
PHP
49 lines
1.2 KiB
PHP
<?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 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();
|
||
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;
|
||
}
|
||
}
|