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:
@@ -1,79 +1,79 @@
|
||||
<?php
|
||||
##
|
||||
## Plugin for htmlArea, to run code through the server's HTML Tidy
|
||||
## By Adam Wright, for The University of Western Australia
|
||||
## This is the server-side script, which dirty code is run through.
|
||||
##
|
||||
## Distributed under the same terms as HTMLArea itself.
|
||||
## This notice MUST stay intact for use (see license.txt).
|
||||
##
|
||||
|
||||
// Get the original source
|
||||
$source = $_POST['htisource_name'];
|
||||
$source = stripslashes($source);
|
||||
$cwd = str_replace("\\","/",getcwd())."/";
|
||||
|
||||
// Open a tidy process - I hope it's installed!
|
||||
$descriptorspec = array(
|
||||
0 => array("pipe", "r"),
|
||||
1 => array("pipe", "w")
|
||||
);
|
||||
$process = @proc_open("tidy -utf8 -config {$cwd}html-tidy-config.cfg", $descriptorspec, $pipes);
|
||||
|
||||
|
||||
// Make sure the program started and we got the hooks...
|
||||
// Either way, get some source code into $source
|
||||
if (is_resource($process)) {
|
||||
|
||||
// Feed untidy source into the stdin
|
||||
fwrite($pipes[0], $source);
|
||||
fclose($pipes[0]);
|
||||
|
||||
// Read clean source out to the browser
|
||||
while (!feof($pipes[1])) {
|
||||
//echo fgets($pipes[1], 1024);
|
||||
$newsrc .= fgets($pipes[1], 1024);
|
||||
}
|
||||
fclose($pipes[1]);
|
||||
|
||||
// Clean up after ourselves
|
||||
proc_close($process);
|
||||
|
||||
} else {
|
||||
/* Use tidy if it's available from PECL */
|
||||
if( function_exists('tidy_parse_string') )
|
||||
{
|
||||
$tempsrc = tidy_parse_string($source);
|
||||
tidy_clean_repair();
|
||||
$newsrc = tidy_get_output();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Better give them back what they came with, so they don't lose it all...
|
||||
$newsrc = "<body>\n" .$source. "\n</body>";
|
||||
}
|
||||
}
|
||||
|
||||
// Split our source into an array by lines
|
||||
$srcLines = preg_split("/\n/",$newsrc,-1,PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
// Get only the lines between the body tags
|
||||
$startLn = 0;
|
||||
while ( strpos( $srcLines[$startLn++], '<body' ) === false && $startLn < sizeof($srcLines) );
|
||||
$endLn = $startLn;
|
||||
while ( strpos( $srcLines[$endLn++], '</body' ) === false && $endLn < sizeof($srcLines) );
|
||||
|
||||
$srcLines = array_slice( $srcLines, $startLn, ($endLn - $startLn - 1) );
|
||||
|
||||
// Create a set of javascript code to compile a new source string
|
||||
foreach ($srcLines as $line) {
|
||||
$jsMakeSrc .= "\tns += '" . str_replace("'","\'",$line) . "\\n';\n";
|
||||
}
|
||||
if(!sizeof($srcLines)) {
|
||||
echo "alert(HTMLArea._lc('Tidy failed. Check your HTML for syntax errors.', 'HtmlTidy'));\n";
|
||||
} else {
|
||||
?>
|
||||
var ns="";
|
||||
<?php echo $jsMakeSrc; ?>
|
||||
editor.setHTML(ns);
|
||||
<?php
|
||||
##
|
||||
## Plugin for htmlArea, to run code through the server's HTML Tidy
|
||||
## By Adam Wright, for The University of Western Australia
|
||||
## This is the server-side script, which dirty code is run through.
|
||||
##
|
||||
## Distributed under the same terms as HTMLArea itself.
|
||||
## This notice MUST stay intact for use (see license.txt).
|
||||
##
|
||||
|
||||
// Get the original source
|
||||
$source = $_POST['htisource_name'];
|
||||
$source = stripslashes($source);
|
||||
$cwd = str_replace("\\","/",getcwd())."/";
|
||||
|
||||
// Open a tidy process - I hope it's installed!
|
||||
$descriptorspec = array(
|
||||
0 => array("pipe", "r"),
|
||||
1 => array("pipe", "w")
|
||||
);
|
||||
$process = @proc_open("tidy -utf8 -config {$cwd}html-tidy-config.cfg", $descriptorspec, $pipes);
|
||||
|
||||
|
||||
// Make sure the program started and we got the hooks...
|
||||
// Either way, get some source code into $source
|
||||
if (is_resource($process)) {
|
||||
|
||||
// Feed untidy source into the stdin
|
||||
fwrite($pipes[0], $source);
|
||||
fclose($pipes[0]);
|
||||
|
||||
// Read clean source out to the browser
|
||||
while (!feof($pipes[1])) {
|
||||
//echo fgets($pipes[1], 1024);
|
||||
$newsrc .= fgets($pipes[1], 1024);
|
||||
}
|
||||
fclose($pipes[1]);
|
||||
|
||||
// Clean up after ourselves
|
||||
proc_close($process);
|
||||
|
||||
} else {
|
||||
/* Use tidy if it's available from PECL */
|
||||
if( function_exists('tidy_parse_string') )
|
||||
{
|
||||
$tempsrc = tidy_parse_string($source);
|
||||
tidy_clean_repair();
|
||||
$newsrc = tidy_get_output();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Better give them back what they came with, so they don't lose it all...
|
||||
$newsrc = "<body>\n" .$source. "\n</body>";
|
||||
}
|
||||
}
|
||||
|
||||
// Split our source into an array by lines
|
||||
$srcLines = preg_split("/\n/",$newsrc,-1,PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
// Get only the lines between the body tags
|
||||
$startLn = 0;
|
||||
while ( strpos( $srcLines[$startLn++], '<body' ) === false && $startLn < sizeof($srcLines) );
|
||||
$endLn = $startLn;
|
||||
while ( strpos( $srcLines[$endLn++], '</body' ) === false && $endLn < sizeof($srcLines) );
|
||||
|
||||
$srcLines = array_slice( $srcLines, $startLn, ($endLn - $startLn - 1) );
|
||||
|
||||
// Create a set of javascript code to compile a new source string
|
||||
foreach ($srcLines as $line) {
|
||||
$jsMakeSrc .= "\tns += '" . str_replace("'","\'",$line) . "\\n';\n";
|
||||
}
|
||||
if(!sizeof($srcLines)) {
|
||||
echo "alert(HTMLArea._lc('Tidy failed. Check your HTML for syntax errors.', 'HtmlTidy'));\n";
|
||||
} else {
|
||||
?>
|
||||
var ns="";
|
||||
<?php echo $jsMakeSrc; ?>
|
||||
editor.setHTML(ns);
|
||||
<? } ?>
|
||||
@@ -1,105 +1,105 @@
|
||||
// Plugin for htmlArea to run code through the server's HTML Tidy
|
||||
// By Adam Wright, for The University of Western Australia
|
||||
//
|
||||
// Distributed under the same terms as HTMLArea itself.
|
||||
// This notice MUST stay intact for use (see license.txt).
|
||||
|
||||
function HtmlTidy(editor) {
|
||||
this.editor = editor;
|
||||
|
||||
var cfg = editor.config;
|
||||
var bl = HtmlTidy.btnList;
|
||||
var self = this;
|
||||
|
||||
this.onMode = this.__onMode;
|
||||
|
||||
// register the toolbar buttons provided by this plugin
|
||||
var toolbar = [];
|
||||
for (var i = 0; i < bl.length; ++i) {
|
||||
var btn = bl[i];
|
||||
if (btn == "html-tidy") {
|
||||
var id = "HT-html-tidy";
|
||||
cfg.registerButton(id, this._lc("HTML Tidy"), editor.imgURL(btn[0] + ".gif", "HtmlTidy"), true,
|
||||
function(editor, id) {
|
||||
// dispatch button press event
|
||||
self.buttonPress(editor, id);
|
||||
}, btn[1]);
|
||||
toolbar.push(id);
|
||||
} else if (btn == "html-auto-tidy") {
|
||||
var btnTxt = [this._lc("Auto-Tidy"), this._lc("Don't Tidy")];
|
||||
var optionItems = new Object();
|
||||
optionItems[btnTxt[0]] = "auto";
|
||||
optionItems[btnTxt[1]] = "noauto";
|
||||
var ht_class = {
|
||||
id : "HT-auto-tidy",
|
||||
options : optionItems,
|
||||
action : function (editor) { self.__onSelect(editor, this); },
|
||||
refresh : function (editor) { },
|
||||
context : "body"
|
||||
};
|
||||
cfg.registerDropdown(ht_class);
|
||||
}
|
||||
}
|
||||
|
||||
for (var i in toolbar) {
|
||||
cfg.toolbar[0].push(toolbar[i]);
|
||||
}
|
||||
}
|
||||
|
||||
HtmlTidy._pluginInfo = {
|
||||
name : "HtmlTidy",
|
||||
version : "1.0",
|
||||
developer : "Adam Wright",
|
||||
developer_url : "http://blog.hipikat.org/",
|
||||
sponsor : "The University of Western Australia",
|
||||
sponsor_url : "http://www.uwa.edu.au/",
|
||||
license : "htmlArea"
|
||||
};
|
||||
|
||||
HtmlTidy.prototype._lc = function(string) {
|
||||
return HTMLArea._lc(string, 'HtmlTidy');
|
||||
};
|
||||
|
||||
HtmlTidy.prototype.__onSelect = function(editor, obj) {
|
||||
// Get the toolbar element object
|
||||
var elem = editor._toolbarObjects[obj.id].element;
|
||||
|
||||
// Set our onMode event appropriately
|
||||
if (elem.value == "auto")
|
||||
this.onMode = this.__onMode;
|
||||
else
|
||||
this.onMode = null;
|
||||
};
|
||||
|
||||
HtmlTidy.prototype.__onMode = function(mode) {
|
||||
if ( mode == "textmode" ) {
|
||||
this.buttonPress(this.editor, "HT-html-tidy");
|
||||
}
|
||||
};
|
||||
|
||||
HtmlTidy.btnList = [
|
||||
null, // separator
|
||||
["html-tidy"],
|
||||
["html-auto-tidy"]
|
||||
];
|
||||
|
||||
HtmlTidy.prototype.buttonPress = function(editor, id) {
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case "HT-html-tidy":
|
||||
{
|
||||
var oldhtml = editor.getHTML();
|
||||
if(oldhtml=="") break; //don't clean empty text
|
||||
// Ask the server for some nice new html, based on the old...
|
||||
HTMLArea._postback(_editor_url + 'plugins/HtmlTidy/html-tidy-logic.php', {'htisource_name' : oldhtml},
|
||||
function(javascriptResponse) { eval(javascriptResponse) });
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
HtmlTidy.prototype.processTidied = function(newSrc) {
|
||||
editor = this.editor;
|
||||
editor.setHTML(newSrc);
|
||||
// Plugin for htmlArea to run code through the server's HTML Tidy
|
||||
// By Adam Wright, for The University of Western Australia
|
||||
//
|
||||
// Distributed under the same terms as HTMLArea itself.
|
||||
// This notice MUST stay intact for use (see license.txt).
|
||||
|
||||
function HtmlTidy(editor) {
|
||||
this.editor = editor;
|
||||
|
||||
var cfg = editor.config;
|
||||
var bl = HtmlTidy.btnList;
|
||||
var self = this;
|
||||
|
||||
this.onMode = this.__onMode;
|
||||
|
||||
// register the toolbar buttons provided by this plugin
|
||||
var toolbar = [];
|
||||
for (var i = 0; i < bl.length; ++i) {
|
||||
var btn = bl[i];
|
||||
if (btn == "html-tidy") {
|
||||
var id = "HT-html-tidy";
|
||||
cfg.registerButton(id, this._lc("HTML Tidy"), editor.imgURL(btn[0] + ".gif", "HtmlTidy"), true,
|
||||
function(editor, id) {
|
||||
// dispatch button press event
|
||||
self.buttonPress(editor, id);
|
||||
}, btn[1]);
|
||||
toolbar.push(id);
|
||||
} else if (btn == "html-auto-tidy") {
|
||||
var btnTxt = [this._lc("Auto-Tidy"), this._lc("Don't Tidy")];
|
||||
var optionItems = new Object();
|
||||
optionItems[btnTxt[0]] = "auto";
|
||||
optionItems[btnTxt[1]] = "noauto";
|
||||
var ht_class = {
|
||||
id : "HT-auto-tidy",
|
||||
options : optionItems,
|
||||
action : function (editor) { self.__onSelect(editor, this); },
|
||||
refresh : function (editor) { },
|
||||
context : "body"
|
||||
};
|
||||
cfg.registerDropdown(ht_class);
|
||||
}
|
||||
}
|
||||
|
||||
for (var i in toolbar) {
|
||||
cfg.toolbar[0].push(toolbar[i]);
|
||||
}
|
||||
}
|
||||
|
||||
HtmlTidy._pluginInfo = {
|
||||
name : "HtmlTidy",
|
||||
version : "1.0",
|
||||
developer : "Adam Wright",
|
||||
developer_url : "http://blog.hipikat.org/",
|
||||
sponsor : "The University of Western Australia",
|
||||
sponsor_url : "http://www.uwa.edu.au/",
|
||||
license : "htmlArea"
|
||||
};
|
||||
|
||||
HtmlTidy.prototype._lc = function(string) {
|
||||
return HTMLArea._lc(string, 'HtmlTidy');
|
||||
};
|
||||
|
||||
HtmlTidy.prototype.__onSelect = function(editor, obj) {
|
||||
// Get the toolbar element object
|
||||
var elem = editor._toolbarObjects[obj.id].element;
|
||||
|
||||
// Set our onMode event appropriately
|
||||
if (elem.value == "auto")
|
||||
this.onMode = this.__onMode;
|
||||
else
|
||||
this.onMode = null;
|
||||
};
|
||||
|
||||
HtmlTidy.prototype.__onMode = function(mode) {
|
||||
if ( mode == "textmode" ) {
|
||||
this.buttonPress(this.editor, "HT-html-tidy");
|
||||
}
|
||||
};
|
||||
|
||||
HtmlTidy.btnList = [
|
||||
null, // separator
|
||||
["html-tidy"],
|
||||
["html-auto-tidy"]
|
||||
];
|
||||
|
||||
HtmlTidy.prototype.buttonPress = function(editor, id) {
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case "HT-html-tidy":
|
||||
{
|
||||
var oldhtml = editor.getHTML();
|
||||
if(oldhtml=="") break; //don't clean empty text
|
||||
// Ask the server for some nice new html, based on the old...
|
||||
HTMLArea._postback(_editor_url + 'plugins/HtmlTidy/html-tidy-logic.php', {'htisource_name' : oldhtml},
|
||||
function(javascriptResponse) { eval(javascriptResponse) });
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
HtmlTidy.prototype.processTidied = function(newSrc) {
|
||||
editor = this.editor;
|
||||
editor.setHTML(newSrc);
|
||||
};
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 609 B After Width: | Height: | Size: 599 B |
8
xinha/plugins/HtmlTidy/lang/ja.js
Normal file
8
xinha/plugins/HtmlTidy/lang/ja.js
Normal file
@@ -0,0 +1,8 @@
|
||||
// I18N constants
|
||||
// LANG: "ja", ENCODING: UTF-8
|
||||
{
|
||||
"HTML Tidy": "HTML Tidy",
|
||||
"Auto-Tidy": "自動適正化",
|
||||
"Don't Tidy": "適正化しない",
|
||||
"Tidy failed. Check your HTML for syntax errors.":"適正化に失敗しました。HTMLの文法エラーを確認してください。"
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
// I18N constants
|
||||
// LANG: "no", ENCODING: UTF-8
|
||||
// LANG: "nb", ENCODING: UTF-8
|
||||
// translated: Kim Steinhaug, http://www.steinhaug.com/, kim@steinhaug.com
|
||||
{
|
||||
"HTML Tidy": "HTML Tidy",
|
||||
"Tidy failed. Check your HTML for syntax errors.": "Tidy feilet. Sjekk HTML koden for syntax feil."
|
||||
"Tidy failed. Check your HTML for syntax errors.": "Tidy feilet. Sjekk HTML koden for syntaksfeil."
|
||||
};
|
||||
Reference in New Issue
Block a user