Ejemplo n.º 1
0
    /**
     * constructor
     * set up an Atom_Text instance
     *
     * @param string $tagName
     * @param string $text
     * @param array $attributes
     * @param boolean $cdata
     * @access public
     */
    public function __construct($tagName='', $text='', Array $attributes=array(), $cdata=0)
    {
        parent::__construct($tagName);
        $this->setAttributes($attributes);
        if(array_key_exists('type',$attributes))
        {
            $type=$attributes['type'];
            /*if($type!='text' && $type!='html' && $type!='xhtml')
            {
                throw new Atom_Exception('Invalid type');
            }*/
            if($text!=null && $text!='')
            {
                if($type=='text' || $type=='html')
                {
                    if(!$cdata)
                    {
                        $temp=$this->createTextNode($text);;
                        $this->documentElement->appendChild($temp);
                    }
                    else
                    {
                        $temp=$this->createCDATASection($text);
                        $this->documentElement->appendChild($temp);
                    }
                }
                if($type=='xhtml')
                {
                    $div=$this->createElement('div');
                    $this->documentElement->appendChild($div);
                    $div->setAttribute('xmlns','http://www.w3.org/1999/xhtml');

                    if(!$cdata)
                    {
                        $temp=$this->createTextNode($text);;
                        $div->appendChild($temp);
                    }
                    else
                    {
                        $temp=$this->createCDATASection($text);
                        $div->appendChild($temp);
                    }
                }
            }
        }
        elseif($text!=null && $text!='')
        {
            if(!$cdata)
            {
                $temp=$this->createTextNode($text);;
                $this->documentElement->appendChild($temp);
            }
            else
            {
                $temp=$this->createCDATASection($text);
                $this->documentElement->appendChild($temp);
            }
        }
    }
Ejemplo n.º 2
0
 /**
  * constuctor
  * set up an Atom_Feed instance
  *
  * @param array $attributes
  * @param boolean $cdata
  * @access public
  */
 public function __construct(Array $attributes=array(),$cdata=0)
 {
     parent::__construct('feed');
     if(!array_key_exists('xmlns',$attributes))
     {
         $this->documentElement->setAttribute('xmlns','http://www.w3.org/2005/Atom');
     }
     $this->setAttributes($attributes);
 }
Ejemplo n.º 3
0
 /**
  * constructor
  * set up Atom_Person intance
  *
  * @param string $tagName
  * @param string $name
  * @param string $email
  * @param string $uri
  * @param array $attributes
  * @access public
  */
 public function __construct($tagName='', $name='', $email='', $uri='', Array $attributes=array())
 {
     parent::__construct($tagName);
     $this->setAttributes($attributes);
     if($name!='' && $name!=null)
     {
         $this->setName($name);
     }
     if($email!='' && $email!=null)
     {
         $this->setEmail($email);
     }
     if($uri!='' && $uri!=null)
     {
         $this->setUri($uri);
     }
 }
Ejemplo n.º 4
0
 /**
  * constructor
  * set up an Atom_Date instance
  *
  * @param string $tagName
  * @param DateTime $date
  * @param array $attributes
  * @param boolean $cdata
  * @access public
  */
 public function __construct($tagName='', DateTime $date=null, Array $attributes=array(), $cdata=0)
 {
     parent::__construct($tagName);
     $this->setAttributes($attributes);
     if($date!=null && $date!='')
     {
         if(!$cdata)
         {
             $temp=$this->createTextNode($date->format(DateTime::ATOM));
             $this->documentElement->appendChild($temp);
         }
         else
         {
             $temp=$this->createCDATASection($date->format(DateTime::ATOM));
             $this->documentElement->appendChild($temp);
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * constructor
  * set up an Atom_Source instance
  *
  * @param array $attributes
  * @param boolean $cdata
  * @access public
  */
 public function __construct(Array $attributes=array(),$cdata=0)
 {
     parent::__construct('source');
     $this->setAttributes($attributes);
 }