MODx.grid.LocalProperty=function(config){config=config||{};Ext.applyIf(config,{dynProperty:'xtype',dynField:'value',propertyRecord:[{name:'name'},{name:'value'}],data:[]});MODx.grid.LocalProperty.superclass.constructor.call(this,config);this.propRecord=Ext.data.Record.create(config.propertyRecord);};Ext.extend(MODx.grid.LocalProperty,MODx.grid.LocalGrid,{onCellDblClick:function(g,ri,ci,e){var cm=this.getColumnModel();if(cm.getColumnId(ci)==this.config.dynField){e.preventDefault();var r=this.getStore().getAt(ri).data;this.initEditor(cm,ci,ri,r);this.startEditing(ri,ci);}},initEditor:function(cm,ci,ri,r){cm.setEditable(ci,true);var xtype=this.config.dynProperty;var o;if(r[xtype]=='list'){o=this.createCombo(r);}else{var z={};z[xtype]=r[xtype]||'textfield';try{o=Ext.ComponentMgr.create(z);}catch(e){z[xtype]='textfield';o=MODx.load(z);}}
var ed=new Ext.grid.GridEditor(o);cm.setEditor(ci,ed);return ed;},renderDynField:function(v,md,rec,ri,ci,s,g){var r=s.getAt(ri).data;var f,idx;var oz=v;var xtype=this.config.dynProperty;if(!r[xtype]||r[xtype]=='combo-boolean'){f=MODx.grid.Grid.prototype.rendYesNo;oz=f(v==1,md);}else if(r[xtype]==='datefield'){f=Ext.util.Format.dateRenderer('Y-m-d');oz=f(v);}else if(r[xtype]==='password'){f=this.rendPassword;oz=f(v,md);}else if(r[xtype].substr(0,5)=='combo'||r[xtype]=='list'||r[xtype].substr(0,9)=='modx-combo'){var cm=g.getColumnModel();var ed=cm.getCellEditor(ci,ri);var cb;if(!ed){r.xtype=r.xtype||'combo-boolean';cb=this.createCombo(r);ed=new Ext.grid.GridEditor(cb);cm.setEditor(ci,ed);}else if(ed&&ed.field&&ed.field.xtype=='modx-combo'){cb=ed.field;}
if(r[xtype]!='list'){f=Ext.util.Format.comboRenderer(ed.field);oz=f(v);}else if(cb){idx=cb.getStore().find(cb.valueField,v);rec=cb.getStore().getAt(idx);if(rec){oz=rec.get(cb.displayField);}else{oz=v;}}}
return Ext.util.Format.htmlEncode(oz);},createCombo:function(p){var obj;try{obj=Ext.ComponentMgr.create({xtype:r.xtype,id:Ext.id()});}catch(e){try{var flds=p.options;var data=[];for(var i=0;i<flds.length;i=i+1){data.push([flds[i].name,flds[i].value,flds[i].text]);}
obj=MODx.load({xtype:'modx-combo',store:new Ext.data.SimpleStore({fields:['d','v','t'],data:data}),displayField:'d',valueField:'v',mode:'local',triggerAction:'all',editable:false,selectOnFocus:false,preventRender:true});}catch(e2){obj=Ext.ComponentMgr.create({xtype:'combo-boolean',id:Ext.id()});}}
return obj;}});Ext.reg('grid-local-property',MODx.grid.LocalProperty);
;MODx.combo.LexiconTopic=function(config){config=config||{};Ext.applyIf(config,{name:'topic',hiddenName:'topic',forceSelection:true,typeAhead:false,editable:false,allowBlank:false,listWidth:300,url:MODx.config.connectors_url+'workspace/lexicon/topic.php',fields:['name'],displayField:'name',valueField:'name',baseParams:{action:'getList','namespace':'core','language':'en'},pageSize:20});MODx.combo.LexiconTopic.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.LexiconTopic,MODx.combo.ComboBox,{setNamespace:function(ns,t){this.store.baseParams['namespace']=ns;this.store.load({callback:function(){if(t){this.setValue(t);}},scope:this});},setLanguage:function(ns,t){this.store.baseParams['language']=ns;this.store.load({callback:function(){if(t){this.setValue(t);}},scope:this});}});Ext.reg('modx-combo-lexicon-topic',MODx.combo.LexiconTopic);
;MODx.grid.Lexicon=function(config){config=config||{};Ext.applyIf(config,{id:'modx-grid-lexicon',url:MODx.config.connectors_url+'workspace/lexicon/index.php',fields:['name','value','namespace','topic','language','editedon','overridden'],baseParams:{action:'getList','namespace':'core',topic:'',language:MODx.config.manager_language||'en'},width:'98%',paging:true,autosave:true,columns:[{header:_('name'),dataIndex:'name',width:200,sortable:true,renderer:this._renderStatus},{header:_('value'),dataIndex:'value',width:500,sortable:false,editor:{xtype:'textarea'},renderer:this._renderStatus},{header:_('last_modified'),dataIndex:'editedon',width:125}],tbar:[{text:_('namespace')+':'},{xtype:'modx-combo-namespace',id:'modx-lexicon-filter-namespace',itemId:'namespace',value:'core',width:120,listeners:{'select':{fn:this.changeNamespace,scope:this}}},{text:_('topic')+':'},{xtype:'modx-combo-lexicon-topic',id:'modx-lexicon-filter-topic',itemId:'topic',value:'default',pageSize:20,width:120,listeners:{'select':{fn:this.changeTopic,scope:this}}},{text:_('language')+':'},{xtype:'modx-combo-language',name:'language',id:'modx-lexicon-filter-language',itemId:'language',value:MODx.config.manager_language||'en',width:100,listeners:{'select':{fn:this.changeLanguage,scope:this}}},'->',{xtype:'button',text:_('entry_create'),handler:this.createEntry,scope:this},'-',{xtype:'textfield',name:'name',id:'modx-lexicon-filter-search',itemId:'search',width:120,emptyText:_('search')+'...',listeners:{'change':{fn:this.filter.createDelegate(this,['search'],true),scope:this},'render':{fn:function(cmp){new Ext.KeyMap(cmp.getEl(),{key:Ext.EventObject.ENTER,fn:this.blur,scope:cmp});},scope:this}}},{xtype:'button',id:'modx-lexicon-filter-clear',itemId:'clear',text:_('filter_clear'),listeners:{'click':{fn:this.clearFilter,scope:this}}}],pagingItems:[{text:_('reload_from_base'),handler:this.reloadFromBase,scope:this}]});MODx.grid.Lexicon.superclass.constructor.call(this,config);};Ext.extend(MODx.grid.Lexicon,MODx.grid.Grid,{console:null,_renderStatus:function(v,md,rec,ri){switch(rec.data.overridden){case 1:return'<span style="color: green;">'+v+'</span>';break;case 2:return'<span style="color: purple;">'+v+'</span>';default:return'<span>'+v+'</span>';}},filter:function(cb,r,i,name){if(!name){return false;}
this.store.baseParams[name]=cb.getValue();this.getBottomToolbar().changePage(1);this.refresh();return true;},clearFilter:function(){this.store.baseParams={action:'getList','namespace':'core',topic:'default',language:'en'};this.getBottomToolbar().changePage(1);var tb=this.getTopToolbar();tb.getComponent('namespace').setValue('core');var tcb=tb.getComponent('topic');tcb.store.baseParams['namespace']='core';tcb.store.load();tcb.setValue('default');var tcl=tb.getComponent('language');tcb.store.baseParams['namespace']='core';tcb.store.load();tcl.setValue('en');tb.getComponent('search').setValue('');this.refresh();},changeNamespace:function(cb,nv,ov){this.setFilterParams(cb.getValue(),'default','en');},changeTopic:function(cb,nv,ov){this.setFilterParams(null,cb.getValue());},changeLanguage:function(cb,nv,ov){this.setFilterParams(null,null,cb.getValue());},setFilterParams:function(ns,t,l){var tb=this.getTopToolbar();if(!tb){return false;}
var tcb,tcl;if(ns){tb.getComponent('namespace').setValue(ns);tcl=tb.getComponent('language');if(tcl){tcl.store.baseParams['namespace']=ns;tcl.store.load({callback:function(){tcl.setValue(l||'en');}});}
tcb=tb.getComponent('topic');if(tcb){tcb.store.baseParams['namespace']=ns;tcb.store.baseParams['language']=l?l:(tcl?tcl.getValue():'en');tcb.store.load({callback:function(){tcb.setValue(t||'default');}});}}else if(t){tcb=tb.getComponent('topic');if(tcb){tcb.setValue(t);}}
var s=this.getStore();if(s){if(ns){s.baseParams['namespace']=ns;}
if(t){s.baseParams['topic']=t||'default';}
if(l){s.baseParams['language']=l||'en';}
s.removeAll();}
this.getBottomToolbar().changePage(1);this.refresh();},loadWindow2:function(btn,e,o){var tb=this.getTopToolbar();this.menu.record={'namespace':tb.getComponent('namespace').getValue(),language:tb.getComponent('language').getValue()};if(o.xtype!='modx-window-lexicon-import'){this.menu.record.topic=tb.getComponent('topic').getValue();}
this.loadWindow(btn,e,o);},reloadFromBase:function(){Ext.Ajax.timeout=0;var topic='/workspace/lexicon/reload/';if(this.console===null){this.console=MODx.load({xtype:'modx-console',register:'mgr',topic:topic});}else{this.console.setRegister('mgr',topic);}
this.console.on('complete',function(){this.refresh();},this);this.console.show(Ext.getBody());MODx.Ajax.request({url:this.config.url,params:{action:'reloadFromBase',register:'mgr',topic:topic},listeners:{'success':{fn:function(r){this.refresh();},scope:this}}});},revertEntry:function(){var p=this.menu.record;p.action='revert';MODx.Ajax.request({url:this.config.url,params:p,listeners:{'success':{fn:function(r){this.refresh();},scope:this}}});},getMenu:function(){var r=this.getSelectionModel().getSelected();var m=[];if(r.data.overridden){m.push({text:_('entry_revert'),handler:this.revertEntry});}
return m;},createEntry:function(btn,e){var r=this.menu.record||{};var tb=this.getTopToolbar();r['namespace']=tb.getComponent('namespace').getValue();r.language=tb.getComponent('language').getValue();r.topic=tb.getComponent('topic').getValue();if(!this.createEntryWindow){this.createEntryWindow=MODx.load({xtype:'modx-window-lexicon-entry-create',record:r,listeners:{'success':{fn:function(o){this.refresh();},scope:this}}});}
this.createEntryWindow.reset();this.createEntryWindow.setValues(r);this.createEntryWindow.show(e.target);}});Ext.reg('modx-grid-lexicon',MODx.grid.Lexicon);MODx.window.ExportLexicon=function(config){config=config||{};this.ident=config.ident||'explex'+Ext.id();var r=config.record;Ext.applyIf(config,{title:_('lexicon_export'),url:MODx.config.connectors_url+'workspace/lexicon/index.php',action:'export',fileUpload:true,fields:[{html:_('lexicon_export_desc'),border:false,bodyStyle:'margin: 10px;',id:'modx-'+this.ident+'-desc',itemId:'desc',anchor:'100%'},{xtype:'modx-combo-namespace',fieldLabel:_('namespace'),name:'namespace',id:'modx-'+this.ident+'-namespace',itemId:'namespace',anchor:'100%',listeners:{'select':{fn:function(cb,r,i){cle=this.fp.getComponent('topic');if(cle){cle.store.baseParams['namespace']=cb.getValue();cle.setValue('');cle.store.reload();}else{MODx.debug('cle not found');}},scope:this}}},{xtype:'modx-combo-lexicon-topic',fieldLabel:_('topic'),name:'topic',id:'modx-'+this.ident+'-topic',itemId:'topic',anchor:'100%'},{xtype:'modx-combo-language',fieldLabel:_('language'),name:'language',id:'modx-'+this.ident+'-language',itemId:'language',anchor:'100%'}]});MODx.window.ExportLexicon.superclass.constructor.call(this,config);};Ext.extend(MODx.window.ExportLexicon,MODx.Window);Ext.reg('modx-window-lexicon-export',MODx.window.ExportLexicon);MODx.window.LexiconEntryCreate=function(config){config=config||{};this.ident=config.ident||'lexentc'+Ext.id();var r=config.record;Ext.applyIf(config,{title:_('entry_create'),url:MODx.config.connectors_url+'workspace/lexicon/index.php',action:'create',fileUpload:true,fields:[{xtype:'textfield',fieldLabel:_('name'),id:'modx-'+this.ident+'-name',itemId:'name',name:'name',anchor:'100%'},{xtype:'modx-combo-namespace',fieldLabel:_('namespace'),name:'namespace',id:'modx-'+this.ident+'-namespace',itemId:'namespace',anchor:'100%',listeners:{'select':{fn:function(cb,r,i){cle=this.fp.getComponent('topic');if(cle){cle.store.baseParams['namespace']=cb.getValue();cle.setValue('');cle.store.reload();}else{MODx.debug('cle not found');}},scope:this}}},{xtype:'modx-combo-lexicon-topic',fieldLabel:_('topic'),name:'topic',id:'modx-'+this.ident+'-topic',itemId:'topic',anchor:'100%'},{xtype:'modx-combo-language',fieldLabel:_('language'),name:'language',id:'modx-'+this.ident+'-language',itemId:'language',anchor:'100%'},{xtype:'textarea',fieldLabel:_('value'),id:'modx-'+this.ident+'-value',itemId:'value',name:'value',anchor:'100%'}]});MODx.window.LexiconEntryCreate.superclass.constructor.call(this,config);};Ext.extend(MODx.window.LexiconEntryCreate,MODx.Window);Ext.reg('modx-window-lexicon-entry-create',MODx.window.LexiconEntryCreate);
;MODx.panel.Lexicon=function(config){config=config||{};Ext.applyIf(config,{id:'modx-panel-lexicon',cls:'container',itemId:'panel-lexicon',bodyStyle:'',defaults:{autoHeight:true,collapsible:false},items:[{html:'<h2>'+_('lexicon_management')+'</h2>',border:false,id:'modx-lexicon-header',itemId:'lexicon-header',cls:'modx-page-header'},MODx.getPageStructure([{title:_('lexicon_management'),layout:'form',items:[{html:'<p>'+_('lexicon_management_desc')+'</p>',bodyCssClass:'panel-desc',border:false},{xtype:'modx-grid-lexicon',itemId:'grid-lexicon',cls:'main-wrapper',title:'',preventRender:true}]}])]});MODx.panel.Lexicon.superclass.constructor.call(this,config);};Ext.extend(MODx.panel.Lexicon,MODx.FormPanel);Ext.reg('modx-panel-lexicon',MODx.panel.Lexicon);
;MODx.page.LexiconManagement=function(config){config=config||{};Ext.applyIf(config,{components:[{xtype:'modx-panel-lexicon'}],buttons:[{text:_('help_ex'),handler:MODx.loadHelpPane}]});MODx.page.LexiconManagement.superclass.constructor.call(this,config);};Ext.extend(MODx.page.LexiconManagement,MODx.Component);Ext.reg('modx-page-lexicon-management',MODx.page.LexiconManagement);