--- /dev/null
+{
+ "id": "roo-file-56",
+ "name": "Pman.Tab.AdminTranslations",
+ "parent": "Pman.Tab.Admin",
+ "title": "Admin - Translations",
+ "path": "/home/alan/gitlive/Pman.Admin/Pman.Tab.AdminTranslations.bjs",
+ "items": [
+ {
+ "region": "center",
+ "title": "Translate App",
+ "xtype": "NestedLayoutPanel",
+ "|xns": "Roo",
+ "items": [
+ {
+ "|xns": "Roo",
+ "xtype": "BorderLayout",
+ "*prop": "layout",
+ "items": [
+ {
+ "*prop": "center",
+ "alwaysShowTabs": true,
+ "tabPosition": "top",
+ "xtype": "LayoutRegion",
+ "|xns": "Roo"
+ },
+ {
+ "listeners": {
+ "|activate": "function() {\n _this.panel = this;\n if (_this.grid) {\n _this.grid.getDataSource().reload(); \n }\n}"
+ },
+ "background": true,
+ "fitContainer": true,
+ "fitToframe": true,
+ "region": "center",
+ "title": "Text in interface",
+ "xtype": "GridPanel",
+ "|xns": "Roo",
+ "items": [
+ {
+ "listeners": {
+ "|render": "function() { \n _this.grid = this; \n //_this.dialog = Pman.Dialog.FILL_IN\n if (_this.panel.active) {\n _this.grid.getDataSource().reload(); \n }\n}",
+ "|beforeedit": "function(e) {\n console.log('beforeedit');\n //if (e.record.get('origtxt').indexOf('<') > -1) {\n // console.log(\"HTML EDITOR!!\");\n \n // return false;\n //}\n if (e.record.get('txt').replace(/\\s+/, '').length) {\n return true;\n }\n if (e.record.get('suggest').length) {\n e.record.set('txt', e.record.get('suggest'));\n // _this.saveRec(e.record);\n return;\n }\n \n \n \n \n var tl = e.record.get('id').split('/')[0];\n \n tl = (tl == 'zh_HK') ? 'zh-TW' : tl; \n tl = tl.replace('_', '-');\n var rec = e.record;\n \n \n \n Pman.gtranslate(e.record.get('origtxt'), 'en', tl, function(result) { \n if (typeof(result) == 'object') { //error\n return; \n }\n \n if (_this.grid.activeEditor) {\n _this.grid.activeEditor.setValue(result);\n } else {\n rec.set('txt',result);\n //_this.saveRec(rec);\n }\n\n //\n \n \n //console.log(result.translation);\n });\n \n \n \n return true;\n } ",
+ "|afteredit": "function (e)\n{\n var saveRec = function(rec)\n {\n var g = _this.grid;\n\n //g.getView().el.mask('Saving');\n Ext.Ajax.request({\n url : baseURL + '/Admin/Translations.php',\n method: 'POST',\n params : {\n id : rec.get('id'),\n txt : rec.get('txt'),\n lang : _this.langCombo.getValue(),\n module : _this.modCombo.getValue()\n },\n success : function()\n {\n //g.getView().el.unmask();\n //g.getDataSource().reload();\n },\n failure : function()\n {\n Ext.Msg.alert(\"Error\", \"There was a problem saving the data - try reloading\");\n // g.getView().el.unmask();\n }\n \n });\n };\n \n saveRec.defer(1000, _this, [ e.record ]);\n}"
+ },
+ "*prop": "grid",
+ "autoExpandColumn": "txt",
+ "clicksToEdit": 1,
+ "loadMask": true,
+ "xtype": "EditorGrid",
+ "|xns": "Roo.grid",
+ "items": [
+ {
+ "*prop": "dataSource",
+ "xtype": "Store",
+ "|reader": "Pman.Readers.Category",
+ "listeners": {
+ "|beforeload": "function (_self, opts)\n{\n\n if (!_this.langCombo || !_this.langCombo.getValue().length) {\n return false;\n }\n if (!_this.modCombo || !_this.modCombo.getValue().length) {\n return false;\n }\n opts.params = {\n lang : _this.langCombo.getValue(),\n module : _this.modCombo.getValue()\n };\n}"
+ },
+ "|xns": "Roo.data",
+ "items": [
+ {
+ "*prop": "proxy",
+ "xtype": "HttpProxy",
+ "method": "GET",
+ "|url": "baseURL + '/Admin/Translations.php'",
+ "listeners": {},
+ "|xns": "Roo.data"
+ },
+ {
+ "xtype": "JsonReader",
+ "|xns": "Roo.data",
+ "*prop": "reader",
+ "root": "data",
+ "totalProperty": "total",
+ "id": "id",
+ "|fields": "[ 'id', 'tablename', 'tableid', 'colname', 'txt', 'lang', { name:'updated', type:'date', dateFormat: 'Y-m-d H:i:s' }, { name:'origupdated', type:'date', dateFormat: 'Y-m-d H:i:s' }, 'origtxt', 'msum', 'suggest' ]",
+ "listeners": {}
+ }
+ ]
+ },
+ {
+ "*prop": "toolbar",
+ "xtype": "Toolbar",
+ "listeners": {},
+ "|xns": "Roo",
+ "items": [
+ {
+ "xtype": "ComboBox",
+ "listeners": {
+ "|render": "function (_self)\n{\n _this.modCombo = _self;\n}",
+ "|select": "function (combo, record, index)\n{\n _this.grid.getDataSource().reload(); \n}"
+ },
+ "valueField": "module",
+ "displayField": "module",
+ "width": 200,
+ "typeAhead": false,
+ "editable": false,
+ "mode": "local",
+ "triggerAction": "all",
+ "emptyText": "Select Module",
+ "selectOnFocus": true,
+ "|xns": "Roo.form",
+ "items": [
+ {
+ "*prop": "store",
+ "xtype": "SimpleStore",
+ "|data": "(function() { \n var modlist = []; \n AppModules = typeof(AppModules) == 'undefined' ? '' : AppModules;\n Roo.each( AppModules.split(','), function(mod) { \n modlist.push( [ mod ] ); \n }); \n return modlist;\n })()",
+ "|fields": "['module']",
+ "|xns": "Roo.data"
+ }
+ ]
+ },
+ {
+ "xtype": "ComboBox",
+ "listeners": {
+ "|select": "function (combo, record, index)\n{\n _this.grid.getDataSource().reload(); \n}",
+ "|render": "function (_self)\n{\n _this.langCombo=_self;\n}"
+ },
+ "valueField": "lang",
+ "displayField": "ldisp",
+ "width": 200,
+ "typeAhead": false,
+ "editable": false,
+ "mode": "local",
+ "triggerAction": "all",
+ "emptyText": "Select Language",
+ "selectOnFocus": true,
+ "|xns": "Roo.form",
+ "items": [
+ {
+ "xtype": "SimpleStore",
+ "|xns": "Roo.data",
+ "*prop": "store",
+ "listeners": {},
+ "|fields": "['lang', 'ldisp']",
+ "|data": "[ [ 'zh_HK' , '\\u7E41\\u4E2D - Trad. Chin. (HK)' ], [ 'zh_CN', '\\u7C21\\u4E2D - Simp. Chin.' ] ]"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "xtype": "ColumnModel",
+ "header": "Name",
+ "width": 150,
+ "dataIndex": "colname",
+ "|renderer": "function(v,x,r) { var c = '#666'; if (r.get('updated') < r.get('origupdated')) { c = 'red'; } return '<div style=\"color:'+c+'\";>' +r.get('tableid')+ ':' + v + '</div>'; }",
+ "listeners": {},
+ "|xns": "Roo.grid",
+ "*prop": "colModel[]"
+ },
+ {
+ "xtype": "ColumnModel",
+ "header": "Original",
+ "width": 300,
+ "dataIndex": "origtxt",
+ "|renderer": "function(v,x,r) { var c = '#666'; if (r.get('updated') < r.get('origupdated')) { c = 'red'; } return '<div style=\"color:' + c+ '\">' + Ext.util.Format.htmlEncode(v) + '</div>'; }",
+ "listeners": {},
+ "|xns": "Roo.grid",
+ "*prop": "colModel[]"
+ },
+ {
+ "*prop": "colModel[]",
+ "dataIndex": "txt",
+ "header": "Translated (Click to Edit)",
+ "width": 150,
+ "xtype": "ColumnModel",
+ "|renderer": "function(v,x,r) { var c = '#666'; if (r.get('updated') < r.get('origupdated')) { c = 'red'; } return '<div style=\"color:' + c+ '\">' + Ext.util.Format.htmlEncode(v) + '</div>'; }",
+ "|xns": "Roo.grid",
+ "items": [
+ {
+ "xtype": "GridEditor",
+ "*prop": "editor",
+ "|xns": "Roo.grid",
+ "listeners": {},
+ "items": [
+ {
+ "xtype": "TextField",
+ "*prop": "field",
+ "|xns": "Roo.form",
+ "listeners": {}
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "listeners": {
+ "|activate": "function() {\n _this.langpanel = this;\n if (_this.langgrid) {\n _this.langgrid.ds.load({});\n }\n}"
+ },
+ "background": true,
+ "fitContainer": true,
+ "fitToframe": true,
+ "region": "center",
+ "tableName": "i18n",
+ "title": "Languages and Countries",
+ "xtype": "GridPanel",
+ "|xns": "Roo",
+ "items": [
+ {
+ "listeners": {
+ "|render": "function() \n{\n _this.langgrid = this; \n //_this.dialog = Pman.Dialog.FILL_IN\n if (_this.langpanel.active) {\n this.ds.load({});\n }\n}",
+ "afteredit": "function (e)\n{\n var saveRec = function(rec)\n {\n var g = _this.grid;\n\n //g.getView().el.mask('Saving');\n Ext.Ajax.request({\n url : baseURL + '/Roo/I18n.php',\n method: 'POST',\n params : {\n id : rec.get('id'),\n lval : rec.get('lval')\n },\n success : function()\n {\n //g.getView().el.unmask();\n //g.getDataSource().reload();\n },\n failure : function()\n {\n Ext.Msg.alert(\"Error\", \"There was a problem saving the data - try reloading\");\n // g.getView().el.unmask();\n }\n \n });\n };\n \n saveRec.defer(1000, _this, [ e.record ]);\n}",
+ "beforeedit": "function(e) {\n console.log('beforeedit');\n //if (e.record.get('origtxt').indexOf('<') > -1) {\n // console.log(\"HTML EDITOR!!\");\n \n // return false;\n //}\n if (e.record.get('lval').replace(/\\s+/, '').length) {\n return true;\n }\n \n \n var tl = _this.langgridCombo.getValue();\n \n tl = (tl == 'zh_HK') ? 'zh-TW' : tl; \n tl = tl.replace('_', '-');\n var rec = e.record;\n \n \n \n Pman.gtranslate(e.record.get('lval_en'), 'en', tl, function(result) { \n if (typeof(result) == 'object') { //error\n return; \n }\n \n if (_this.grid.activeEditor) {\n _this.grid.activeEditor.setValue(result);\n } else {\n rec.set('lval',result);\n //_this.saveRec(rec);\n }\n\n //\n \n \n //console.log(result.translation);\n });\n \n \n \n return true;\n } "
+ },
+ "*prop": "grid",
+ "autoExpandColumn": "lval",
+ "clicksToEdit": 1,
+ "loadMask": true,
+ "xtype": "EditorGrid",
+ "|xns": "Roo.grid",
+ "items": [
+ {
+ "listeners": {
+ "beforeload": "function (_self, options)\n{\n options =options || {};\n options.params =options.params|| {};\n options.params.ltype = _this.langtypeCombo.getValue();\n options.params.inlang = _this.langgridCombo.getValue();\n options.params['query[_with_en]'] = 1;\n if (!options.params.ltype.length || !options.params.inlang.length) {\n return false;\n }\n \n options.params.limit = 9999;\n \n}"
+ },
+ "*prop": "dataSource",
+ "remoteSort": true,
+ "xtype": "Store",
+ "|sortInfo": "{ field : 'lkey', direction: 'ASC' }",
+ "|xns": "Roo.data",
+ "items": [
+ {
+ "*prop": "proxy",
+ "xtype": "HttpProxy",
+ "method": "GET",
+ "|url": "baseURL + '/Roo/i18n.php'",
+ "|xns": "Roo.data"
+ },
+ {
+ "|xns": "Roo.data",
+ "xtype": "JsonReader",
+ "totalProperty": "total",
+ "root": "data",
+ "*prop": "reader",
+ "id": "id",
+ "|fields": "[\n {\n 'name': 'id',\n 'type': 'int'\n },\n {\n 'name': 'ltype',\n 'type': 'string'\n },\n {\n 'name': 'lkey',\n 'type': 'string'\n },\n {\n 'name': 'inlang',\n 'type': 'string'\n },\n {\n 'name': 'lval',\n 'type': 'string'\n }\n]"
+ }
+ ]
+ },
+ {
+ "*prop": "toolbar",
+ "xtype": "Toolbar",
+ "|xns": "Roo",
+ "items": [
+ {
+ "listeners": {
+ "|render": "function (_self)\n{\n _this.langtypeCombo = _self;\n}",
+ "|select": "function (combo, record, index)\n{\n _this.langgrid.getDataSource().reload(); \n}"
+ },
+ "displayField": "lval",
+ "editable": false,
+ "emptyText": "Select Translation of",
+ "mode": "local",
+ "selectOnFocus": true,
+ "triggerAction": "all",
+ "typeAhead": false,
+ "valueField": "lkey",
+ "width": 200,
+ "xtype": "ComboBox",
+ "|xns": "Roo.form",
+ "items": [
+ {
+ "*prop": "store",
+ "xtype": "SimpleStore",
+ "|data": "[\n [ 'l', 'Language Names' ],\n [ 'c', 'Country Names' ],\n [ 'm', 'Currency Names' ]\n]",
+ "|fields": "['lkey','lval']",
+ "|xns": "Roo.data"
+ }
+ ]
+ },
+ {
+ "listeners": {
+ "|select": "function (combo, record, index)\n{\n _this.langgrid.getDataSource().reload(); \n}",
+ "|render": "function (_self)\n{\n _this.langgridCombo=_self;\n}"
+ },
+ "displayField": "ldisp",
+ "editable": false,
+ "emptyText": "Select Language",
+ "mode": "local",
+ "selectOnFocus": true,
+ "triggerAction": "all",
+ "typeAhead": false,
+ "valueField": "lang",
+ "width": 200,
+ "xtype": "ComboBox",
+ "|xns": "Roo.form",
+ "items": [
+ {
+ "xtype": "SimpleStore",
+ "|xns": "Roo.data",
+ "*prop": "store",
+ "listeners": {},
+ "|fields": "['lang', 'ldisp']",
+ "|data": "[ [ 'zh_HK' , '\\u7E41\\u4E2D - Trad. Chin. (HK)' ], [ 'zh_CN', '\\u7C21\\u4E2D - Simp. Chin.' ] ]"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "*prop": "colModel[]",
+ "dataIndex": "lkey",
+ "header": "Code",
+ "width": 50,
+ "xtype": "ColumnModel",
+ "|renderer": "function(v) { return String.format('{0}', v); }",
+ "|xns": "Roo.grid"
+ },
+ {
+ "*prop": "colModel[]",
+ "dataIndex": "lval_en",
+ "header": "English",
+ "width": 150,
+ "xtype": "ColumnModel",
+ "|renderer": "function(v) { return String.format('{0}', v); }",
+ "|xns": "Roo.grid"
+ },
+ {
+ "*prop": "colModel[]",
+ "dataIndex": "lval",
+ "header": "Translation",
+ "width": 200,
+ "xtype": "ColumnModel",
+ "|renderer": "function(v) { return String.format('{0}', v); }",
+ "|xns": "Roo.grid",
+ "items": [
+ {
+ "xtype": "GridEditor",
+ "*prop": "editor",
+ "|xns": "Roo.grid",
+ "listeners": {},
+ "items": [
+ {
+ "xtype": "TextField",
+ "*prop": "field",
+ "|xns": "Roo.form",
+ "listeners": {}
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "permname": "Admin.Translations",
+ "modOrder": "950"
+}
\ No newline at end of file
--- /dev/null
+//<script type="text/javascript">
+
+// Auto generated file - created by app.Builder.js- do not edit directly (at present!)
+
+
+
+// register the module first
+Pman.on('beforeload', function()
+{
+ Pman.register({
+ modKey : '950-Pman.Tab.AdminTranslations',
+ module : Pman.Tab.AdminTranslations,
+ region : 'center',
+ parent : Pman.Tab.Admin,
+ name : "Admin - Translations",
+ disabled : false,
+ permname: 'Admin.Translations'
+ });
+});
+
+Pman.Tab.AdminTranslations = new Roo.util.Observable({
+
+ panel : false,
+ disabled : false,
+ parentLayout: false,
+
+ add : function(parentLayout, region)
+ {
+
+ var _this = this;
+ this.parentLayout = parentLayout;
+
+ this.panel = parentLayout.addxtype({
+ xtype: 'NestedLayoutPanel',
+ xns: Roo,
+ region : 'center',
+ title : "Translate App",
+ layout : {
+ xtype: 'BorderLayout',
+ xns: Roo,
+ items : [
+ {
+ xtype: 'GridPanel',
+ xns: Roo,
+ listeners : {
+ activate : function() {
+ _this.panel = this;
+ if (_this.grid) {
+ _this.grid.getDataSource().reload();
+ }
+ }
+ },
+ background : true,
+ fitContainer : true,
+ fitToframe : true,
+ region : 'center',
+ title : "Text in interface",
+ grid : {
+ xtype: 'EditorGrid',
+ xns: Roo.grid,
+ listeners : {
+ render : function() {
+ _this.grid = this;
+ //_this.dialog = Pman.Dialog.FILL_IN
+ if (_this.panel.active) {
+ _this.grid.getDataSource().reload();
+ }
+ },
+ beforeedit : function(e) {
+ console.log('beforeedit');
+ //if (e.record.get('origtxt').indexOf('<') > -1) {
+ // console.log("HTML EDITOR!!");
+
+ // return false;
+ //}
+ if (e.record.get('txt').replace(/\s+/, '').length) {
+ return true;
+ }
+ if (e.record.get('suggest').length) {
+ e.record.set('txt', e.record.get('suggest'));
+ // _this.saveRec(e.record);
+ return;
+ }
+
+
+
+
+ var tl = e.record.get('id').split('/')[0];
+
+ tl = (tl == 'zh_HK') ? 'zh-TW' : tl;
+ tl = tl.replace('_', '-');
+ var rec = e.record;
+
+
+
+ Pman.gtranslate(e.record.get('origtxt'), 'en', tl, function(result) {
+ if (typeof(result) == 'object') { //error
+ return;
+ }
+
+ if (_this.grid.activeEditor) {
+ _this.grid.activeEditor.setValue(result);
+ } else {
+ rec.set('txt',result);
+ //_this.saveRec(rec);
+ }
+
+ //
+
+
+ //console.log(result.translation);
+ });
+
+
+
+ return true;
+ },
+ afteredit : function (e)
+ {
+ var saveRec = function(rec)
+ {
+ var g = _this.grid;
+
+ //g.getView().el.mask('Saving');
+ Ext.Ajax.request({
+ url : baseURL + '/Admin/Translations.php',
+ method: 'POST',
+ params : {
+ id : rec.get('id'),
+ txt : rec.get('txt'),
+ lang : _this.langCombo.getValue(),
+ module : _this.modCombo.getValue()
+ },
+ success : function()
+ {
+ //g.getView().el.unmask();
+ //g.getDataSource().reload();
+ },
+ failure : function()
+ {
+ Ext.Msg.alert("Error", "There was a problem saving the data - try reloading");
+ // g.getView().el.unmask();
+ }
+
+ });
+ };
+
+ saveRec.defer(1000, _this, [ e.record ]);
+ }
+ },
+ autoExpandColumn : 'txt',
+ clicksToEdit : 1,
+ loadMask : true,
+ dataSource : {
+ xtype: 'Store',
+ xns: Roo.data,
+ reader : Pman.Readers.Category,
+ listeners : {
+ beforeload : function (_self, opts)
+ {
+
+ if (!_this.langCombo || !_this.langCombo.getValue().length) {
+ return false;
+ }
+ if (!_this.modCombo || !_this.modCombo.getValue().length) {
+ return false;
+ }
+ opts.params = {
+ lang : _this.langCombo.getValue(),
+ module : _this.modCombo.getValue()
+ };
+ }
+ },
+ proxy : {
+ xtype: 'HttpProxy',
+ xns: Roo.data,
+ method : 'GET',
+ url : baseURL + '/Admin/Translations.php'
+ },
+ reader : {
+ xtype: 'JsonReader',
+ xns: Roo.data,
+ root : 'data',
+ totalProperty : 'total',
+ id : 'id',
+ fields : [ 'id', 'tablename', 'tableid', 'colname', 'txt', 'lang', { name:'updated', type:'date', dateFormat: 'Y-m-d H:i:s' }, { name:'origupdated', type:'date', dateFormat: 'Y-m-d H:i:s' }, 'origtxt', 'msum', 'suggest' ]
+ }
+ },
+ toolbar : {
+ xtype: 'Toolbar',
+ xns: Roo,
+ items : [
+ {
+ xtype: 'ComboBox',
+ xns: Roo.form,
+ listeners : {
+ render : function (_self)
+ {
+ _this.modCombo = _self;
+ },
+ select : function (combo, record, index)
+ {
+ _this.grid.getDataSource().reload();
+ }
+ },
+ valueField : 'module',
+ displayField : 'module',
+ width : 200,
+ typeAhead : false,
+ editable : false,
+ mode : 'local',
+ triggerAction : 'all',
+ emptyText : "Select Module",
+ selectOnFocus : true,
+ store : {
+ xtype: 'SimpleStore',
+ xns: Roo.data,
+ data : (function() {
+ var modlist = [];
+ AppModules = typeof(AppModules) == 'undefined' ? '' : AppModules;
+ Roo.each( AppModules.split(','), function(mod) {
+ modlist.push( [ mod ] );
+ });
+ return modlist;
+ })(),
+ fields : ['module']
+ }
+ },
+ {
+ xtype: 'ComboBox',
+ xns: Roo.form,
+ listeners : {
+ select : function (combo, record, index)
+ {
+ _this.grid.getDataSource().reload();
+ },
+ render : function (_self)
+ {
+ _this.langCombo=_self;
+ }
+ },
+ valueField : 'lang',
+ displayField : 'ldisp',
+ width : 200,
+ typeAhead : false,
+ editable : false,
+ mode : 'local',
+ triggerAction : 'all',
+ emptyText : "Select Language",
+ selectOnFocus : true,
+ store : {
+ xtype: 'SimpleStore',
+ xns: Roo.data,
+ fields : ['lang', 'ldisp'],
+ data : [ [ 'zh_HK' , '\u7E41\u4E2D - Trad. Chin. (HK)' ], [ 'zh_CN', '\u7C21\u4E2D - Simp. Chin.' ] ]
+ }
+ }
+ ]
+ },
+ colModel : [
+ {
+ xtype: 'ColumnModel',
+ xns: Roo.grid,
+ header : 'Name',
+ width : 150,
+ dataIndex : 'colname',
+ renderer : function(v,x,r) { var c = '#666'; if (r.get('updated') < r.get('origupdated')) { c = 'red'; } return '<div style="color:'+c+'";>' +r.get('tableid')+ ':' + v + '</div>'; }
+ },
+ {
+ xtype: 'ColumnModel',
+ xns: Roo.grid,
+ header : 'Original',
+ width : 300,
+ dataIndex : 'origtxt',
+ renderer : function(v,x,r) { var c = '#666'; if (r.get('updated') < r.get('origupdated')) { c = 'red'; } return '<div style="color:' + c+ '">' + Ext.util.Format.htmlEncode(v) + '</div>'; }
+ },
+ {
+ xtype: 'ColumnModel',
+ xns: Roo.grid,
+ dataIndex : 'txt',
+ header : 'Translated (Click to Edit)',
+ width : 150,
+ renderer : function(v,x,r) { var c = '#666'; if (r.get('updated') < r.get('origupdated')) { c = 'red'; } return '<div style="color:' + c+ '">' + Ext.util.Format.htmlEncode(v) + '</div>'; },
+ editor : {
+ xtype: 'GridEditor',
+ xns: Roo.grid,
+ field : {
+ xtype: 'TextField',
+ xns: Roo.form
+ }
+ }
+ }
+ ]
+ }
+ },
+ {
+ xtype: 'GridPanel',
+ xns: Roo,
+ listeners : {
+ activate : function() {
+ _this.langpanel = this;
+ if (_this.langgrid) {
+ _this.langgrid.ds.load({});
+ }
+ }
+ },
+ background : true,
+ fitContainer : true,
+ fitToframe : true,
+ region : 'center',
+ tableName : 'i18n',
+ title : "Languages and Countries",
+ grid : {
+ xtype: 'EditorGrid',
+ xns: Roo.grid,
+ listeners : {
+ render : function()
+ {
+ _this.langgrid = this;
+ //_this.dialog = Pman.Dialog.FILL_IN
+ if (_this.langpanel.active) {
+ this.ds.load({});
+ }
+ },
+ afteredit : function (e)
+ {
+ var saveRec = function(rec)
+ {
+ var g = _this.grid;
+
+ //g.getView().el.mask('Saving');
+ Ext.Ajax.request({
+ url : baseURL + '/Roo/I18n.php',
+ method: 'POST',
+ params : {
+ id : rec.get('id'),
+ lval : rec.get('lval')
+ },
+ success : function()
+ {
+ //g.getView().el.unmask();
+ //g.getDataSource().reload();
+ },
+ failure : function()
+ {
+ Ext.Msg.alert("Error", "There was a problem saving the data - try reloading");
+ // g.getView().el.unmask();
+ }
+
+ });
+ };
+
+ saveRec.defer(1000, _this, [ e.record ]);
+ },
+ beforeedit : function(e) {
+ console.log('beforeedit');
+ //if (e.record.get('origtxt').indexOf('<') > -1) {
+ // console.log("HTML EDITOR!!");
+
+ // return false;
+ //}
+ if (e.record.get('lval').replace(/\s+/, '').length) {
+ return true;
+ }
+
+
+ var tl = _this.langgridCombo.getValue();
+
+ tl = (tl == 'zh_HK') ? 'zh-TW' : tl;
+ tl = tl.replace('_', '-');
+ var rec = e.record;
+
+
+
+ Pman.gtranslate(e.record.get('lval_en'), 'en', tl, function(result) {
+ if (typeof(result) == 'object') { //error
+ return;
+ }
+
+ if (_this.grid.activeEditor) {
+ _this.grid.activeEditor.setValue(result);
+ } else {
+ rec.set('lval',result);
+ //_this.saveRec(rec);
+ }
+
+ //
+
+
+ //console.log(result.translation);
+ });
+
+
+
+ return true;
+ }
+ },
+ autoExpandColumn : 'lval',
+ clicksToEdit : 1,
+ loadMask : true,
+ dataSource : {
+ xtype: 'Store',
+ xns: Roo.data,
+ listeners : {
+ beforeload : function (_self, options)
+ {
+ options =options || {};
+ options.params =options.params|| {};
+ options.params.ltype = _this.langtypeCombo.getValue();
+ options.params.inlang = _this.langgridCombo.getValue();
+ options.params['query[_with_en]'] = 1;
+ if (!options.params.ltype.length || !options.params.inlang.length) {
+ return false;
+ }
+
+ options.params.limit = 9999;
+
+ }
+ },
+ remoteSort : true,
+ sortInfo : { field : 'lkey', direction: 'ASC' },
+ proxy : {
+ xtype: 'HttpProxy',
+ xns: Roo.data,
+ method : 'GET',
+ url : baseURL + '/Roo/i18n.php'
+ },
+ reader : {
+ xtype: 'JsonReader',
+ xns: Roo.data,
+ totalProperty : 'total',
+ root : 'data',
+ id : 'id',
+ fields : [
+ {
+ 'name': 'id',
+ 'type': 'int'
+ },
+ {
+ 'name': 'ltype',
+ 'type': 'string'
+ },
+ {
+ 'name': 'lkey',
+ 'type': 'string'
+ },
+ {
+ 'name': 'inlang',
+ 'type': 'string'
+ },
+ {
+ 'name': 'lval',
+ 'type': 'string'
+ }
+ ]
+ }
+ },
+ toolbar : {
+ xtype: 'Toolbar',
+ xns: Roo,
+ items : [
+ {
+ xtype: 'ComboBox',
+ xns: Roo.form,
+ listeners : {
+ render : function (_self)
+ {
+ _this.langtypeCombo = _self;
+ },
+ select : function (combo, record, index)
+ {
+ _this.langgrid.getDataSource().reload();
+ }
+ },
+ displayField : 'lval',
+ editable : false,
+ emptyText : "Select Translation of",
+ mode : 'local',
+ selectOnFocus : true,
+ triggerAction : 'all',
+ typeAhead : false,
+ valueField : 'lkey',
+ width : 200,
+ store : {
+ xtype: 'SimpleStore',
+ xns: Roo.data,
+ data : [
+ [ 'l', 'Language Names' ],
+ [ 'c', 'Country Names' ],
+ [ 'm', 'Currency Names' ]
+ ],
+ fields : ['lkey','lval']
+ }
+ },
+ {
+ xtype: 'ComboBox',
+ xns: Roo.form,
+ listeners : {
+ select : function (combo, record, index)
+ {
+ _this.langgrid.getDataSource().reload();
+ },
+ render : function (_self)
+ {
+ _this.langgridCombo=_self;
+ }
+ },
+ displayField : 'ldisp',
+ editable : false,
+ emptyText : "Select Language",
+ mode : 'local',
+ selectOnFocus : true,
+ triggerAction : 'all',
+ typeAhead : false,
+ valueField : 'lang',
+ width : 200,
+ store : {
+ xtype: 'SimpleStore',
+ xns: Roo.data,
+ fields : ['lang', 'ldisp'],
+ data : [ [ 'zh_HK' , '\u7E41\u4E2D - Trad. Chin. (HK)' ], [ 'zh_CN', '\u7C21\u4E2D - Simp. Chin.' ] ]
+ }
+ }
+ ]
+ },
+ colModel : [
+ {
+ xtype: 'ColumnModel',
+ xns: Roo.grid,
+ dataIndex : 'lkey',
+ header : 'Code',
+ width : 50,
+ renderer : function(v) { return String.format('{0}', v); }
+ },
+ {
+ xtype: 'ColumnModel',
+ xns: Roo.grid,
+ dataIndex : 'lval_en',
+ header : 'English',
+ width : 150,
+ renderer : function(v) { return String.format('{0}', v); }
+ },
+ {
+ xtype: 'ColumnModel',
+ xns: Roo.grid,
+ dataIndex : 'lval',
+ header : 'Translation',
+ width : 200,
+ renderer : function(v) { return String.format('{0}', v); },
+ editor : {
+ xtype: 'GridEditor',
+ xns: Roo.grid,
+ field : {
+ xtype: 'TextField',
+ xns: Roo.form
+ }
+ }
+ }
+ ]
+ }
+ }
+ ],
+ center : {
+ xtype: 'LayoutRegion',
+ xns: Roo,
+ alwaysShowTabs : true,
+ tabPosition : 'top'
+ }
+ }
+ });
+ this.layout = this.panel.layout;
+
+ }
+});
--- /dev/null
+//<script type="text/javascript">
+
+/**
+ *
+ * needs a translation list..
+ *
+ *
+ */
+ Pman.on('beforeload', function()
+{
+
+
+ Pman.register({
+ modKey : '002-pman-tab-groups-rights',
+ module : Pman.Tab.Group_Rights,
+ region : 'center',
+ parent : Pman.Tab.GroupMgr,
+ name : "Permission Groups"
+ });
+});
+
+
+
+Pman.ColModels.Group_RightsRenderer = function(v, c, r, ri, ci, st) {
+ // work out what the column is..
+ var h = Pman.Tab.Group_Rights.grid.getColumnModel().getColumnId(ci).toUpperCase();
+ // ADESPIM
+ var fm = r.json.FullMask;
+ state = '';
+ if (h == 'AA') { // All....
+ state = v== fm ? '-checked' : '';
+ } else if (v.indexOf(h.substring(3)) > -1) {
+ state = '-checked';
+ }
+ if (fm.indexOf(h.substring(3)) < 0) { // dont show checkboxes for no perms.
+ return '';
+ }
+
+ return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
+
+
+};
+
+
+Pman.Tab.Group_Rights = {
+ rightNames : { }, // filled in by modules.
+
+
+ grid : false,
+ panel : false,
+ add : function(parentLayout, region) {
+
+
+ if (this.panel) {
+ parentLayout.getRegion(region).showPanel(this.panel);
+ return;
+ }
+ var _this= this;
+ /*
+ this.innerLayout = new Ext.BorderLayout(
+ parentLayout.getEl().createChild({tag:'div'}),
+ {
+
+ center: {
+ autoScroll:true,
+ hideTabs: true
+ }
+ }
+ );
+
+
+
+ this.tab = parentLayout.add(region, new Ext.NestedLayoutPanel(
+ this.innerLayout, {title: "Rights", id: 'Group_Rights'}));
+ */
+
+ //this.innerLayout.beginUpdate();
+
+
+ var frm = parentLayout.getRegion(region).getEl().createChild({tag:'div', id: 'grid-group_rights'});
+ //this.grid = new Ext.grid.EditorGrid(frm, {
+ this.grid = new Ext.grid.Grid(frm, {
+
+ ds: new Ext.data.Store({
+ // load using HTTP
+ proxy: new Ext.data.HttpProxy({
+ url: baseURL + '/Admin/GroupRights.php',
+ method: 'GET'
+ }),
+ reader: Pman.Readers.Group_Rights,
+ remoteSort: false,
+ listeners : {
+ beforeload : function(t,o)
+ {
+ if (!o.params) {
+ o.params = {}
+ }
+ var s = Pman.Tab.Groups.grid.getSelectionModel().getSelections();
+ if (!s.length) {
+ o.params.group_id = -1;
+ } else {
+ o.params.group_id = s[0].data.id;
+ }
+ if (o.params.group_id < 0) {
+ _this.grid.getView().el.mask("You can not set permissions for that group");
+ return false;
+ }
+ _this.grid.getView().el.unmask();
+ return true;
+ },
+ loadexception : Pman.loadException
+
+ }
+ }),
+ selModel: new Ext.grid.CellSelectionModel(),
+ cm: new Ext.grid.ColumnModel([
+ {
+ 'id' : 'aa',
+ header : "[All]",
+ dataIndex : 'AccessMask',
+ 'sortable' : false,
+ 'width' : 50,
+ renderer : Pman.ColModels.Group_RightsRenderer
+ },
+
+ {
+ 'id' : 'group-rights-module',
+ header : "Module",
+ dataIndex : 'rightname',
+ 'sortable' : false,
+ 'width' : 50,
+ renderer : function(v,x,r)
+ {
+ return String.format('<span qtip="{1}">{0}</span>',
+ v.split('.').shift(), v);
+ }
+ },
+
+ {
+ 'id' : 'group_rights-rightname',
+ header : "Permission",
+ 'dataIndex' : 'rightname',
+ 'sortable' : false,
+ 'width' : 300,
+ renderer : function (v,x,r) {
+
+ if (r.json.descript && r.json.descript.length) {
+ return String.format('{0}',r.json.descript);
+ }
+
+
+ // this needs to be generated by the modules..
+ /*
+ if (typeof(Pman.rightNames[v]) == 'string' && Pman.rightNames[v].length) {
+ return String.format('{0}',Pman.rightNames[v]);
+ }
+ */
+ return '???' + v;
+
+
+
+ }
+ },
+ {
+ 'id' : 'am-a',
+ header : "Add",
+ 'dataIndex' : 'AccessMask',
+ 'width' : 50,
+ 'sortable' : false,
+ renderer : Pman.ColModels.Group_RightsRenderer
+ },
+ {
+ 'id' : 'am-e',
+ header : "Edit",
+ 'dataIndex' : 'AccessMask',
+ 'width' : 50,
+ 'sortable' : false,
+ renderer : Pman.ColModels.Group_RightsRenderer
+ },
+ {
+ 'id' : 'am-d',
+ header : "Delete",
+ 'dataIndex' : 'AccessMask',
+ 'width' : 50,
+ 'sortable' : false,
+ renderer : Pman.ColModels.Group_RightsRenderer
+ },
+ {
+ 'id' : 'am-s', // S
+ header : "List/View",
+ 'dataIndex' : 'AccessMask',
+ 'width' : 90,
+ 'sortable' : false,
+ renderer : Pman.ColModels.Group_RightsRenderer
+ }, // P= print / I= import (not used)
+
+ {
+ 'id' : 'am-p',
+ header : "Print / Export",
+ 'dataIndex' : 'AccessMask',
+ 'width' : 100,
+ 'sortable' : false,
+ renderer : Pman.ColModels.Group_RightsRenderer
+ }, /*
+ {
+ 'id' : 'AM-I',
+ header : "Import",
+ 'dataIndex' : 'AccessMask',
+ 'width' : 50,
+ 'sortable' : false,
+ renderer : Pman.ColModels.Group_RightsRenderer
+ },
+ /*
+ {
+ 'id' : 'AM-M',
+ 'header' : 'Admin mode',
+ 'dataIndex' : 'AccessMask',
+ 'width' : 100,
+ 'sortable' : false,
+ renderer : Pman.ColModels.Group_RightsRenderer
+ },
+ */
+ {
+ 'id': 'group_rights-remarks',
+ header : '',
+ dataIndex : 'Remarks',
+ 'sortable' : false,
+ 'width' : 50
+ }
+ ]),
+ autoExpandColumn: 'group_rights-remarks' , // fixme!!!!
+ clicksToEdit : 1,
+
+ loadMask: true,
+ trackMouseOver : false,
+ listeners : {
+ cellclick: function (g, ri, ci, e)
+ {
+ var h = g.getColumnModel().getColumnId(ci);
+ //console.log(h);
+ var fm = g.getDataSource().getAt(ri).json.FullMask;
+
+ if (h.substring(0,2) == 'aa') {
+ var old = g.getDataSource().getAt(ri).data.AccessMask;
+
+ g.getDataSource().getAt(ri).set('AccessMask',
+ old == fm ? "" : fm );
+ return;
+ }
+
+ if (h.substring(0,2) != 'am') {
+ return;
+ }
+ var c = h.substring(3).toUpperCase();
+
+ if (fm.indexOf(c) < 0) {
+ return; // skip no perms boxes
+ }
+ // ADESPIM
+ //var def = 'ADESPIM';
+ function toKV(str) {
+
+ var ret = { };
+ for(var i = 0;i< fm.length; i++) {
+ var cc = fm.substring(i,i+1);
+ ret[cc] = str.indexOf(cc) > -1;
+ }
+ return ret;
+ }
+ function toStr(obj) {
+
+ var ret = '';
+ for(var i = 0;i< fm.length; i++) {
+ var cc = fm.substring(i,i+1);
+ if (obj[cc]) {
+ ret += cc;
+ }
+ }
+ //console.log(ret);
+ return ret;
+ }
+
+
+ // get existing value..
+ var conf = toKV(g.getDataSource().getAt(ri).data.AccessMask);
+ conf[c] = !conf[c];
+ g.getDataSource().getAt(ri).set('AccessMask',toStr(conf));
+ }
+
+ }
+
+ });
+ this.grid.getSelectionModel().lock();
+ this.panel = parentLayout.add(region, new Ext.GridPanel(this.grid ,
+ { fitToframe: true,fitContainer: true, title: "Rights", id: 'group_rights', controller : this })
+ );
+ this.grid.render();
+ /*
+ var gridFoot = this.grid.getView().getFooterPanel(true);
+
+ this.paging = new Ext.PagingToolbar(gridFoot, this.grid.getDataSource(), {
+ pageSize: 25,
+ displayInfo: true,
+ displayMsg: "",
+ emptyMsg: ""
+ });
+ */
+ var grid = this.grid;
+
+ var gridHead = this.grid.getView().getHeaderPanel(true);
+ var tb = new Ext.Toolbar(gridHead);
+
+
+
+ tb.add(
+ {
+ text: "Save",
+ cls: 'x-btn-text-icon',
+ icon: rootURL + '/Pman/templates/images/save.gif',
+ hidden : !Pman.hasPerm('Core.Groups', 'E'),
+ handler : function(){
+ var data = {};
+ grid.getDataSource().each(function(r) {
+ if (!r.dirty) {
+ return;
+ }
+ data[r.data.id > -1 ? 'dataUpdate['+r.data.id+']' : 'dataAdd['+r.data.rightname+']'] = r.data.AccessMask;
+
+ });
+
+ data.group_id = grid.getDataSource().lastOptions.params.group_id;
+ Ext.Ajax.request({
+ url: baseURL + '/Admin/GroupRights.php',
+ params : data,
+ method: 'POST',
+ success : function() {
+ _this.refresh();
+ //Pman.Tab.Group_Rights.paging.onClick('first');
+ },
+ failure: function() {
+ Ext.MessageBox.alert("There was a problem saving the data");
+ }
+ });
+ }
+ },
+ '-',
+ {
+ text: "Reload",
+ cls: 'x-btn-text-icon',
+ icon: rootURL + '/Pman/templates/images/refresh.gif',
+ handler : function(){
+ _this.refresh();
+ }
+ }
+ );
+ this.panel.on('activate', function() {
+ _this.refresh();
+ });
+
+ //this.toolbar = tb;
+ // add stuff to toolbar?
+ //this.innerLayout.endUpdate();
+
+
+
+ },
+ refresh : function() {
+ this.grid.getDataSource().reload();
+ },
+ /*
+ show: function (parentLayout, region)
+ {
+ this.add(parentLayout, region);
+ this.grid.getDataSource().load({
+ params: {
+ start:0,
+ limit:25
+ }
+ });
+
+ },
+ */
+ renderer: function(v, c, r, ri, ci, st) {
+ // work out what the column is..
+ var h = Pman.Tab.Group_Rights.grid.getColumnModel().getColumnId(ci).toUpperCase();
+ // ADESPIM
+
+ if (v.indexOf(h.substring(3)) > -1) {
+ return 'Y';
+ }
+
+ return '-';
+
+ },
+ save : function()
+ {
+
+ }
+
+
+};
+