--- /dev/null
+<?php
+
+/**
+ * generic import routine..
+ *
+ * - upload a file..
+ *
+ * - preview the result. / edit?
+ *
+ * - import..
+ *
+ *
+ */
+
+
+require_once 'Pman.php';
+class Pman_Admin_Import_Core_templatestr extends Pman
+{
+ var $cli = false;
+
+
+
+ function getAuth()
+ {
+ $cli = HTML_FlexyFramework::get()->cli;
+ if ($cli) {
+ $this->cli = true;
+ return true;
+ }
+ parent::getAuth();
+ $au = $this->getAuthUser();
+ if (!$au) {
+ $this->jerrAuth();
+ }
+ return true;
+ }
+
+ function post($base = '' )
+ {
+
+ // should handle uploaded file..
+ if (empty($_FILES['imageUpload']['tmp_name']) ||
+ empty($_FILES['imageUpload']['name']) ||
+ empty($_FILES['imageUpload']['type'])
+ ) {
+ $this->jerr ("Missing file details");
+ exit;
+ }
+
+ PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
+
+
+ $this->transObj = DB_DataObject::factory('core_enum');
+
+ $this->transObj->query('BEGIN');
+
+ // first convert the file to a readable format..
+ //$rows = $this->readXLS("/home/alan/Downloads/oll_example.xls") ;
+ $rows = $this->readXLS($_FILES['imageUpload']['tmp_name']) ;
+
+ //$ret = $this->processRows($rows);
+
+
+ $this->jok("DONE", false, array('extra'=> $rows));
+
+ }
+
+ /*
+ function get($base = '', $opts = array())
+ {
+ $rows = $this->readXLS("/var/lib/php/sessions/pressrelease-translations.xls") ;
+
+
+
+ $ret = $this->processRows($rows);
+
+ $this->jdata($ret);
+ exit;
+
+ }
+ */
+ function processRows($rows)
+ {
+ $ret = array();
+ foreach($rows as $r) {
+ $ret[] = $this->updateTranslation($r);
+
+ }
+ return $ret;
+ }
+
+
+ var $seq = 1;
+ function updateTranslation($r)
+ {
+ //print_R($r); DB_DataObject::DebugLevel(1);
+ $tr = DB_DataObject::Factory('core_templatestr');
+ $tr->autoJoin();
+
+
+ $tr->whereAdd("join_template_id_id.template='{$tr->escape($r['template'])}'");
+ $tr->whereAdd("join_template_id_id.view_name='{$tr->escape($r['module'])}'");
+ $tr->whereAdd("join_src_id_id.mdsum='{$tr->escape($r['code'])}'");
+ $tr->lang = $r['language'];
+ if ($tr->find(true)) {
+ $tt = DB_DataObject::Factory('core_templatestr');
+ $tt->get($tr->id);
+ $tr= clone($tt);
+ $tt->txt = $r['translation'];
+ $tt->updated = date('Y-m-d H:i:s');
+ $tt->update($tr);
+
+ return 1;
+ }
+ return 0;
+ }
+
+
+ function readXLS($file) {
+
+ require_once 'System.php';
+ $ssconvert = System::which('ssconvert');
+ if (!$ssconvert) die("ssconvert not installed");
+ $csv = $this->tempName('csv');
+ $cmd = "$ssconvert -T Gnumeric_stf:stf_csv ". escapeshellarg($file) . ' '.$csv;
+
+ $data= `$cmd`;
+
+ clearstatcache();
+ if (!file_exists($csv)) {
+ $this->jerr("Failed to make file . \n".
+ $cmd . "\n" .
+ $data
+ );
+
+
+ }
+ //echo $data;
+ $fh = fopen($csv, 'r');
+ if (!$fh) {
+ $this->jerr("file invalid");
+ }
+ $rows = array();
+ $head = false;
+ $blank = 0;
+ while (false !== ($row = fgetcsv($fh))) {
+
+ if ($head === false) {
+
+ $h = $row;
+ // skip header lines.
+ array_shift($h);
+ if (!strlen(implode('', $h))) {
+ continue;
+ }
+ // how many empty rows..
+ if (count(explode(',',(rtrim(implode(',', $h), " ,")))) < 3) {
+ continue;
+ }
+
+ $head = array();
+ foreach($row as $i=>$c) {
+ $c = preg_replace('/[\t \n]+/', ' ', $c);
+ $head[$i] = strtolower(trim($c));
+ }
+ continue;
+ }
+
+ if (!strlen(trim(implode('', $h)))) {
+ $blank++;
+ if ($blank > 3) {
+ break;
+ }
+ continue;
+ }
+
+ $blank = 0;
+ $rrow = array();
+ foreach($row as $i=>$c) {
+ $c = preg_replace('/[\t \n]+/', ' ', $c);
+ $rrow[$head[$i]] = trim($c);
+ }
+ // var_dump($row);
+ // print_r($max);
+ $rows[] = $rrow;
+ }
+ unlink($csv);
+ return $rows;
+
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+{
+ "name" : "Pman.Tab.AdminTranslationsInt",
+ "parent" : "Pman.Tab.Admin",
+ "title" : "Admin - AdminTranslationsInt",
+ "path" : "/home/alan/gitlive/Pman.Admin/Pman.Tab.AdminTranslationInt.bjs",
+ "permname" : "Admin.TranslationsInt",
+ "modOrder" : "950",
+ "strings" : {
+ "deccbe4e9083c3b5f7cd2632722765bb" : "Translate",
+ "4994a8ffeba4ac3140beb89e8d41f174" : "Language",
+ "ae739a236065a45c64ad51aacb19498c" : "Active?",
+ "d41d8cd98f00b204e9800998ecf8427e" : "",
+ "6dd08874f83507e9c7b23f1a46b7fa7c" : "Translation",
+ "83dad8107f9459efe2b4fabcf5b63108" : "Select Language",
+ "78463a384a5aa4fad5fa73e2f506ecfc" : "English",
+ "552bcc4e00cd663f09cc4efbaca1cd45" : "Select Translation of",
+ "ca0dbad92a874b2f69b549293387925e" : "Code",
+ "0a9e8bd9e8b301dfb2c21c355e0b377d" : "Languages and Countries"
+ },
+ "named_strings" : {
+ "language_title_value" : "d41d8cd98f00b204e9800998ecf8427e",
+ "language_title_qtip" : "83dad8107f9459efe2b4fabcf5b63108",
+ "language_title_fieldLabel" : "4994a8ffeba4ac3140beb89e8d41f174"
+ },
+ "items" : [
+ {
+ "region" : "center",
+ "title" : "Translate",
+ "xtype" : "NestedLayoutPanel",
+ "$ xns" : "Roo",
+ "items" : [
+ {
+ "xtype" : "BorderLayout",
+ "$ xns" : "Roo",
+ "* prop" : "layout",
+ "items" : [
+ {
+ "alwaysShowTabs" : true,
+ "xtype" : "LayoutRegion",
+ "tabPosition" : "top",
+ "$ xns" : "Roo",
+ "* prop" : "center"
+ },
+ {
+ "listeners" : {
+ "|activate" : "function() {\n _this.langpanel = this;\n if (_this.langgrid) {\n _this.langgrid.ds.load({});\n }\n}"
+ },
+ "region" : "center",
+ "fitToframe" : true,
+ "background" : true,
+ "title" : "Languages and Countries",
+ "xtype" : "GridPanel",
+ "fitContainer" : true,
+ "$ xns" : "Roo",
+ "tableName" : "i18n",
+ "items" : [
+ {
+ "listeners" : {
+ "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 } ",
+ "cellclick" : "function (_self, rowIndex, columnIndex, e)\n{\n if(_this.langgrid.colModel.getDataIndex(columnIndex) !== 'is_active'){\n return;\n }\n \n var s = _this.langgrid.ds.getAt(rowIndex);\n \n if(!s || s.data.id * 1 < 0){\n return;\n }\n \n s.set('is_active', s.data.is_active ? 0 : 1);\n \n new Pman.Request({\n url : baseURL+'/Roo/I18n',\n method : 'POST',\n params : {\n id : s.data.id,\n is_active : s.data.is_active\n }\n }); \n \n}",
+ "|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 ltype : rec.get('ltype')\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}"
+ },
+ "autoExpandColumn" : "lval",
+ "xtype" : "EditorGrid",
+ "loadMask" : true,
+ "clicksToEdit" : 1,
+ "$ xns" : "Roo.grid",
+ "* prop" : "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}"
+ },
+ "xtype" : "Store",
+ "remoteSort" : true,
+ "$ sortInfo" : "{ field : 'lkey', direction: 'ASC' }",
+ "$ xns" : "Roo.data",
+ "* prop" : "dataSource",
+ "items" : [
+ {
+ "$ url" : "baseURL + '/Roo/i18n.php'",
+ "xtype" : "HttpProxy",
+ "method" : "GET",
+ "$ xns" : "Roo.data",
+ "* prop" : "proxy"
+ },
+ {
+ "id" : "id",
+ "root" : "data",
+ "xtype" : "JsonReader",
+ "$ xns" : "Roo.data",
+ "$ 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" : "reader",
+ "totalProperty" : "total"
+ }
+ ]
+ },
+ {
+ "xtype" : "Toolbar",
+ "$ xns" : "Roo",
+ "* prop" : "toolbar",
+ "items" : [
+ {
+ "listeners" : {
+ "|render" : "function (_self)\n{\n _this.langtypeCombo = _self;\n}",
+ "|select" : "function (combo, record, index)\n{\n _this.langgrid.getDataSource().reload(); \n}"
+ },
+ "triggerAction" : "all",
+ "selectOnFocus" : true,
+ "emptyText" : "Select Translation of",
+ "displayField" : "lval",
+ "valueField" : "lkey",
+ "xtype" : "ComboBox",
+ "typeAhead" : false,
+ "editable" : false,
+ "width" : 200,
+ "$ xns" : "Roo.form",
+ "mode" : "local",
+ "items" : [
+ {
+ "xtype" : "SimpleStore",
+ "$ data" : "[\n [ 'l', 'Language Names' ],\n [ 'c', 'Country Names' ],\n [ 'm', 'Currency Names' ]\n]",
+ "$ fields" : "['lkey','lval']",
+ "$ xns" : "Roo.data",
+ "* prop" : "store"
+ }
+ ]
+ },
+ {
+ "listeners" : {
+ "render" : "function (_self)\n{\n _this.langgridCombo=_self;\n}",
+ "select" : "function (combo, record, index)\n{\n _this.langgrid.getDataSource().reload(); \n}"
+ },
+ "listWidth" : 300,
+ "Number pageSize" : 400,
+ "triggerAction" : "all",
+ "Number minChars" : 2,
+ "fieldLabel" : "Language",
+ "selectOnFocus" : true,
+ "String queryParam" : "query[name_starts]",
+ "displayField" : "title",
+ "hiddenName" : "language",
+ "value" : "",
+ "valueField" : "code",
+ "xtype" : "ComboBox",
+ "allowBlank" : false,
+ "typeAhead" : true,
+ "editable" : true,
+ "width" : 200,
+ "$ xns" : "Roo.form",
+ "name" : "language_title",
+ "qtip" : "Select Language",
+ "items" : [
+ {
+ "listeners" : {
+ "beforeload" : "function (_self, options)\n{\n options =options || {};\n options.params =options.params|| {};\n options.params.ltype = 'l';\n options.params.inlang = 'en';\n \n options.params._as_code_and_title = 1;\n \n}"
+ },
+ "$ Object sortInfo" : "{ field : 'title', direction: 'ASC' }",
+ "xtype" : "Store",
+ "$ xns" : "Roo.data",
+ "* prop" : "store",
+ "items" : [
+ {
+ "$ url" : "baseURL + '/Roo/i18n.php'",
+ "method" : "GET",
+ "xtype" : "HttpProxy",
+ "$ xns" : "Roo.data",
+ "* prop" : "proxy"
+ },
+ {
+ "id" : "id",
+ "root" : "data",
+ "xtype" : "JsonReader",
+ "$ xns" : "Roo.data",
+ "$ 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" : "reader",
+ "totalProperty" : "total"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "xtype" : "ColumnModel",
+ "width" : 50,
+ "header" : "Code",
+ "$ renderer" : "function(v) { return String.format('{0}', v); }",
+ "$ xns" : "Roo.grid",
+ "Boolean sortable" : true,
+ "* prop" : "colModel[]",
+ "dataIndex" : "lkey"
+ },
+ {
+ "xtype" : "ColumnModel",
+ "width" : 150,
+ "header" : "English",
+ "$ renderer" : "function(v) { return String.format('{0}', v); }",
+ "$ xns" : "Roo.grid",
+ "Boolean sortable" : true,
+ "* prop" : "colModel[]",
+ "dataIndex" : "lval_en"
+ },
+ {
+ "xtype" : "ColumnModel",
+ "width" : 200,
+ "header" : "Translation",
+ "$ renderer" : "function(v) { return String.format('{0}', v); }",
+ "$ xns" : "Roo.grid",
+ "Boolean sortable" : true,
+ "* prop" : "colModel[]",
+ "dataIndex" : "lval",
+ "items" : [
+ {
+ "xtype" : "GridEditor",
+ "$ xns" : "Roo.grid",
+ "* prop" : "editor",
+ "items" : [
+ {
+ "xtype" : "TextField",
+ "$ xns" : "Roo.form",
+ "* prop" : "field"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "xtype" : "ColumnModel",
+ "width" : 150,
+ "header" : "Active?",
+ "$ renderer" : "function(v,x,r) { \n\n return '<img class=\"x-grid-check-icon' + (v*1 ? '-checked' : '') + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n \n \n}",
+ "$ xns" : "Roo.grid",
+ "* prop" : "colModel[]",
+ "dataIndex" : "is_active"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ]
+}
\ 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!)
+
+Roo.namespace('Pman.Tab');
+
+Pman.Tab.AdminTranslationsInt = new Roo.XComponent({
+
+ _strings : {
+ 'deccbe4e9083c3b5f7cd2632722765bb' :"Translate",
+ '4994a8ffeba4ac3140beb89e8d41f174' :"Language",
+ 'ae739a236065a45c64ad51aacb19498c' :"Active?",
+ 'd41d8cd98f00b204e9800998ecf8427e' :"",
+ '6dd08874f83507e9c7b23f1a46b7fa7c' :"Translation",
+ '83dad8107f9459efe2b4fabcf5b63108' :"Select Language",
+ '78463a384a5aa4fad5fa73e2f506ecfc' :"English",
+ '552bcc4e00cd663f09cc4efbaca1cd45' :"Select Translation of",
+ 'ca0dbad92a874b2f69b549293387925e' :"Code",
+ '0a9e8bd9e8b301dfb2c21c355e0b377d' :"Languages and Countries"
+ },
+ _named_strings : {
+ 'language_title_value' : 'd41d8cd98f00b204e9800998ecf8427e' /* */ ,
+ 'language_title_qtip' : '83dad8107f9459efe2b4fabcf5b63108' /* Select Language */ ,
+ 'language_title_fieldLabel' : '4994a8ffeba4ac3140beb89e8d41f174' /* Language */
+ },
+
+ part : ["Admin", "TranslationInt" ],
+ order : '950-Pman.Tab.AdminTranslationsInt',
+ region : 'center',
+ parent : 'Pman.Tab.Admin',
+ name : "Admin - AdminTranslationsInt",
+ disabled : false,
+ permname : 'Admin.TranslationsInt',
+ _tree : function(_data)
+ {
+ var _this = this;
+ var MODULE = this;
+ return {
+ xtype : 'NestedLayoutPanel',
+ region : 'center',
+ title : _this._strings['deccbe4e9083c3b5f7cd2632722765bb'] /* Translate */,
+ xns : Roo,
+ '|xns' : 'Roo',
+ layout : {
+ xtype : 'BorderLayout',
+ xns : Roo,
+ '|xns' : 'Roo',
+ center : {
+ xtype : 'LayoutRegion',
+ alwaysShowTabs : true,
+ tabPosition : 'top',
+ xns : Roo,
+ '|xns' : 'Roo'
+ },
+ items : [
+ {
+ xtype : 'GridPanel',
+ background : true,
+ fitContainer : true,
+ fitToframe : true,
+ region : 'center',
+ tableName : 'i18n',
+ title : _this._strings['0a9e8bd9e8b301dfb2c21c355e0b377d'] /* Languages and Countries */,
+ listeners : {
+ activate : function() {
+ _this.langpanel = this;
+ if (_this.langgrid) {
+ _this.langgrid.ds.load({});
+ }
+ }
+ },
+ xns : Roo,
+ '|xns' : 'Roo',
+ grid : {
+ xtype : 'EditorGrid',
+ autoExpandColumn : 'lval',
+ clicksToEdit : 1,
+ loadMask : true,
+ listeners : {
+ 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'),
+ ltype : rec.get('ltype')
+ },
+ 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;
+ },
+ cellclick : function (_self, rowIndex, columnIndex, e)
+ {
+ if(_this.langgrid.colModel.getDataIndex(columnIndex) !== 'is_active'){
+ return;
+ }
+
+ var s = _this.langgrid.ds.getAt(rowIndex);
+
+ if(!s || s.data.id * 1 < 0){
+ return;
+ }
+
+ s.set('is_active', s.data.is_active ? 0 : 1);
+
+ new Pman.Request({
+ url : baseURL+'/Roo/I18n',
+ method : 'POST',
+ params : {
+ id : s.data.id,
+ is_active : s.data.is_active
+ }
+ });
+
+ },
+ render : function()
+ {
+ _this.langgrid = this;
+ //_this.dialog = Pman.Dialog.FILL_IN
+ if (_this.langpanel.active) {
+ this.ds.load({});
+ }
+ }
+ },
+ xns : Roo.grid,
+ '|xns' : 'Roo.grid',
+ toolbar : {
+ xtype : 'Toolbar',
+ xns : Roo,
+ '|xns' : 'Roo',
+ items : [
+ {
+ xtype : 'ComboBox',
+ displayField : 'lval',
+ editable : false,
+ emptyText : _this._strings['552bcc4e00cd663f09cc4efbaca1cd45'] /* Select Translation of */,
+ mode : 'local',
+ selectOnFocus : true,
+ triggerAction : 'all',
+ typeAhead : false,
+ valueField : 'lkey',
+ width : 200,
+ listeners : {
+ render : function (_self)
+ {
+ _this.langtypeCombo = _self;
+ },
+ select : function (combo, record, index)
+ {
+ _this.langgrid.getDataSource().reload();
+ }
+ },
+ xns : Roo.form,
+ '|xns' : 'Roo.form',
+ store : {
+ xtype : 'SimpleStore',
+ data : [
+ [ 'l', 'Language Names' ],
+ [ 'c', 'Country Names' ],
+ [ 'm', 'Currency Names' ]
+ ],
+ fields : ['lkey','lval'],
+ xns : Roo.data,
+ '|xns' : 'Roo.data'
+ }
+ },
+ {
+ xtype : 'ComboBox',
+ allowBlank : false,
+ displayField : 'title',
+ editable : true,
+ fieldLabel : _this._strings['4994a8ffeba4ac3140beb89e8d41f174'] /* Language */,
+ hiddenName : 'language',
+ listWidth : 300,
+ minChars : 2,
+ name : 'language_title',
+ pageSize : 400,
+ qtip : _this._strings['83dad8107f9459efe2b4fabcf5b63108'] /* Select Language */,
+ queryParam : 'query[name_starts]',
+ selectOnFocus : true,
+ triggerAction : 'all',
+ typeAhead : true,
+ value : _this._strings['d41d8cd98f00b204e9800998ecf8427e'] /* */,
+ valueField : 'code',
+ width : 200,
+ listeners : {
+ render : function (_self)
+ {
+ _this.langgridCombo=_self;
+ },
+ select : function (combo, record, index)
+ {
+ _this.langgrid.getDataSource().reload();
+ }
+ },
+ xns : Roo.form,
+ '|xns' : 'Roo.form',
+ store : {
+ xtype : 'Store',
+ sortInfo : { field : 'title', direction: 'ASC' },
+ listeners : {
+ beforeload : function (_self, options)
+ {
+ options =options || {};
+ options.params =options.params|| {};
+ options.params.ltype = 'l';
+ options.params.inlang = 'en';
+
+ options.params._as_code_and_title = 1;
+
+ }
+ },
+ xns : Roo.data,
+ '|xns' : 'Roo.data',
+ proxy : {
+ xtype : 'HttpProxy',
+ method : 'GET',
+ url : baseURL + '/Roo/i18n.php',
+ xns : Roo.data,
+ '|xns' : 'Roo.data'
+ },
+ reader : {
+ xtype : 'JsonReader',
+ fields : [
+ {
+ 'name': 'id',
+ 'type': 'int'
+ },
+ {
+ 'name': 'ltype',
+ 'type': 'string'
+ },
+ {
+ 'name': 'lkey',
+ 'type': 'string'
+ },
+ {
+ 'name': 'inlang',
+ 'type': 'string'
+ },
+ {
+ 'name': 'lval',
+ 'type': 'string'
+ }
+ ],
+ id : 'id',
+ root : 'data',
+ totalProperty : 'total',
+ xns : Roo.data,
+ '|xns' : 'Roo.data'
+ }
+ }
+ }
+ ]
+ },
+ dataSource : {
+ xtype : 'Store',
+ remoteSort : true,
+ sortInfo : { field : 'lkey', direction: 'ASC' },
+ 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;
+
+ }
+ },
+ xns : Roo.data,
+ '|xns' : 'Roo.data',
+ proxy : {
+ xtype : 'HttpProxy',
+ method : 'GET',
+ url : baseURL + '/Roo/i18n.php',
+ xns : Roo.data,
+ '|xns' : 'Roo.data'
+ },
+ reader : {
+ xtype : 'JsonReader',
+ fields : [
+ {
+ 'name': 'id',
+ 'type': 'int'
+ },
+ {
+ 'name': 'ltype',
+ 'type': 'string'
+ },
+ {
+ 'name': 'lkey',
+ 'type': 'string'
+ },
+ {
+ 'name': 'inlang',
+ 'type': 'string'
+ },
+ {
+ 'name': 'lval',
+ 'type': 'string'
+ }
+ ],
+ id : 'id',
+ root : 'data',
+ totalProperty : 'total',
+ xns : Roo.data,
+ '|xns' : 'Roo.data'
+ }
+ },
+ colModel : [
+ {
+ xtype : 'ColumnModel',
+ dataIndex : 'lkey',
+ header : _this._strings['ca0dbad92a874b2f69b549293387925e'] /* Code */,
+ renderer : function(v) { return String.format('{0}', v); },
+ sortable : true,
+ width : 50,
+ xns : Roo.grid,
+ '|xns' : 'Roo.grid'
+ },
+ {
+ xtype : 'ColumnModel',
+ dataIndex : 'lval_en',
+ header : _this._strings['78463a384a5aa4fad5fa73e2f506ecfc'] /* English */,
+ renderer : function(v) { return String.format('{0}', v); },
+ sortable : true,
+ width : 150,
+ xns : Roo.grid,
+ '|xns' : 'Roo.grid'
+ },
+ {
+ xtype : 'ColumnModel',
+ dataIndex : 'lval',
+ header : _this._strings['6dd08874f83507e9c7b23f1a46b7fa7c'] /* Translation */,
+ renderer : function(v) { return String.format('{0}', v); },
+ sortable : true,
+ width : 200,
+ xns : Roo.grid,
+ '|xns' : 'Roo.grid',
+ editor : {
+ xtype : 'GridEditor',
+ xns : Roo.grid,
+ '|xns' : 'Roo.grid',
+ field : {
+ xtype : 'TextField',
+ xns : Roo.form,
+ '|xns' : 'Roo.form'
+ }
+ }
+ },
+ {
+ xtype : 'ColumnModel',
+ dataIndex : 'is_active',
+ header : _this._strings['ae739a236065a45c64ad51aacb19498c'] /* Active? */,
+ renderer : function(v,x,r) {
+
+ return '<img class="x-grid-check-icon' + (v*1 ? '-checked' : '') + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
+
+
+ },
+ width : 150,
+ xns : Roo.grid,
+ '|xns' : 'Roo.grid'
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }; }
+});
{
"name" : "Pman.Tab.AdminTranslations",
- "parent" : "Pman.Tab.Admin",
+ "parent" : "Pman.Tab.AdminTranslationsInt",
"title" : "Admin - Translations",
"path" : "/home/alan/gitlive/Pman.Admin/Pman.Tab.AdminTranslations.bjs",
"permname" : "Admin.Translations",
"modOrder" : "950",
"strings" : {
"0a52da7a03a6de3beefe54f8c03ad80d" : "Original",
- "0b8d92bc19b720bb1065649535463409" : "Translations",
"69fd71b6f79260924a32a45850a13ab7" : "Translations (rescan this to update strings)",
"9d1ead73e678fa2f51a70a933b0bf017" : "Not Found",
"801ab24683a4a8c433c6eb40c48bcd9d" : "Download",
"6dd08874f83507e9c7b23f1a46b7fa7c" : "Translation",
+ "07a1d316d1065473f290c3c2b72a80f3" : "Application Words",
"e3d388b2c43e5ba0905702620ae2abc1" : "Search for",
"e2f9d206562d8f5ea421ad51100f7151" : "Displaying petition_entry{0} - {1} of {2}",
"cd6ae20e52d83f601c5fa12b66f0f6d0" : "Rescan",
+ "91412465ea9169dfd901dd5e7c96dd99" : "Upload",
"4d1c8263ba1036754f8db14a98f9f006" : "Reload",
"f2a6c498fb90ee345d997f888fce3b18" : "Delete",
"03c2e7e41ffc181a4e84080b4710e81e" : "New",
"items" : [
{
"region" : "center",
+ "title" : "Application Words",
"xtype" : "NestedLayoutPanel",
- "title" : "Translations",
"$ xns" : "Roo",
"items" : [
{
"items" : [
{
"xtype" : "LayoutRegion",
- "width" : 450,
"$ xns" : "Roo",
+ "width" : 450,
"split" : true,
"* prop" : "west"
},
},
{
"listeners" : {
- "click" : "function (_self, e)\n{\n var tree = _this.treepanel.tree;\n\n var sn = tree.getSelectionModel().getSelectedNode();\n \n p = {\n csvCols : 'src_id_mdsum,template_id_view_name,template_id_template,src_id_txt,lang,txt',\n csvTitles : 'Code,Module,Template,Original,Language,Translation',\n limit : 9999,\n sort: 'template_id_view_name,template_id_template,src_id_txt',\n dir: 'ASC'\n };\n if (!sn || sn.id == 'transtree') {\n Roo.MessageBox.alert(\"Error\", \"Select language, module or page\");\n return;\n }\n if (typeof(sn.id) == 'number') {\n p.template_id = sn.id;\n\n }\n if (sn.id.match(/^view:/)) {\n var sns = sn.id.split(':');\n p.lang = sns[1];\n p.template_id_view_name = sns[2];\n }\n if (sn.id.match(/^lang:/)) {\n var sns = sn.id.split(':');\n p.lang = sns[1];\n\n }\n // transtree\n // view: {lang} : {view_name}\n // lang:\n \n new Pman.Download({\n url : baseURL + '/Roo/Core_templatestr',\n params : p,\n method : 'GET' \n });\n \n \n \n \n \n}"
+ "click" : "function (_self, e)\n{\n \n \n Pman.Dialog.Image.show({\n _url : baseURL + '/Admin/Import/Core_templatestr',\n \n \n }, function() {\n _this.treepanel.tree.getRootNode().reload();\n });\n \n \n \n}"
+ },
+ "text" : "Upload",
+ "xtype" : "Button",
+ "$ xns" : "Roo.Toolbar"
+ },
+ {
+ "xtype" : "Fill",
+ "$ xns" : "Roo.Toolbar"
+ },
+ {
+ "listeners" : {
+ "click" : "function (_self, e)\n{\n var tree = _this.treepanel.tree;\n\n var sn = tree.getSelectionModel().getSelectedNode();\n \n p = {\n csvCols : 'src_id_mdsum,template_id_view_name,template_id_template,src_id_txt,lang,txt',\n csvTitles : 'Code,Module,Template,Original,Language,Translation',\n limit : 9999,\n sort: 'template_id_view_name,template_id_template,src_id_txt',\n dir: 'ASC'\n };\n if (!sn || sn.id == 'transtree') {\n Roo.MessageBox.alert(\"Error\", \"Select language, module or page\");\n return;\n }\n if (typeof(sn.id) == 'number') {\n p.template_id = sn.id;\n\n }\n \n \n if (sn.id.match(/^table:/)) {\n var sns = sn.id.split(':');\n p.lang = sns[1];\n p.on_table = sns[2];\n p.csvCols = 'src_id_mdsum,on_table,on_id,on_col,src_id_txt,lang,txt';\n p.csvTitles = 'Code,Table,Table id,Column,Language,Translation';\n }\n \n if (sn.id.match(/^view:/)) {\n var sns = sn.id.split(':');\n p.lang = sns[1];\n p.template_id_view_name = sns[2];\n \n }\n if (sn.id.match(/^lang:/)) {\n var sns = sn.id.split(':');\n p.lang = sns[1];\n\n }\n // transtree\n // view: {lang} : {view_name}\n // lang:\n \n new Pman.Download({\n url : baseURL + '/Roo/Core_templatestr',\n params : p,\n method : 'GET' \n });\n \n \n \n \n \n}"
},
"text" : "Download",
"xtype" : "Button",
{
"listeners" : {
"update" : "function (_self, rec, operation)\n{\n Roo.log(operation);\n \n if (operation != 'commit') {\n return;\n }\n \n\n _this.grid.getView().el.mask(\"Saving\");\n new Pman.Request({\n url : baseURL + '/Roo/Core_templatestr',\n method: 'POST',\n params : {\n id : rec.get('id'),\n txt : rec.get('txt')\n },\n success : function()\n {\n _this.grid.getView().el.unmask();\n //g.getDataSource().reload();\n },\n failure : function()\n {\n _this.grid.getView().el.unmask();\n Roo.MessageBox.alert(\"Error\", \"There was a problem saving the data - try reloading\");\n }\n \n });\n \n}",
- "beforeload" : "function (_self, o)\n{\n \n var sn = _this.treepanel.tree.getSelectionModel().getSelectedNode();\n\n if (!sn || typeof(sn.attributes) == 'undefined' || typeof(sn.attributes.leaf) == 'undefined' || !sn.attributes.leaf) { \n _this.grid.ds.removeAll();\n return false;\n }\n\n o.params = o.params || {};\n o.params.lang = sn.parentNode.attributes.id.split(':')[1];\n o.params.template_id = sn.attributes.id * 1;\n o.params.active = 1;\n o.params['!src_id'] = 0;\n \n if (_this.searchBox && _this.searchBox.getValue().length) { \n o.params['_search_txt'] = _this.searchBox.getValue();\n }\n \n \n if(sn.attributes.on_table){\n o.params.on_table = sn.attributes.on_table;\n }\n \n}\n\n\n"
+ "beforeload" : "function (_self, o)\n{\n \n var sn = _this.treepanel.tree.getSelectionModel().getSelectedNode();\n\n if (!sn || typeof(sn.attributes) == 'undefined' || typeof(sn.attributes.leaf) == 'undefined' || !sn.attributes.leaf) { \n _this.grid.ds.removeAll();\n return false;\n }\n\n o.params = o.params || {};\n o.params.lang = sn.parentNode.attributes.id.split(':')[1];\n \n o.params.active = 1;\n o.params['!src_id'] = 0;\n \n if (_this.searchBox && _this.searchBox.getValue().length) { \n o.params['_search_txt'] = _this.searchBox.getValue();\n }\n \n \n if(sn.attributes.on_table){\n o.params.on_table = sn.attributes.on_table;\n } else {\n o.params.template_id = sn.attributes.id * 1;\n }\n \n}\n\n\n"
},
"xtype" : "Store",
"remoteSort" : true,
"items" : [
{
"$ url" : "baseURL + '/Roo/Core_templatestr.php'",
- "xtype" : "HttpProxy",
"method" : "GET",
+ "xtype" : "HttpProxy",
"$ xns" : "Roo.data",
"* prop" : "proxy"
},
},
{
"xtype" : "ColumnModel",
- "width" : 300,
"header" : "Original",
+ "width" : 300,
"$ renderer" : "function(v,x,r) \n{\n var c = '#666';\n if (r.data.updated < r.data.src_id_updated) {\n c = 'red';\n }\n \n return String.format('<div style=\"color:'+c+'\";>{0}</div>', v)\n\n}",
"$ xns" : "Roo.grid",
"* prop" : "cm[]",
},
{
"xtype" : "ColumnModel",
- "width" : 200,
"header" : "Translation",
+ "width" : 200,
"$ renderer" : "function(v,x,r) \n{ \n\n var c = '#666';\n if (r.data.updated < r.data.src_id_updated) {\n c = 'red';\n }\n \n return String.format('<div style=\"color:'+c+'\";>{0}</div>', v)\n\n}",
"$ xns" : "Roo.grid",
"* prop" : "cm[]",
},
{
"xtype" : "ColumnModel",
- "width" : 250,
"header" : "md5",
+ "width" : 250,
"$ renderer" : "function(v,x,r) \n{\n return v ? v : '';\n\n}",
"$ xns" : "Roo.grid",
"* prop" : "cm[]",
_strings : {
'0a52da7a03a6de3beefe54f8c03ad80d' :"Original",
- '0b8d92bc19b720bb1065649535463409' :"Translations",
'69fd71b6f79260924a32a45850a13ab7' :"Translations (rescan this to update strings)",
'9d1ead73e678fa2f51a70a933b0bf017' :"Not Found",
'801ab24683a4a8c433c6eb40c48bcd9d' :"Download",
'6dd08874f83507e9c7b23f1a46b7fa7c' :"Translation",
+ '07a1d316d1065473f290c3c2b72a80f3' :"Application Words",
'e3d388b2c43e5ba0905702620ae2abc1' :"Search for",
'e2f9d206562d8f5ea421ad51100f7151' :"Displaying petition_entry{0} - {1} of {2}",
'cd6ae20e52d83f601c5fa12b66f0f6d0' :"Rescan",
+ '91412465ea9169dfd901dd5e7c96dd99' :"Upload",
'4d1c8263ba1036754f8db14a98f9f006' :"Reload",
'f2a6c498fb90ee345d997f888fce3b18' :"Delete",
'03c2e7e41ffc181a4e84080b4710e81e' :"New",
part : ["Admin", "Translations" ],
order : '950-Pman.Tab.AdminTranslations',
region : 'center',
- parent : 'Pman.Tab.Admin',
+ parent : 'Pman.Tab.AdminTranslationsInt',
name : "Admin - Translations",
disabled : false,
permname : 'Admin.Translations',
return {
xtype : 'NestedLayoutPanel',
region : 'center',
- title : _this._strings['0b8d92bc19b720bb1065649535463409'] /* Translations */,
+ title : _this._strings['07a1d316d1065473f290c3c2b72a80f3'] /* Application Words */,
xns : Roo,
'|xns' : 'Roo',
layout : {
+ }
+ },
+ xns : Roo.Toolbar,
+ '|xns' : 'Roo.Toolbar'
+ },
+ {
+ xtype : 'Fill',
+ xns : Roo.Toolbar,
+ '|xns' : 'Roo.Toolbar'
+ },
+ {
+ xtype : 'Button',
+ text : _this._strings['91412465ea9169dfd901dd5e7c96dd99'] /* Upload */,
+ listeners : {
+ click : function (_self, e)
+ {
+
+
+ Pman.Dialog.Image.show({
+ _url : baseURL + '/Admin/Import/Core_templatestr',
+
+
+ }, function() {
+ _this.treepanel.tree.getRootNode().reload();
+ });
+
+
+
}
},
xns : Roo.Toolbar,
p.template_id = sn.id;
}
+
+
+ if (sn.id.match(/^table:/)) {
+ var sns = sn.id.split(':');
+ p.lang = sns[1];
+ p.on_table = sns[2];
+ p.csvCols = 'src_id_mdsum,on_table,on_id,on_col,src_id_txt,lang,txt';
+ p.csvTitles = 'Code,Table,Table id,Column,Language,Translation';
+ }
+
if (sn.id.match(/^view:/)) {
var sns = sn.id.split(':');
p.lang = sns[1];
p.template_id_view_name = sns[2];
+
}
if (sn.id.match(/^lang:/)) {
var sns = sn.id.split(':');
o.params = o.params || {};
o.params.lang = sn.parentNode.attributes.id.split(':')[1];
- o.params.template_id = sn.attributes.id * 1;
+
o.params.active = 1;
o.params['!src_id'] = 0;
if(sn.attributes.on_table){
o.params.on_table = sn.attributes.on_table;
- }
+ } else {
+ o.params.template_id = sn.attributes.id * 1;
+ }
},
update : function (_self, rec, operation)
$this->scanTables();
$this->syncLanguage();
+ DB_DataObject::factory('core_template')->query(
+ "update core_template set is_deleted = 1 where filetype = ''"
+ );
+
$this->jok('OK');
}
if($template->find(true)){
$o = clone ($template);
}
+ $template->filetype = 'bjs';
$template->updated = $template->sqlValue("NOW()");
function scanPmanBJS()
{
+
+ $ids = array();
foreach ($this->modules() as $m){
$view_name = "Pman.$m";
if(!$dh){
continue;
}
-
+
while (($fn = readdir($dh)) !== false) {
if(empty($fn) || $fn[0] == '.' || !preg_match('/\.bjs$/', $fn)){
$template->setFrom(array(
'template' => $fn,
'lang' => 'en',
- 'view_name' => $view_name
+ 'view_name' => $view_name,
+
));
$o = false;
if($template->find(true)){
$o = clone ($template);
}
+ $template->is_deleted = 0;
+ $template->filetype = 'bjs';
$template->updated = $template->sqlValue("NOW()");
(empty($o)) ? $template->insert() : $template->update($o);
-
+ $ids[] = $template->id;
$data = json_decode(file_get_contents('Pman' . '/' . $m . '/' . $fn), true);
$template->words = empty($data['strings']) ? array() : $data['strings'];
}
}
+ $del = DB_DataObject::factory('core_template');
+ $del->whereAddIn('!id', $ids, 'int');
+ $del->whereAddIn('view_name', $this->modules(), 'string');
+ $del->filetype = 'bjs';
+ $delids = $del->fetchAll('id');
+ if ($delids) {
+ DB_DataObject::factory('core_template')->query(
+ 'update core_template set is_deleted = 1 where id in('. implode(',', $delids). ')'
+ );
+ }
+
+
+
+
+
}
function scanTables()
foreach($ar as $pg) {
-
- $tp->syncTemplatePage(array(
+ $temp = $tp->syncTemplatePage(array(
'base' =>'Pman.'.$m,
'template_dir' => "Pman/$m/templates",
'template' => $pg
));
+ if ($temp) {
+ $ids[] = $temp->id;
+ }
}
// should clean up old templates..
// php files..
foreach($ar as $pg) {
- $tp->syncPhpGetText(array(
+ $temp = $tp->syncPhpGetText(array(
'base' =>'Pman.'.$m,
'template_dir' => "Pman/$m",
'template' => $pg
));
+ if ($temp) {
+ $ids[] = $temp->id;
+ }
+
}
//$tp->syncTemplatePage($pg);
}
-
+ $del = DB_DataObject::factory('core_template');
+ $del->whereAddIn('!id', $ids, 'int');
+ $del->whereAddIn('view_name', $this->modules(), 'string');
+ $del->whereAddIn('filetype' , array( 'php', 'html' ), 'string');
+ $delids = $del->fetchAll('id');
+ if ($delids) {
+ DB_DataObject::factory('core_template')->query(
+ 'update core_template set is_deleted = 1 where id in('. implode(',', $delids). ')'
+ );
+ }
}