Source for file rss.class.php

Documentation is available at rss.class.php

  1. <?php
  2. /**
  3.  * TPLN Rss Plugin
  4.  * @package Template Engine
  5.  */
  6. class Rss extends Image
  7. {
  8. /**
  9. * This method allows to create a Rss 2.0 feeds
  10. *
  11. @param array $rss 
  12. @param array $items 
  13. @param string $charset 
  14. @param bool $write 
  15. @return string $xml
  16. @since 2.9.2
  17. @author H2LSOFT */
  18. public function rssWrite($rss$items$charset='iso-8859-1'$write true)
  19. {
  20.     if(empty($charset))$charset 'iso-8859-1';
  21.  
  22.     @header("content-type: application/xml");
  23.     $rss['description'str_replace(array("&","<",">")array('&amp;'"&lt;""&gt;")$rss['description']);
  24.  
  25.     $xml '<?xml version="1.0" encoding="'.$charset.'"?>'."\n";
  26.     $xml .= '<rss version="2.0">'."\n";
  27.     $xml .= '<channel>'."\n";
  28.     $xml .= '<title>'.$rss['title'].'</title>'."\n";
  29.     $xml .= '<link>'.$rss['link'].'</link>'."\n";
  30.     $xml .= '<description>'.$rss['description'].'</description>'."\n";
  31.     $xml .= '<copyright>'.$rss['copyright'].'</copyright>'."\n";
  32.     $xml .= '<generator>'.'TPLN Php Template v'.TPLN_VERSION.'</generator>'."\n";
  33.  
  34.     // image
  35.     $xml .= '        <image>'."\n";
  36.     $xml .= '            <title>'.$rss['title'].'</title>'."\n";
  37.     $xml .= '            <url>'.$rss['image_url'].'</url>'."\n";
  38.     $xml .= '            <link>'.$rss['link'].'</link>'."\n";
  39.     $xml .= '        </image>'."\n";
  40.  
  41.     // items
  42.     foreach($items as $item)
  43.     {
  44.             $item['description'str_replace(array("&","<",">")array('&amp;'"&lt;""&gt;")$item['description']);
  45.             $xml .= '        <item>'."\n";
  46.             $xml .= '            <title>'.$item['title'].'</title>'."\n";
  47.             $xml .= '            <link>'.$item['link'].'</link>'."\n";
  48.             $xml .= '            <pubDate>'.$item['pubDate'].'</pubDate>'."\n";
  49.             $xml .= '            <description>'.$item['description'].'</description>'."\n";
  50.             $xml .= '        </item>'."\n";
  51.     }
  52.  
  53.     $xml .= '    </channel>'."\n";
  54.     $xml .= '</rss>'."\n";
  55.  
  56.     // exit or not ?
  57.     if($write)
  58.         echo $xml;
  59.     else
  60.         return $xml;
  61. }
  62.         
  63. }
  64.  
  65.  
  66. ?>

Documentation generated on Sat, 06 Mar 2010 21:34:00 +0100 by phpDocumentor 1.4.3