You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@shindig.apache.org by "Bastian Hofmann (JIRA)" <ji...@apache.org> on 2010/07/28 13:36:16 UTC

[jira] Commented: (SHINDIG-1139) Gadget Url Renderer: parameters substitution

    [ https://issues.apache.org/jira/browse/SHINDIG-1139?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12893142#action_12893142 ] 

Bastian Hofmann commented on SHINDIG-1139:
------------------------------------------

Any reason why this patch has not been applied yet? It works fine for me, I just had to adapt it a tiny bit because of one other change which happend after this patch was created:

--- -   2010-07-27 12:57:57.000000000 +0200
+++ php/src/gadgets/render/GadgetUrlRenderer.php       2010-07-26 08:55:15.000000000 +0200
@@ -32,9 +32,7 @@
   public function renderGadget(Gadget $gadget, $view) {
     // Preserve existing query string parameters.
     $redirURI = $view['href'];
-    $queryStr = strpos($redirURI, '?') !== false ? substr($redirURI, strpos($redirURI, '?')) : '';
-    $query = $queryStr;
-    $query .= $this->getPrefsQueryString($gadget->gadgetSpec->userPrefs);
+    $query = $this->getPrefsQueryString($gadget->gadgetSpec->userPrefs);

     // deal with features
     $registry = $this->context->getRegistry();
@@ -46,9 +44,14 @@
     $query .= $this->appendLibsToQuery($features);
     $query .= '&lang=' . urlencode(isset($_GET['lang']) ? $_GET['lang'] : 'en');
     $query .= '&country=' . urlencode(isset($_GET['country']) ? $_GET['country'] : 'US');
-    if (substr($query, 0, 1) == '&') {
-    $query = '?' . substr($query, 1);
+
+    $redirURI = $gadget->substitutions->substituteUri(null, $redirURI);
+    if (strpos($redirURI, '?') !== false) {
+      $redirURI = $redirURI . $query;
+    } elseif (substr($query, 0, 1) == '&') {
+      $redirURI = $redirURI . '?' . substr($query, 1);
+    } else {
+      $redirURI = $redirURI . '?' . $query;
     }
-    $redirURI .= $query;
     header('Location: ' . $redirURI);
   }


> Gadget Url Renderer: parameters substitution
> --------------------------------------------
>
>                 Key: SHINDIG-1139
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-1139
>             Project: Shindig
>          Issue Type: Bug
>          Components: PHP
>    Affects Versions: 1.1-BETA2
>            Reporter: Chris Chabot
>            Assignee: Chris Chabot
>
> This was originally SHINDIG-1138 by Dmitry Vorobyev, but due to spamming auto responders i've deleted that issue. Original content:
> Substitute __MODULE_ID__ and other parameters in url.
> ### Eclipse Workspace Patch 1.0
> #P shindig
> Index: http://svn.apache.org/repos/asf/incubator/shindig/trunk/php/src/gadgets/render/GadgetUrlRenderer.php
> ===================================================================
> --- http://svn.apache.org/repos/asf/incubator/shindig/trunk/php/src/gadgets/render/GadgetUrlRenderer.php (revision 800379)
> +++ http://svn.apache.org/repos/asf/incubator/shindig/trunk/php/src/gadgets/render/GadgetUrlRenderer.php (working copy)
> @@ -32,9 +32,7 @@
>    public function renderGadget(Gadget $gadget, $view) {
>      // Preserve existing query string parameters.
>      $redirURI = $view['href'];
> - $queryStr = strpos($redirURI, '?') !== false ? substr($redirURI, strpos($redirURI, '?')) : '';
> - $query = $queryStr;
> - $query .= $this->getPrefsQueryString($gadget->gadgetSpec->userPrefs);
> + $query = $this->getPrefsQueryString($gadget->gadgetSpec->userPrefs);
>      $features = array();
>      $forcedLibs = Config::get('focedJsLibs');
>      if ($forcedLibs == null) {
> @@ -45,10 +43,15 @@
>      $query .= $this->appendLibsToQuery($features);
>      $query .= '&lang=' . urlencode(isset($_GET['lang']) ? $_GET['lang'] : 'en');
>      $query .= '&country=' . urlencode(isset($_GET['country']) ? $_GET['country'] : 'US');
> - if (substr($query, 0, 1) == '&') {
> - $query = '?' . substr($query, 1);
> +
> + $redirURI = $gadget->substitutions->substituteUri(null, $redirURI);
> + if (strpos($redirURI, '?') !== false) {
> + $redirURI = $redirURI . $query;
> + } elseif (substr($query, 0, 1) == '&') {
> + $redirURI = $redirURI . '?' . substr($query, 1);
> + } else {
> + $redirURI = $redirURI . '?' . $query;
>      }
> - $redirURI .= $query;
>      header('Location: ' . $redirURI);
>    }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.