PHP8 fix
[Pman.Cms] / Pman.Tab.CmsTranslateTemplates.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Roo.namespace('Pman.Tab');
6
7 Pman.Tab.CmsTranslateTemplates = new Roo.XComponent({
8
9  _strings : {
10   '0a52da7a03a6de3beefe54f8c03ad80d' :"Original",
11   '0b8d92bc19b720bb1065649535463409' :"Translations",
12   '9d1ead73e678fa2f51a70a933b0bf017' :"Not Found",
13   '801ab24683a4a8c433c6eb40c48bcd9d' :"Download",
14   '6dd08874f83507e9c7b23f1a46b7fa7c' :"Translation",
15   'e3d388b2c43e5ba0905702620ae2abc1' :"Search for",
16   'e2f9d206562d8f5ea421ad51100f7151' :"Displaying petition_entry{0} - {1} of {2}",
17   'dc00a593c8be0a664ba934335b093154' :"Translate Templates",
18   'cd6ae20e52d83f601c5fa12b66f0f6d0' :"Rescan",
19   '91412465ea9169dfd901dd5e7c96dd99' :"Upload",
20   '4d1c8263ba1036754f8db14a98f9f006' :"Reload",
21   'f2a6c498fb90ee345d997f888fce3b18' :"Delete",
22   '03c2e7e41ffc181a4e84080b4710e81e' :"New",
23   '193cfc9be3b995831c6af2fea6650e60' :"Page",
24   '1bc29b36f623ba82aaf6724fd3b16718' :"md5"
25  },
26
27   part     :  ["Cms", "TranslateTemplates" ],
28   order    : '800-Pman.Tab.CmsTranslateTemplates',
29   region   : 'center',
30   parent   : 'Pman.Tab.Cms',
31   name     : "Pman.Tab.CmsTranslateTemplates",
32   disabled : false, 
33   permname : '', 
34   _tree : function(_data)
35   {
36    var _this = this;
37    var MODULE = this;
38    return {
39    xtype : 'NestedLayoutPanel',
40    region : 'center',
41    title : _this._strings['dc00a593c8be0a664ba934335b093154'] /* Translate Templates */,
42    xns : Roo,
43    '|xns' : 'Roo',
44    layout : {
45     xtype : 'BorderLayout',
46     xns : Roo,
47     '|xns' : 'Roo',
48     center : {
49      xtype : 'LayoutRegion',
50      xns : Roo,
51      '|xns' : 'Roo'
52     },
53     west : {
54      xtype : 'LayoutRegion',
55      split : true,
56      width : 350,
57      xns : Roo,
58      '|xns' : 'Roo'
59     },
60     items  : [
61      {
62       xtype : 'TreePanel',
63       region : 'west',
64       listeners : {
65        render : function (_self)
66         {
67             _this.treepanel = _self;
68         }
69       },
70       xns : Roo,
71       '|xns' : 'Roo',
72       toolbar : {
73        xtype : 'Toolbar',
74        xns : Roo,
75        '|xns' : 'Roo',
76        items  : [
77         {
78          xtype : 'Button',
79          text : _this._strings['03c2e7e41ffc181a4e84080b4710e81e'] /* New */,
80          listeners : {
81           click : function (_self, e)
82            {
83                Pman.Dialog.CmsLanguagePick.show( {  }, function(lang) {
84                    
85                    new Pman.Request({
86                        url : baseURL + '/Roo/cms_templatestr',
87                        method : 'POST',
88                        params : {
89                            _rescan : lang
90                        }, 
91                        success : function()
92                        {
93                            _this.treepanel.tree.getRootNode().reload();
94                        }
95                    });
96                
97                });
98                
99            }
100          },
101          xns : Roo.Toolbar,
102          '|xns' : 'Roo.Toolbar'
103         },
104         {
105          xtype : 'Separator',
106          xns : Roo.Toolbar,
107          '|xns' : 'Roo.Toolbar'
108         },
109         {
110          xtype : 'Button',
111          text : _this._strings['f2a6c498fb90ee345d997f888fce3b18'] /* Delete */,
112          listeners : {
113           click : function (_self, e)
114            {
115                var tree = _this.treepanel.tree;
116                var sn  = tree.getSelectionModel().getSelectedNode();
117            
118                if (!sn || typeof(sn.attributes.language) == 'undefined' || !sn.attributes.language) {
119                    Roo.MessageBox.alert("Error", "Select a language");
120                    return;
121                }
122            
123                 Roo.MessageBox.confirm("Confirm", "Are sure you want to delete the language", function (v){
124                        if (v != 'yes') {
125                            return;
126                        }
127                        Roo.MessageBox.alert("Not yet", "not done yet");
128                        return;
129                        Roo.Ajax.request({
130                            url : baseURL + '/Roo/cms_language.php',
131                            method: 'POST',
132                            params : {
133                                _delete : _t.selectedNode.id 
134                            },
135                            success : function()
136                            {
137                               _this.treepanel.tree.getRootNode().reload();
138                                //g.getDataSource().reload();
139                            },
140                            failure : function()
141                            {
142                                Roo.MessageBox.alert("Error", 
143                                    "There was a problem saving the data - try reloading");
144                                
145                            }
146                            
147                        });
148                        
149                        
150                        
151                        
152                    });
153            }
154          },
155          xns : Roo.Toolbar,
156          '|xns' : 'Roo.Toolbar'
157         },
158         {
159          xtype : 'Separator',
160          xns : Roo.Toolbar,
161          '|xns' : 'Roo.Toolbar'
162         },
163         {
164          xtype : 'Button',
165          text : _this._strings['cd6ae20e52d83f601c5fa12b66f0f6d0'] /* Rescan */,
166          listeners : {
167           click : function (_self, e)
168            {
169                var tree = _this.treepanel.tree;
170                Roo.log(tree);
171                var sn  = tree.getSelectionModel().getSelectedNode();
172            
173                if (!sn) {
174                    Roo.MessageBox.alert("Error", "Select a node");
175                    return;
176                }
177                
178                var syncTemplate = function(){
179                    new Pman.Request({
180                        url : baseURL + '/Cms/UpdateBjsTemplates',
181                        method : 'GET',
182                        mask : 'Processing...',
183                        timeout : 9000000,
184                        success : function()
185                        {
186                            _this.treepanel.tree.getRootNode().reload();
187                        }
188                    });
189                
190                };
191                
192                
193                var syncLanguage = function(){
194                    new Pman.Request({
195                        url : baseURL + '/Roo/cms_templatestr',
196                        method : 'POST',
197                        mask : 'Processing...',
198                        params : {
199                            _rescan : sn.attributes.id
200                        }, 
201                        success : function()
202                        {
203                            _this.treepanel.tree.getRootNode().reload();
204                        }
205                    });
206                };
207                
208                if(typeof(sn.isRoot) != 'undefined' && sn.isRoot){
209                    syncTemplate();
210                    return;
211                }
212                
213                if(typeof(sn.attributes.language) != 'undefined' && sn.attributes.language){
214                    syncLanguage();
215                    return;
216                }
217                
218                
219                
220                
221                
222            }
223          },
224          xns : Roo.Toolbar,
225          '|xns' : 'Roo.Toolbar'
226         },
227         {
228          xtype : 'Separator',
229          xns : Roo.Toolbar,
230          '|xns' : 'Roo.Toolbar'
231         },
232         {
233          xtype : 'Button',
234          text : _this._strings['91412465ea9169dfd901dd5e7c96dd99'] /* Upload */,
235          listeners : {
236           click : function (_self, e)
237            {
238                
239                
240                Pman.Dialog.Image.show({
241                   _url : baseURL + '/Cms/Import/Cms_templatestr' 
242                 
243                }, function() {
244                     _this.treepanel.tree.getRootNode().reload();
245                });
246                
247                
248                
249            }
250          },
251          xns : Roo.Toolbar,
252          '|xns' : 'Roo.Toolbar'
253         },
254         {
255          xtype : 'Button',
256          text : _this._strings['801ab24683a4a8c433c6eb40c48bcd9d'] /* Download */,
257          listeners : {
258           click : function (_self, e)
259            {
260                var tree = _this.treepanel.tree;
261            
262                var sn  = tree.getSelectionModel().getSelectedNode();
263                
264                p = {
265                    csvCols : 'src_id_mdsum,template_id_view_name,template_id_template,src_id_txt,lang,txt',
266                    csvTitles : 'Code,Module,Template,Original,Language,Translation',
267                    limit : 9999,
268                    sort: 'template_id_view_name,template_id_template,src_id_txt',
269                    dir: 'ASC'
270                };
271                if (!sn ||  sn.id == 'transtree') {
272                    Roo.MessageBox.alert("Error", "Select language, module or page");
273                    return;
274                }
275                if (typeof(sn.id) == 'number') {
276                    p.template_id = sn.id;
277                    p.lang = sn.parentNode.attributes.id;
278                    
279                } else {
280                    
281                    
282                    if (sn.id.match(/^table:/)) {
283                        var sns = sn.id.split(':');
284                        p.lang = sns[1];
285                        p.on_table = sns[2];
286                        p.csvCols = 'src_id_mdsum,on_table,on_id,on_col,src_id_txt,lang,txt';
287                        p.csvTitles = 'Code,Table,Table id,Column,Language,Translation';
288                    }
289                    
290                    if (sn.id.match(/^view:/)) {
291                        var sns = sn.id.split(':');
292                        p.lang = sns[1];
293                        p.template_id_view_name = sns[2];
294                        
295                    }
296                    if (sn.id.match(/^lang:/)) {
297                        var sns = sn.id.split(':');
298                        p.lang = sns[1];
299            
300                   }
301               }
302                // transtree
303                // view: {lang} : {view_name}
304                // lang:
305                 
306                new Pman.Download({
307                    url : baseURL + '/Roo/Cms_templatestr',
308                    params : p,
309                    method : 'GET' 
310                });
311                
312                
313                
314                
315                
316            }
317          },
318          xns : Roo.Toolbar,
319          '|xns' : 'Roo.Toolbar'
320         },
321         {
322          xtype : 'Fill',
323          xns : Roo.Toolbar,
324          '|xns' : 'Roo.Toolbar'
325         },
326         {
327          xtype : 'Button',
328          text : _this._strings['4d1c8263ba1036754f8db14a98f9f006'] /* Reload */,
329          listeners : {
330           click : function (_self, e)
331            {
332                _this.treepanel.tree.getRootNode().reload();
333                
334            }
335          },
336          xns : Roo.Toolbar,
337          '|xns' : 'Roo.Toolbar'
338         }
339        ]
340       },
341       tree : {
342        xtype : 'TreePanel',
343        containerScroll : false,
344        rootVisible : true,
345        xns : Roo.tree,
346        '|xns' : 'Roo.tree',
347        root : {
348         xtype : 'AsyncTreeNode',
349         id : 'transtree',
350         text : _this._strings['0b8d92bc19b720bb1065649535463409'] /* Translations */,
351         xns : Roo.tree,
352         '|xns' : 'Roo.tree'
353        },
354        selModel : {
355         xtype : 'DefaultSelectionModel',
356         listeners : {
357          selectionchange : function (_self, node)
358           {
359               Roo.log(node);
360               
361               //if (node.id.split('/').length < 2) {
362               //    return;
363              // }
364               (function() {
365                   _this.grid.footer.onClick('first');
366               }).defer(100);
367               
368           }
369         },
370         xns : Roo.tree,
371         '|xns' : 'Roo.tree'
372        },
373        loader : {
374         xtype : 'TreeLoader',
375         baseParams : { _tree : 1 },
376         dataUrl : baseURL + '/Roo/cms_templatestr',
377         requestMethod : 'GET',
378         listeners : {
379          beforeload : function (This, node, callback)
380           {
381               // set some params.
382               Roo.log(node);
383               this.baseParams._tree = 1;
384               
385               //this.baseParams.category = node.attributes.category;
386           },
387          loadexception : function (This, node, response)
388           {
389               Roo.MessageBox.alert("Error", "Problem loading tree");
390           }
391         },
392         xns : Roo.tree,
393         '|xns' : 'Roo.tree'
394        }
395       }
396      },
397      {
398       xtype : 'GridPanel',
399       background : false,
400       fitContainer : true,
401       fitToframe : true,
402       region : 'center',
403       tableName : 'Page',
404       title : _this._strings['193cfc9be3b995831c6af2fea6650e60'] /* Page */,
405       listeners : {
406        activate : function() {
407             _this.panel = this;
408             if (_this.grid) {
409                 _this.grid.footer.onClick('first');
410             }
411         }
412       },
413       xns : Roo,
414       '|xns' : 'Roo',
415       grid : {
416        xtype : 'EditorGrid',
417        autoExpandColumn : 'txt',
418        clicksToEdit : 1,
419        loadMask : true,
420        listeners : {
421         afteredit : function (e)
422          {
423              e.record.commit();
424          },
425         beforeedit : function (e)
426          {   
427              /*if (e.record.data.src_id_txt.indexOf('<') > -1) {
428                 // console.log("HTML EDITOR!!");
429                  Pman.Dialog.CmsTranslateEditor.show(e.record);
430                  return false;
431              }*/
432              
433              var str=e.record.data.src_id_txt;
434              var patt=/{(.*?)}/g;
435              
436              Roo.log(str.length);
437              
438              
439              if(patt.test(str)){
440                  e.cancel = true;
441                  Pman.Dialog.CmsTranslateTemplates.show(e.record.data, function(v){
442                      Roo.log(v);
443                      e.value = v.txt;
444                      e.record.set('txt', v.txt);
445                      e.record.commit();
446                  });
447                  /*
448                  Roo.MessageBox.prompt('WARNING', 'This text is with {TEMPLATE VARIABLE}, PLEASE BE CAREFUL EDITING. What\'s change? '+str, function(btn, text){
449                      if (btn == 'ok'){
450                          e.value = text;
451                          e.record.set('txt', text);
452                          e.record.commit();
453                      }
454                  });*/
455                  return;
456              }
457              
458              if(str.length > 150){
459                  e.cancel = true;
460                  Pman.Dialog.CmsTranslateTemplates.show(e.record.data, function(v){
461                      e.value = v.txt;
462                      e.record.set('txt', v.txt);
463                      e.record.commit();
464                  });
465                  /*
466                  Roo.MessageBox.prompt('WARNING', 'This text is with {TEMPLATE VARIABLE}, PLEASE BE CAREFUL EDITING. What\'s change? '+str, function(btn, text){
467                      if (btn == 'ok'){
468                          e.value = text;
469                          e.record.set('txt', text);
470                          e.record.commit();
471                      }
472                  });*/
473                  return;
474              }
475              
476          
477              if (e.record.data.txt.replace(/\s+/, '').length) {
478                  return true;
479              }
480              
481              var tl = _this.treepanel.tree.getSelectionModel().getSelectedNode().parentNode.attributes.id;
482              // mapping?
483              
484              tl = (tl == 'zh_HK') ? 'zh-TW' : tl;
485              
486              if (tl == 'en' && !e.value.length) {
487          
488                  e.value = e.record.data.src_id_txt;
489                  e.record.set('txt', e.record.data.src_id_txt);
490                  return true;
491              }
492              
493              Pman.GoogleTranslate(e.record.data.src_id_txt, "en", tl, function(result) {
494                 // Roo.log(result);
495                  _this.grid.activeEditor.setValue(result);
496                  //console.log(result.translation);
497              });
498              
499          
500              
501              return true;
502          },
503         render : function() 
504          {
505              _this.grid = this; 
506              //_this.dialog = Pman.Dialog.FILL_IN
507              if (_this.panel.active) {
508                  this.footer.onClick('first');
509                // this.ds.onc.onClick('first');
510              }
511          },
512         rowdblclick : function (_self, rowIndex, e)
513          {
514              if (!_this.dialog) {
515                  return;
516              }
517              _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
518                  _this.grid.footer.onClick('first');
519              }); 
520          }
521        },
522        xns : Roo.grid,
523        '|xns' : 'Roo.grid',
524        footer : {
525         xtype : 'PagingToolbar',
526         displayInfo : true,
527         displayMsg : _this._strings['e2f9d206562d8f5ea421ad51100f7151'] /* Displaying petition_entry{0} - {1} of {2} */,
528         emptyMsg : _this._strings['9d1ead73e678fa2f51a70a933b0bf017'] /* Not Found */,
529         pageSize : 100,
530         xns : Roo,
531         '|xns' : 'Roo'
532        },
533        toolbar : {
534         xtype : 'Toolbar',
535         xns : Roo,
536         '|xns' : 'Roo',
537         items  : [
538          {
539           xtype : 'TextField',
540           emptyText : _this._strings['e3d388b2c43e5ba0905702620ae2abc1'] /* Search for */,
541           listeners : {
542            render : function (_self)
543             {
544                 _this.searchBox = this;
545             },
546            specialkey : function (_self, e)
547             {
548             _this.grid.footer.onClick('first');
549             }
550           },
551           xns : Roo.form,
552           '|xns' : 'Roo.form'
553          },
554          {
555           xtype : 'Button',
556           cls : 'x-btn-icon',
557           icon : rootURL + '/Pman/templates/images/search.gif',
558           listeners : {
559            click : function (_self, e)
560             {
561             _this.grid.footer.onClick('first');
562             }
563           },
564           xns : Roo.Toolbar,
565           '|xns' : 'Roo.Toolbar'
566          },
567          {
568           xtype : 'Button',
569           cls : 'x-btn-icon',
570           icon : rootURL + '/Pman/templates/images/edit-clear.gif',
571           listeners : {
572            click : function (_self, e)
573             {
574                 _this.searchBox.setValue('');
575                 
576                 _this.grid.footer.onClick('first');
577             }
578           },
579           xns : Roo.Toolbar,
580           '|xns' : 'Roo.Toolbar'
581          }
582         ]
583        },
584        dataSource : {
585         xtype : 'Store',
586         remoteSort : true,
587         sortInfo : { field : 'src_id_txt', direction: 'ASC' },
588         listeners : {
589          beforeload : function (_self, o)
590           {
591              
592               var sn = _this.treepanel.tree.getSelectionModel().getSelectedNode();
593           
594               if (!sn || typeof(sn.attributes) == 'undefined' || typeof(sn.attributes.leaf) == 'undefined' || !sn.attributes.leaf) { 
595                   _this.grid.ds.removeAll();
596                   return false;
597               }
598           
599               o.params = o.params || {};
600               
601               //var pn = sn.parentNode.attributes.id.split(':')[1]; // should be view:en:{module}
602               
603               
604               o.params.lang = sn.parentNode.attributes.id;
605               o.params.template_id = sn.attributes.id * 1;
606               o.params.active = 1;
607               o.params['!src_id'] = 0;
608               
609               if (_this.searchBox && _this.searchBox.getValue().length) { 
610                   o.params['_search_txt'] = _this.searchBox.getValue();
611               }
612               
613               
614               if(sn.attributes.on_table){
615                   o.params.on_table = sn.attributes.on_table;
616               }
617               
618           },
619          update : function (_self, rec, operation)
620           {
621               Roo.log(operation);
622               
623               if (operation != 'commit') {
624                   return;
625               }
626               
627           
628               _this.grid.getView().el.mask("Saving");
629               new Pman.Request({
630                   url : baseURL + '/Roo/cms_templatestr',
631                   method: 'POST',
632                   params : {
633                       id : rec.get('id'),
634                       txt : rec.get('txt')
635                   },
636                   success : function()
637                   {
638                       _this.grid.getView().el.unmask();
639                           //g.getDataSource().reload();
640                   },
641                   failure : function()
642                   {
643                       _this.grid.getView().el.unmask();
644                       Roo.MessageBox.alert("Error", "There was a problem saving the data - try reloading");
645                    }
646                       
647               });
648               
649           }
650         },
651         xns : Roo.data,
652         '|xns' : 'Roo.data',
653         proxy : {
654          xtype : 'HttpProxy',
655          method : 'GET',
656          url : baseURL + '/Roo/cms_templatestr.php',
657          xns : Roo.data,
658          '|xns' : 'Roo.data'
659         },
660         reader : {
661          xtype : 'JsonReader',
662          fields : [
663              {
664                  'name': 'id',
665                  'type': 'int'
666              },
667              {
668                  'name': 'shortname',
669                  'type': 'string'
670              }
671             
672          ],
673          id : 'id',
674          root : 'data',
675          totalProperty : 'total',
676          xns : Roo.data,
677          '|xns' : 'Roo.data'
678         }
679        },
680        cm : [
681         {
682          xtype : 'ColumnModel',
683          dataIndex : 'src_id_txt',
684          header : _this._strings['0a52da7a03a6de3beefe54f8c03ad80d'] /* Original */,
685          renderer : function(v,x,r) 
686          {
687              var c = '#666';
688              if (r.data.updated  < r.data.src_id_updated) {
689                  c = 'red';
690              }
691              
692              return String.format('<div style="color:'+c+'";>{0}</div>', v)
693          
694          },
695          width : 200,
696          xns : Roo.grid,
697          '|xns' : 'Roo.grid'
698         },
699         {
700          xtype : 'ColumnModel',
701          dataIndex : 'txt',
702          header : _this._strings['6dd08874f83507e9c7b23f1a46b7fa7c'] /* Translation */,
703          renderer : function(v,x,r) 
704          { 
705          
706              var c = '#666';
707              if (r.data.updated  < r.data.src_id_updated) {
708                  c = 'red';
709              }
710              
711              return String.format('<div style="color:'+c+'";>{0}</div>', v)
712          
713          },
714          width : 200,
715          xns : Roo.grid,
716          '|xns' : 'Roo.grid',
717          editor : {
718           xtype : 'GridEditor',
719           xns : Roo.grid,
720           '|xns' : 'Roo.grid',
721           field : {
722            xtype : 'TextField',
723            allowBlank : false,
724            xns : Roo.form,
725            '|xns' : 'Roo.form'
726           }
727          }
728         },
729         {
730          xtype : 'ColumnModel',
731          dataIndex : 'src_id_mdsum',
732          header : _this._strings['1bc29b36f623ba82aaf6724fd3b16718'] /* md5 */,
733          hidden : true,
734          renderer : function(v,x,r) 
735          {
736              return v ? v : '';
737          
738          },
739          width : 250,
740          xns : Roo.grid,
741          '|xns' : 'Roo.grid'
742         }
743        ]
744       }
745      }
746     ]
747    }
748   };  }
749 });