fix #8131 - chinese translations
[Pman.Core] / DataObjects / Core_domain.php
index 6420b7f..3c50da4 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * Table Definition for core_domain
  */
-require_once 'DB/DataObject.php';
+class_exists('DB_DataObject') ? '' : require_once 'DB/DataObject.php';
 
 class Pman_Core_DataObjects_Core_domain extends DB_DataObject 
 {
@@ -15,5 +15,22 @@ class Pman_Core_DataObjects_Core_domain extends DB_DataObject
 
     /* the code above is auto generated do not remove the tag below */
     ###END_AUTOCODE
-    
+    function loadOrCreate($dom)
+    {
+        // should we validate domain?
+        static $cache = array();
+        if (isset($cache[$dom])) {
+            return $cache[$dom];
+        }
+        
+        $cd = DB_DataObject::Factory($this->tableName());
+        if ($cd->get('domain', $dom)) {
+            $cache[$dom] = $cd;
+            return $cd;
+        }
+        $cd->domain = $dom;
+        $cd->insert();
+        $cache[$dom] = $cd;
+        return $cd;
+    }
 }