Florianschmidtwelzow has uploaded a new change for review.
https://gerrit.wikimedia.org/r/319911
Change subject: Add a possibility to add a "cite this page" link without adding
the NS as a content namespace
......................................................................
Add a possibility to add a "cite this page" link without adding the NS as a
content namespace
Sometimes it's required or at least a good option to have a cite this page
link on pages, that aren't content pages (like the project namespace).
This change adds a new configuration option for this extensions to allow to
add namespaces as namespaces that should have a cite this page link, even if
they're not a content page.
Bug: T150053
Change-Id: I2523bd9124ab8998a7c327d8045d7585d4dcf8b4
---
M CiteThisPage.hooks.php
M extension.json
2 files changed, 19 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CiteThisPage
refs/changes/11/319911/1
diff --git a/CiteThisPage.hooks.php b/CiteThisPage.hooks.php
index 502045b..e95069f 100644
--- a/CiteThisPage.hooks.php
+++ b/CiteThisPage.hooks.php
@@ -15,7 +15,7 @@
// 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
) ) {
+ if ( self::shouldCiteLinkAdded( $title ) && $revid !== 0 &&
!empty( $revid ) ) {
$nav_urls['citethispage'] = [
'text' => $skintemplate->msg(
'citethispage-link' )->text(),
'href' => SpecialPage::getTitleFor(
'CiteThisPage' )
@@ -30,6 +30,21 @@
}
/**
+ * Checks, if the "cite this page" link should be added. By default the
link is added to all
+ * pages in the main namespace, and additionally to pages, which are in
one of the namespaces
+ * named in $wgCiteThisPageAddiotionalNamespaces.
+ *
+ * @param Title $title
+ * @return bool
+ */
+ private static function shouldCiteLinkAdded( Title $title ) {
+ global $wgCiteThisPageAddiotionalNamespaces;
+
+ return $title->isContentPage() ||
+ in_array( $title->getNamespace(),
$wgCiteThisPageAddiotionalNamespaces );
+ }
+
+ /**
* @param BaseTemplate $baseTemplate
* @param array $toolbox
* @return bool
diff --git a/extension.json b/extension.json
index e02d812..c3792dc 100644
--- a/extension.json
+++ b/extension.json
@@ -39,5 +39,8 @@
"SpecialCiteThisPage": "SpecialCiteThisPage.php",
"CiteThisPageHooks": "CiteThisPage.hooks.php"
},
+ "config": {
+ "CiteThisPageAddiotionalNamespaces": {}
+ },
"manifest_version": 1
}
--
To view, visit https://gerrit.wikimedia.org/r/319911
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2523bd9124ab8998a7c327d8045d7585d4dcf8b4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CiteThisPage
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits