DataObjects/core.sql
[Pman.Core] / I18n.php
index addc585..009c26d 100644 (file)
--- a/I18n.php
+++ b/I18n.php
@@ -116,23 +116,24 @@ class Pman_Core_I18n extends Pman
         
         switch($s) {
             case 'Lang':
-                DB_DatatObject::DebugLevel(1);
+                 
+                
                 $i->ltype = 'l';
                 $i->applyFilters($_REQUEST, $this->authUser, $this);
-                $this->jdata($i->toTransList('l',  $lbits[0]));
+                $this->jdata($i->toTransList('l',  implode('_',$lbits)));
                 break;
 
             case 'Country':
                 $i->ltype = 'c';
                 $i->applyFilters($_REQUEST, $this->authUser, $this);
-                $this->jdata($i->toTransList('c',  $lbits[0]));
+                $this->jdata($i->toTransList('c',  implode('_',$lbits)));
                
                 break;
                 
             case 'Currency':
                 $i->ltype = 'm';
                 $i->applyFilters($_REQUEST, $this->authUser, $this);
-                $this->jdata($i->toTransList('m',  $lbits[0]));
+                $this->jdata($i->toTransList('m',  implode('_',$lbits)));
                 break;
             
             case 'Timezone':
@@ -168,8 +169,9 @@ class Pman_Core_I18n extends Pman
         if (!empty($_REQUEST['debug'])) {
             DB_DataObject::debugLevel(1);
         }
+        
         $i = DB_DataObject::Factory('I18n');
-        $i->buildDb();
+        $i->buildDB();
       
        
         $i = DB_DataObject::Factory('I18n');
@@ -179,7 +181,8 @@ class Pman_Core_I18n extends Pman
         $ar = array();
         foreach($langs as $lang)
         {
-            $rlang = array_shift(explode('_', strtoupper($lang)));
+            //$rlang = array_shift(explode('_', strtoupper($lang)));
+            $rlang = array_shift(explode('_', $lang));
             
             $ar[$lang] = array();
             $i = DB_DataObject::Factory('I18n');
@@ -203,7 +206,7 @@ class Pman_Core_I18n extends Pman
      /**
      * translate (used by database building);
      * usage :
-     * require_once 'Pman/Core/I18N.php';
+     * require_once 'Pman/Core/I18n.php';
      * $x = new Pman_Core_I18N();
      * $x->translate($this->authuser, 'c', 'US');
      * @param au - auth User
@@ -284,11 +287,15 @@ class Pman_Core_I18n extends Pman
         }
         $target = ini_get('session.save_path').'/eurofxref-daily.xml';
         if (!file_exists($target) || filemtime($target) < (time() - 60*60*24)) {
-            $f = file_get_contents('http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml');
+            // this may fail...
+            $f = @file_get_contents('http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml');
             if (!strlen($f)) {
-                return false;
+                $target = dirname(__FILE__).'/eurofxref-daily.xml';
+                
+                
+            } else {
+                file_put_contents($target,$f);
             }
-            file_put_contents($target,$f);
         } 
         $dom = simplexml_load_file($target);
         $this->rates['EUR'] = 1.0;