sync
[Pman.Admin] / UpdateBjsTemplates.php
index 75b51da..be1a92d 100644 (file)
@@ -50,7 +50,8 @@ class Pman_Admin_UpdateBjsTemplates extends Pman
          
     }
     
-    function updateData()
+    function updateData() // this does everything?? not used?
+    
     {   
         $this->scanProjectBJS();
         $this->scanPmanBJS();
@@ -67,7 +68,7 @@ class Pman_Admin_UpdateBjsTemplates extends Pman
         
     }
     
-    function scanProjectBJS()
+    function scanProjectBJS()  // this is probably not used (replace by the CMS scanner)
     {
         $ff = HTML_FlexyFramework::get();
         
@@ -127,7 +128,6 @@ class Pman_Admin_UpdateBjsTemplates extends Pman
     
     function scanPmanBJS()
     {
-        
         $ids = array();
         foreach ($this->modules() as $m){
             $view_name = "Pman.$m";
@@ -157,18 +157,27 @@ class Pman_Admin_UpdateBjsTemplates extends Pman
                     'view_name' => $view_name,
                     
                 ));
+                
+                
 
                 $o = false;
 
                 if($template->find(true)){
                     $o = clone ($template);
                 }
+                $updated = empty($template->updated) ? '1970-01-01' : $template->updated ;
+                
                 $template->is_deleted = 0;
 
                 $template->filetype = 'bjs';
                 $template->updated = $template->sqlValue("NOW()");
 
                 (empty($o)) ? $template->insert() : $template->update($o);
+
+                if (strtotime($updated) >= filemtime('Pman' . '/' . $m . '/' . $fn)) {
+                    continue;
+                }
+                
                 $ids[] = $template->id;
                 $data = json_decode(file_get_contents('Pman' . '/' . $m . '/' . $fn), true);
 
@@ -210,7 +219,16 @@ class Pman_Admin_UpdateBjsTemplates extends Pman
             if($this->cli){
                 echo "Sync tables.....\n";
             }
+
+            // deactivate all table translation
+            $t = DB_DataObject::factory('core_templatestr');
+            $t->query(
+                "UPDATE core_templatestr
+                SET active = 0 
+                WHERE on_table != ''"
+            );
             
+            // activate the used table translation
             foreach($ff->Pman_Core['DataObjects_Core_templatestr']['tables'] as $table=>$cols){
                 $t = DB_DataObject::factory($table);
                 foreach($t->fetchAll() as $d) {
@@ -227,14 +245,15 @@ class Pman_Admin_UpdateBjsTemplates extends Pman
         if (empty($ff->Pman_Core)) {
             $this->jerr("config[Pman_Core] is not set");
         }
-        
-        $opt_lang = empty($ff->Pman_Core_I18n) ? array( 'l' => array()) : $ff->Pman_Core_I18n;
+         $ff = HTML_FlexyFramework::get();
+     
+        $opt_lang = empty($ff->Pman_Admin['languages']) ? array( 'l' => array()) : $ff->Pman_Admin['languages'];
         
         if($this->cli){
             echo "Sync the Languages template.....\n";
         }
         
-        foreach($opt_lang['l'] as $l) {
+        foreach($opt_lang as $l) {
             if($this->cli){
                 echo "Sync $l Language.....\n";
             }
@@ -259,7 +278,7 @@ class Pman_Admin_UpdateBjsTemplates extends Pman
                 'skipdir' => array('images','css','js'),
                 
             ));
-            //print_r($ar);
+           //  print_r($ar);
             
             foreach($ar as $pg) {