Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: Joomla-Framework

Developer Network License

The Joomla! Developer Network content is © copyright 2006 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5
Source code for file /joomla/document/feed/renderer/rss.php

Documentation is available at rss.php

  1. <?php
  2. /**
  3.  * @version        $Id: rss.php 6472 2007-02-03 10:47:26Z pasamio $
  4.  * @package        Joomla.Framework
  5.  * @subpackage    Document
  6.  * @copyright    Copyright (C) 2005 - 2007 Open Source Matters. All rights reserved.
  7.  * @license        GNU/GPL, see LICENSE.php
  8.  *  Joomla! is free software. This version may have been modified pursuant
  9.  *  to the GNU General Public License, and as distributed it includes or
  10.  *  is derivative of works licensed under the GNU General Public License or
  11.  *  other free or open source software licenses.
  12.  *  See COPYRIGHT.php for copyright notices and details.
  13.  */
  14.  
  15. // Check to ensure this file is within the rest of the framework
  16. defined('JPATH_BASE'or die();
  17.  
  18. jimport'joomla.utilities.date' );
  19.  
  20.  /**
  21.  * JDocumentRenderer_RSS is a feed that implements RSS 2.0 Specification
  22.  *
  23.  * @author    Johan Janssens <[email protected]>
  24.  *
  25.  * @package     Joomla.Framework
  26.  * @subpackage        Document
  27.  * @see http://www.rssboard.org/rss-specification
  28.  * @since    1.5
  29.  */
  30.  
  31. {
  32.     /**
  33.      * Renderer mime type
  34.      *
  35.      * @var        string 
  36.      * @access    private
  37.      */
  38.     // var $_mime = "application/rss+xml";
  39.           var $_mime "text/xml";
  40.  
  41.  
  42.     /**
  43.      * Render the feed
  44.      *
  45.      * @access public
  46.      * @return    string 
  47.      */
  48.     function render()
  49.     {
  50.         $now    new JDate();
  51.         $data    =$this->_doc;
  52.  
  53.         $feed "<rss version=\"2.0\">\n";
  54.         $feed.= "    <channel>\n";
  55.         $feed.= "        <title>".$data->title."</title>\n";
  56.         $feed.= "        <description>".$data->description."</description>\n";
  57.         $feed.= "        <link>".$data->link."</link>\n";
  58.         $feed.= "        <lastBuildDate>".htmlspecialchars($now->toRFC822())."</lastBuildDate>\n";
  59.         $feed.= "        <generator>".$data->getGenerator()."</generator>\n";
  60.  
  61.         if ($data->image!=null)
  62.         {
  63.             $re.= "        <image>\n";
  64.             $feed.= "            <url>".$data->image->url."</url>\n";
  65.             $feed.= "            <title>".htmlspecialchars($data->image->title)."</title>\n";
  66.             $feed.= "            <link>".$data->image->link."</link>\n";
  67.             if ($data->image->width != ""{
  68.                 $feed.= "            <width>".$data->image->width."</width>\n";
  69.             }
  70.             if ($data->image->height!=""{
  71.                 $feed.= "            <height>".$data->image->height."</height>\n";
  72.             }
  73.             if ($data->image->description!=""{
  74.                 $feed.= "            <description><![CDATA[".$data->image->description."]]></description>\n";
  75.             }
  76.             $feed.= "        </image>\n";
  77.         }
  78.         if ($data->language!=""{
  79.             $feed.= "        <language>".$data->language."</language>\n";
  80.         }
  81.         if ($data->copyright!=""{
  82.             $feed.= "        <copyright>".htmlspecialchars($data->copyright)."</copyright>\n";
  83.         }
  84.         if ($data->editor!=""{
  85.             $feed.= "        <managingEditor>".htmlspecialchars($data->editor)."</managingEditor>\n";
  86.         }
  87.         if ($data->webmaster!=""{
  88.             $feed.= "        <webMaster>".htmlspecialchars($data->webmaster)."</webMaster>\n";
  89.         }
  90.         if ($data->pubDate!=""{
  91.             $pubDate new JDate($data->pubDate);
  92.             $feed.= "        <pubDate>".htmlspecialchars($pubDate->toRFC822())."</pubDate>\n";
  93.         }
  94.         if ($data->category!=""{
  95.             $feed.= "        <category>".htmlspecialchars($data->category)."</category>\n";
  96.         }
  97.         if ($data->docs!=""{
  98.             $feed.= "        <docs>".htmlspecialchars($data->docs)."</docs>\n";
  99.         }
  100.         if ($data->ttl!=""{
  101.             $feed.= "        <ttl>".htmlspecialchars($data->ttl)."</ttl>\n";
  102.         }
  103.         if ($data->rating!=""{
  104.             $feed.= "        <rating>".htmlspecialchars($data->rating)."</rating>\n";
  105.         }
  106.         if ($data->skipHours!=""{
  107.             $feed.= "        <skipHours>".htmlspecialchars($data->skipHours)."</skipHours>\n";
  108.         }
  109.         if ($data->skipDays!=""{
  110.             $feed.= "        <skipDays>".htmlspecialchars($data->skipDays)."</skipDays>\n";
  111.         }
  112.  
  113.         for ($i=0$i<count($data->items)$i++)
  114.         {
  115.             $feed.= "        <item>\n";
  116.             $feed.= "            <title>".htmlspecialchars(strip_tags($data->items[$i]->title))."</title>\n";
  117.             $feed.= "            <link>".htmlspecialchars($data->items[$i]->link)."</link>\n";
  118.             $feed.= "            <description><![CDATA[".$data->items[$i]->description."]]></description>\n";
  119.  
  120.             if ($data->items[$i]->author!=""{
  121.                 $feed.= "            <author>".htmlspecialchars($data->items[$i]->author)."</author>\n";
  122.             }
  123.             /*
  124.             // on hold
  125.             if ($data->items[$i]->source!="") {
  126.                     $data.= "            <source>".htmlspecialchars($data->items[$i]->source)."</source>\n";
  127.             }
  128.             */
  129.             if ($data->items[$i]->category!=""{
  130.                 $feed.= "            <category>".htmlspecialchars($data->items[$i]->category)."</category>\n";
  131.             }
  132.             if ($data->items[$i]->comments!=""{
  133.                 $feed.= "            <comments>".htmlspecialchars($data->items[$i]->comments)."</comments>\n";
  134.             }
  135.             if ($data->items[$i]->date!=""{
  136.             $itemDate new JDate($data->items[$i]->date);
  137.                 $feed.= "            <pubDate>".htmlspecialchars($itemDate->toRFC822())."</pubDate>\n";
  138.             }
  139.             if ($data->items[$i]->guid!=""{
  140.                 $feed.= "            <guid>".htmlspecialchars($data->items[$i]->guid)."</guid>\n";
  141.             }
  142.             if ($data->items[$i]->enclosure != NULL)
  143.             {
  144.                     $feed.= "            <enclosure url=\"";
  145.                     $feed.= $data->items[$i]->enclosure->url;
  146.                     $feed.= "\" length=\"";
  147.                     $feed.= $data->items[$i]->enclosure->length;
  148.                     $feed.= "\" type=\"";
  149.                     $feed.= $data->items[$i]->enclosure->type;
  150.                     $feed.= "\"/>\n";
  151.             }
  152.  
  153.             $feed.= "        </item>\n";
  154.         }
  155.         $feed.= "    </channel>\n";
  156.         $feed.= "</rss>\n";
  157.         return $feed;
  158.     }
  159. }
  160. ?>

Documentation generated on Mon, 05 Mar 2007 21:20:28 +0000 by phpDocumentor 1.3.1