2010年2月16日 星期二

CuHtmlGeneric

//


class CuHtmlGeneric
{
    function OnHTML()
    {
        
    }   
}



class CuHTMLString extends CuHtmlGeneric
{
    var $m_string;
    
    function CuHTMLString()
    {
        $this->m_string = "";
    }
    
    function OnAdd($str)
    {
        $this->m_string .= $str;
    }
    
    function OnHTML()
    {
        return $this->m_string;
    }
}

class CuWebControl extends CuHtmlGeneric
{
    var $Attribute;
    
    function CuWebControl()
    {
        $this->Attribute = array();
    }
    
    
    function __set($member, $val){
        $this->Attribute[$member] = $val;
    }
    
    function Set($member, $val)
    {
        $this->__set($member, $val);
    }
    
    function __get($member)
    {
        return $this->Attribute[$member];
    }
    
    function Get($member)
    {
        return $this->__get($member);
    }
    
    function Remove($member)
    {
        $Attribute = $this->Attribute[$member];
        unset($this->Attribute[$member]);
        return $Attribute;
    }
    
    function MakeAttribute()
    {
        foreach($this->Attribute as $key => $value)
        {
            if( $value != "" )
                $str = "$key=\"$value\" ";
            else
                $str = "$key ";
            
            $html .= $str;
        }
        
        return $html;
    }
    
    
    function OnHTML()
    {
        $html = "<" . $this->MakeAttribute() . ">";
        return $html;
    }
    
}

/************************************************
* 類別名稱: CuHTMLAnchor
* 類別說明: 將HTML 的 連結控制項 Tag <a>
************************************************/
class CuHTMLAnchor extends CuWebControl
{
    
    function CuHTMLAnchor()
    {
        //CuHTMLAnchor
    }
    
    function OnHTML()
    {
        
        $value = $this->Remove("value");
        
        $html = "<" . $this->MakeAttribute() . ">" . $value . "</a>";
        
        return $html;
    }
}

支援 CuPage 的相關類別, 控制項類別, 組合字串類別, 方便用來操做HTML組裝

沒有留言:

張貼留言