Location: PHPKode > scripts > ooeLite > ooelite/ooeTagTemplate.class.php
<?php
/**
* Classe que retorna html a partir de um template php com marcações especiais
* @author Marcelo Soares da Costa
* @email phpmafia at yahoo dot com dot br
* @copyright Marcelo Soares da Costa © 2007/2009. 
* @license FreeBSD http://www.freebsd.org/copyright/freebsd-license.html
* @version 1.1
* @access public
* @package OOE
* @chagelog 2009-07-02 Port for OOE Framework V2.0
* @data 2009-07-02
* @page http://www.phpclasses.org/browse/package/4751.html
*/
################################################################################
class ooeTagTemplate{

	/**
	* Concatena em uma string o array de parametrosa
	* @access
	* @input param array
	* @return string
	*/

   protected function array2string($param){
   $string=null;
 
   if($param!=null)
   {
     if(is_array($param))
     {
       foreach($param as $key=>$value)
       {
       $string.=" ".$key."=\"".$value."\"";
       }     
     }else{
     throw new Exception("".$param." => Nao eh array");
     }
     return $string;
   }
  }

	/**
	* Abre uma tag genérica
	* @access protected
	* @input args
	* @return tag object
	*/

   protected function openTag($tag,$param=null){
   return "<".$tag.$this->array2string($param).">";
   }

	/**
	* Fecha uma tag genérica
	* @access protected
	* @input args
	* @return tag object
	*/
	
   protected function closeTag($tag){
   return "</".$tag.">\r\n";
   }

	/**
	* Cria uma tag generica com conteudo <tag>content</tag>
	* @access public
	* @input args
	* @return tag object
	*/

   public function setTagContent($tagName,$tag,$content,$param=null){
   $this->_TAG[$tagName]=$this->openTag($tag,$param).$content.$this->closeTag($tag);
   } 

  /**
	* Cria uma tag generica simples <tag/>
	* @access public
	* @input args
	* @return tag object
	*/

   public function setTagSimple($tagName,$tag,$param=null){
   $this->_TAG[$tagName]="<".$tag.$this->array2string($param)."/>\r\n";
   } 

  /**
	* Recupera a tag criada
	* @access public
	* @input tagname
	* @return fomated tag
	*/
	
  public function getTag($tagName){
    if(array_key_exists($tagName, $this->_TAG))
    {
    echo $this->_TAG[$tagName];
    }
  }
    
	/**
	* Passa um array para o template ou para o plugin
	* @access public
	* @input args
	* @return array object
	*/

   public function setArray($arrayName,$arrayValue){
   $this->_ARRAY[$arrayName]=$arrayValue;
   } 
   
  /**
	* Recupera o array passado
	* @access public
	* @input arrayname
	* @return fomated tag
	*/
	
  public function getArray($arrayName){
    if(is_array($this->_ARRAY[$arrayName])){
    return $this->_ARRAY[$arrayName];
    }else{
    return false;
    }
 
  }   

// fim da classe
}
?>
Return current item: ooeLite