Legoktm has uploaded a new change for review.
https://gerrit.wikimedia.org/r/186930
Change subject: Move hooks to static class
......................................................................
Move hooks to static class
Change-Id: Idad4cda047ae64fc955775f0de5f538e6d9aff15
---
A CiteThisPage.hooks.php
M CiteThisPage.php
2 files changed, 48 insertions(+), 46 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CiteThisPage
refs/changes/30/186930/1
diff --git a/CiteThisPage.hooks.php b/CiteThisPage.hooks.php
new file mode 100644
index 0000000..e238b4f
--- /dev/null
+++ b/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;
+ }
+}
diff --git a/CiteThisPage.php b/CiteThisPage.php
index e6393da..70aefde 100644
--- a/CiteThisPage.php
+++ b/CiteThisPage.php
@@ -26,12 +26,13 @@
$wgMessagesDirs['CiteThisPage'] = __DIR__ . '/i18n';
$wgExtensionMessagesFiles['CiteThisPageAliases'] = __DIR__ .
'/CiteThisPage.alias.php';
-$wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink'][] =
'efCiteThisPageNav';
-$wgHooks['SkinTemplateToolboxEnd'][] = 'efSpecialCiteThisPageToolbox';
+$wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink'][] =
'CiteThisPageHooks::onSkinTemplateBuildNavUrlsNav_urlsAfterPermalink';
+$wgHooks['SkinTemplateToolboxEnd'][] =
'CiteThisPageHooks::onSkinTemplateToolboxEnd';
$wgSpecialPages['CiteThisPage'] = 'SpecialCiteThisPage';
$wgSpecialPageGroups['CiteThisPage'] = 'pagetools';
$wgAutoloadClasses['SpecialCiteThisPage'] = __DIR__ .
'/SpecialCiteThisPage.php';
+$wgAutoloadClasses['CiteThisPageHooks'] = __DIR__ . '/CiteThisPage.hooks.php';
// Resources
$citeThisPageResourceTemplate = array(
@@ -42,47 +43,3 @@
$wgResourceModules['ext.citeThisPage'] = $citeThisPageResourceTemplate + array(
'styles' => 'ext.citeThisPage.css',
);
-
-/**
- * @param $skintemplate SkinTemplate
- * @param $nav_urls
- * @param $oldid
- * @param $revid
- * @return bool
- */
-function efCiteThisPageNav( &$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;
-}
-
-/**
- * Add the cite link to the toolbar
- *
- * @param $skin Skin
- *
- * @return bool
- */
-function efSpecialCiteThisPageToolbox( &$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;
-}
--
To view, visit https://gerrit.wikimedia.org/r/186930
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idad4cda047ae64fc955775f0de5f538e6d9aff15
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CiteThisPage
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits