0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-12-22 16:31:53 +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) {
switch ($tag->type) {
case 'end':
$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;
}
$new_tag = $tag->copy();
$new_tag->name = $this->transform_to;
return $new_tag;
}
@ -58,17 +44,9 @@ class HTMLPurifier_TagTransform_Center extends HTMLPurifier_TagTransform
} else {
$attributes['style'] = $prepend_css;
}
switch ($tag->type) {
case 'start':
$new_tag = new HTMLPurifier_Token_Start($this->transform_to, $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;
}
$new_tag = $tag->copy();
$new_tag->name = $this->transform_to;
$new_tag->attributes = $attributes;
return $new_tag;
}
}
@ -132,17 +110,10 @@ class HTMLPurifier_TagTransform_Font extends HTMLPurifier_TagTransform
$prepend_style;
}
switch ($tag->type) {
case 'start':
$new_tag = new HTMLPurifier_Token_Start($this->transform_to, $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;
}
$new_tag = $tag->copy();
$new_tag->name = $this->transform_to;
$new_tag->attributes = $attributes;
return $new_tag;
}