jenkins-bot has submitted this change and it was merged.
Change subject: Simplified banner rendering and fixed empty partner URL
......................................................................
Simplified banner rendering and fixed empty partner URL
* Greatly simplified the code to generate banner
* Properly handle missing partner URL
* Removed impossible "display:None" style
Change-Id: Icae36b7126e9e08f91785947d0cab7e6ad7c2c00
---
M includes/PageRenderingHooks.php
M includes/ZeroConfigContent.php
2 files changed, 35 insertions(+), 40 deletions(-)
Approvals:
Dr0ptp4kt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/PageRenderingHooks.php b/includes/PageRenderingHooks.php
index 2f900d0..77324c3 100644
--- a/includes/PageRenderingHooks.php
+++ b/includes/PageRenderingHooks.php
@@ -464,54 +464,48 @@
* @return string
*/
public function renderBanner( $config, $lang = null, $sitename = null,
$wap = false ) {
- $bannerText = self::getBannerText( $config, $lang, $sitename );
- if ( $bannerText !== false ) {
- $billingURL = $config['bannerUrl'];
- $billingURL = $this->makeRedirect( $billingURL );
- $carrierLink = Html::rawElement( 'a', array( 'href' =>
$billingURL ), $bannerText );
- if ( !$config['bannerWarning'] ) {
- preg_match( '/<a href="(.+)">/', $carrierLink,
$match );
- if ( isset( $match[1] ) ) {
- $originalHref = $match[1];
- $info = parse_url( $originalHref );
- if ( isset( $info['query'] ) ) {
- $query = $info['query'];
- parse_str( html_entity_decode(
$query ), $queryArray );
- if ( isset(
$queryArray['returnto'] ) ) {
- $carrierLink =
str_replace( $originalHref, $queryArray['returnto'], $carrierLink );
- }
- }
- }
+ $banner = self::getBannerText( $config, $lang, $sitename );
+ if ( !$banner ) {
+ return '';
+ }
+ if ( !$wap ) {
+ $background = $config['background'];
+ $foreground = $config['foreground'];
+ }
+ $billingURL = $config['bannerUrl'];
+ if ( $billingURL ) {
+ if ( $config['bannerWarning'] ) {
+ $billingURL = $this->makeRedirect( $billingURL
);
}
- } else {
- $carrierLink = '';
+ $attr = array( 'href' => $billingURL );
+ if ( !$wap ) {
+ $attr['style'] = "color:$foreground;";
+ }
+ $banner = Html::rawElement( 'a', $attr, $banner );
}
if ( $wap ) {
- $banner = $carrierLink !== '' ? Html::rawElement( 'p',
null, $carrierLink ) : '';
+ $banner = $banner !== '' ? Html::rawElement( 'p', null,
$banner ) : '';
} else {
- $background = $config['background'];
- $foreground = $config['foreground'];
- $carrierLink = str_replace(
- '<a href="',
- "<a style=\"color:$foreground;\" href=\"",
- $carrierLink );
-
- $bannerText = Html::rawElement( 'span',
- array(
- 'class' => 'mw-mf-message',
- 'id' => 'zero-rated-banner-text',
- 'style' => $config['fontSize'] !== '' ?
' font-size:' . $config['fontSize'] . ';' : ''
- ),
- $carrierLink );
+ $attr = array(
+ 'class' => 'mw-mf-message',
+ 'id' => 'zero-rated-banner-text',
+ );
+ $style = $config['fontSize'] !== '' ? 'font-size:' .
$config['fontSize'] . ';' : '';
+ if ( !$billingURL ) {
+ $style .= "color:$foreground;";
+ }
+ if ( $style !== '' ) {
+ $attr['style'] = $style;
+ }
+ $banner = Html::rawElement( 'span', $attr, $banner );
$dismissTitle = wfMessage(
'zero-rated-mobile-access-dismiss-notification' )->escaped();
- $displayNone = $carrierLink === '' ? 'display:none;' :
'';
$banner = <<<END
-<div id="zero-rated-banner" class="mw-mf-banner"
style="background:$background;color:$foreground;$displayNone">
+<div id="zero-rated-banner" class="mw-mf-banner"
style="background:$background;color:$foreground;">
<button class="notify-close" style="background:$background;"
title="$dismissTitle">
<span class="notify-close-x"
style="background:$background;border-color:$foreground;color:$foreground;">x</span>
</button>
-$bannerText
+$banner
</div>
END;
}
diff --git a/includes/ZeroConfigContent.php b/includes/ZeroConfigContent.php
index ada000b..3e292e3 100644
--- a/includes/ZeroConfigContent.php
+++ b/includes/ZeroConfigContent.php
@@ -206,8 +206,9 @@
// Get localized "wikipedia" sitename. If null, will
use default {{SITENAME}}
$sitename = $wgConf->get( 'wgSitename', str_replace(
'-', '_', $langCode ) . 'wiki' );
- $bannerInTheory = Xml::tags( 'td', null,
- $state->renderBanner( $conf, $lang, $sitename )
);
+ $bannerInTheory = $state->renderBanner( $conf, $lang,
$sitename );
+ $bannerInTheory = Xml::tags( 'td', null,
$bannerInTheory ?: '???' );
+
$iframe = Xml::tags( 'iframe', array(
'src' =>
"//{$langCode}.{$bannerSubdomain}.wikipedia.org/wiki/MediaWiki:terms-use?X-CS={$configXcs}",
'frameborder' => '0',
--
To view, visit https://gerrit.wikimedia.org/r/90566
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Icae36b7126e9e08f91785947d0cab7e6ad7c2c00
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/ZeroRatedMobileAccess
Gerrit-Branch: master
Gerrit-Owner: Yurik <[email protected]>
Gerrit-Reviewer: Dfoy <[email protected]>
Gerrit-Reviewer: Dr0ptp4kt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits