Index: trunk/extensions/ZeroRatedMobileAccess/ZeroRatedMobileAccess.body.php |
— | — | @@ -277,11 +277,9 @@ |
278 | 278 | foreach ( $zeroRatedLinks as $zeroRatedLink ) { |
279 | 279 | $zeroRatedLinkHref = $zeroRatedLink->getAttribute( 'href' ); |
280 | 280 | if ( $zeroRatedLinkHref && substr( $zeroRatedLinkHref, 0, 1 ) !== '#' ) { |
281 | | - $zeroPartnerUrl = $this->appendQueryString( $zeroRatedLinkHref, |
282 | | - array( array( 'name' => 'zeropartner', |
283 | | - 'value' => ( isset( self::$carrier['partnerId'] ) ) ? self::$carrier['partnerId'] : 0 ), |
284 | | - array('name' => 'renderZeroRatedBanner', |
285 | | - 'value' => 'true') ) ); |
| 281 | + $partnerId = isset( self::$carrier['partnerId'] ) ? self::$carrier['partnerId'] : 0; |
| 282 | + $zeroPartnerUrl = wfAppendQuery( $zeroRatedLinkHref, |
| 283 | + array( 'zeropartner' => $partnerId, 'renderZeroRatedBanner' => 'true' ) ); |
286 | 284 | if ( $zeroPartnerUrl ) { |
287 | 285 | $zeroRatedLink->setAttribute( 'href', $zeroPartnerUrl ); |
288 | 286 | } |
— | — | @@ -292,11 +290,9 @@ |
293 | 291 | foreach ( $zeroRatedExternalLinks as $zeroRatedExternalLink ) { |
294 | 292 | $zeroRatedExternalLinkHref = $zeroRatedExternalLink->getAttribute( 'href' ); |
295 | 293 | if ( $zeroRatedExternalLinkHref && substr( $zeroRatedExternalLinkHref, 0, 1 ) !== '#' ) { |
296 | | - $zeroPartnerUrl = $this->appendQueryString( $zeroRatedLinkHref, |
297 | | - array( array( 'name' => 'zeropartner', |
298 | | - 'value' => ( isset( self::$carrier['partnerId'] ) ) ? self::$carrier['partnerId'] : 0 ), |
299 | | - array('name' => 'renderZeroRatedBanner', |
300 | | - 'value' => 'true') ) ); |
| 294 | + $partnerId = isset( self::$carrier['partnerId'] ) ? self::$carrier['partnerId'] : 0; |
| 295 | + $zeroPartnerUrl = wfAppendQuery( $zeroRatedLinkHref, |
| 296 | + array( 'zeropartner' => $partnerId, 'renderZeroRatedBanner' => 'true' ) ); |
301 | 297 | if ( $zeroPartnerUrl ) { |
302 | 298 | $zeroRatedExternalLink->setAttribute( 'href', '?renderZeroRatedRedirect=true&returnto=' . urlencode($zeroRatedExternalLinkHref) ); |
303 | 299 | } |
— | — | @@ -309,56 +305,6 @@ |
310 | 306 | } |
311 | 307 | |
312 | 308 | /** |
313 | | - * Returns the url with querystring parameters appended |
314 | | - * |
315 | | - * @param String $url: valid url to append querystring |
316 | | - * @param Array $queryStringParameters: array of parameters to add to querystring |
317 | | - * @return String |
318 | | - */ |
319 | | - private function appendQueryString( $url, $queryStringParameters ) { |
320 | | - wfProfileIn( __METHOD__ ); |
321 | | - $parsedUrl = parse_url( $url ); |
322 | | - if ( isset( $parsedUrl['query'] ) ) { |
323 | | - parse_str( $parsedUrl['query'], $queryString ); |
324 | | - foreach ( $queryStringParameters as $queryStringParameter ) { |
325 | | - $queryString[$queryStringParameter['name']] = $queryStringParameter['value']; |
326 | | - } |
327 | | - $parsedUrl['query'] = http_build_query( $queryString ); |
328 | | - } else { |
329 | | - $parsedUrl['query'] = ''; |
330 | | - foreach ( $queryStringParameters as $queryStringParameter ) { |
331 | | - $parsedUrl['query'] .= "{$queryStringParameter['name']}={$queryStringParameter['value']}&"; |
332 | | - } |
333 | | - if ( substr( $parsedUrl['query'], -1, 1 ) === '&' ) { |
334 | | - $parsedUrl['query'] = substr( $parsedUrl['query'], 0, -1 ); |
335 | | - } |
336 | | - } |
337 | | - wfProfileOut( __METHOD__ ); |
338 | | - return $this->unParseUrl( $parsedUrl ); |
339 | | - } |
340 | | - |
341 | | - /** |
342 | | - * Returns the full url |
343 | | - * |
344 | | - * @param Array $parsedUrl: the array returned from parse_url |
345 | | - * @return String |
346 | | - */ |
347 | | - private function unParseUrl( $parsedUrl ) { |
348 | | - wfProfileIn( __METHOD__ ); |
349 | | - $scheme = isset( $parsedUrl['scheme'] ) ? $parsedUrl['scheme'] . '://' : ''; |
350 | | - $host = isset( $parsedUrl['host'] ) ? $parsedUrl['host'] : ''; |
351 | | - $port = isset( $parsedUrl['port'] ) ? ':' . $parsedUrl['port'] : ''; |
352 | | - $user = isset( $parsedUrl['user'] ) ? $parsedUrl['user'] : ''; |
353 | | - $pass = isset( $parsedUrl['pass'] ) ? ':' . $parsedUrl['pass'] : ''; |
354 | | - $pass = ( $user || $pass ) ? "$pass@" : ''; |
355 | | - $path = isset( $parsedUrl['path'] ) ? $parsedUrl['path'] : ''; |
356 | | - $query = isset( $parsedUrl['query'] ) ? '?' . $parsedUrl['query'] : ''; |
357 | | - $fragment = isset( $parsedUrl['fragment'] ) ? '#' . $parsedUrl['fragment'] : ''; |
358 | | - wfProfileOut( __METHOD__ ); |
359 | | - return "$scheme$user$pass$host$port$path$query$fragment"; |
360 | | - } |
361 | | - |
362 | | - /** |
363 | 309 | * Adds object to debugOutput Array |
364 | 310 | * |
365 | 311 | * @param Object $object: any valid PHP object |