the editor of classic CMSimple, oEdit, is often critized, as it sometimes fails to produce valid HTML and does completely ignore the setting of xhtml_endtags. While the latter had could been easily fixed by emitting an appropriate doctype in the "retrieve handling", the former is solely a problem of its simplicity. Like most (all?) other "online" editors, oEdit uses the so-called designMode of the browser. Contrary to several other editors (e.g. tinyMCE and CKEditor), oEdit doesn't clean up what the browser produces (which is quite different depending on the browser, as the interface is not standardized in any way).
So I've thought about a simple way to alleviate the situation, and the one with the best cost-benefit ratio is probably to do the most basic clean up server side using PHP's "tidy" extension. If you have PHP 5 with the "tidy" extension available (check phpinfo() or ask your provider) and want oEdit to produce valid (X)HTML, you can put the following code at the end of your cmsimple/functions.php (just before the closing ?>):
Code: Select all
function tidyHTM($htm)
{
global $cf;
if (class_exists('tidy') && version_compare(PHP_VERSION, '5', '>=')) {
$tidy = new tidy();
$mul = $cf['xhtml']['endtags'] == 'true'
? 'output-xhtml'
: 'output-html';
$config = array($mul => true, 'alt-text' => '', 'show-body-only' => true); // configuration
$tidy->parseString($htm, $config, 'raw');
if ($tidy->cleanRepair()) {
return (string) $tidy;
} else {
return $htm;
}
} else {
return $htm;
}
}
Code: Select all
$c[$s] = preg_replace("/<h[1-".$cf['menu']['levels']."][^>]*>(\ | )?<\/h[1-".$cf['menu']['levels']."]>/i", "", tidyHTM(stsl($text)));
And please note, that the chosen configuration of "tidy" is rather unobtrusive; you can force further clean up depending on your needs; see http://tidy.sourceforge.net/docs/quickref.html for details.
Christoph