Ejemplo n.º 1
0
 /**
  * Build an XML document for this channel
  */
 private function build_document()
 {
     /* Build the channel and description properties*/
     $channel = new AnewtXMLDomElement('channel');
     foreach ($this->properties as $property => $property_spec) {
         list($tagname, $status, $type) = $property_spec;
         $element = AnewtRssChannel::_build_rss_element($this, $property, $tagname, $status, $type);
         if (is_null($element)) {
             continue;
         }
         $channel->append_child($element);
         unset($element);
     }
     /* Always add 'docs' element */
     $d = new AnewtXMLDomElement('docs');
     $d->append_child(new AnewtXMLDomText('http://www.rssboard.org/rss-specification'));
     $channel->append_child($d);
     /* Add an atom:link element. Only call the canonical_url() method if no
      * explicit url was provided. */
     $url = $this->_get('url');
     if (is_null($url)) {
         $url = AnewtRequest::canonical_url();
     }
     $channel->append_child(new AnewtXMLDomElement('atom:link', array('href' => $url, 'rel' => 'self', 'type' => $this->_get('content-type'))));
     /* Loop over items in the channel and append those */
     foreach ($this->items as $item) {
         $channel->append_child($item->_build_element());
     }
     /* Final output */
     $document = new AnewtXMLDomDocument();
     $document->set_content_type($this->_get('content-type'));
     $document->set_encoding($this->_get('encoding'));
     $rss = new AnewtXMLDomElement('rss', array('version' => '2.0', 'xmlns:atom' => 'http://www.w3.org/2005/Atom'));
     $rss->append_child($channel);
     $document->append_child($rss);
     return $document;
 }