Pman.Dialog.CmsBlog.bjs
[Pman.Cms] / Pman.Tab.CmsTranslateTemplates.js
index 9333b7b..565539a 100644 (file)
@@ -11,12 +11,15 @@ Pman.Tab.CmsTranslateTemplates = new Roo.XComponent({
   '0b8d92bc19b720bb1065649535463409' :"Translations",
   '9d1ead73e678fa2f51a70a933b0bf017' :"Not Found",
   '6dd08874f83507e9c7b23f1a46b7fa7c' :"Translation",
+  'e3d388b2c43e5ba0905702620ae2abc1' :"Search for",
   'e2f9d206562d8f5ea421ad51100f7151' :"Displaying petition_entry{0} - {1} of {2}",
   'dc00a593c8be0a664ba934335b093154' :"Translate Templates",
+  'cd6ae20e52d83f601c5fa12b66f0f6d0' :"Rescan",
   '4d1c8263ba1036754f8db14a98f9f006' :"Reload",
   'f2a6c498fb90ee345d997f888fce3b18' :"Delete",
   '03c2e7e41ffc181a4e84080b4710e81e' :"New",
-  '193cfc9be3b995831c6af2fea6650e60' :"Page"
+  '193cfc9be3b995831c6af2fea6650e60' :"Page",
+  '1bc29b36f623ba82aaf6724fd3b16718' :"md5"
  },
 
   part     :  ["Cms", "TranslateTemplates" ],
@@ -31,33 +34,48 @@ Pman.Tab.CmsTranslateTemplates = new Roo.XComponent({
    var _this = this;
    var MODULE = this;
    return {
+   region : 'center',
+   title : _this._strings['dc00a593c8be0a664ba934335b093154'] /* Translate Templates */,
+   xns : Roo,
+   '|xns' : 'Roo',
+   xtype : 'NestedLayoutPanel',
    layout : {
-    west : {
-     '|xns' : 'Roo',
-     split : true,
-     width : 200,
+    xns : Roo,
+    '|xns' : 'Roo',
+    xtype : 'BorderLayout',
+    center : {
      xns : Roo,
+     '|xns' : 'Roo',
      xtype : 'LayoutRegion'
     },
-    center : {
-     '|xns' : 'Roo',
+    west : {
+     split : true,
+     width : 300,
      xns : Roo,
+     '|xns' : 'Roo',
      xtype : 'LayoutRegion'
     },
-    '|xns' : 'Roo',
-    xns : Roo,
-    xtype : 'BorderLayout',
-    items : [
+    items  : [
      {
+      region : 'west',
+      xns : Roo,
+      '|xns' : 'Roo',
+      xtype : 'TreePanel',
+      listeners : {
+       render : function (_self)
+        {
+            _this.treepanel = _self;
+        }
+      },
       toolbar : {
-       '|xns' : 'Roo',
        xns : Roo,
+       '|xns' : 'Roo',
        xtype : 'Toolbar',
-       items : [
+       items  : [
         {
-         '|xns' : 'Roo.Toolbar',
-         text : _this._strings['03c2e7e41ffc181a4e84080b4710e81e'],
+         text : _this._strings['03c2e7e41ffc181a4e84080b4710e81e'] /* New */,
          xns : Roo.Toolbar,
+         '|xns' : 'Roo.Toolbar',
          xtype : 'Button',
          listeners : {
           click : function (_self, e)
@@ -66,7 +84,7 @@ Pman.Tab.CmsTranslateTemplates = new Roo.XComponent({
                    
                    new Pman.Request({
                        url : baseURL + '/Roo/cms_templatestr',
-                       method : 'GET',
+                       method : 'POST',
                        params : {
                            _rescan : lang
                        }, 
@@ -82,9 +100,14 @@ Pman.Tab.CmsTranslateTemplates = new Roo.XComponent({
          }
         },
         {
+         xns : Roo.Toolbar,
          '|xns' : 'Roo.Toolbar',
-         text : _this._strings['f2a6c498fb90ee345d997f888fce3b18'],
+         xtype : 'Separator'
+        },
+        {
+         text : _this._strings['f2a6c498fb90ee345d997f888fce3b18'] /* Delete */,
          xns : Roo.Toolbar,
+         '|xns' : 'Roo.Toolbar',
          xtype : 'Button',
          listeners : {
           click : function (_self, e)
@@ -92,7 +115,7 @@ Pman.Tab.CmsTranslateTemplates = new Roo.XComponent({
                var tree = _this.treepanel.tree;
                var sn  = tree.getSelectionModel().getSelectedNode();
            
-               if (!sn || sn.id.split('/').length > 1) {
+               if (!sn || typeof(sn.attributes.language) == 'undefined' || !sn.attributes.language) {
                    Roo.MessageBox.alert("Error", "Select a language");
                    return;
                }
@@ -131,9 +154,83 @@ Pman.Tab.CmsTranslateTemplates = new Roo.XComponent({
          }
         },
         {
+         xns : Roo.Toolbar,
+         '|xns' : 'Roo.Toolbar',
+         xtype : 'Separator'
+        },
+        {
+         text : _this._strings['cd6ae20e52d83f601c5fa12b66f0f6d0'] /* Rescan */,
+         xns : Roo.Toolbar,
+         '|xns' : 'Roo.Toolbar',
+         xtype : 'Button',
+         listeners : {
+          click : function (_self, e)
+           {
+               var tree = _this.treepanel.tree;
+               Roo.log(tree);
+               var sn  = tree.getSelectionModel().getSelectedNode();
+           
+               if (!sn) {
+                   Roo.MessageBox.alert("Error", "Select a node");
+                   return;
+               }
+               
+               var syncTemplate = function(){
+                   new Pman.Request({
+                       url : baseURL + '/Cms/UpdateBjsTemplates',
+                       method : 'GET',
+                       mask : 'Processing...',
+                       timeout : 9000000,
+                       success : function()
+                       {
+                           _this.treepanel.tree.getRootNode().reload();
+                       }
+                   });
+               
+               };
+               
+               
+               var syncLanguage = function(){
+                   new Pman.Request({
+                       url : baseURL + '/Roo/cms_templatestr',
+                       method : 'POST',
+                       mask : 'Processing...',
+                       params : {
+                           _rescan : sn.attributes.id
+                       }, 
+                       success : function()
+                       {
+                           _this.treepanel.tree.getRootNode().reload();
+                       }
+                   });
+               };
+               
+               if(typeof(sn.isRoot) != 'undefined' && sn.isRoot){
+                   syncTemplate();
+                   return;
+               }
+               
+               if(typeof(sn.attributes.language) != 'undefined' && sn.attributes.language){
+                   syncLanguage();
+                   return;
+               }
+               
+               
+               
+               
+               
+           }
+         }
+        },
+        {
+         xns : Roo.Toolbar,
          '|xns' : 'Roo.Toolbar',
-         text : _this._strings['4d1c8263ba1036754f8db14a98f9f006'],
+         xtype : 'Fill'
+        },
+        {
+         text : _this._strings['4d1c8263ba1036754f8db14a98f9f006'] /* Reload */,
          xns : Roo.Toolbar,
+         '|xns' : 'Roo.Toolbar',
          xtype : 'Button',
          listeners : {
           click : function (_self, e)
@@ -144,41 +241,23 @@ Pman.Tab.CmsTranslateTemplates = new Roo.XComponent({
          }
         }
        ]
-
       },
       tree : {
-       loader : {
-        '|xns' : 'Roo.tree',
-        baseParams : { _tree : 1 },
-        dataUrl : baseURL + '/Roo/cms_templatestr',
-        requestMethod : 'GET',
-        xns : Roo.tree,
-        xtype : 'TreeLoader',
-        listeners : {
-         beforeload : function (This, node, callback)
-          {
-              // set some params.
-              Roo.log(node);
-              this.baseParams._tree = 1;
-              
-              //this.baseParams.category = node.attributes.category;
-          },
-         loadexception : function (This, node, response)
-          {
-              Roo.MessageBox.alert("Error", "Problem loading tree");
-          }
-        }
-       },
+       containerScroll : false,
+       rootVisible : true,
+       xns : Roo.tree,
+       '|xns' : 'Roo.tree',
+       xtype : 'TreePanel',
        root : {
-        '|xns' : 'Roo.tree',
         id : 'transtree',
-        text : _this._strings['0b8d92bc19b720bb1065649535463409'],
+        text : _this._strings['0b8d92bc19b720bb1065649535463409'] /* Translations */,
         xns : Roo.tree,
+        '|xns' : 'Roo.tree',
         xtype : 'AsyncTreeNode'
        },
        selModel : {
-        '|xns' : 'Roo.tree',
         xns : Roo.tree,
+        '|xns' : 'Roo.tree',
         xtype : 'DefaultSelectionModel',
         listeners : {
          selectionchange : function (_self, node)
@@ -195,199 +274,55 @@ Pman.Tab.CmsTranslateTemplates = new Roo.XComponent({
           }
         }
        },
-       '|xns' : 'Roo.tree',
-       containerScroll : false,
-       rootVisible : true,
-       xns : Roo.tree,
-       xtype : 'TreePanel',
-       items : [
-
-       ]
-
-      },
-      '|xns' : 'Roo',
-      region : 'west',
-      xns : Roo,
-      xtype : 'TreePanel',
-      listeners : {
-       render : function (_self)
-        {
-            _this.treepanel = _self;
-        }
-      },
-      items : [
-
-      ]
-
-     },
-     {
-      grid : {
-       footer : {
-        '|xns' : 'Roo',
-        displayInfo : true,
-        displayMsg : _this._strings['e2f9d206562d8f5ea421ad51100f7151'],
-        emptyMsg : _this._strings['9d1ead73e678fa2f51a70a933b0bf017'],
-        pageSize : 100,
-        xns : Roo,
-        xtype : 'PagingToolbar'
-       },
-       dataSource : {
-        proxy : {
-         '|xns' : 'Roo.data',
-         method : 'GET',
-         url : baseURL + '/Roo/cms_templatestr.php',
-         xns : Roo.data,
-         xtype : 'HttpProxy'
-        },
-        reader : {
-         '|xns' : 'Roo.data',
-         fields : [
-             {
-                 'name': 'id',
-                 'type': 'int'
-             },
-             {
-                 'name': 'shortname',
-                 'type': 'string'
-             },
-            
-         ],
-         id : 'id',
-         root : 'data',
-         totalProperty : 'total',
-         xns : Roo.data,
-         xtype : 'JsonReader'
-        },
-        '|xns' : 'Roo.data',
-        remoteSort : true,
-        sortInfo : { field : 'shortname', direction: 'ASC' },
-        xns : Roo.data,
-        xtype : 'Store',
+       loader : {
+        baseParams : { _tree : 1 },
+        dataUrl : baseURL + '/Roo/cms_templatestr',
+        requestMethod : 'GET',
+        xns : Roo.tree,
+        '|xns' : 'Roo.tree',
+        xtype : 'TreeLoader',
         listeners : {
-         beforeload : function (_self, o)
+         beforeload : function (This, node, callback)
           {
-             
-              var sn = _this.treepanel.tree.getSelectionModel().getSelectedNode();
-          
-              if (!sn || typeof(sn.attributes) == 'undefined' || typeof(sn.attributes.leaf) == 'undefined' || !sn.attributes.leaf) { 
-                  _this.grid.ds.removeAll();
-                  return false;
-              }
-          
-              o.params = o.params || {};
-              o.params.lang = sn.parentNode.attributes.id ;
-              o.params.template_id = sn.attributes.id * 1;
-              o.params.active = 1;
-              o.params['!src_id'] = 0;
+              // set some params.
+              Roo.log(node);
+              this.baseParams._tree = 1;
               
-              if(sn.attributes.on_table){
-                  o.params.on_table = sn.attributes.on_table;
-              }
-              o.params.sort= 'src_id_txt';
-              o.params.dir = 'ASC';
+              //this.baseParams.category = node.attributes.category;
           },
-         update : function (_self, rec, operation)
+         loadexception : function (This, node, response)
           {
-              Roo.log(operation);
-              
-              if (operation != 'commit') {
-                  return;
-              }
-              
-          
-              _this.grid.getView().el.mask("Saving");
-              new Pman.Request({
-                  url : baseURL + '/Roo/cms_templatestr',
-                  method: 'POST',
-                  params : {
-                      id : rec.get('id'),
-                      txt : rec.get('txt')
-                  },
-                  success : function()
-                  {
-                      _this.grid.getView().el.unmask();
-                          //g.getDataSource().reload();
-                  },
-                  failure : function()
-                  {
-                      _this.grid.getView().el.unmask();
-                      Roo.MessageBox.alert("Error", "There was a problem saving the data - try reloading");
-                   }
-                      
-              });
-              
+              Roo.MessageBox.alert("Error", "Problem loading tree");
           }
-        },
-        items : [
-
-        ]
-
-       },
-       '|xns' : 'Roo.grid',
+        }
+       }
+      }
+     },
+     {
+      background : false,
+      fitContainer : true,
+      fitToframe : true,
+      region : 'center',
+      tableName : 'Page',
+      title : _this._strings['193cfc9be3b995831c6af2fea6650e60'] /* Page */,
+      xns : Roo,
+      '|xns' : 'Roo',
+      xtype : 'GridPanel',
+      listeners : {
+       activate : function() {
+            _this.panel = this;
+            if (_this.grid) {
+                _this.grid.footer.onClick('first');
+            }
+        }
+      },
+      grid : {
        autoExpandColumn : 'txt',
        clicksToEdit : 1,
        loadMask : true,
        xns : Roo.grid,
+       '|xns' : 'Roo.grid',
        xtype : 'EditorGrid',
-       colModel : [
-         {
-          '|xns' : 'Roo.grid',
-          dataIndex : 'src_id_txt',
-          header : _this._strings['0a52da7a03a6de3beefe54f8c03ad80d'],
-          renderer : function(v,x,r) { 
-          
-           var c = '#666';
-                  if (r.data.updated  < r.data.src_id_origupdated) {
-                      c = 'red';
-                  }
-                  
-          //        return '<div style="color:'+c+'";>' +r.data.tableid + ':' + v + '</div>';
-                  return String.format('<div style="color:'+c+'";>{0}</div>', v)
-          
-          },
-          width : 200,
-          xns : Roo.grid,
-          xtype : 'ColumnModel'
-         },
-{
-          editor : {
-           field : {
-            '|xns' : 'Roo.form',
-            allowBlank : false,
-            xns : Roo.form,
-            xtype : 'TextField'
-           },
-           '|xns' : 'Roo.grid',
-           xns : Roo.grid,
-           xtype : 'GridEditor',
-           items : [
-
-           ]
-
-          },
-          '|xns' : 'Roo.grid',
-          dataIndex : 'txt',
-          header : _this._strings['6dd08874f83507e9c7b23f1a46b7fa7c'],
-          renderer : function(v,x,r) { 
-          
-           var c = '#666';
-                  if (r.data.updated  < r.data.src_id_updated) {
-                      c = 'red';
-                  }
-                  
-          //        return '<div style="color:'+c+'";>' +r.data.tableid + ':' + v + '</div>';
-                  return String.format('<div style="color:'+c+'";>{0}</div>', v)
-          
-          },
-          width : 200,
-          xns : Roo.grid,
-          xtype : 'ColumnModel',
-          items : [
-
-          ]
-
-         }
-       ],
        listeners : {
         afteredit : function (e)
          {
@@ -482,50 +417,233 @@ Pman.Tab.CmsTranslateTemplates = new Roo.XComponent({
          },
         rowdblclick : function (_self, rowIndex, e)
          {
-             if (!_this.dialog) return;
+             if (!_this.dialog) {
+                 return;
+             }
              _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
                  _this.grid.footer.onClick('first');
              }); 
          }
        },
-       items : [
-
-       ]
-
-      },
-      '|xns' : 'Roo',
-      background : false,
-      fitContainer : true,
-      fitToframe : true,
-      region : 'center',
-      tableName : 'Page',
-      title : _this._strings['193cfc9be3b995831c6af2fea6650e60'],
-      xns : Roo,
-      xtype : 'GridPanel',
-      listeners : {
-       activate : function() {
-            _this.panel = this;
-            if (_this.grid) {
+       footer : {
+        displayInfo : true,
+        displayMsg : _this._strings['e2f9d206562d8f5ea421ad51100f7151'] /* Displaying petition_entry{0} - {1} of {2} */,
+        emptyMsg : _this._strings['9d1ead73e678fa2f51a70a933b0bf017'] /* Not Found */,
+        pageSize : 100,
+        xns : Roo,
+        '|xns' : 'Roo',
+        xtype : 'PagingToolbar'
+       },
+       toolbar : {
+        xns : Roo,
+        '|xns' : 'Roo',
+        xtype : 'Toolbar',
+        items  : [
+         {
+          emptyText : _this._strings['e3d388b2c43e5ba0905702620ae2abc1'] /* Search for */,
+          xns : Roo.form,
+          '|xns' : 'Roo.form',
+          xtype : 'TextField',
+          listeners : {
+           render : function (_self)
+            {
+                _this.searchBox = this;
+            },
+           specialkey : function (_self, e)
+            {
+            _this.grid.footer.onClick('first');
+            }
+          }
+         },
+         {
+          cls : 'x-btn-icon',
+          icon : rootURL + '/Pman/templates/images/search.gif',
+          xns : Roo.Toolbar,
+          '|xns' : 'Roo.Toolbar',
+          xtype : 'Button',
+          listeners : {
+           click : function (_self, e)
+            {
+            _this.grid.footer.onClick('first');
+            }
+          }
+         },
+         {
+          cls : 'x-btn-icon',
+          icon : rootURL + '/Pman/templates/images/edit-clear.gif',
+          xns : Roo.Toolbar,
+          '|xns' : 'Roo.Toolbar',
+          xtype : 'Button',
+          listeners : {
+           click : function (_self, e)
+            {
+                _this.searchBox.setValue('');
+                
                 _this.grid.footer.onClick('first');
             }
+          }
+         }
+        ]
+       },
+       dataSource : {
+        remoteSort : true,
+        sortInfo : { field : 'src_id_txt', direction: 'ASC' },
+        xns : Roo.data,
+        '|xns' : 'Roo.data',
+        xtype : 'Store',
+        listeners : {
+         beforeload : function (_self, o)
+          {
+             
+              var sn = _this.treepanel.tree.getSelectionModel().getSelectedNode();
+          
+              if (!sn || typeof(sn.attributes) == 'undefined' || typeof(sn.attributes.leaf) == 'undefined' || !sn.attributes.leaf) { 
+                  _this.grid.ds.removeAll();
+                  return false;
+              }
+          
+              o.params = o.params || {};
+              o.params.lang = sn.parentNode.attributes.id ;
+              o.params.template_id = sn.attributes.id * 1;
+              o.params.active = 1;
+              o.params['!src_id'] = 0;
+              
+              if (_this.searchBox && _this.searchBox.getValue().length) { 
+                  o.params['_search_txt'] = _this.searchBox.getValue();
+              }
+              
+              
+              if(sn.attributes.on_table){
+                  o.params.on_table = sn.attributes.on_table;
+              }
+              
+          },
+         update : function (_self, rec, operation)
+          {
+              Roo.log(operation);
+              
+              if (operation != 'commit') {
+                  return;
+              }
+              
+          
+              _this.grid.getView().el.mask("Saving");
+              new Pman.Request({
+                  url : baseURL + '/Roo/cms_templatestr',
+                  method: 'POST',
+                  params : {
+                      id : rec.get('id'),
+                      txt : rec.get('txt')
+                  },
+                  success : function()
+                  {
+                      _this.grid.getView().el.unmask();
+                          //g.getDataSource().reload();
+                  },
+                  failure : function()
+                  {
+                      _this.grid.getView().el.unmask();
+                      Roo.MessageBox.alert("Error", "There was a problem saving the data - try reloading");
+                   }
+                      
+              });
+              
+          }
+        },
+        proxy : {
+         method : 'GET',
+         url : baseURL + '/Roo/cms_templatestr.php',
+         xns : Roo.data,
+         '|xns' : 'Roo.data',
+         xtype : 'HttpProxy'
+        },
+        reader : {
+         fields : [
+             {
+                 'name': 'id',
+                 'type': 'int'
+             },
+             {
+                 'name': 'shortname',
+                 'type': 'string'
+             }
+            
+         ],
+         id : 'id',
+         root : 'data',
+         totalProperty : 'total',
+         xns : Roo.data,
+         '|xns' : 'Roo.data',
+         xtype : 'JsonReader'
         }
-      },
-      items : [
-
-      ]
-
+       },
+       cm : [
+        {
+         dataIndex : 'src_id_txt',
+         header : _this._strings['0a52da7a03a6de3beefe54f8c03ad80d'] /* Original */,
+         renderer : function(v,x,r) 
+         {
+             var c = '#666';
+             if (r.data.updated  < r.data.src_id_updated) {
+                 c = 'red';
+             }
+             
+             return String.format('<div style="color:'+c+'";>{0}</div>', v)
+         
+         },
+         width : 200,
+         xns : Roo.grid,
+         '|xns' : 'Roo.grid',
+         xtype : 'ColumnModel'
+        },
+        {
+         dataIndex : 'txt',
+         header : _this._strings['6dd08874f83507e9c7b23f1a46b7fa7c'] /* Translation */,
+         renderer : function(v,x,r) 
+         { 
+         
+             var c = '#666';
+             if (r.data.updated  < r.data.src_id_updated) {
+                 c = 'red';
+             }
+             
+             return String.format('<div style="color:'+c+'";>{0}</div>', v)
+         
+         },
+         width : 200,
+         xns : Roo.grid,
+         '|xns' : 'Roo.grid',
+         xtype : 'ColumnModel',
+         editor : {
+          xns : Roo.grid,
+          '|xns' : 'Roo.grid',
+          xtype : 'GridEditor',
+          field : {
+           allowBlank : false,
+           xns : Roo.form,
+           '|xns' : 'Roo.form',
+           xtype : 'TextField'
+          }
+         }
+        },
+        {
+         dataIndex : 'src_id_mdsum',
+         header : _this._strings['1bc29b36f623ba82aaf6724fd3b16718'] /* md5 */,
+         hidden : true,
+         renderer : function(v,x,r) 
+         {
+             return v ? v : '';
+         
+         },
+         width : 250,
+         xns : Roo.grid,
+         '|xns' : 'Roo.grid',
+         xtype : 'ColumnModel'
+        }
+       ]
+      }
      }
     ]
-
-   },
-   '|xns' : 'Roo',
-   region : 'center',
-   title : _this._strings['dc00a593c8be0a664ba934335b093154'],
-   xns : Roo,
-   xtype : 'NestedLayoutPanel',
-   items : [
-
-   ]
-
+   }
   };  }
 });