UpdateDatabase.php
[Pman.Core] / UpdateDatabase.php
index 923ab8a..79de922 100644 (file)
@@ -474,6 +474,17 @@ class Pman_Core_UpdateDatabase extends Pman
     
     function checkOpts($opts)
     {
+        
+        
+        foreach($opts as $o=>$v) {
+            if (!preg_match('/^json-/', $o) || empty($v)) {
+                continue;
+            }
+            if (!file_exists($v)) {
+                die("File does not exist : OPTION --{$o} = {$v} \n");
+            }
+        }
+        
         $modules = array_reverse($this->modulesList());
         
         // move 'project' one to the end...
@@ -493,14 +504,34 @@ class Pman_Core_UpdateDatabase extends Pman
         }
                 
     }
-    
+    static function jsonImportFromArray($opts)
+    {
+        foreach($opts as $o=>$v) {
+            if (!preg_match('/^json-/', $o) || empty($v)) {
+                continue;
+            }
+            $type = str_replace('_', '-', substr($o,6));
+            $data= json_decode(file_get_contents($file),true);
+            DB_DataObject::factory($type)->importFromArray($data);
+            
+        }
+        
+        
+        
+    }
     
     function runUpdateModulesData()
     {
+        
+        
         HTML_FlexyFramework::get()->generateDataobjectsCache(true);
-               
+        echo "Running jsonImportFromArray\n";
+        Pman_Core_UpdateDatabase::jsonImportFromArray($this->opts);
         
+        
+        echo "Running updateData on modules\n";
         // runs core...
+        echo "Core\n";
         $this->updateData(); 
         $modules = array_reverse($this->modulesList());
         
@@ -511,12 +542,14 @@ class Pman_Core_UpdateDatabase extends Pman
             if($module == 'Core' || !file_exists($file)){
                 continue;
             }
+            
             require_once $file;
             $class = "Pman_{$module}_UpdateDatabase";
             $x = new $class;
             if(!method_exists($x, 'updateData')){
                 continue;
             };
+            echo "$module\n";
             $x->updateData();
         }