diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:30:02 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:30:02 -0400 |
commit | 1de335ad3f395ca6861085393ba366a9e3fb4a0d (patch) | |
tree | f1fdd326034e05177596851be6a7127615d81498 /extensions/CiteThisPage/CiteThisPage.hooks.php | |
parent | 9c75fa8ff6d4d38ef552c00fef5969fb154765e8 (diff) | |
parent | f6d65e533c62f6deb21342d4901ece24497b433e (diff) |
Merge commit 'f6d65'
# Conflicts:
# skins/ArchLinux/ArchLinux.php
Diffstat (limited to 'extensions/CiteThisPage/CiteThisPage.hooks.php')
-rw-r--r-- | extensions/CiteThisPage/CiteThisPage.hooks.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/extensions/CiteThisPage/CiteThisPage.hooks.php b/extensions/CiteThisPage/CiteThisPage.hooks.php new file mode 100644 index 00000000..e238b4ff --- /dev/null +++ b/extensions/CiteThisPage/CiteThisPage.hooks.php @@ -0,0 +1,45 @@ +<?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'] = 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; + } +} |