You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by ch...@apache.org on 2010/03/01 10:27:46 UTC

svn commit: r917431 - /shindig/trunk/php/src/gadgets/render/GadgetBaseRenderer.php

Author: chabotc
Date: Mon Mar  1 09:27:46 2010
New Revision: 917431

URL: http://svn.apache.org/viewvc?rev=917431&view=rev
Log:
SHINDIG-1262 by Jacky Wang - Fix default UserPrefs

Modified:
    shindig/trunk/php/src/gadgets/render/GadgetBaseRenderer.php

Modified: shindig/trunk/php/src/gadgets/render/GadgetBaseRenderer.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/render/GadgetBaseRenderer.php?rev=917431&r1=917430&r2=917431&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/render/GadgetBaseRenderer.php (original)
+++ shindig/trunk/php/src/gadgets/render/GadgetBaseRenderer.php Mon Mar  1 09:27:46 2010
@@ -331,6 +331,7 @@
     $script .= "\n";
     $script .= $this->appendJsConfig($this->gadget, $sortedExternFeatures, $sortedInlineFeatures);
     $script .= $this->appendMessages($this->gadget);
+    $script .= $this->appendPreferences($this->gadget);
     $script .= $this->appendPreloads($this->gadget);
     if (count($this->dataInserts)) {
       foreach ($this->dataInserts as $data) {
@@ -467,14 +468,22 @@
    * @return string
    */
   private function appendMessages(Gadget $gadget) {
-    $msgs = '';
-    if (! empty($gadget->gadgetSpec->locales)) {
-      $msgs = json_encode($gadget->gadgetSpec->locales);
-    }
+    $msgs = json_encode($this->dataContext['Msg']);
     return "gadgets.Prefs.setMessages_($msgs);\n";
   }
 
   /**
+   * Injects the pre-defined user preferences into the javascript api
+   *
+   * @param Gadget $gadget
+   * @return string
+   */
+  private function appendPreferences(Gadget $gadget) {
+    $prefs = json_encode($this->dataContext['UserPrefs']);
+    return "gadgets.Prefs.setDefaultPrefs_($prefs);\n";
+  }
+
+  /**
    * Injects the preloaded content into the javascript api
    *
    * @param Gadget $gadget