X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=I18n.php;h=8367964c9ef63a8bb91a933936131919a577046c;hp=ffd6b4ce69a78438ffdbb28ddcc7b077644e6511;hb=refs%2Fheads%2Fwip_alan_T5884_add_photo_to_report;hpb=8da091a3af65af9953dff76e3dd04cf8632bb93e diff --git a/I18n.php b/I18n.php index ffd6b4ce..8367964c 100644 --- a/I18n.php +++ b/I18n.php @@ -81,7 +81,9 @@ class Pman_Core_I18n extends Pman } - function guessUsersLanguage() { + function guessUsersLanguage() + { + $this->sessionState(0); $lang = !$this->authUser || empty($this->authUser->lang ) ? 'en' : $this->authUser->lang; @@ -105,7 +107,7 @@ class Pman_Core_I18n extends Pman return explode('_', $lang); } - function get($s ='') + function get($s ='', $opts=array()) { $this->sessionState(0); @@ -118,7 +120,7 @@ class Pman_Core_I18n extends Pman $i = DB_DataObject::Factory('I18n'); - + $i->is_active = 1; switch($s) { case 'Lang': @@ -187,7 +189,8 @@ class Pman_Core_I18n extends Pman foreach($langs as $lang) { //$rlang = array_shift(explode('_', strtoupper($lang))); - $rlang = array_shift(explode('_', $lang)); + $ll = explode('_', $lang); + $rlang = array_shift($ll); $ar[$lang] = array(); $i = DB_DataObject::Factory('I18n'); @@ -199,6 +202,7 @@ class Pman_Core_I18n extends Pman } //echo '
';print_r($ar);
         header('Content-type: text/javascript');
+        echo "Roo.namespace('Pman.I18n');";
         echo 'Pman.I18n.Data = ' .  json_encode($ar);
         exit;
         
@@ -263,22 +267,26 @@ class Pman_Core_I18n extends Pman
     function convertCurrency($val, $from, $to)
     {
         
-        DB_DAtaObject::Factory('core_curr_rate')->convert($val,$from,$to);
+        return DB_DAtaObject::Factory('core_curr_rate')->convert($val,$from,$to);
     
     }
     /**
      * DO NOT USE THIS -- see core_curr_rates dataobject.
      *
      */
-    var $rates = array();
+    
+    
+    
     function loadRates()
-    {
-        if (!empty($this->rates)) {
-            return true;
-        }
+    {   
+        static $rates = array();
         
-        $this->rates = DB_DAtaObject::Factory('core_curr_rate')->currentRates();
+        if (!empty($rates)) {
+            $this->rates = $rates;
+            return;
+        }
         
+        $this->rates = $rates = DB_DAtaObject::Factory('core_curr_rate')->currentRates();
         
     }