15 public $levels = array(0 =>
'none',
'light',
'medium',
'heavy');
38 public function setup($config) {
45 $level = $config->get(
'HTML.TidyLevel');
49 $add_fixes = $config->get(
'HTML.TidyAdd');
50 $remove_fixes = $config->get(
'HTML.TidyRemove');
52 foreach ($fixes as
$name => $fix) {
55 isset($remove_fixes[
$name]) ||
56 (!isset($add_fixes[$name]) && !isset($fixes_lookup[$name]))
74 if ($level == $this->levels[0]) {
77 $activated_levels = array();
78 for ($i = 1, $c = count($this->levels); $i < $c; $i++) {
79 $activated_levels[] = $this->levels[$i];
80 if ($this->levels[$i] == $level)
break;
84 'Tidy level ' . htmlspecialchars($level) .
' not recognized',
90 foreach ($activated_levels as $level) {
91 foreach ($this->fixesForLevel[$level] as $fix) {
104 if (!isset($this->defaultLevel))
return;
105 if (!isset($this->fixesForLevel[$this->defaultLevel])) {
107 'Default level ' . $this->defaultLevel .
' does not exist',
121 foreach ($fixes as
$name => $fix) {
125 case 'attr_transform_pre':
126 case 'attr_transform_post':
127 $attr = $params[
'attr'];
128 if (isset($params[
'element'])) {
129 $element = $params[
'element'];
130 if (empty($this->info[$element])) {
133 $e = $this->info[$element];
136 $type =
"info_$type";
144 case 'tag_transform':
145 $this->info_tag_transform[$params[
'element']] = $fix;
148 case 'content_model_type':
149 $element = $params[
'element'];
150 if (empty($this->info[$element])) {
153 $e = $this->info[$element];
158 trigger_error(
"Fix type $type not supported", E_USER_ERROR);
174 $property = $attr = null;
175 if (strpos(
$name,
'#') !==
false) list(
$name, $property) = explode(
'#',
$name);
176 if (strpos(
$name,
'@') !==
false) list(
$name, $attr) = explode(
'@',
$name);
181 if (!is_null($attr)) $params[
'attr'] = $attr;
184 if (!is_null($attr)) {
185 if (is_null($property)) $property =
'pre';
186 $type =
'attr_transform_' . $property;
187 return array($type, $params);
191 if (is_null($property)) {
192 return array(
'tag_transform', $params);
195 return array($property, $params);