0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-12-23 00:41:52 +00:00

Eliminate duplication in TagTransform.php by using copy()

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@164 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang 2006-08-05 02:19:08 +00:00
parent 9d390fca56
commit 8890449398

View File

@ -21,22 +21,8 @@ class HTMLPurifier_TagTransform_Simple extends HTMLPurifier_TagTransform
} }
function transform($tag) { function transform($tag) {
switch ($tag->type) { $new_tag = $tag->copy();
case 'end': $new_tag->name = $this->transform_to;
$new_tag = new HTMLPurifier_Token_End($this->transform_to);
break;
case 'start':
$new_tag = new HTMLPurifier_Token_Start($this->transform_to,
$tag->attributes);
break;
case 'empty':
$new_tag = new HTMLPurifier_Token_Empty($this->transform_to,
$tag->attributes);
break;
default:
trigger_error('Failed tag transformation', E_USER_WARNING);
return;
}
return $new_tag; return $new_tag;
} }
@ -58,17 +44,9 @@ class HTMLPurifier_TagTransform_Center extends HTMLPurifier_TagTransform
} else { } else {
$attributes['style'] = $prepend_css; $attributes['style'] = $prepend_css;
} }
switch ($tag->type) { $new_tag = $tag->copy();
case 'start': $new_tag->name = $this->transform_to;
$new_tag = new HTMLPurifier_Token_Start($this->transform_to, $attributes); $new_tag->attributes = $attributes;
break;
case 'empty':
$new_tag = new HTMLPurifier_Token_Empty($this->transform_to, $attributes);
break;
default:
trigger_error('Failed tag transformation', E_USER_WARNING);
return;
}
return $new_tag; return $new_tag;
} }
} }
@ -132,17 +110,10 @@ class HTMLPurifier_TagTransform_Font extends HTMLPurifier_TagTransform
$prepend_style; $prepend_style;
} }
switch ($tag->type) { $new_tag = $tag->copy();
case 'start': $new_tag->name = $this->transform_to;
$new_tag = new HTMLPurifier_Token_Start($this->transform_to, $attributes); $new_tag->attributes = $attributes;
break;
case 'empty':
$new_tag = new HTMLPurifier_Token_Empty($this->transform_to, $attributes);
break;
default:
trigger_error('Failed tag transformation', E_USER_WARNING);
return;
}
return $new_tag; return $new_tag;
} }