mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-09 23:28:42 +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:
parent
9d390fca56
commit
8890449398
@ -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;
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user