CKEDITOR.plugins.add('rewrite',{init:function(a){if(a.config.rewrite_urls){var b={};for(var c in a.config.rewrite_rules){var d=a.config.rewrite_rules[c],e=0;for(var f in d){var g=d[f].from,h=d[f].to,i=d[f].to;if(g===false)g=a.config.rewrite_default_from;if(h===false)i=h=a.config.rewrite_default_to;if(typeof h==='function'){e++;i='___function___'+e;}var j=':'+g+':'+i;if(!b[j])b[j]={from:g,to:h,rules:[]};b[j].rules.push('<'+c+'\\s+[^>]*s*'+f+'="');}}for(var k=0;k<a.config.rewrite_events.length;k++){var l=a.config.rewrite_events[k];a.on(l,(function(m){return function(n){for(var o in b){var p=b[o].from,q=b[o].to,r=b[o].rules,s=new RegExp('('+r.join('|')+')('+p+')','i'),t=new RegExp(p,'i');if(m=='mode'&&a.mode=='source')a.setData(a.getData());else if(typeof n.data!=='undefined')if(typeof n.data.dataValue!=='undefined')n.data.dataValue=n.data.dataValue.replace(s,function(u,v,w){return v+w.replace(t,q);});else n.data=n.data.replace(s,function(u,v,w){return v+w.replace(t,q);});}};})(l));}}}});CKEDITOR.config.rewrite_events=['afterSetDara','getData','insertHtml','mode'];CKEDITOR.config.rewrite_default_from=document.location.href.replace(/^(http:\/\/[^\/]*).*/,'$1').replace(/^https?/,'https?');CKEDITOR.config.rewrite_default_to='';CKEDITOR.config.rewrite_rules={a:{href:{from:false,to:false}},area:{href:{from:false,to:false}},img:{src:{from:false,to:false}},object:{data:{from:false,to:false}},param:{value:{from:false,to:false}},embed:{src:{from:false,to:false}},input:{src:{from:false,to:false}},iframe:{src:{from:false,to:false}},frame:{src:{from:false,to:false}},form:{action:{from:false,to:false}}};CKEDITOR.config.rewrite_urls=false;
