Dr0ptp4kt has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/90465


Change subject: Add interstitial to all appropriate footer links. Fixes bug 
55748.
......................................................................

Add interstitial to all appropriate footer links. Fixes bug 55748.

* Currently, the first qualifying link on a footer line gets rewritten.
* This patch rewrites every qualifying link per footer line.

Change-Id: I39d18a60e09f1ffd0e0e35e5284da4c421ca2f11
---
M ZeroRatedMobileAccess.i18n.php
M includes/PageRenderingHooks.php
2 files changed, 27 insertions(+), 14 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ZeroRatedMobileAccess 
refs/changes/65/90465/1

diff --git a/ZeroRatedMobileAccess.i18n.php b/ZeroRatedMobileAccess.i18n.php
index d48e17e..a983783 100644
--- a/ZeroRatedMobileAccess.i18n.php
+++ b/ZeroRatedMobileAccess.i18n.php
@@ -286,6 +286,14 @@
        'zero-rated-mobile-access-banner-text-data-charges-no' => 'нѣтъ',
 );
 
+/** Welsh (Cymraeg)
+ * @author Lloffiwr
+ */
+$messages['cy'] = array(
+       'zero-rated-mobile-access-search' => 'Chwilier',
+       'zero-rated-mobile-access-language-selection' => 'Pob iaith',
+);
+
 /** German (Deutsch)
  * @author Dfoy
  * @author Kghbln
diff --git a/includes/PageRenderingHooks.php b/includes/PageRenderingHooks.php
index e400928..44c7f7c 100644
--- a/includes/PageRenderingHooks.php
+++ b/includes/PageRenderingHooks.php
@@ -880,20 +880,25 @@
         */
        private function addWarning( BaseTemplate $template, $templateValName ) 
{
                $link = $template->get( $templateValName );
-               if ( preg_match( '/href=([\'"])(.*?)\1/', $link, $match ) ) {
-                       $href = $match[2];
-                       $ch0 = substr( $href, 0, 1 );
-                       $ch1 = substr( $href, 1, 1 );
-                       // Local links start with either '#...', '?...' or 
'/...', but not '//...'
-                       if ( $ch0 !== '#' && $ch0 !== '?' && ( $ch0 !== '/' || 
$ch1 === '/' ) ) {
-                               $link = str_replace(
-                                       $href,
-                                       $this->makeRedirect( $href ),
-                                       $link
-                               );
-                               $template->set( $templateValName, $link );
-                       }
-               }
+               $self = $this;
+               $link = preg_replace_callback( '/href=([\'"])(.*?)\1/',
+                       function ( $matches ) use ( $self ) {
+                               $quoteChar = $matches[1];
+                               $a = "href=" . $quoteChar;
+                               $b = $quoteChar;
+                               $href = $matches[2];
+                               $ch0 = substr( $href, 0, 1 );
+                               $ch1 = substr( $href, 1, 1 );
+                               // Local links start with either '#...', '?...' 
or '/...', but not '//...'
+                               if ( $ch0 !== '#' && $ch0 !== '?' && ( $ch0 !== 
'/' || $ch1 === '/' ) ) {
+                                       return $a . $self->makeRedirect( $href 
) . $b ;
+                               } else {
+                                       return $matches[0];
+                               }
+                       },
+                       $link
+               );
+               $template->set( $templateValName, $link );
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/90465
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I39d18a60e09f1ffd0e0e35e5284da4c421ca2f11
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ZeroRatedMobileAccess
Gerrit-Branch: master
Gerrit-Owner: Dr0ptp4kt <[email protected]>
Gerrit-Reviewer: L10n-bot <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to