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