MODx.Console=function(A){A=A||{};Ext.Updater.defaults.showLoadIndicator=false;Ext.applyIf(A,{title:_("console"),modal:Ext.isIE?false:true,shadow:true,resizable:false,collapsible:false,closable:false,maximizable:true,autoScroll:true,height:400,width:650,refreshRate:2,cls:"modx-window modx-console",items:[{itemId:"header",cls:"modx-console-text",html:_("console_running"),border:false},{xtype:"panel",itemId:"body",cls:"x-form-text modx-console-text"}],buttons:[{text:_("console_download_output"),handler:this.download,scope:this},{text:_("ok"),id:"modx-console-ok",itemId:"okBtn",disabled:true,scope:this,handler:this.hideConsole}]});MODx.Console.superclass.constructor.call(this,A);this.config=A;this.addEvents({shutdown:true,complete:true});this.on("show",this.init,this);this.on("hide",function(){this.getComponent("body").el.update("");});this.on("complete",this.onComplete,this);};Ext.extend(MODx.Console,Ext.Window,{mgr:null,running:false,init:function(){Ext.Msg.hide();this.fbar.getComponent("okBtn").setDisabled(true);this.getComponent("body").el.dom.innerHTML="";this.provider=new Ext.direct.PollingProvider({type:"polling",url:MODx.config.connectors_url+"system/index.php",interval:1000,baseParams:{action:"console",register:this.config.register||"",topic:this.config.topic||"",show_filename:this.config.show_filename||0,format:this.config.format||"html_log"}});Ext.Direct.addProvider(this.provider);Ext.Direct.on("message",function(C,B){if(C.data.search("COMPLETED")!=-1){this.fireEvent("complete");}else{var A=this.getComponent("body");if(A){A.el.insertHtml("beforeEnd",C.data);C.data="";A.el.scroll("b",A.el.getHeight(),true);}}delete C;},this);},onComplete:function(){this.provider.disconnect();this.fbar.getComponent("okBtn").setDisabled(false);},download:function(){var A=this.getComponent("body").getEl().dom.innerHTML||"&nbsp;";MODx.Ajax.request({url:MODx.config.connectors_url+"system/index.php",params:{action:"downloadOutput",data:A},listeners:{success:{fn:function(B){location.href=MODx.config.connectors_url+"system/index.php?action=downloadOutput&HTTP_MODAUTH="+MODx.siteId+"&download="+B.message;},scope:this}}});},setRegister:function(B,A){this.config.register=B;this.config.topic=A;},hideConsole:function(){if(this.provider&&this.provider.disconnect){try{this.provider.disconnect();}catch(A){}}this.fireEvent("shutdown");this.hide();}});Ext.reg("modx-console",MODx.Console);