Fix #7554 - performance on import of langs
[Pman.Admin] / UpdateBjsTemplates.php
index fd7d672..5ca48a9 100644 (file)
@@ -30,11 +30,24 @@ class Pman_Admin_UpdateBjsTemplates extends Pman
         return true;
     }
      
-    function get($tbl, $opts=array())
+    function get($step, $opts=array())
     {
         PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
         $this->opts = $opts;
-        $this->updateData();
+        
+        switch($step) {
+            case 'scanProjectBJS':
+            case 'scanPmanBJS':
+            case 'scanPmanTemplates':
+            case 'scanTables':
+            case 'syncLanguage':
+                  $this->{$step}();
+                  $this->jok("DONE - " . $step);
+            default:
+                $this->jerr("invalid step");
+        }
+        
+         
     }
     
     function updateData()
@@ -144,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);
 
@@ -214,14 +236,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";
             }
@@ -237,7 +260,7 @@ class Pman_Admin_UpdateBjsTemplates extends Pman
         $tp = DB_DAtaObject::Factory('core_template');
         
         foreach ($this->modules() as $m){
-            
+            //var_dump($m);
             // templates...
             $ar = $this->scanDir(array(
                  'tdir' => "Pman/$m/templates",
@@ -246,7 +269,7 @@ class Pman_Admin_UpdateBjsTemplates extends Pman
                 'skipdir' => array('images','css','js'),
                 
             ));
-            
+           //  print_r($ar);
             
             foreach($ar as $pg) {