Changed DataObjects/Core_template.phpDataObjects/Core_templatestr.php
authorAlan <alan@roojs.com>
Mon, 28 Mar 2022 03:56:30 +0000 (11:56 +0800)
committerAlan <alan@roojs.com>
Mon, 28 Mar 2022 03:56:30 +0000 (11:56 +0800)
DataObjects/Core_template.php
DataObjects/Core_templatestr.php

index 23f885b..d996336 100644 (file)
@@ -58,6 +58,38 @@ class Pman_Core_DataObjects_Core_template  extends DB_DataObject
         
     }
     
+    function beforeUpdate($old, $q, $roo)
+    {
+        if (!empty($q['_rescan'])){
+            if ($this->filetype != 'html') {
+                $roo->jerr("can not update a php source file currently - TDOD");
+            }
+            $pg = HTML_FlexyFramework::get()->page;
+            
+            $this->syncTemplatePage(array(
+                'template_dir' => $pg->rootdir . '/'. str_replace('.', ',/', $this->view_name). '/templates',
+                'template' => $this->template,
+                'base' => $this->view_name
+            ));
+            // update the different langage versions of this page.
+            $x = DB_Dataobject::Factory('core_template_str');
+            $x->selectAdd();
+            $x->selectAdd('distinct(lang) as lang');
+            $x->whereAdd("lang != ''");
+            $langs  = $x->fetchAll('lang');
+            foreach($langs as $l) {
+                $x = DB_Dataobject::Factory('core_template_str');
+                $x->syncLang($l, $this->id);
+            }
+           
+            
+            $this->jok("updated");
+        }
+    }
+   
+    
+    
+    
     /*
      * @param base (should be full path to template directory)
      * @param subdir = empty for top or subpath.
index 44e58e1..7353a86 100644 (file)
@@ -263,7 +263,7 @@ class Pman_Core_DataObjects_Core_templatestr extends DB_DataObject
         $tt = DB_DataObject::factory($this->tableName());
 
 
-        $t = DB_DataObject::factory($this->tableName());
+        $t = clone($t);
         $t->template_id = $tmpl->id;
         $t->whereAdd("lang = ''");