Mwalker has uploaded a new change for review.

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


Change subject: FR #1113 Rather more intelligent thank you link generation
......................................................................

FR #1113 Rather more intelligent thank you link generation

Merge new components with old components.

Change-Id: Ie444228bb46680a0f5da2af257bf8f398075831f
---
M gateway_common/gateway.adapter.php
1 file changed, 19 insertions(+), 15 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface 
refs/changes/12/99612/1

diff --git a/gateway_common/gateway.adapter.php 
b/gateway_common/gateway.adapter.php
index 89c1c5d..7882e9e 100644
--- a/gateway_common/gateway.adapter.php
+++ b/gateway_common/gateway.adapter.php
@@ -351,8 +351,8 @@
        }
 
        /**
-        * getThankYouPage should either return a full page url, or false. 
-        * @global type $wgLang
+        * getThankYouPage should either return a full page url, or false.
+        *
         * @return mixed Page URL in string format, or false if none is set. 
         */
        public function getThankYouPage() {
@@ -395,23 +395,27 @@
        /**
         * For pages we intend to redirect to. This function will take either a 
full 
         * URL or a page title, and turn it into a URL with the appropriate 
language 
-        * appended onto the end. 
+        * appended onto the end.
+        *
         * @param string $url Either a wiki page title, or a URL to an external 
wiki 
-        * page title. 
-        * @return string A URL  
+        * page title.
+        *
+        * @return string A URL
         */
-       protected function appendLanguageAndMakeURL( $url ){
+       protected function appendLanguageAndMakeURL( $url ) {
                $language = $this->getData_Unstaged_Escaped( 'language' );
-               //make sure we don't already have the language in there...
-               $dirs = explode('/', $url);
-               if ( !is_array($dirs) || !in_array( $language, $dirs ) ){
-                       $url = $url . "/$language";
-               }
                
-               if ( strpos( $url, 'http' ) === 0) { 
-                       return $url;
-               } else { //this isn't a url yet.
-                       $returnTitle = Title::newFromText( $url );
+               if ( ( strpos( $url, 'http' ) === 0 ) || ( strpos( $url, '//' ) 
=== 0 ) ) {
+                       return http_build_url(
+                               wfParseUrl( $url ),
+                               array(
+                                        'path' => $language,
+                               ),
+                               HTTP_URL_JOIN_PATH
+                       );
+               } else {
+                       // this isn't a url yet, must be a mediawiki page
+                       $returnTitle = Title::newFromText( "{$url}/{$language}" 
);
                        $url = $returnTitle->getFullURL();
                        return $url;
                }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie444228bb46680a0f5da2af257bf8f398075831f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Mwalker <[email protected]>

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

Reply via email to