Cytat(wookieb @ 11.09.2009, 19:14:55 )

No to przy generowaniu jednego taga sprawdza, jakie tagi ma w before. Generujesz je i wstawiasz przed tag. Podobine z after. Ale skoro mówisz, że źle ci działa to może byś sypnął kodem?
Problem tkwi w metodzie renderAll()
class Tag
{
public $tagType;
public $tagAttributes;
public $neberTags = array('before'=>array
(), 'after'=>array
(), 'inner'=>array
(), 'outer'=>array
()); public $options = false;
private $optionsDefault = array('quotation'=>'"'); private $closedTags = array('img'=>1,'input'=>1
);
public function __construct
($tagType, $tagAttributes = array(), $options = array()) {
$this->tagType = $tagType;
$this->tagAttributes = $tagAttributes;
$this->options = array_merge($this->optionsDefault, $options); }
public function after
($tagType, $tagAttributes = array(), $options = array()) {
$tag = new Tag($tagType, $tagAttributes, $options);
//$tag = $this->neberTags['after'][] = new Tag($tagType, $tagAttributes, $options);
return $tag;
}
public function before
($tagType, $tagAttributes = array(), $options = array()) {
$tag = new Tag($tagType, $tagAttributes, $options);
return $tag;
}
public function outer
($tagType, $tagAttributes = array(), $options = array()) {
$tag = new Tag($tagType, $tagAttributes, $options);
return $tag;
}
public function inner
($tagType, $tagAttributes = array(), $options = array()) {
$tag = new Tag($tagType, $tagAttributes, $options);
return $tag;
}
public function link($url, $tagAttributes = array(), $options = array()) {
$defaultAttributes = array('href'=>$url, 'title'=>''); $tagAttributes = array_merge($defaultAttributes, $tagAttributes);
if(!$tagAttributes['href'] || !file_exists($tagAttributes['href'])) return false;
$tag = new Tag('a', $tagAttributes, $options);
return $tag;
}
public function render($echo = true)
{
$attributes = $this->attributes($this->tagAttributes);
if(!empty($this->closedTags[$this->tagType])){ if($echo === true){
echo "<{$this->tagType}{$attributes} />"; }else{
return "<{$this->tagType}{$attributes} />";
}
}else{
if($echo === true){
echo "<{$this->tagType}{$attributes}></{$this->tagType}>"; }else{
return "<{$this->tagType}{$attributes}></{$this->tagType}>";
}
}
}
public function renderAll($html = false, $type = false)
{
if($type == false) $html = $this->render(false);
if($type == 'after') $html = $html.$this->render(false);
if($type == 'before') $html = $this->render(false).$html;
if($type == 'outer'){
$out = explode('><',$this->render(false)); $html = $out[0].'>'.$html.'<'.$out[1];
}
if($type == 'inner'){
$html = $out[0].'>'.$this->render(false).'<'.$out[1];
}
foreach($this->neberTags as $k=>$types){
foreach($types as $k2=>$v2){
$html = $v2->renderAll($html, $k);
}
}
return $html;
}
private function attributes($tagAttributes)
{
foreach($tagAttributes as $attribute=>$value){
$attributes .= ' '.$attribute.'='.$this->options['quotation'].$value.$this->options['quotation'];
}
return $attributes;
}
}