DataObjects/I18n.php
authorAlan Knowles <alan@akbkhome.com>
Thu, 15 Sep 2011 04:13:39 +0000 (12:13 +0800)
committerAlan Knowles <alan@akbkhome.com>
Thu, 15 Sep 2011 04:13:39 +0000 (12:13 +0800)
DataObjects/I18n.php

index 3b5310c..489e216 100644 (file)
@@ -77,6 +77,48 @@ class Pman_Core_DataObjects_I18n extends DB_DataObject
     
     
     
+    function transToList($ltype, $inlang)
+    {
+        
+        $x = DB_DataObject::factory('i18n');
+        $x->ltype = $ltype;
+        $x->inlang= $inlang;
+        $x->selectAdd();
+        $x->selectAdd('lkey as code, lval as title');
+        $x->find();
+        $ret = array();
+        while ($x->fetch()) {
+            $ret[] = array('code' => $x->code, 'title' =>$x->title);
+        }
+        
+    }
+    
+    function objToList($type, $obj) {
+        $ret = array();
+         
+         
+        foreach($this->cfg[$type] as $k) {
+            $sub = false;
+            
+            if (strpos($k, '_') !== false) {
+                $bits = explode('_', $k);
+                $k = array_shift($bits);
+                $sub = array_shift($bits);
+            }
+            $v = $k == '**' ? 'Other' : $obj->getName($k);
+            
+            if ($sub) {
+                $v .= ' ('.$sub.')';
+            }
+            
+            $ret[] = array(
+                'code'=>   ($type=='l' ? strtolower($k) : strtoupper($k)) . ($sub ? '_'.strtoupper($sub) : ''), 
+                'title' => $v
+            );
+        }
+        return $ret;
+    }
+