Phuedx has uploaded a new change for review.
https://gerrit.wikimedia.org/r/253920
Change subject: Configure footer and sidebar placements
......................................................................
Configure footer and sidebar placements
Changes:
* Rename $wgRelatedArticlesShowReadMore to $wgRelatedArticlesShowInFooter
* Add $wgRelatedArticlesShowInSidebar, which is truthy by default, and
short circuit the SkinBuildSidebar and SkinTemplateToolboxEnd hook
handlers if it is falsy
Change-Id: Idf04bf3221ba44d7b898160764fbd6ba83561abb
---
M extension.json
M includes/FooterHooks.php
M includes/SidebarHooks.php
3 files changed, 29 insertions(+), 6 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/RelatedArticles
refs/changes/20/253920/1
diff --git a/extension.json b/extension.json
index c9e0634..6f39367 100644
--- a/extension.json
+++ b/extension.json
@@ -94,7 +94,8 @@
}
},
"config": {
- "RelatedArticlesShowReadMore": false,
+ "RelatedArticlesShowInSidebar": true,
+ "RelatedArticlesShowInFooter": false,
"RelatedArticlesUseCirrusSearch": false,
"RelatedArticlesOnlyUseCirrusSearch": false,
"RelatedArticlesLoggingSamplingRate": 0.01
diff --git a/includes/FooterHooks.php b/includes/FooterHooks.php
index c6dad41..9906669 100644
--- a/includes/FooterHooks.php
+++ b/includes/FooterHooks.php
@@ -38,7 +38,7 @@
* to the output when:
*
* <ol>
- * <li><code>$wgRelatedArticlesShowReadMore</code> is truthy</li>
+ * <li><code>$wgRelatedArticlesShowInFooter</code> is truthy</li>
* <li>
* The output is being rendered with the
* <code>SkinMinervaBeta<code> skin, i.e. the user is currently
@@ -53,7 +53,7 @@
*/
public static function onBeforePageDisplay( OutputPage $out, Skin $skin
) {
$config = ConfigFactory::getDefaultInstance()->makeConfig(
'RelatedArticles' );
- $showReadMore = $config->get( 'RelatedArticlesShowReadMore' );
+ $showReadMore = $config->get( 'RelatedArticlesShowInFooter' );
$title = $out->getContext()->getTitle();
diff --git a/includes/SidebarHooks.php b/includes/SidebarHooks.php
index 100fd67..e54a234 100644
--- a/includes/SidebarHooks.php
+++ b/includes/SidebarHooks.php
@@ -7,19 +7,25 @@
use Html;
use BaseTemplate;
use SkinTemplate;
+use ConfigFactory;
class SidebarHooks {
/**
* Handler for the <code>SkinBuildSidebar</code> hook.
*
- * Retrieves the list of related pages and adds its HTML representation
to the sidebar.
+ * If <code>$wgRelatedArticlesShowInSidebar</code> is truthy, then the
list of related pages
+ * is retrieved and its HTML representation added to the list of
sidebar HTML elements.
*
* @param Skin $skin
* @param array $bar
* @return boolean Always <code>true</code>
*/
public static function onSkinBuildSidebar( Skin $skin, &$bar ) {
+ if ( !self::canShowInSidebar() ) {
+ return true;
+ }
+
$out = $skin->getOutput();
$relatedPages = $out->getProperty( 'RelatedArticles' );
@@ -52,13 +58,18 @@
/**
* Handler for the <code>SkinTemplateToolboxEnd</code> hook.
*
- * Retrieves the list of related pages from the template and
<code>echo</code>s its HTML
- * representation to the sidebar.
+ * If <code>$wgRelatedArticlesShowInSidebar</code> is truthy, then the
list of related pages
+ * is retrieved from the template and its HTML representation is
<code>echo</code>d to the
+ * sidebar.
*
* @param SkinTemplate $skinTpl
* @return boolean Always <code>true</code>
*/
public static function onSkinTemplateToolboxEnd( BaseTemplate &$skinTpl
) {
+ if ( !self::canShowInSidebar() ) {
+ return true;
+ }
+
$relatedPages = $skinTpl->getSkin()->getOutput()->getProperty(
'RelatedArticles' );
if ( !$relatedPages ) {
@@ -137,4 +148,15 @@
return $relatedPagesUrls;
}
+
+ /**
+ * Gets whether or not the list of related pages can be shown in the
sidebar.
+ *
+ * @return boolean
+ */
+ private static function canShowInSidebar() {
+ $config = ConfigFactory::getDefaultInstance()->makeConfig(
'RelatedArticles' );
+
+ return (boolean)$config->get( 'RelatedArticlesShowInSidebar' );
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/253920
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idf04bf3221ba44d7b898160764fbd6ba83561abb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/RelatedArticles
Gerrit-Branch: dev
Gerrit-Owner: Phuedx <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits