Yurik has uploaded a new change for review.
https://gerrit.wikimedia.org/r/92789
Change subject: Hide W0 banner on File pages when carrier doesn't zero-rate
images.
......................................................................
Hide W0 banner on File pages when carrier doesn't zero-rate images.
Change-Id: I2edc337f377f96261a2ac56d9ea45871228d6fb3
---
M includes/PageRenderingHooks.php
M includes/ZeroSpecialPage.php
2 files changed, 13 insertions(+), 5 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ZeroRatedMobileAccess
refs/changes/89/92789/1
diff --git a/includes/PageRenderingHooks.php b/includes/PageRenderingHooks.php
index 1a8e326..160c232 100644
--- a/includes/PageRenderingHooks.php
+++ b/includes/PageRenderingHooks.php
@@ -442,6 +442,9 @@
$special = SpecialPage::getTitleFor(
'ZeroRatedMobileAccess' );
$query = 'renderesibanner=1';
+ if ( $this->title->inNamespace( NS_FILE ) ) {
+ $query .= '&img=1';
+ }
if ( $wap ) {
$query .= '&wap=1';
}
@@ -474,7 +477,7 @@
return '';
}
}
- return $this->renderBanner( $config, null, null, $wap );
+ return $this->renderBanner( $config, null, null, $wap,
$this->title->inNamespace( NS_FILE ) );
}
return '';
}
@@ -484,9 +487,13 @@
* @param Language $lang
* @param string $sitename
* @param bool $wap
+ * @param bool $isImage
* @return string
*/
- public function renderBanner( $config, $lang = null, $sitename = null,
$wap = false ) {
+ public function renderBanner( $config, $lang = null, $sitename = null,
$wap = false, $isImage = false ) {
+ if ( $isImage && !$config['showImages'] ) {
+ return '';
+ }
$banner = self::getBannerText( $config, $lang, $sitename );
if ( !$banner ) {
return '';
diff --git a/includes/ZeroSpecialPage.php b/includes/ZeroSpecialPage.php
index 5420891..cb56029 100644
--- a/includes/ZeroSpecialPage.php
+++ b/includes/ZeroSpecialPage.php
@@ -44,7 +44,7 @@
$this->state = PageRenderingHooks::getState(
$this->getContext() );
$req = $this->getRequest();
if ( $req->getCheck( 'renderesibanner' ) ) {
- $this->showBanner( $this->state->getConfig(),
$req->getCheck( 'wap' ) );
+ $this->showBanner( $this->state->getConfig(),
$req->getCheck( 'wap' ), $req->getCheck( 'img' ) );
return;
}
@@ -77,8 +77,9 @@
* Render raw HTML snippet for ESI inclusion
* @param $config
* @param $wap
+ * @param $isImage
*/
- private function showBanner( $config, $wap ) {
+ private function showBanner( $config, $wap, $isImage ) {
$out = $this->getOutput();
$out->disable();
@@ -97,7 +98,7 @@
$response->header( 'Cache-Control: public, s-maxage=' .
$smaxage . ', max-age=' . $maxage );
- $banner = $this->state->renderBanner( $config, null, null, $wap
);
+ $banner = $this->state->renderBanner( $config, null, null,
$wap, $isImage );
echo $banner;
}
--
To view, visit https://gerrit.wikimedia.org/r/92789
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2edc337f377f96261a2ac56d9ea45871228d6fb3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ZeroRatedMobileAccess
Gerrit-Branch: master
Gerrit-Owner: Yurik <[email protected]>
Gerrit-Reviewer: Dr0ptp4kt <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits