Fix #7173 - translation code split up process into parts.
authorAlan <alan@roojs.com>
Mon, 28 Mar 2022 02:26:29 +0000 (10:26 +0800)
committerAlan <alan@roojs.com>
Mon, 28 Mar 2022 02:26:29 +0000 (10:26 +0800)
Pman.Tab.AdminTranslations.bjs
Pman.Tab.AdminTranslations.js
UpdateBjsTemplates.php

index 9daa11b..fa44582 100644 (file)
@@ -25,8 +25,8 @@
  "items" : [
   {
    "region" : "center",
-   "title" : "Application Words",
    "xtype" : "NestedLayoutPanel",
+   "title" : "Application Words",
    "$ xns" : "Roo",
    "items" : [
     {
@@ -36,8 +36,8 @@
      "items" : [
       {
        "xtype" : "LayoutRegion",
-       "$ xns" : "Roo",
        "width" : 450,
+       "$ xns" : "Roo",
        "split" : true,
        "* prop" : "west"
       },
@@ -85,7 +85,7 @@
           },
           {
            "listeners" : {
-            "click" : "function (_self, e)\n{\n    var tree = _this.treepanel.tree;\n    Roo.log(tree);\n    var sn  = tree.getSelectionModel().getSelectedNode();\n\n    if (!sn) {\n        Roo.MessageBox.alert(\"Error\", \"Select a node\");\n        return;\n    }\n    \n    var syncTemplate = function(){\n        new Pman.Request({\n            url : baseURL + '/Admin/UpdateBjsTemplates',\n            method : 'GET',\n            mask : 'Processing...',\n            timeout : 9000000,\n            success : function()\n            {\n                _this.treepanel.tree.getRootNode().reload();\n            }\n        });\n    \n    };\n    \n    \n    var syncLanguage = function(){\n        new Pman.Request({\n            url : baseURL + '/Roo/Core_templatestr',\n            method : 'POST',\n            mask : 'Processing...',\n            params : {\n                _rescan : sn.attributes.id.split(':')[1]\n            }, \n            success : function()\n            {\n                _this.treepanel.tree.getRootNode().reload();\n            }\n        });\n    };\n    \n    if(typeof(sn.isRoot) != 'undefined' && sn.isRoot){\n        syncTemplate();\n        return;\n    }\n    \n    if(typeof(sn.attributes.language) != 'undefined' && sn.attributes.language){\n        syncLanguage();\n        return;\n    }\n    \n    \n    \n    \n    \n}"
+            "click" : "function (_self, e)\n{\n    var tree = _this.treepanel.tree;\n    Roo.log(tree);\n    var sn  = tree.getSelectionModel().getSelectedNode();\n\n    if (!sn) {\n        Roo.MessageBox.alert(\"Error\", \"Select a node\");\n        return;\n    }\n    \n    \n    var steps = [ \n           'scanProjectBJS',\n             'scanPmanBJS',\n             'scanPmanTemplates',\n             'scanTables',\n             'syncLanguage'  \n    ];\n    \n    \n    var syncTemplate = function(){\n    \n        var step = steps.shift();\n        Roo.MessageBox.updateProgress( (5.0 - steps.length) / 5.0, \"Running \" + step);\n    \n        new Pman.Request({\n            url : baseURL + '/Admin/UpdateBjsTemplates/' + step,\n            method : 'GET',\n            //mask : 'Processing...',\n            timeout : 9000000,\n            success : function()\n            {\n               if (steps.length > 0 ) { \n                    syncTemplate();\n                    return;\n                }\n                Roo.MessageBox.hide();\n                _this.treepanel.tree.getRootNode().reload();\n            }\n        });\n    \n    };\n    \n    \n    var syncLanguage = function(){\n        new Pman.Request({\n            url : baseURL + '/Roo/Core_templatestr',\n            method : 'POST',\n            mask : 'Processing...',\n            params : {\n                _rescan : sn.attributes.id.split(':')[1]\n            }, \n            success : function()\n            {\n                _this.treepanel.tree.getRootNode().reload();\n            }\n        });\n    };\n    \n    if(typeof(sn.isRoot) != 'undefined' && sn.isRoot){\n        Roo.MessageBox.progress(\"Syncing templates\", \"Starting\");\n        syncTemplate();\n        return;\n    }\n    \n    if(typeof(sn.attributes.language) != 'undefined' && sn.attributes.language){\n        syncLanguage();\n        return;\n    }\n    \n    \n    \n    \n    \n}"
            },
            "text" : "Rescan",
            "xtype" : "Button",
        "listeners" : {
         "|activate" : "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
        },
+       "fitToframe" : true,
        "background" : false,
        "region" : "center",
-       "fitToframe" : true,
        "title" : "Page",
        "xtype" : "GridPanel",
        "fitContainer" : true,
            "items" : [
             {
              "$ url" : "baseURL + '/Roo/Core_templatestr.php'",
-             "method" : "GET",
              "xtype" : "HttpProxy",
+             "method" : "GET",
              "$ xns" : "Roo.data",
              "* prop" : "proxy"
             },
           },
           {
            "xtype" : "ColumnModel",
-           "header" : "Original",
            "width" : 300,
+           "header" : "Original",
            "$ renderer" : "function(v,x,r) \n{\n    var c = '#666';\n    if (r.data.updated  < r.data.src_id_updated) {\n        c = 'red';\n    }\n    \n    return String.format('<div style=\"color:'+c+'\";>{0}</div>', v)\n\n}",
            "$ xns" : "Roo.grid",
            "* prop" : "cm[]",
           },
           {
            "xtype" : "ColumnModel",
-           "header" : "Translation",
            "width" : 200,
+           "header" : "Translation",
            "$ renderer" : "function(v,x,r) \n{ \n\n    var c = '#666';\n    if (r.data.updated  < r.data.src_id_updated) {\n        c = 'red';\n    }\n    \n    return String.format('<div style=\"color:'+c+'\";>{0}</div>', v)\n\n}",
            "$ xns" : "Roo.grid",
            "* prop" : "cm[]",
           },
           {
            "xtype" : "ColumnModel",
-           "header" : "md5",
            "width" : 250,
+           "header" : "md5",
            "$ renderer" : "function(v,x,r) \n{\n    return v ? v : '';\n\n}",
            "$ xns" : "Roo.grid",
            "* prop" : "cm[]",
index 6124955..e66f55c 100644 (file)
@@ -156,14 +156,33 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({
                    return;
                }
                
+               
+               var steps = [ 
+                      'scanProjectBJS',
+                        'scanPmanBJS',
+                        'scanPmanTemplates',
+                        'scanTables',
+                        'syncLanguage'  
+               ];
+               
+               
                var syncTemplate = function(){
+               
+                   var step = steps.shift();
+                   Roo.MessageBox.updateProgress( (5.0 - steps.length) / 5.0, "Running " + step);
+               
                    new Pman.Request({
-                       url : baseURL + '/Admin/UpdateBjsTemplates',
+                       url : baseURL + '/Admin/UpdateBjsTemplates/' + step,
                        method : 'GET',
-                       mask : 'Processing...',
+                       //mask : 'Processing...',
                        timeout : 9000000,
                        success : function()
                        {
+                          if (steps.length > 0 ) { 
+                               syncTemplate();
+                               return;
+                           }
+                           Roo.MessageBox.hide();
                            _this.treepanel.tree.getRootNode().reload();
                        }
                    });
@@ -187,6 +206,7 @@ Pman.Tab.AdminTranslations = new Roo.XComponent({
                };
                
                if(typeof(sn.isRoot) != 'undefined' && sn.isRoot){
+                   Roo.MessageBox.progress("Syncing templates", "Starting");
                    syncTemplate();
                    return;
                }
index fd7d672..75b51da 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()
@@ -237,7 +250,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 +259,7 @@ class Pman_Admin_UpdateBjsTemplates extends Pman
                 'skipdir' => array('images','css','js'),
                 
             ));
-            
+            //print_r($ar);
             
             foreach($ar as $pg) {