15 public $levels = array(0 =>
'none',
'light',
'medium',
'heavy');
50 $level =
$config->get(
'HTML.TidyLevel');
54 $add_fixes =
$config->get(
'HTML.TidyAdd');
55 $remove_fixes =
$config->get(
'HTML.TidyRemove');
57 foreach ($fixes as
$name => $fix) {
59 if (isset($remove_fixes[
$name]) ||
60 (!isset($add_fixes[$name]) && !isset($fixes_lookup[$name]))) {
77 if ($level == $this->levels[0]) {
80 $activated_levels = array();
81 for (
$i = 1,
$c = count($this->levels);
$i <
$c;
$i++) {
82 $activated_levels[] = $this->levels[
$i];
83 if ($this->levels[
$i] == $level) {
89 'Tidy level ' . htmlspecialchars($level) .
' not recognized',
95 foreach ($activated_levels as $level) {
96 foreach ($this->fixesForLevel[$level] as $fix) {
111 if (!isset($this->defaultLevel)) {
114 if (!isset($this->fixesForLevel[$this->defaultLevel])) {
116 'Default level ' . $this->defaultLevel .
' does not exist',
131 foreach ($fixes as
$name => $fix) {
135 case 'attr_transform_pre':
136 case 'attr_transform_post':
138 if (isset(
$params[
'element'])) {
140 if (empty($this->
info[$element])) {
143 $e = $this->
info[$element];
146 $type =
"info_$type";
154 case 'tag_transform':
155 $this->info_tag_transform[
$params[
'element']] = $fix;
158 case 'content_model_type':
159 $element = $params[
'element'];
160 if (empty($this->
info[$element])) {
163 $e = $this->
info[$element];
168 trigger_error(
"Fix type $type not supported", E_USER_ERROR);
185 $property = $attr = null;
186 if (strpos(
$name,
'#') !==
false) {
189 if (strpos(
$name,
'@') !==
false) {
198 if (!is_null($attr)) {
203 if (!is_null($attr)) {
204 if (is_null($property)) {
207 $type =
'attr_transform_' . $property;
212 if (is_null($property)) {
213 return array(
'tag_transform',
$params);
216 return array($property,
$params);
populate($fixes)
Populates the module with transforms and other special-case code based on a list of fixes passed to i...
getFixType($name)
Parses a fix name and determines what kind of fix it is, as well as other information defined by the ...
addBlankElement($element)
Convenience function that creates a totally blank, non-standalone element.
$defaultLevel
Default level to place all fixes in.
Abstract class for a set of proprietary modules that clean up (tidy) poorly written HTML...
$fixesForLevel
Lists of fixes used by getFixesForLevel().
$levels
List of supported levels.
setup($config)
Lazy load constructs the module by determining the necessary fixes to create and then delegating to t...
Represents an XHTML 1.1 module, with information on elements, tags and attributes.
makeFixesForLevel($fixes)
Dynamically populates the $fixesForLevel member variable using the fixes array.
getFixesForLevel($level)
Retrieves all fixes per a level, returning fixes for that specific level as well as all levels below ...
$name
Short unique string identifier of the module.
makeFixes()
Defines all fixes the module will perform in a compact associative array of fix name to fix implement...