Created default tag methods

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@45662 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Jeremy Shipman 2007-11-26 04:20:19 +00:00
parent 609a8528b8
commit 949f10221e

View File

@ -77,10 +77,10 @@ class XML extends Object {
// Strip namespaces out of tags and attributes // Strip namespaces out of tags and attributes
$tag = ereg_replace('[^:]+:','',$tag); $tag = ereg_replace('[^:]+:','',$tag);
if($attributes) foreach($attributes as $k => $v) $newAttributes[ereg_replace('[^:]+:','',$k)] = $v; if($attributes) foreach($attributes as $k => $v) $newAttributes[ereg_replace('[^:]+:','',$k)] = $v;
$attributes = $newAttributes; $attributes = isset($newAttributes) ? $newAttributes : $attributes;
if($attributes['class']) { if(isset($attributes['class'])) {
$this->context[] = "$tag.{$attributes['class']}"; $this->context[] = "$tag.{$attributes['class']}";
} else { } else {
$this->context[] = $tag; $this->context[] = $tag;
@ -92,6 +92,8 @@ class XML extends Object {
$tagProcessorFunc = "process_$tag"; $tagProcessorFunc = "process_$tag";
if($this->hasMethod($tagProcessorFunc)) { if($this->hasMethod($tagProcessorFunc)) {
$this->$tagProcessorFunc($attributes); $this->$tagProcessorFunc($attributes);
}elseif($this->hasMethod($tagProcessorFunc = "process_tag")){
$this->$tagProcessorFunc($tag, $attributes);
} }
@ -111,6 +113,9 @@ class XML extends Object {
if(method_exists($this, $funcName = "process_{$tag}_end")) { if(method_exists($this, $funcName = "process_{$tag}_end")) {
$this->$funcName($this->collatedText, $attributes); $this->$funcName($this->collatedText, $attributes);
}elseif(method_exists($this,$funcName = "process_tag_end")){
// else run default method
$this->$funcName($tag,$this->collatedText, $attributes);
} }
$this->collatedText = ""; $this->collatedText = "";