Exemple #1
0
 protected function generateRSS()
 {
     $this->generateContent();
     $root = new SimpleXML('<rss />');
     $root->addAttribute('version', '2.0');
     $channel = $root->addChild('channel');
     $channel->addChild('title', CFG_NAME_SHORT . ' - ' . $this->name);
     $channel->addChild('link', HOST_URL . '/?' . $this->page . ($this->category ? '=' . $this->category[0] : null));
     $channel->addChild('description', CFG_NAME);
     $channel->addChild('language', implode('-', str_split(User::$localeString, 2)));
     $channel->addChild('ttl', CFG_TTL_RSS);
     $channel->addChild('lastBuildDate', date(DATE_RSS));
     foreach ($this->feedData as $row) {
         $item = $channel->addChild('item');
         foreach ($row as $key => list($isCData, $attrib, $text)) {
             if ($isCData && $text) {
                 $child = $item->addChild($key)->addCData($text);
             } else {
                 $child = $item->addChild($key, $text);
             }
             foreach ($attrib as $k => $v) {
                 $child->addAttribute($k, $v);
             }
         }
     }
     return $root->asXML();
 }