Exemplo n.º 1
0
 public function generate()
 {
     $output = new Ra_StringBuilder();
     $output->appendln('<?xml version="1.0" encoding="' . $this->data->encoding . '" ?>');
     $output->appendln('<rss version="2.0">');
     $output->increase_indent();
     $output->appendln('<channel>');
     $output->increase_indent();
     $output->appendln("<title>{$this->data->title}</title>");
     $output->appendln("<link>{$this->data->website}</link>");
     $output->appendln("<description>{$this->data->description}</description>");
     if ($this->data->language) {
         $output->appendln("<language>{$this->data->language}</language>");
     }
     if ($this->data->copyright) {
         $output->appendln("<copyright>{$this->data->copyright}</copyright>");
     }
     if ($this->data->last_change) {
         $output->appendln("<lastBuildDate>{$this->data->last_change}</lastBuildDate>");
     }
     if ($this->data->generator) {
         $output->appendln("<generator>{$this->data->generator}</generator>");
     }
     foreach ($this->data->get_entries() as $entry) {
         $output->appendln('<item>');
         $output->increase_indent();
         if ($entry->title) {
             $output->appendln("<title>{$entry->title}</title>");
         }
         if ($entry->permalink) {
             $output->appendln("<link>{$entry->permalink}</link>");
         }
         if ($entry->author) {
             $output->appendln("<author>{$entry->author}</author>");
         }
         if ($entry->content) {
             $output->appendln("<description><![CDATA[{$entry->content}]]></description>");
         }
         if ($entry->updated) {
             $output->appendln("<pubDate>" . $this->convert_date($entry->updated) . "</pubDate>");
         }
         $output->decrease_indent();
         $output->appendln('</item>');
     }
     $output->decrease_indent();
     $output->appendln('</channel>');
     $output->decrease_indent();
     $output->appendln('</rss>');
     return $output->get_data();
 }
Exemplo n.º 2
0
 public function generate()
 {
     $output = new Ra_StringBuilder();
     $output->appendln('<?xml version="1.0" encoding="' . $this->data->encoding . '" ?>');
     $output->appendln('<feed xmlns="http://www.w3.org/2005/Atom">');
     $output->increase_indent();
     $output->appendln("<id>{$this->data->website}</id>");
     $output->appendln("<title>{$this->data->title}</title>");
     $output->appendln("<updated>{$this->data->last_change}</updated>");
     if ($this->data->description) {
         $output->appendln("<subtitle>{$this->data->description}</subtitle>");
     }
     if ($this->data->copyright) {
         $output->appendln("<rights>{$this->data->copyright}</rights>");
     }
     if ($this->data->generator) {
         $output->appendln("<generator>{$this->data->generator}</generator>");
     }
     foreach ($this->data->get_entries() as $entry) {
         $output->appendln('<entry>');
         $output->increase_indent();
         $output->appendln("<id>{$entry->permalink}</id>");
         $output->appendln("<title>{$entry->title}</title>");
         $output->appendln("<updated>{$entry->updated}</updated>");
         if ($entry->author) {
             $output->appendln("<author>{$entry->author}</author>");
         }
         if ($entry->content) {
             $output->appendln("<content type=\"xhtml\"><div xmlns=\"http://www.w3.org/1999/xhtml\">{$entry->content}</div></content>");
         }
         $output->decrease_indent();
         $output->appendln('</entry>');
     }
     $output->decrease_indent();
     $output->appendln('</feed>');
     return $output->get_data();
 }