X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=DataObjects%2FI18n.php;h=1edb61b2a1488d26876ba2dd62e4d106e6e0e777;hb=77c77114f7a1bf347b5cf550209d27199ab0172e;hp=e939dd748b446ba5d9dda237d830675345db0bb4;hpb=2d91720d987149a8a2f74380822a63cd61d2790f;p=Pman.Core diff --git a/DataObjects/I18n.php b/DataObjects/I18n.php index e939dd74..1edb61b2 100644 --- a/DataObjects/I18n.php +++ b/DataObjects/I18n.php @@ -46,9 +46,9 @@ class Pman_Core_DataObjects_I18n extends DB_DataObject // 'ta', // tamil // '**', // other ), - 'c' => array( - 'AU', 'CN', 'HK', 'IN', 'ID', 'JP', 'MY', 'NZ', 'TW', 'SG', 'TH', 'KR', 'US', 'PH', 'VN','**' - ), + 'c' => '*', // array( + //'AU', 'CN', 'HK', 'IN', 'ID', 'JP', 'MY', 'NZ', 'TW', 'SG', 'TH', 'KR', 'US', 'PH', 'VN','**' + //), 'm' => array( 'USD', 'HKD', 'GBP', 'CNY', 'SGD', 'JPY' ), @@ -68,22 +68,46 @@ class Pman_Core_DataObjects_I18n extends DB_DataObject if ($loaded) { return self::$cfg; } + $loaded =true; $ff= HTML_FlexyFramework::get(); + + // BC compatible.. if any of these are set, then we use them as the settings.. + $opts = array(); + foreach(array('Pman_Core_I18n', 'Pman_Core_I18N', 'Pman_I18N','Pman_I18n') as $pk) { + if (isset($ff->$pk)) { + //var_dump($pk); + $opts = $ff->$pk; + break; + } + } + //echo '
';print_R($opts);//exit;
+        
          
-        // since our opts array changed alot..
-        $opts = empty($ff->Pman_Core_I18N) ? (empty($ff->Pman_I18N) ? array() : $ff->Pman_I18N)  : $ff->Pman_Core_I18N;
+        // var_dump($opts);exit;
         
         $i = DB_DataObject::Factory('I18n');
         // load the cofiguration
         foreach($opts as $k=>$v) {
             
             if ($v == '*') { // everything..
-                self::$cfg[$k] = $i->availableCodes($k);
+               // self::$cfg[$k] = $i->availableCodes($k, false);
                 continue;
             }
+             
             self::$cfg[$k] = is_array($v) ? $v  : explode(',', $v);
         }
+        // available codes recursively calls this... -- so the above has to be set first..
+        foreach($opts as $k=>$v) {
+            
+            if ($v == '*') { // everything..
+                self::$cfg[$k] = '*'; //$i->availableCodes($k, false);
+                continue;
+            }
+           
+        }
+        
+        
         return self::$cfg;
         
         
@@ -107,8 +131,18 @@ class Pman_Core_DataObjects_I18n extends DB_DataObject
         }
         if (!empty($q['query']['name'])) {
             //DB_DAtaObject::debugLevel(1);
+            $v = strtoupper($this->escape($q['query']['name']));
+            $this->whereAdd("upper(lval) LIKE '%{$v}%'");
+        }
         
-            $this->whereAdd("lval LIKE '". $this->escape($q['query']['name']). "%'");
+        if (!empty($q['_filtered']) && !empty($this->ltype)) {
+            $cfg = $this->cfg();
+            print_r($cfg);exit;
+            $filter = $cfg[$this->ltype];
+            
+            $this->whereAddIn('lkey', $filter, 'string'); 
+            
+            
         }
     }
     
@@ -163,11 +197,11 @@ class Pman_Core_DataObjects_I18n extends DB_DataObject
     
     
     // returns a list of all countries/languages etc.. (with '*')
-    function availableCodes($t)
+    function availableCodes($t, $filtered = true)
     {
         $ret = array();
         $cfg = $this->cfg();
-
+        //echo '
';print_r($cfg);
         switch ($t) {
             case 'c':
                 require_once 'I18Nv2/Country.php';
@@ -178,9 +212,11 @@ class Pman_Core_DataObjects_I18n extends DB_DataObject
                     $ret = array_merge($ret, array_keys($cfg['add_c']));
                 }
                 
+                
                  
                 
                 $ret[] = '**';
+                //echo '
';print_R($cfg); print_r($ret); exit;
                 break;
             
             case 'l':
@@ -215,9 +251,12 @@ class Pman_Core_DataObjects_I18n extends DB_DataObject
                 $ret[] = '**';
                 break;
         }
-        if (!empty($cfg[$t]) && is_array($cfg[$t])) {
-            // then there is a filter.
-            return array_intersect($cfg[$t], $ret);
+        
+        
+        
+        if ($filtered  && !empty($cfg[$t]) && is_array($cfg[$t])) {
+            // then there is a filter. - we should include all of them, even if they are not relivatn??
+            return $cfg[$t]; //array_intersect($cfg[$t], $ret);
             
         }
         
@@ -234,6 +273,8 @@ class Pman_Core_DataObjects_I18n extends DB_DataObject
     function buildDB($ltype= false, $inlang= false )
     {
         $cfg = $this->cfg();
+        
+        //print_r($cfg);
         if ($ltype === false) {
             // trigger all builds.
             //DB_DataObject::debugLevel(1);
@@ -346,7 +387,7 @@ class Pman_Core_DataObjects_I18n extends DB_DataObject
             $ret = $cache[$lang][$type]->getName($k);
         }
         
-        if ($orig_lang == 'zh_HK') {
+        if ($orig_lang == 'zh_HK' || $orig_lang == 'zh_TW' ) {
             // then translation is by default in simplified.
             //print_r($ret);
             $ret = @iconv("UTF-8", "GB2312//IGNORE", $ret);