Upgrade to Xinha 0.931. Xinha has been optimized for size and dozens of issues have been closed
out since the last upgrade . Add Firefox and Xinha buttons to main page to show our support.
This commit is contained in:
@@ -4,6 +4,6 @@
|
||||
<!--filters-->
|
||||
<div style="margin-top: 10px;">
|
||||
<input type="button" id="[ok]" value="_(OK)" />
|
||||
<input type="button" id="[cancel]" value="_(CANCEL)" />
|
||||
<input type="button" id="[cancel]" value="_(Cancel)" />
|
||||
</div>
|
||||
</div>
|
||||
6
xinha/plugins/SuperClean/filters/paragraph.js
Normal file
6
xinha/plugins/SuperClean/filters/paragraph.js
Normal file
@@ -0,0 +1,6 @@
|
||||
function(html) {
|
||||
html = html.replace(/<\s*p[^>]*>/gi, '');
|
||||
html = html.replace(/<\/\s*p\s*>/gi, '');
|
||||
html = html.trim();
|
||||
return html;
|
||||
}
|
||||
53
xinha/plugins/SuperClean/filters/word.js
Normal file
53
xinha/plugins/SuperClean/filters/word.js
Normal file
@@ -0,0 +1,53 @@
|
||||
function(html) {
|
||||
// Remove HTML comments
|
||||
html = html.replace(/<!--[\w\s\d@{}:.;,'"%!#_=&|?~()[*+\/\-\]]*-->/gi, "" );
|
||||
html = html.replace(/<!--[^\0]*-->/gi, '');
|
||||
// Remove all HTML tags
|
||||
html = html.replace(/<\/?\s*HTML[^>]*>/gi, "" );
|
||||
// Remove all BODY tags
|
||||
html = html.replace(/<\/?\s*BODY[^>]*>/gi, "" );
|
||||
// Remove all META tags
|
||||
html = html.replace(/<\/?\s*META[^>]*>/gi, "" );
|
||||
// Remove all SPAN tags
|
||||
html = html.replace(/<\/?\s*SPAN[^>]*>/gi, "" );
|
||||
// Remove all FONT tags
|
||||
html = html.replace(/<\/?\s*FONT[^>]*>/gi, "");
|
||||
// Remove all IFRAME tags.
|
||||
html = html.replace(/<\/?\s*IFRAME[^>]*>/gi, "");
|
||||
// Remove all STYLE tags & content
|
||||
html = html.replace(/<\/?\s*STYLE[^>]*>(.|[\n\r\t])*<\/\s*STYLE\s*>/gi, "" );
|
||||
// Remove all TITLE tags & content
|
||||
html = html.replace(/<\s*TITLE[^>]*>(.|[\n\r\t])*<\/\s*TITLE\s*>/gi, "" );
|
||||
// Remove javascript
|
||||
html = html.replace(/<\s*SCRIPT[^>]*>[^\0]*<\/\s*SCRIPT\s*>/gi, "");
|
||||
// Remove all HEAD tags & content
|
||||
html = html.replace(/<\s*HEAD[^>]*>(.|[\n\r\t])*<\/\s*HEAD\s*>/gi, "" );
|
||||
// Remove Class attributes
|
||||
html = html.replace(/<\s*(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;
|
||||
// Remove Style attributes
|
||||
html = html.replace(/<\s*(\w[^>]*) style="([^"]*)"([^>]*)/gi, "<$1$3") ;
|
||||
// Remove Lang attributes
|
||||
html = html.replace(/<\s*(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;
|
||||
// Remove XML elements and declarations
|
||||
html = html.replace(/<\\?\?xml[^>]*>/gi, "") ;
|
||||
// Remove Tags with XML namespace declarations: <o:p></o:p>
|
||||
html = html.replace(/<\/?\w+:[^>]*>/gi, "") ;
|
||||
// Replace the
|
||||
html = html.replace(/ /, " " );
|
||||
|
||||
// Transform <p><br /></p> to <br>
|
||||
//html = html.replace(/<\s*p[^>]*>\s*<\s*br\s*\/>\s*<\/\s*p[^>]*>/gi, "<br>");
|
||||
html = html.replace(/<\s*p[^>]*><\s*br\s*\/?>\s*<\/\s*p[^>]*>/gi, "<br>");
|
||||
|
||||
// Remove <P>
|
||||
html = html.replace(/<\s*p[^>]*>/gi, "");
|
||||
|
||||
// Replace </p> with <br>
|
||||
html = html.replace(/<\/\s*p[^>]*>/gi, "<br>");
|
||||
|
||||
// Remove any <br> at the end
|
||||
html = html.replace(/(\s*<br>\s*)*$/, "");
|
||||
|
||||
html = html.trim();
|
||||
return html;
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 941 B After Width: | Height: | Size: 334 B |
18
xinha/plugins/SuperClean/lang/ja.js
Normal file
18
xinha/plugins/SuperClean/lang/ja.js
Normal file
@@ -0,0 +1,18 @@
|
||||
// I18N constants
|
||||
// LANG: "ja", ENCODING: UTF-8
|
||||
{
|
||||
"Clean up HTML": "HTMLのクリーンナップ",
|
||||
"Please select from the following cleaning options...": "以下のクリーンナップオプションを選択してください...",
|
||||
"General tidy up and correction of some problems.": "一般的な適正化といくつかの問題を修正します。",
|
||||
"Clean bad HTML from Microsoft Word": "Microsoft Wordによる不正なHTMLの清潔化",
|
||||
"Remove custom typefaces (font \"styles\").": "独自フォント名設定の除去 (font face)。",
|
||||
"Remove custom font sizes.": "独自フォントサイズ設定の除去。",
|
||||
"Remove custom text colors.": "独自文字色設定の除去。",
|
||||
"Remove lang attributes.": "言語属性の除去。",
|
||||
"Go": "実行",
|
||||
"Cancel": "中止",
|
||||
"Tidy failed. Check your HTML for syntax errors.": "適正化に失敗しました。HTMLの文法エラーを確認してください。",
|
||||
"You don't have anything to tidy!": "適正化するものは何もありません!",
|
||||
"Replace directional quote marks with non-directional quote marks.": "方向つき引用符を方向なし引用符に置換。",
|
||||
"CANCEL": "中止"
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
// I18N constants
|
||||
// LANG: "no", ENCODING: UTF-8
|
||||
// LANG: "nb", ENCODING: UTF-8
|
||||
// translated: Kim Steinhaug, http://www.steinhaug.com/, kim@steinhaug.com
|
||||
{
|
||||
"Clean up HTML": "Vask HTML kode",
|
||||
@@ -9,7 +9,7 @@
|
||||
"Remove custom typefaces (font \"styles\").": "Fjerne egendefinerte skrifttyper (font face)",
|
||||
"Remove custom font sizes.": "Fjerne egendefinerte skriftstørrelser (font size)",
|
||||
"Remove custom text colors.": "Fjerne egendefinerte skriftfarger (font color)",
|
||||
"Remove lang attributes.": "Fjerne lang attributter.",
|
||||
"Remove lang attributes.": "Fjerne lang-attributter.",
|
||||
"Go": "Utfør",
|
||||
"Cancel": "Avbryt",
|
||||
"Tidy failed. Check your HTML for syntax errors.": "Tidy (Programmet som retter HTML koden) feilet. Vennligst se over HTML koden for feil.",
|
||||
@@ -1,285 +1,211 @@
|
||||
// Make our right side panel and insert appropriatly
|
||||
function SuperClean(editor, args)
|
||||
{
|
||||
this.editor = editor;
|
||||
var superclean = this;
|
||||
editor._superclean_on = false;
|
||||
editor.config.registerButton('superclean', this._lc("Clean up HTML"), editor.imgURL('ed_superclean.gif', 'SuperClean'), true, function(e, objname, obj) { superclean._superClean(null, obj); });
|
||||
|
||||
// See if we can find 'killword' and replace it with superclean
|
||||
editor.config.addToolbarElement("superclean", "killword", 0);
|
||||
function SuperClean(_1,_2){
|
||||
this.editor=_1;
|
||||
var _3=this;
|
||||
_1._superclean_on=false;
|
||||
_1.config.registerButton("superclean",this._lc("Clean up HTML"),_1.imgURL("ed_superclean.gif","SuperClean"),true,function(e,_5,_6){
|
||||
_3._superClean(null,_6);
|
||||
});
|
||||
_1.config.addToolbarElement("superclean","killword",0);
|
||||
}
|
||||
|
||||
SuperClean._pluginInfo =
|
||||
{
|
||||
name : "SuperClean",
|
||||
version : "1.0",
|
||||
developer: "James Sleeman, Niko Sams",
|
||||
developer_url: "http://www.gogo.co.nz/",
|
||||
c_owner : "Gogo Internet Services",
|
||||
license : "htmlArea",
|
||||
sponsor : "Gogo Internet Services",
|
||||
sponsor_url : "http://www.gogo.co.nz/"
|
||||
SuperClean._pluginInfo={name:"SuperClean",version:"1.0",developer:"James Sleeman, Niko Sams",developer_url:"http://www.gogo.co.nz/",c_owner:"Gogo Internet Services",license:"htmlArea",sponsor:"Gogo Internet Services",sponsor_url:"http://www.gogo.co.nz/"};
|
||||
SuperClean.prototype._lc=function(_7){
|
||||
return Xinha._lc(_7,"SuperClean");
|
||||
};
|
||||
|
||||
SuperClean.prototype._lc = function(string) {
|
||||
return HTMLArea._lc(string, 'SuperClean');
|
||||
SuperClean.prototype._superClean=function(_8,_9){
|
||||
var _a=this;
|
||||
var _b=function(){
|
||||
var _c=_a._dialog.hide();
|
||||
var _d=_a.editor;
|
||||
if(_c.word_clean){
|
||||
_d._wordClean();
|
||||
}
|
||||
var D=_d.getInnerHTML();
|
||||
for(var _f in _d.config.SuperClean.filters){
|
||||
if(_f=="tidy"||_f=="word_clean"){
|
||||
continue;
|
||||
}
|
||||
if(_c[_f]){
|
||||
D=SuperClean.filterFunctions[_f](D,_d);
|
||||
}
|
||||
}
|
||||
D=D.replace(/(style|class)="\s*"/gi,"");
|
||||
D=D.replace(/<(font|span)\s*>/gi,"");
|
||||
_d.setHTML(D);
|
||||
if(_c.tidy){
|
||||
var _10=function(_11){
|
||||
eval("var response = "+_11);
|
||||
switch(response.action){
|
||||
case "setHTML":
|
||||
_d.setHTML(response.value);
|
||||
break;
|
||||
case "alert":
|
||||
alert(_a._lc(response.value));
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
/** superClean combines HTMLTidy, Word Cleaning and font stripping into a single function
|
||||
* it works a bit differently in how it asks for parameters */
|
||||
|
||||
SuperClean.prototype._superClean = function(opts, obj)
|
||||
{
|
||||
var superclean = this;
|
||||
|
||||
// Do the clean if we got options
|
||||
var doOK = function()
|
||||
{
|
||||
var opts = superclean._dialog.hide();
|
||||
var editor = superclean.editor;
|
||||
|
||||
if(opts.word_clean) editor._wordClean();
|
||||
var D = editor.getInnerHTML();
|
||||
|
||||
for(var filter in editor.config.SuperClean.filters)
|
||||
{
|
||||
if(filter=='tidy' || filter=='word_clean') continue;
|
||||
if(opts[filter])
|
||||
{
|
||||
D = SuperClean.filterFunctions[filter](D);
|
||||
}
|
||||
}
|
||||
|
||||
D = D.replace(/(style|class)="\s*"/gi, '');
|
||||
D = D.replace(/<(font|span)\s*>/gi, '');
|
||||
|
||||
editor.setHTML(D);
|
||||
|
||||
if(opts.tidy)
|
||||
{
|
||||
HTMLArea._postback(editor.config.SuperClean.tidy_handler, {'content' : editor.getInnerHTML()},
|
||||
function(javascriptResponse) { eval(javascriptResponse) });
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if(this.editor.config.SuperClean.show_dialog)
|
||||
{
|
||||
var inputs = {};
|
||||
this._dialog.show(inputs, doOK);
|
||||
}
|
||||
else
|
||||
{
|
||||
var editor = this.editor;
|
||||
var html = editor.getInnerHTML();
|
||||
for(var filter in editor.config.SuperClean.filters)
|
||||
{
|
||||
if(filter=='tidy') continue; //call tidy last
|
||||
html = SuperClean.filterFunctions[filter](html, editor);
|
||||
}
|
||||
|
||||
html = html.replace(/(style|class)="\s*"/gi, '');
|
||||
html = html.replace(/<(font|span)\s*>/gi, '');
|
||||
|
||||
editor.setHTML(html);
|
||||
|
||||
if(editor.config.SuperClean.filters.tidy)
|
||||
{
|
||||
SuperClean.filterFunctions.tidy(html, editor);
|
||||
}
|
||||
}
|
||||
Xinha._postback(_d.config.SuperClean.tidy_handler,{"content":_d.getInnerHTML()},_10);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
HTMLArea.Config.prototype.SuperClean =
|
||||
{
|
||||
// set to the URL of a handler for html tidy, this handler
|
||||
// (see tidy.php for an example) must that a single post variable
|
||||
// "content" which contains the HTML to tidy, and return javascript like
|
||||
// editor.setHTML('<strong>Tidied Html</strong>')
|
||||
// it's called through XMLHTTPRequest
|
||||
'tidy_handler': _editor_url + 'plugins/SuperClean/tidy.php',
|
||||
|
||||
//avaliable filters (these are built-in filters)
|
||||
'filters': { 'tidy': HTMLArea._lc('General tidy up and correction of some problems.', 'SuperClean'),
|
||||
'word_clean': HTMLArea._lc('Clean bad HTML from Microsoft Word', 'SuperClean'),
|
||||
'remove_faces': HTMLArea._lc('Remove custom typefaces (font "styles").', 'SuperClean'),
|
||||
'remove_sizes': HTMLArea._lc('Remove custom font sizes.', 'SuperClean'),
|
||||
'remove_colors': HTMLArea._lc('Remove custom text colors.', 'SuperClean'),
|
||||
'remove_lang': HTMLArea._lc('Remove lang attributes.', 'SuperClean')
|
||||
//additional custom filters (defined in plugins/SuperClean/filters/word.js)
|
||||
//'paragraph': 'remove paragraphs'},
|
||||
//'word': 'exteded Word-Filter' },
|
||||
},
|
||||
//if false all filters are applied, if true a dialog asks what filters should be used
|
||||
'show_dialog': true
|
||||
if(this.editor.config.SuperClean.show_dialog){
|
||||
var _12={};
|
||||
this._dialog.show(_12,_b);
|
||||
}else{
|
||||
var _13=this.editor;
|
||||
var _14=_13.getInnerHTML();
|
||||
for(var _15 in _13.config.SuperClean.filters){
|
||||
if(_15=="tidy"){
|
||||
continue;
|
||||
}
|
||||
_14=SuperClean.filterFunctions[_15](_14,_13);
|
||||
}
|
||||
_14=_14.replace(/(style|class)="\s*"/gi,"");
|
||||
_14=_14.replace(/<(font|span)\s*>/gi,"");
|
||||
_13.setHTML(_14);
|
||||
if(_13.config.SuperClean.filters.tidy){
|
||||
SuperClean.filterFunctions.tidy(_14,_13);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
SuperClean.filterFunctions = { };
|
||||
SuperClean.filterFunctions.remove_colors = function(D)
|
||||
{
|
||||
D = D.replace(/color="?[^" >]*"?/gi, '');
|
||||
// { (stops jedit's fold breaking)
|
||||
D = D.replace(/([^-])color:[^;}"']+;?/gi, '$1');
|
||||
return(D);
|
||||
Xinha.Config.prototype.SuperClean={"tidy_handler":_editor_url+"plugins/SuperClean/tidy.php","filters":{"tidy":Xinha._lc("General tidy up and correction of some problems.","SuperClean"),"word_clean":Xinha._lc("Clean bad HTML from Microsoft Word","SuperClean"),"remove_faces":Xinha._lc("Remove custom typefaces (font \"styles\").","SuperClean"),"remove_sizes":Xinha._lc("Remove custom font sizes.","SuperClean"),"remove_colors":Xinha._lc("Remove custom text colors.","SuperClean"),"remove_lang":Xinha._lc("Remove lang attributes.","SuperClean"),"remove_fancy_quotes":{label:Xinha._lc("Replace directional quote marks with non-directional quote marks.","SuperClean"),checked:false}},"show_dialog":true};
|
||||
SuperClean.filterFunctions={};
|
||||
SuperClean.filterFunctions.remove_colors=function(D){
|
||||
D=D.replace(/color="?[^" >]*"?/gi,"");
|
||||
D=D.replace(/([^-])color:[^;}"']+;?/gi,"$1");
|
||||
return (D);
|
||||
};
|
||||
SuperClean.filterFunctions.remove_sizes = function(D)
|
||||
{
|
||||
D = D.replace(/size="?[^" >]*"?/gi, '');
|
||||
// { (stops jedit's fold breaking)
|
||||
D = D.replace(/font-size:[^;}"']+;?/gi, '');
|
||||
return(D);
|
||||
SuperClean.filterFunctions.remove_sizes=function(D){
|
||||
D=D.replace(/size="?[^" >]*"?/gi,"");
|
||||
D=D.replace(/font-size:[^;}"']+;?/gi,"");
|
||||
return (D);
|
||||
};
|
||||
SuperClean.filterFunctions.remove_faces = function(D)
|
||||
{
|
||||
D = D.replace(/face="?[^" >]*"?/gi, '');
|
||||
// { (stops jedit's fold breaking)
|
||||
D = D.replace(/font-family:[^;}"']+;?/gi, '');
|
||||
return(D);
|
||||
SuperClean.filterFunctions.remove_faces=function(D){
|
||||
D=D.replace(/face="?[^" >]*"?/gi,"");
|
||||
D=D.replace(/font-family:[^;}"']+;?/gi,"");
|
||||
return (D);
|
||||
};
|
||||
SuperClean.filterFunctions.remove_lang = function(D)
|
||||
{
|
||||
D = D.replace(/lang="?[^" >]*"?/gi, '');
|
||||
return(D);
|
||||
SuperClean.filterFunctions.remove_lang=function(D){
|
||||
D=D.replace(/lang="?[^" >]*"?/gi,"");
|
||||
return (D);
|
||||
};
|
||||
SuperClean.filterFunctions.word_clean = function(html, editor)
|
||||
{
|
||||
editor.setHTML(html);
|
||||
editor._wordClean();
|
||||
return editor.getInnerHTML();
|
||||
SuperClean.filterFunctions.word_clean=function(_1a,_1b){
|
||||
_1b.setHTML(_1a);
|
||||
_1b._wordClean();
|
||||
return _1b.getInnerHTML();
|
||||
};
|
||||
SuperClean.filterFunctions.tidy = function(html, editor)
|
||||
{
|
||||
HTMLArea._postback(editor.config.SuperClean.tidy_handler, {'content' : html},
|
||||
function(javascriptResponse) { eval(javascriptResponse) });
|
||||
SuperClean.filterFunctions.remove_fancy_quotes=function(D){
|
||||
D=D.replace(new RegExp(String.fromCharCode(8216),"g"),"'");
|
||||
D=D.replace(new RegExp(String.fromCharCode(8217),"g"),"'");
|
||||
D=D.replace(new RegExp(String.fromCharCode(8218),"g"),"'");
|
||||
D=D.replace(new RegExp(String.fromCharCode(8219),"g"),"'");
|
||||
D=D.replace(new RegExp(String.fromCharCode(8220),"g"),"\"");
|
||||
D=D.replace(new RegExp(String.fromCharCode(8221),"g"),"\"");
|
||||
D=D.replace(new RegExp(String.fromCharCode(8222),"g"),"\"");
|
||||
D=D.replace(new RegExp(String.fromCharCode(8223),"g"),"\"");
|
||||
return D;
|
||||
};
|
||||
|
||||
|
||||
|
||||
SuperClean.prototype.onGenerate = function()
|
||||
{
|
||||
if(this.editor.config.SuperClean.show_dialog && !this._dialog)
|
||||
{
|
||||
this._dialog = new SuperClean.Dialog(this);
|
||||
}
|
||||
if(this.editor.config.tidy_handler)
|
||||
{
|
||||
//for backwards compatibility
|
||||
this.editor.config.SuperClean.tidy_handler = this.editor.config.tidy_handler;
|
||||
this.editor.config.tidy_handler = null;
|
||||
}
|
||||
if(!this.editor.config.SuperClean.tidy_handler && this.editor.config.filters.tidy) {
|
||||
//unset tidy-filter if no tidy_handler
|
||||
this.editor.config.filters.tidy = null;
|
||||
}
|
||||
|
||||
var sc = this;
|
||||
//load the filter-functions
|
||||
for(var filter in this.editor.config.SuperClean.filters)
|
||||
{
|
||||
if(!SuperClean.filterFunctions[filter])
|
||||
{
|
||||
HTMLArea._getback(_editor_url + 'plugins/SuperClean/filters/'+filter+'.js',
|
||||
function(func) {
|
||||
eval('SuperClean.filterFunctions.'+filter+'='+func+';');
|
||||
sc.onGenerate();
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
SuperClean.filterFunctions.tidy=function(_1d,_1e){
|
||||
Xinha._postback(_1e.config.SuperClean.tidy_handler,{"content":_1d},function(_1f){
|
||||
eval(_1f);
|
||||
});
|
||||
};
|
||||
// Inline Dialog for SuperClean
|
||||
|
||||
|
||||
SuperClean.Dialog = function (SuperClean)
|
||||
{
|
||||
var lDialog = this;
|
||||
this.Dialog_nxtid = 0;
|
||||
this.SuperClean = SuperClean;
|
||||
this.id = { }; // This will be filled below with a replace, nifty
|
||||
|
||||
this.ready = false;
|
||||
this.files = false;
|
||||
this.html = false;
|
||||
this.dialog = false;
|
||||
|
||||
// load the dTree script
|
||||
this._prepareDialog();
|
||||
|
||||
SuperClean.prototype.onGenerate=function(){
|
||||
if(this.editor.config.SuperClean.show_dialog&&!this._dialog){
|
||||
this._dialog=new SuperClean.Dialog(this);
|
||||
}
|
||||
if(this.editor.config.tidy_handler){
|
||||
this.editor.config.SuperClean.tidy_handler=this.editor.config.tidy_handler;
|
||||
this.editor.config.tidy_handler=null;
|
||||
}
|
||||
if(!this.editor.config.SuperClean.tidy_handler&&this.editor.config.filters.tidy){
|
||||
this.editor.config.filters.tidy=null;
|
||||
}
|
||||
var sc=this;
|
||||
for(var _21 in this.editor.config.SuperClean.filters){
|
||||
if(!SuperClean.filterFunctions[_21]){
|
||||
var _22=this.editor.config.SuperClean.filters[_21];
|
||||
if(typeof _22.filterFunction!="undefined"){
|
||||
SuperClean.filterFunctions[_21]=filterFunction;
|
||||
}else{
|
||||
Xinha._getback(_editor_url+"plugins/SuperClean/filters/"+_21+".js",function(_23){
|
||||
eval("SuperClean.filterFunctions."+_21+"="+_23+";");
|
||||
sc.onGenerate();
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
SuperClean.Dialog.prototype._prepareDialog = function()
|
||||
{
|
||||
var lDialog = this;
|
||||
var SuperClean = this.SuperClean;
|
||||
|
||||
if(this.html == false)
|
||||
{
|
||||
HTMLArea._getback(_editor_url + 'plugins/SuperClean/dialog.html', function(txt) { lDialog.html = txt; lDialog._prepareDialog(); });
|
||||
return;
|
||||
}
|
||||
|
||||
var htmlFilters = "";
|
||||
for(var filter in this.SuperClean.editor.config.SuperClean.filters)
|
||||
{
|
||||
htmlFilters += " <div>\n";
|
||||
htmlFilters += " <input type=\"checkbox\" name=\"["+filter+"]\" id=\"["+filter+"]\" checked />\n";
|
||||
htmlFilters += " <label for=\"["+filter+"]\">"+this.SuperClean.editor.config.SuperClean.filters[filter]+"</label>\n";
|
||||
htmlFilters += " </div>\n";
|
||||
}
|
||||
this.html = this.html.replace('<!--filters-->', htmlFilters);
|
||||
|
||||
var html = this.html;
|
||||
|
||||
// Now we have everything we need, so we can build the dialog.
|
||||
var dialog = this.dialog = new HTMLArea.Dialog(SuperClean.editor, this.html, 'SuperClean');
|
||||
|
||||
this.ready = true;
|
||||
SuperClean.Dialog=function(_24){
|
||||
var _25=this;
|
||||
this.Dialog_nxtid=0;
|
||||
this.SuperClean=_24;
|
||||
this.id={};
|
||||
this.ready=false;
|
||||
this.files=false;
|
||||
this.html=false;
|
||||
this.dialog=false;
|
||||
this._prepareDialog();
|
||||
};
|
||||
|
||||
SuperClean.Dialog.prototype._lc = SuperClean.prototype._lc;
|
||||
|
||||
SuperClean.Dialog.prototype.show = function(inputs, ok, cancel)
|
||||
{
|
||||
if(!this.ready)
|
||||
{
|
||||
var lDialog = this;
|
||||
window.setTimeout(function() {lDialog.show(inputs,ok,cancel);},100);
|
||||
return;
|
||||
}
|
||||
|
||||
// Connect the OK and Cancel buttons
|
||||
var dialog = this.dialog;
|
||||
var lDialog = this;
|
||||
if(ok)
|
||||
{
|
||||
this.dialog.getElementById('ok').onclick = ok;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dialog.getElementById('ok').onclick = function() {lDialog.hide();};
|
||||
}
|
||||
|
||||
if(cancel)
|
||||
{
|
||||
this.dialog.getElementById('cancel').onclick = cancel;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dialog.getElementById('cancel').onclick = function() { lDialog.hide()};
|
||||
}
|
||||
|
||||
// Show the dialog
|
||||
this.SuperClean.editor.disableToolbar(['fullscreen','SuperClean']);
|
||||
|
||||
this.dialog.show(inputs);
|
||||
|
||||
// Init the sizes
|
||||
this.dialog.onresize();
|
||||
SuperClean.Dialog.prototype._prepareDialog=function(){
|
||||
var _26=this;
|
||||
var _27=this.SuperClean;
|
||||
if(this.html==false){
|
||||
Xinha._getback(_editor_url+"plugins/SuperClean/dialog.html",function(txt){
|
||||
_26.html=txt;
|
||||
_26._prepareDialog();
|
||||
});
|
||||
return;
|
||||
}
|
||||
var _29="";
|
||||
for(var _2a in this.SuperClean.editor.config.SuperClean.filters){
|
||||
_29+=" <div>\n";
|
||||
var _2b=this.SuperClean.editor.config.SuperClean.filters[_2a];
|
||||
if(typeof _2b.label=="undefined"){
|
||||
_29+=" <input type=\"checkbox\" name=\"["+_2a+"]\" id=\"["+_2a+"]\" checked />\n";
|
||||
_29+=" <label for=\"["+_2a+"]\">"+this.SuperClean.editor.config.SuperClean.filters[_2a]+"</label>\n";
|
||||
}else{
|
||||
_29+=" <input type=\"checkbox\" name=\"["+_2a+"]\" id=\"["+_2a+"]\" "+(_2b.checked?"checked":"")+" />\n";
|
||||
_29+=" <label for=\"["+_2a+"]\">"+_2b.label+"</label>\n";
|
||||
}
|
||||
_29+=" </div>\n";
|
||||
}
|
||||
this.html=this.html.replace("<!--filters-->",_29);
|
||||
var _2c=this.html;
|
||||
var _2d=this.dialog=new Xinha.Dialog(_27.editor,this.html,"SuperClean");
|
||||
this.ready=true;
|
||||
};
|
||||
|
||||
SuperClean.Dialog.prototype.hide = function()
|
||||
{
|
||||
this.SuperClean.editor.enableToolbar();
|
||||
return this.dialog.hide();
|
||||
};
|
||||
SuperClean.Dialog.prototype._lc=SuperClean.prototype._lc;
|
||||
SuperClean.Dialog.prototype.show=function(_2e,ok,_30){
|
||||
if(!this.ready){
|
||||
var _31=this;
|
||||
window.setTimeout(function(){
|
||||
_31.show(_2e,ok,_30);
|
||||
},100);
|
||||
return;
|
||||
}
|
||||
var _32=this.dialog;
|
||||
var _31=this;
|
||||
if(ok){
|
||||
this.dialog.getElementById("ok").onclick=ok;
|
||||
}else{
|
||||
this.dialog.getElementById("ok").onclick=function(){
|
||||
_31.hide();
|
||||
};
|
||||
}
|
||||
if(_30){
|
||||
this.dialog.getElementById("cancel").onclick=_30;
|
||||
}else{
|
||||
this.dialog.getElementById("cancel").onclick=function(){
|
||||
_31.hide();
|
||||
};
|
||||
}
|
||||
this.SuperClean.editor.disableToolbar(["fullscreen","SuperClean"]);
|
||||
this.dialog.show(_2e);
|
||||
this.dialog.onresize();
|
||||
};
|
||||
SuperClean.Dialog.prototype.hide=function(){
|
||||
this.SuperClean.editor.enableToolbar();
|
||||
return this.dialog.hide();
|
||||
};
|
||||
|
||||
|
||||
@@ -1,179 +1,179 @@
|
||||
<?php
|
||||
/** This PHP file is intended for use with XMLHTTPRequest from an HTMLArea
|
||||
* it requrns javascript to set the htmlarea html with tidied html that is
|
||||
* submitted in a $_POST parameter called 'content'
|
||||
*/
|
||||
|
||||
if(get_magic_quotes_gpc())
|
||||
{
|
||||
// trigger_error('Magic Quotes GPC is on, cleaning GPC.', E_USER_NOTICE);
|
||||
$to_clean = array(&$_GET, &$_POST, &$_REQUEST, &$_COOKIE);
|
||||
while(count($to_clean))
|
||||
{
|
||||
$cleaning =& $to_clean[array_pop(array_keys($to_clean))];
|
||||
unset($to_clean[array_pop(array_keys($to_clean))]);
|
||||
foreach(array_keys($cleaning) as $k)
|
||||
{
|
||||
if(is_array($cleaning[$k]))
|
||||
{
|
||||
$to_clean[] =& $cleaning[$k];
|
||||
}
|
||||
else
|
||||
{
|
||||
$cleaning[$k] = stripslashes($cleaning[$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
header('Content-Type: text/javascript; charset=utf-8');
|
||||
|
||||
/** Function to POST some data to a URL */
|
||||
function PostIt($DataStream, $URL)
|
||||
{
|
||||
|
||||
// Strip http:// from the URL if present
|
||||
$URL = ereg_replace("^http://", "", $URL);
|
||||
|
||||
// Separate into Host and URI
|
||||
$Host = substr($URL, 0, strpos($URL, "/"));
|
||||
$URI = strstr($URL, "/");
|
||||
|
||||
// Form up the request body
|
||||
$ReqBody = "";
|
||||
while (list($key, $val) = each($DataStream)) {
|
||||
if ($ReqBody) $ReqBody.= "&";
|
||||
$ReqBody.= $key."=".urlencode($val);
|
||||
}
|
||||
$ContentLength = strlen($ReqBody);
|
||||
|
||||
// Generate the request header
|
||||
$ReqHeader =
|
||||
"POST $URI HTTP/1.0\n".
|
||||
"Host: $Host\n".
|
||||
"User-Agent: PostIt\n".
|
||||
"Content-Type: application/x-www-form-urlencoded\n".
|
||||
"Content-Length: $ContentLength\n\n".
|
||||
"$ReqBody\n";
|
||||
|
||||
// echo $ReqHeader;
|
||||
|
||||
|
||||
// Open the connection to the host
|
||||
$socket = fsockopen($Host, 80, &$errno, &$errstr);
|
||||
if (!$socket) {
|
||||
$result = "($errno) $errstr";
|
||||
return $Result;
|
||||
}
|
||||
|
||||
fputs($socket, $ReqHeader);
|
||||
|
||||
$result = '';
|
||||
while(!feof($socket))
|
||||
{
|
||||
$result .= fgets($socket);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
function js_encode($string)
|
||||
{
|
||||
static $strings = "\\,\",',%,&,<,>,{,},@,\n,\r";
|
||||
|
||||
if(!is_array($strings))
|
||||
{
|
||||
$tr = array();
|
||||
foreach(explode(',', $strings) as $chr)
|
||||
{
|
||||
$tr[$chr] = sprintf('\x%02X', ord($chr));
|
||||
}
|
||||
$strings = $tr;
|
||||
}
|
||||
|
||||
return strtr($string, $strings);
|
||||
}
|
||||
|
||||
// Any errors would screq up our javascript
|
||||
error_reporting(E_NONE);
|
||||
ini_set('display_errors', false);
|
||||
|
||||
if(trim(@$_REQUEST['content']))
|
||||
{
|
||||
// PHP's urldecode doesn't understand %uHHHH for unicode
|
||||
$_REQUEST['content'] = preg_replace('/%u([a-f0-9]{4,4})/ei', 'utf8_chr(0x$1)', $_REQUEST['content']);
|
||||
function utf8_chr($num)
|
||||
{
|
||||
if($num<128)return chr($num);
|
||||
if($num<1024)return chr(($num>>6)+192).chr(($num&63)+128);
|
||||
if($num<32768)return chr(($num>>12)+224).chr((($num>>6)&63)+128).chr(($num&63)+128);
|
||||
if($num<2097152)return chr(($num>>18)+240).chr((($num>>12)&63)+128).chr((($num>>6)&63)+128) .chr(($num&63)+128);
|
||||
return '';
|
||||
}
|
||||
ob_start();
|
||||
passthru("echo " . escapeshellarg($_REQUEST['content']) . " | tidy -q -i -u -wrap 9999 -utf8 -bare -asxhtml 2>/dev/null", $result);
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
if(!strlen($content))
|
||||
{
|
||||
// Tidy on the local machine failed, try a post
|
||||
$res_1
|
||||
= PostIt(
|
||||
array
|
||||
(
|
||||
'_function' => 'tidy',
|
||||
'_html' => $_REQUEST['content'],
|
||||
'char-encoding' => 'utf8',
|
||||
'_output' => 'warn',
|
||||
'indent' => 'auto',
|
||||
'wrap' => 9999,
|
||||
'break-before-br' => 'y',
|
||||
'bare' => 'n',
|
||||
'word-2000' => 'n',
|
||||
'drop-empty-paras' => 'y',
|
||||
'drop-font-tags' => 'n',
|
||||
|
||||
),
|
||||
'http://infohound.net/tidy/tidy.pl');
|
||||
|
||||
if(preg_match('/<a href="([^"]+)" title="Save the tidied HTML/', $res_1, $m))
|
||||
{
|
||||
$tgt = strtr($m[1], array_flip(get_html_translation_table(HTML_ENTITIES)));
|
||||
$content = implode('', file('http://infohound.net/tidy/' . $tgt));
|
||||
}
|
||||
}
|
||||
|
||||
if(strlen($content) && ! preg_match('/<\/body>/i', $_REQUEST['content']))
|
||||
{
|
||||
if( preg_match('/<body[^>]*>(.*)<\/body>/is', $content, $matches) )
|
||||
{
|
||||
$content = $matches[1];
|
||||
}
|
||||
}
|
||||
elseif(!strlen($content))
|
||||
{
|
||||
$content = $_REQUEST['content'];
|
||||
}
|
||||
|
||||
if($content)
|
||||
{
|
||||
?>
|
||||
editor.setHTML('<?php echo js_encode($content) ?>');
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
?>
|
||||
alert(this._lc('Tidy failed. Check your HTML for syntax errors.'));
|
||||
<?php
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
?>
|
||||
alert(this._lc("You don't have anything to tidy!"));
|
||||
<?php
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/** This PHP file is intended for use with XMLHTTPRequest from Xinha
|
||||
* it requrns javascript to set the Xinha html with tidied html that is
|
||||
* submitted in a $_POST parameter called 'content'
|
||||
*/
|
||||
|
||||
if(get_magic_quotes_gpc())
|
||||
{
|
||||
// trigger_error('Magic Quotes GPC is on, cleaning GPC.', E_USER_NOTICE);
|
||||
$to_clean = array(&$_GET, &$_POST, &$_REQUEST, &$_COOKIE);
|
||||
while(count($to_clean))
|
||||
{
|
||||
$cleaning =& $to_clean[array_pop(array_keys($to_clean))];
|
||||
unset($to_clean[array_pop(array_keys($to_clean))]);
|
||||
foreach(array_keys($cleaning) as $k)
|
||||
{
|
||||
if(is_array($cleaning[$k]))
|
||||
{
|
||||
$to_clean[] =& $cleaning[$k];
|
||||
}
|
||||
else
|
||||
{
|
||||
$cleaning[$k] = stripslashes($cleaning[$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
header('Content-Type: text/javascript; charset=utf-8');
|
||||
|
||||
/** Function to POST some data to a URL */
|
||||
function PostIt($DataStream, $URL)
|
||||
{
|
||||
|
||||
// Strip http:// from the URL if present
|
||||
$URL = ereg_replace("^http://", "", $URL);
|
||||
|
||||
// Separate into Host and URI
|
||||
$Host = substr($URL, 0, strpos($URL, "/"));
|
||||
$URI = strstr($URL, "/");
|
||||
|
||||
// Form up the request body
|
||||
$ReqBody = "";
|
||||
while (list($key, $val) = each($DataStream)) {
|
||||
if ($ReqBody) $ReqBody.= "&";
|
||||
$ReqBody.= $key."=".urlencode($val);
|
||||
}
|
||||
$ContentLength = strlen($ReqBody);
|
||||
|
||||
// Generate the request header
|
||||
$ReqHeader =
|
||||
"POST $URI HTTP/1.0\n".
|
||||
"Host: $Host\n".
|
||||
"User-Agent: PostIt\n".
|
||||
"Content-Type: application/x-www-form-urlencoded\n".
|
||||
"Content-Length: $ContentLength\n\n".
|
||||
"$ReqBody\n";
|
||||
|
||||
// echo $ReqHeader;
|
||||
|
||||
|
||||
// Open the connection to the host
|
||||
$socket = fsockopen($Host, 80, &$errno, &$errstr);
|
||||
if (!$socket) {
|
||||
$result = "($errno) $errstr";
|
||||
return $Result;
|
||||
}
|
||||
|
||||
fputs($socket, $ReqHeader);
|
||||
|
||||
$result = '';
|
||||
while(!feof($socket))
|
||||
{
|
||||
$result .= fgets($socket);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
function js_encode($string)
|
||||
{
|
||||
static $strings = "\\,\",',%,&,<,>,{,},@,\n,\r";
|
||||
|
||||
if(!is_array($strings))
|
||||
{
|
||||
$tr = array();
|
||||
foreach(explode(',', $strings) as $chr)
|
||||
{
|
||||
$tr[$chr] = sprintf('\x%02X', ord($chr));
|
||||
}
|
||||
$strings = $tr;
|
||||
}
|
||||
|
||||
return strtr($string, $strings);
|
||||
}
|
||||
|
||||
// Any errors would screq up our javascript
|
||||
error_reporting(E_NONE);
|
||||
ini_set('display_errors', false);
|
||||
|
||||
if(trim(@$_REQUEST['content']))
|
||||
{
|
||||
// PHP's urldecode doesn't understand %uHHHH for unicode
|
||||
$_REQUEST['content'] = preg_replace('/%u([a-f0-9]{4,4})/ei', 'utf8_chr(0x$1)', $_REQUEST['content']);
|
||||
function utf8_chr($num)
|
||||
{
|
||||
if($num<128)return chr($num);
|
||||
if($num<1024)return chr(($num>>6)+192).chr(($num&63)+128);
|
||||
if($num<32768)return chr(($num>>12)+224).chr((($num>>6)&63)+128).chr(($num&63)+128);
|
||||
if($num<2097152)return chr(($num>>18)+240).chr((($num>>12)&63)+128).chr((($num>>6)&63)+128) .chr(($num&63)+128);
|
||||
return '';
|
||||
}
|
||||
ob_start();
|
||||
passthru("echo " . escapeshellarg($_REQUEST['content']) . " | tidy -q -i -u -wrap 9999 -utf8 -bare -asxhtml 2>/dev/null", $result);
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
if(strlen($content) < 4)
|
||||
{
|
||||
// Tidy on the local machine failed, try a post
|
||||
$res_1
|
||||
= PostIt(
|
||||
array
|
||||
(
|
||||
'_function' => 'tidy',
|
||||
'_html' => $_REQUEST['content'],
|
||||
'char-encoding' => 'utf8',
|
||||
'_output' => 'warn',
|
||||
'indent' => 'auto',
|
||||
'wrap' => 9999,
|
||||
'break-before-br' => 'y',
|
||||
'bare' => 'n',
|
||||
'word-2000' => 'n',
|
||||
'drop-empty-paras' => 'y',
|
||||
'drop-font-tags' => 'n',
|
||||
|
||||
),
|
||||
'http://infohound.net/tidy/tidy.pl');
|
||||
|
||||
if(preg_match('/<a href="([^"]+)" title="Save the tidied HTML/', $res_1, $m))
|
||||
{
|
||||
$tgt = strtr($m[1], array_flip(get_html_translation_table(HTML_ENTITIES)));
|
||||
$content = implode('', file('http://infohound.net/tidy/' . $tgt));
|
||||
}
|
||||
}
|
||||
|
||||
if(strlen($content) && ! preg_match('/<\/body>/i', $_REQUEST['content']))
|
||||
{
|
||||
if( preg_match('/<body[^>]*>(.*)<\/body>/is', $content, $matches) )
|
||||
{
|
||||
$content = $matches[1];
|
||||
}
|
||||
}
|
||||
elseif(!strlen($content))
|
||||
{
|
||||
$content = $_REQUEST['content'];
|
||||
}
|
||||
|
||||
if($content)
|
||||
{
|
||||
?>
|
||||
{action:'setHTML',value:'<?php echo js_encode($content) ?>'};
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
?>
|
||||
{action:'alert',value:'Tidy failed. Check your HTML for syntax errors.'};
|
||||
<?php
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
?>
|
||||
{action:'alert',value:"You don't have anything to tidy!"}
|
||||
<?php
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user