@define('PLUGIN_EVENT_XHTMLCLEANUP_NAME', 'Fix common XHTML errors');
@define('PLUGIN_EVENT_XHTMLCLEANUP_DESC', 'This plugin corrects common issues with XHTML markup in entries. It assists in keeping your blog XHTML compliant.');
+@define('PLUGIN_EVENT_XHTMLCLEANUP_XHTML', 'Encode XML-parsed data?');
+@define('PLUGIN_EVENT_XHTMLCLEANUP_XHTML_DESC', 'This plugin uses a XML parsing method to ensure XHTML validity of your code. This xml parsing may convert already valid entities to unescaped entities, so the plugin encodes all entities after the parsing. Set this flag to OFF if that introduces double encoding for you!');
if (!function_exists('html_entity_decode')) {
function html_entity_decode($given_html, $quote_style = ENT_QUOTES) {
class serendipity_event_xhtmlcleanup extends serendipity_event
{
var $title = PLUGIN_EVENT_XHTMLCLEANUP_NAME;
- var $cleanup_tag, $cleanup_checkfor, $cleanup_val;
+ var $cleanup_tag, $cleanup_checkfor, $cleanup_val, $cleanup_parse;
function introspect(&$propbag)
{
$propbag->add('description', PLUGIN_EVENT_XHTMLCLEANUP_DESC);
$propbag->add('stackable', false);
$propbag->add('author', 'Garvin Hicking');
- $propbag->add('version', '1.1');
+ $propbag->add('version', '1.2');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'smarty' => '2.6.7',
foreach($this->markup_elements as $element) {
$conf_array[] = $element['name'];
}
+ $conf_array[] = 'xhtml_parse';
$propbag->add('configuration', $conf_array);
}
function introspect_config_item($name, &$propbag)
{
- $propbag->add('type', 'boolean');
- $propbag->add('name', constant($name));
- $propbag->add('description', sprintf(APPLY_MARKUP_TO, constant($name)));
- $propbag->add('default', 'true');
+ if ($name == 'xhtml_parse') {
+ $propbag->add('type', 'boolean');
+ $propbag->add('name', PLUGIN_EVENT_XHTMLCLEANUP_XHTML);
+ $propbag->add('description', PLUGIN_EVENT_XHTMLCLEANUP_XHTML_DESC);
+ $propbag->add('default', 'true');
+ } else {
+ $propbag->add('type', 'boolean');
+ $propbag->add('name', constant($name));
+ $propbag->add('description', sprintf(APPLY_MARKUP_TO, constant($name)));
+ $propbag->add('default', 'true');
+ }
+
return true;
}
if (isset($hooks[$event])) {
switch($event) {
case 'frontend_display':
+ $this->cleanup_parse = serendipity_db_bool($this->get_config('xhtml_parse'));
foreach ($this->markup_elements as $temp) {
if (serendipity_db_bool($this->get_config($temp['name'], true)) && isset($eventData[$temp['element']])) {
$element = $temp['element'];
// Reconstruct XHTML tag.
$atts = ' ';
foreach($vals[0]['attributes'] AS $att => $att_con) {
- $atts .= strtolower($att) . '="' . $att_con . '" ';
+ $atts .= strtolower($att) . '="' . ($this->cleanup_parse ? htmlspecialchars($att_con) : $att_con) . '" ';
}
return '<' . strtolower($tag) . $atts . ' />';
}
/* vim: set sts=4 ts=4 expandtab : */
-?>