MODx.panel.Plugin=function(A){A=A||{};Ext.applyIf(A,{url:MODx.config.connectors_url+"element/plugin.php",baseParams:{},id:"modx-panel-plugin",class_key:"modPlugin",plugin:"",bodyStyle:"",allowDrop:false,items:[{html:"<h2>"+_("plugin_new")+"</h2>",id:"modx-plugin-header",cls:"modx-page-header",border:false},MODx.getPageStructure([{title:_("plugin_title"),bodyStyle:"padding: 15px;",layout:"form",id:"modx-plugin-form",labelWidth:150,defaults:{border:false,msgTarget:"side"},items:[{html:"<p>"+_("plugin_msg")+"</p>",id:"modx-plugin-msg"},{xtype:"hidden",name:"id",id:"modx-plugin-id",value:A.record.id||0},{xtype:"hidden",name:"props",id:"modx-plugin-props",value:A.record.props||null},{xtype:"textfield",fieldLabel:_("plugin_name"),name:"name",id:"modx-plugin-name",width:300,maxLength:255,enableKeyEvents:true,allowBlank:false,value:A.record.name,listeners:{keyup:{scope:this,fn:function(B,C){Ext.getCmp("modx-plugin-header").getEl().update("<h2>"+_("plugin")+": "+B.getValue()+"</h2>");}}}},{xtype:"textfield",fieldLabel:_("plugin_desc"),name:"description",id:"modx-plugin-description",width:300,maxLength:255,value:A.record.description},{xtype:"modx-combo-category",fieldLabel:_("category"),name:"category",id:"modx-plugin-category",width:250,value:A.record.category||0},{xtype:"xcheckbox",fieldLabel:_("plugin_disabled"),name:"disabled",id:"modx-plugin-disabled",inputValue:1,checked:A.record.disabled||0},{xtype:"xcheckbox",fieldLabel:_("plugin_lock"),description:_("plugin_lock_msg"),name:"locked",id:"modx-plugin-locked",inputValue:1,checked:A.record.locked||0},{xtype:"xcheckbox",fieldLabel:_("clear_cache_on_save"),description:_("clear_cache_on_save_msg"),name:"clearCache",id:"modx-plugin-clear-cache",inputValue:1,checked:Ext.isDefined(A.record.clearCache)||true},{html:MODx.onPluginFormRender,border:false},{html:"<br />"+_("plugin_code")},{xtype:"textarea",hideLabel:true,name:"plugincode",id:"modx-plugin-plugincode",width:"95%",height:400,value:A.record.plugincode||"<?php\n"}]},{title:_("system_events"),bodyStyle:"padding: 15px;",id:"modx-plugin-sysevents",items:[{html:"<p>"+_("plugin_event_msg")+"</p>",id:"modx-plugin-sysevents-msg",border:false},{xtype:"modx-grid-plugin-event",preventRender:true,plugin:A.plugin,listeners:{updateEvent:{fn:this.markDirty,scope:this},rowclick:{fn:this.markDirty,scope:this}}}]},{xtype:"modx-panel-element-properties",elementPanel:"modx-panel-plugin",elementId:A.plugin,elementType:"modPlugin"}],{id:"modx-plugin-tabs"})],useLoadingMask:true,listeners:{setup:{fn:this.setup,scope:this},success:{fn:this.success,scope:this},beforeSubmit:{fn:this.beforeSubmit,scope:this}}});MODx.panel.Plugin.superclass.constructor.call(this,A);};Ext.extend(MODx.panel.Plugin,MODx.FormPanel,{initialized:false,setup:function(){if(!this.initialized){this.getForm().setValues(this.config.record);}if(!Ext.isEmpty(this.config.record.name)){Ext.getCmp("modx-plugin-header").getEl().update("<h2>"+_("plugin")+": "+this.config.record.name+"</h2>");}if(!Ext.isEmpty(this.config.record.properties)){var B=this.config.record.properties;var A=Ext.getCmp("modx-grid-element-properties");if(A){A.defaultProperties=B;A.getStore().loadData(B);}}this.fireEvent("ready",this.config.record);if(MODx.onLoadEditor){MODx.onLoadEditor(this);}this.clearDirty();MODx.fireEvent("ready");this.initialized=true;},beforeSubmit:function(B){var A=Ext.getCmp("modx-grid-plugin-event");Ext.apply(B.form.baseParams,{events:A.encodeModified(),propdata:Ext.getCmp("modx-grid-element-properties").encode()});this.cleanupEditor();return this.fireEvent("save",{values:this.getForm().getValues(),stay:MODx.config.stay});},success:function(C){if(MODx.request.id){Ext.getCmp("modx-grid-element-properties").save();}Ext.getCmp("modx-grid-plugin-event").getStore().commitChanges();this.getForm().setValues(C.result.object);var B=Ext.getCmp("modx-element-tree");if(B){var D=Ext.getCmp("modx-plugin-category").getValue();var A=D!=""&&D!=null?"n_plugin_category_"+D:"n_type_plugin";B.refreshNode(A,true);}},changeEditor:function(){this.cleanupEditor();this.on("success",function(C){var D=C.result.object.id;var A=Ext.getCmp("modx-plugin-which-editor").getValue();MODx.request.a=MODx.action["element/plugin/update"];var B="?"+Ext.urlEncode(MODx.request)+"&which_editor="+A+"&id="+D;location.href=B;});this.submit();},cleanupEditor:function(){if(MODx.onSaveEditor){var A=Ext.getCmp("modx-plugin-plugincode");MODx.onSaveEditor(A);}}});Ext.reg("modx-panel-plugin",MODx.panel.Plugin);