function htmltidy_nodeapi in HTML Tidy 5
Same name and namespace in other branches
- 6 htmltidy.module \htmltidy_nodeapi()
File
- ./
htmltidy.module, line 295
Code
function htmltidy_nodeapi(&$node, $op, $a3 = NULL, $page = NULL) {
if (variable_get('htmltidy_process_input', TRUE)) {
switch ($op) {
case 'prepare':
//var_dump($htmltidy_filter); exit();
$_POST['body'] = htmltidy_fragment($_POST['body'], $errors, $warnings);
if ($errors) {
$errors = array_map('htmlentities', $errors);
form_set_error('body', theme('item_list', $errors));
}
break;
case 'validate':
global $htmltidy_filter;
if ($node->body) {
// call the filters so if they're using html tidy as a filter it'll
// be called in order
check_markup($node->body, $node->format);
if (isset($htmltidy_filter['filtered']) && $htmltidy_filter['filtered']) {
$errors = $htmltidy_filter['errors'];
$warnings = $htmltidy_filter['warnings'];
}
else {
$clean = htmltidy_fragment($node->body, $errors, $warnings);
form_set_value(array(
'#parents' => array(
'body',
),
), $clean);
}
if ($errors || $warnings) {
$message = '<p>Original body:</p><pre>' . htmlentities($node->body) . '</pre>';
if ($errors) {
$message .= theme('item_list', array_map('htmlentities', $errors));
form_set_error('body', $message);
}
if ($warnings) {
drupal_set_message(theme('item_list', array_map('htmlentities', $warnings)));
}
}
}
break;
}
}
}