Import xinha so we can switch from htmlarea and fix a bunch of in-browser issues that htmlarea has

This commit is contained in:
Chris Morgan
2005-09-30 02:25:07 +00:00
committed by WineHQ
parent 2311d4d572
commit 9242a68c4a
375 changed files with 26623 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
<h1 id="[h1]"><l10n>Clean up HTML</l10n></h1>
<div style="margin-left: 10px;">
<l10n>Please select from the following cleaning options...</l10n>
<div id="[divTidy]">
<input type="checkbox" name="[tidy]" id="[tidy]" />
<label for="[tidy]">
<l10n>General tidy up and correction of some problems.</l10n></label>
</div>
<div>
<input type="checkbox" name="[word_clean]" id="[word_clean]" />
<label for="[word_clean]">
<l10n>Clean bad HTML from Microsoft Word</l10n></label>
</div>
<div>
<input type="checkbox" name="[faces]" id="[faces]" />
<label for="[faces]">
<l10n>Remove custom typefaces (font "styles").</l10n></label>
</div>
<div>
<input type="checkbox" name="[sizes]" id="[sizes]" />
<label for="[sizes]">
<l10n>Remove custom font sizes.</l10n></label>
</div>
<div>
<input type="checkbox" name="[colors]" id="[colors]" />
<label for="[colors]">
<l10n>Remove custom text colors.</l10n></label>
</div>
<div style="margin-top: 10px;">
<input type="button" id="[ok]" value="_(OK)" />
<input type="button" id="[cancel]" value="_(CANCEL)" />
</div>
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 988 B

View File

@@ -0,0 +1,27 @@
// I18N constants
// LANG: "de", ENCODING: UTF-8
// translated: Raimund Meyer xinha@ray-of-light.org
// FOR TRANSLATORS:
//
// 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE
// (at least a valid email address)
//
// 2. PLEASE TRY TO USE UTF-8 FOR ENCODING;
// (if this is not possible, please include a comment
// that states what encoding is necessary.)
{
"Clean Up HTML": "HTML säubern",
"Please select from the following cleaning options...": "Bitte Optionen auswählen...",
"General tidy up and correction of some problems.": "Allgemeines aufräumen und Korrektur einiger Probleme.",
"Clean bad HTML from Microsoft Word": "Schlechtes HTML aus Microsoft Word aufräumen",
"Remove custom typefaces (font \"styles\").": "Schriftarten entfernen (font face).",
"Remove custom font sizes.": "Schriftgrößen entfernen (font size).",
"Remove custom text colors.": "Schriftfarben entfernen (font color).",
"Go": "Go",
"Cancel": "Abbrechen",
"Tidy failed. Check your HTML for syntax errors.": "Säubern fehlgeschlagen. Überprüfen Sie Ihren Code auf Fehler.",
"You don't have anything to tidy!": "Es gibt nichts zu säubern...!"
}

View File

@@ -0,0 +1,27 @@
// I18N constants
// LANG: "fr", ENCODING: UTF-8
// Author: Laurent Vilday, mokhet@mokhet.com
// FOR TRANSLATORS:
//
// 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE
// (at least a valid email address)
//
// 2. PLEASE TRY TO USE UTF-8 FOR ENCODING;
// (if this is not possible, please include a comment
// that states what encoding is necessary.)
{
"Clean Up HTML": "Nettoyer le code HTML",
"Please select from the following cleaning options...": "Veuillez sélectionner une options de nettoyage.",
"General tidy up and correction of some problems.": "Nettoyage générique et correction des problèmes mineurs.",
"Clean bad HTML from Microsoft Word": "Nettoyer les balises HTML de Microsoft Word",
"Remove custom typefaces (font \"styles\").": "Supprimer les polices personalisées (font \"styles\").",
"Remove custom font sizes.": "Supprimer les tailles de polices personnalisées.",
"Remove custom text colors.": "Supprimer les couleurs de texte personalisées.",
"Go": "Commencer",
"Cancel": "Annuler",
"Tidy failed. Check your HTML for syntax errors.": "Tidy a échoué. Vérifier la syntaxe HTML.",
"You don't have anything to tidy!": "Rien à transmettre à tidy !"
}

View File

@@ -0,0 +1,17 @@
// I18N constants
// LANG: "no", ENCODING: UTF-8
// translated: Kim Steinhaug, http://www.steinhaug.com/, kim@steinhaug.com
{
"Clean Up HTML": "Vask HTML kode",
"Please select from the following cleaning options...": "Vennligst velg blandt de forskjellige mulighetene å vaske/ rydde i HTML koden",
"General tidy up and correction of some problems.": "Generell opprydding i HTML koden samt korrigering av typiske feil",
"Clean bad HTML from Microsoft Word": "Vask HTML kode for feil og problemer etter Microsoft Word",
"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)",
"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.",
"You don't have anything to tidy!": "Det finnes ingen HTML kode å vaske!"
}

View File

@@ -0,0 +1,181 @@
// 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);
}
SuperClean._pluginInfo =
{
name : "SuperClean",
version : "1.0",
developer: "James Sleeman",
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(string) {
return HTMLArea._lc(string, 'SuperClean');
}
/** 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();
if(opts.faces)
{
D = D.replace(/face="[^"]*"/gi, '');
// { (stops jedit's fold breaking)
D = D.replace(/font-family:[^;}"']+;?/gi, '');
}
if(opts.sizes)
{
D = D.replace(/size="[^"]*"/gi, '');
// { (stops jedit's fold breaking)
D = D.replace(/font-size:[^;}"']+;?/gi, '');
}
if(opts.colors)
{
D = D.replace(/color="[^"]*"/gi, '');
// { (stops jedit's fold breaking)
D = D.replace(/([^-])color:[^;}"']+;?/gi, '$1');
}
D = D.replace(/(style|class)="\s*"/gi, '');
D = D.replace(/<(font|span)\s*>/gi, '');
editor.setHTML(D);
if(editor.config.tidy_handler && opts.tidy)
{
HTMLArea._postback(editor.config.tidy_handler, {'content' : editor.getInnerHTML()},
function(javascriptResponse) { eval(javascriptResponse) });
}
return true;
}
var inputs = {};
this._dialog.show(inputs, doOK);
}
// 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
//
// set to false if you need to disable this.
HTMLArea.Config.prototype.tidy_handler = _editor_url + 'plugins/SuperClean/tidy.php';
SuperClean.prototype.onGenerate = function()
{
this._dialog = new SuperClean.Dialog(this);
}
// 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.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 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.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;
}
if(!this.SuperClean.editor.config.tidy_handler) {
this.dialog.getElementById('divTidy').style.display = 'none';
}
// 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.hide = function()
{
this.SuperClean.editor.enableToolbar();
return this.dialog.hide();
}

View File

@@ -0,0 +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
}
?>