diff --git a/app/classes/Transvision/Utils.php b/app/classes/Transvision/Utils.php index 4ed12ff4..0ddd907a 100644 --- a/app/classes/Transvision/Utils.php +++ b/app/classes/Transvision/Utils.php @@ -438,10 +438,32 @@ public static function ago($datetime, $ref_time = '') * This is used on views which also exist in our public API * https://github.com/mozfr/transvision/wiki/JSON-API * - * @return string URL with 'json' appended as part of the query string + * @param boolean $revert if true, invert the locale and the source_locale in the API generated link + * @return string URL with 'json' appended as part of the query string */ - public static function redirectToAPI() + public static function redirectToAPI($revert = false) { - return $_SERVER["REQUEST_URI"] . (is_null($_SERVER['QUERY_STRING']) ? '?json' : '&json'); + if (! is_null($_SERVER['QUERY_STRING'])) { + if ($revert == true) { + $arg = []; + parse_str($_SERVER['QUERY_STRING'], $arg); + $source_locale = $arg["sourcelocale"]; + $locale = $arg["locale"]; + $arg["sourcelocale"] = $locale; + $arg["locale"] = $source_locale; + $query = http_build_query($arg); + } else { + $query = $_SERVER['QUERY_STRING']; + } +// dump($_SERVER["REQUEST_URI"]); + $address = (strstr($_SERVER["REQUEST_URI"], '?') ? + strstr($_SERVER["REQUEST_URI"], '?', true) : + $_SERVER["REQUEST_URI"]) . '?' . $query; + } else { + $query = null; + $address = $_SERVER["REQUEST_URI"]; + } + + return $address . (is_null($query) ? '?json' : '&json'); } } diff --git a/app/views/templates/api_promotion.php b/app/views/templates/api_promotion.php index 89ecae32..53d35821 100644 --- a/app/views/templates/api_promotion.php +++ b/app/views/templates/api_promotion.php @@ -1,4 +1,19 @@ + +
+ APIThese results are also available as an API request for the =$requested_sourcelocale?> locale or the =$requested_locale?> locale.
+ Learn more about the Transvision API.
+
APIThese results are also available as an API request.
- Learn more about Transvision API.
+ Learn more about the Transvision API.