示例#1
0
 /**
  * 
  * @param XMLManager $xml
  * @param array $contributor
  * 
  * @return \DOMNode
  */
 private function createContributor(XMLManager $xml, array $contributor)
 {
     $contributorNode = $xml->getXml()->createElement('contributor');
     if (isset($author['name'])) {
         $xml->addTextNode('name', $contributor['name'], $authorNode);
     }
     if (isset($author['website'])) {
         $xml->addTextNode('uri', $contributor['website'], $authorNode);
     }
     if (isset($author['email'])) {
         $xml->addTextNode('email', $contributor['email'], $authorNode);
     }
     return $contributorNode;
 }
示例#2
0
 /**
  * Build the feed properties
  *
  * @param \Nekland\FeedBundle\XML\XMLManager $xml
  * @param \Nekland\FeedBundle\Feed $feed
  * @return void
  */
 private function init(XMLManager $xml, Feed $feed)
 {
     $root = $xml->getXml()->createElement('rss');
     $root->setAttribute('version', '2.0');
     $root = $xml->getXml()->appendChild($root);
     $channel = $xml->getXml()->createElement('channel');
     $channel = $root->appendChild($channel);
     $xml->addTextNode('description', $feed->get('description'), $channel);
     $xml->addTextNode('pubDate', $feed->get('pubDate', new \DateTime())->format(\DateTime::RSS), $channel);
     $date = new \DateTime();
     $xml->addTextNode('lastBuildDate', $date->format(\DateTime::RSS), $channel);
     $xml->addTextNode('link', $feed->get('link'), $channel);
     $xml->addTextNode('title', $feed->get('title'), $channel);
     $xml->addTextNode('language', $feed->get('language'), $channel);
     if (null !== $feed->get('copyright')) {
         $xml->addTextNode('copyright', $feed->get('copyright'), $channel);
     }
     if (null !== $feed->get('managingEditor')) {
         $xml->addTextNode('managingEditor', $feed->get('managingEditor'), $channel);
     }
     if (null !== $feed->get('generator')) {
         $xml->addTextNode('generator', $feed->get('generator'), $channel);
     }
     if (null !== $feed->get('webMaster')) {
         $xml->addTextNode('webMaster', $feed->get('webMaster'), $channel);
     }
     $image = $feed->get('image', array());
     if (isset($image['url']) && isset($image['title']) && isset($image['link'])) {
         $imageNode = $xml->getXml()->createElement('image');
         $imageNode = $channel->appendChild($imageNode);
         $xml->addTextNode('url', $image['url'], $imageNode);
         $xml->addTextNode('title', $image['url'], $imageNode);
         $xml->addTextNode('link', $image['url'], $imageNode);
         if (isset($image['height'])) {
             $xml->addTextNode('height', $image['height'], $imageNode);
         }
         if (isset($image['width'])) {
             $xml->addTextNode('width', $image['width'], $imageNode);
         }
     }
     if (null !== $feed->get('ttl')) {
         $xml->addTextNode('ttl', $feed->get('ttl'), $channel);
     }
 }