Support Joomla!

Packages

Package: Joomla-Framework

License

Content on this site is copyright © 2005 - 2008 Open Source Matters Inc and can be used in accordance with the Joomla! Electronic Documentation License. Some parts of this website may be subject to other licenses.
Source code for file /joomla/document/feed/feed.php

Documentation is available at feed.php

  1. <?php
  2. /**
  3. @version        $Id: feed.php 10707 2008-08-21 09:52:47Z eddieajau $
  4. @package        Joomla.Framework
  5. @subpackage    Document
  6. @copyright    Copyright (C) 2005 - 2008 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. /**
  19.  * DocumentFeed class, provides an easy interface to parse and display any feed document
  20.  *
  21.  * @package        Joomla.Framework
  22.  * @subpackage    Document
  23.  * @since        1.5
  24.  */
  25.  
  26. class JDocumentFeed extends JDocument
  27. {
  28.     /**
  29.      * Syndication URL feed element
  30.      *
  31.      * optional
  32.      *
  33.      * @var        string 
  34.      * @access    public
  35.      */
  36.      var $syndicationURL = "";
  37.  
  38.      /**
  39.      * Image feed element
  40.      *
  41.      * optional
  42.      *
  43.      * @var        object 
  44.      * @access    public
  45.      */
  46.      var $image = null;
  47.  
  48.     /**
  49.      * Copyright feed elememnt
  50.      *
  51.      * optional
  52.      *
  53.      * @var        string 
  54.      * @access    public
  55.      */
  56.      var $copyright = "";
  57.  
  58.      /**
  59.      * Published date feed element
  60.      *
  61.      *  optional
  62.      *
  63.      * @var        string 
  64.      * @access    public
  65.      */
  66.      var $pubDate = "";
  67.  
  68.      /**
  69.      * Lastbuild date feed element
  70.      *
  71.      * optional
  72.      *
  73.      * @var        string 
  74.      * @access    public
  75.      */
  76.      var $lastBuildDate = "";
  77.  
  78.      /**
  79.      * Editor feed element
  80.      *
  81.      * optional
  82.      *
  83.      * @var        string 
  84.      * @access    public
  85.      */
  86.      var $editor = "";
  87.  
  88.     /**
  89.      * Docs feed element
  90.      *
  91.      * @var        string 
  92.      * @access    public
  93.      */
  94.      var $docs = "";
  95.  
  96.      /**
  97.      * Editor email feed element
  98.      *
  99.      * optional
  100.      *
  101.      * @var        string 
  102.      * @access    public
  103.      */
  104.      var $editorEmail = "";
  105.  
  106.     /**
  107.      * Webmaster email feed element
  108.      *
  109.      * optional
  110.      *
  111.      * @var        string 
  112.      * @access    public
  113.      */
  114.      var $webmaster = "";
  115.  
  116.     /**
  117.      * Category feed element
  118.      *
  119.      * optional
  120.      *
  121.      * @var        string 
  122.      * @access    public
  123.      */
  124.      var $category = "";
  125.  
  126.     /**
  127.      * TTL feed attribute
  128.      *
  129.      * optional
  130.      *
  131.      * @var        string 
  132.      * @access    public
  133.      */
  134.      var $ttl = "";
  135.  
  136.     /**
  137.      * Rating feed element
  138.      *
  139.      * optional
  140.      *
  141.      * @var        string 
  142.      * @access    public
  143.      */
  144.      var $rating = "";
  145.  
  146.     /**
  147.      * Skiphours feed element
  148.      *
  149.      * optional
  150.      *
  151.      * @var        string 
  152.      * @access    public
  153.      */
  154.      var $skipHours = "";
  155.  
  156.     /**
  157.      * Skipdays feed element
  158.      *
  159.      * optional
  160.      *
  161.      * @var        string 
  162.      * @access    public
  163.      */
  164.      var $skipDays = "";
  165.  
  166.     /**
  167.      * The feed items collection
  168.      *
  169.      * @var array 
  170.      * @access public
  171.      */
  172.     var $items = array();
  173.  
  174.     /**
  175.      * Class constructor
  176.      *
  177.      * @access protected
  178.      * @param    array    $options Associative array of options
  179.      */
  180.     function __construct($options array())
  181.     {
  182.         parent::__construct($options);
  183.  
  184.         //set document type
  185.         $this->_type 'feed';
  186.     }
  187.  
  188.     /**
  189.      * Render the document
  190.      *
  191.      * @access public
  192.      * @param boolean     $cache        If true, cache the output
  193.      * @param array        $params        Associative array of attributes
  194.      * @return     The rendered data
  195.      */
  196.     function render$cache false$params array())
  197.     {
  198.         global $option;
  199.  
  200.         // Get the feed type
  201.         $type JRequest::getCmd('type''rss');
  202.  
  203.         /*
  204.          * Cache TODO In later release
  205.          */
  206.         $cache        0;
  207.         $cache_time 3600;
  208.         $cache_path JPATH_BASE.DS.'cache';
  209.  
  210.         // set filename for rss feeds
  211.         $file strtolowerstr_replace'.'''$type ) );
  212.         $file $cache_path.DS.$file.'_'.$option.'.xml';
  213.  
  214.  
  215.         // Instantiate feed renderer and set the mime encoding
  216.         $renderer =$this->loadRenderer(($type$type 'rss');
  217.         if (!is_a($renderer'JDocumentRenderer')) {
  218.             JError::raiseError(404JText::_('Resource Not Found'));
  219.         }
  220.         $this->setMimeEncoding($renderer->getContentType());
  221.  
  222.         //output
  223.         // Generate prolog
  224.         $data    "<?xml version=\"1.0\" encoding=\"".$this->_charset."\"?>\n";
  225.         $data    .= "<!-- generator=\"".$this->getGenerator()."\" -->\n";
  226.  
  227.          // Generate stylesheet links
  228.         foreach ($this->_styleSheets as $src => $attr {
  229.             $data .= "<?xml-stylesheet href=\"$src\" type=\"".$attr['mime']."\"?>\n";
  230.         }
  231.  
  232.         // Render the feed
  233.         $data .= $renderer->render();
  234.  
  235.         parent::render();
  236.         return $data;
  237.     }
  238.  
  239.     /**
  240.      * Adds an JFeedItem to the feed.
  241.      *
  242.      * @param object JFeedItem $item The feeditem to add to the feed.
  243.      * @access public
  244.      */
  245.     function addItem&$item )
  246.     {
  247.         $item->source $this->link;
  248.         $this->items[$item;
  249.     }
  250. }
  251.  
  252. /**
  253.  * JFeedItem is an internal class that stores feed item information
  254.  *
  255.  * @package     Joomla.Framework
  256.  * @subpackage        Document
  257.  * @since    1.5
  258.  */
  259. class JFeedItem extends JObject
  260. {
  261.     /**
  262.      * Title item element
  263.      *
  264.      * required
  265.      *
  266.      * @var        string 
  267.      * @access    public
  268.      */
  269.     var $title;
  270.  
  271.     /**
  272.      * Link item element
  273.      *
  274.      * required
  275.      *
  276.      * @var        string 
  277.      * @access    public
  278.      */
  279.     var $link;
  280.  
  281.     /**
  282.      * Description item element
  283.      *
  284.      * required
  285.      *
  286.      * @var        string 
  287.      * @access    public
  288.      */
  289.      var $description;
  290.  
  291.     /**
  292.      * Author item element
  293.      *
  294.      * optional
  295.      *
  296.      * @var        string 
  297.      * @access    public
  298.      */
  299.      var $author;
  300.  
  301.      /**
  302.      * Author email element
  303.      *
  304.      * optional
  305.      *
  306.      * @var        string 
  307.      * @access    public
  308.      */
  309.      var $authorEmail;
  310.  
  311.  
  312.     /**
  313.      * Category element
  314.      *
  315.      * optional
  316.      *
  317.      * @var        string 
  318.      * @access    public
  319.      */
  320.      var $category;
  321.  
  322.      /**
  323.      * Comments element
  324.      *
  325.      * optional
  326.      *
  327.      * @var        string 
  328.      * @access    public
  329.      */
  330.      var $comments;
  331.  
  332.      /**
  333.      * Enclosure element
  334.      *
  335.      * @var        object 
  336.      * @access    public
  337.      */
  338.      var $enclosure =  null;
  339.  
  340.      /**
  341.      * Guid element
  342.      *
  343.      * optional
  344.      *
  345.      * @var        string 
  346.      * @access    public
  347.      */
  348.      var $guid;
  349.  
  350.     /**
  351.      * Published date
  352.      *
  353.      * optional
  354.      *
  355.      *  May be in one of the following formats:
  356.      *
  357.      *    RFC 822:
  358.      *    "Mon, 20 Jan 03 18:05:41 +0400"
  359.      *    "20 Jan 03 18:05:41 +0000"
  360.      *
  361.      *    ISO 8601:
  362.      *    "2003-01-20T18:05:41+04:00"
  363.      *
  364.      *    Unix:
  365.      *    1043082341
  366.      *
  367.      * @var        string 
  368.      * @access    public
  369.      */
  370.      var $pubDate;
  371.  
  372.      /**
  373.      * Source element
  374.      *
  375.      * optional
  376.      *
  377.      * @var        string 
  378.      * @access    public
  379.      */
  380.      var $source;
  381.  
  382.  
  383.      /**
  384.      * Set the JFeedEnclosure for this item
  385.      *
  386.      * @access public
  387.      * @param object $enclosure The JFeedItem to add to the feed.
  388.      */
  389.      function setEnclosure($enclosure)    {
  390.          $this->enclosure = $enclosure;
  391.      }
  392. }
  393.  
  394. /**
  395.  * JFeedEnclosure is an internal class that stores feed enclosure information
  396.  *
  397.  * @package     Joomla.Framework
  398.  * @subpackage        Document
  399.  * @since    1.5
  400.  */
  401. class JFeedEnclosure extends JObject
  402. {
  403.     /**
  404.      * URL enclosure element
  405.      *
  406.      * required
  407.      *
  408.      * @var        string 
  409.      * @access    public
  410.      */
  411.      var $url = "";
  412.  
  413.     /**
  414.      * Lenght enclosure element
  415.      *
  416.      * required
  417.      *
  418.      * @var        string 
  419.      * @access    public
  420.      */
  421.      var $length = "";
  422.  
  423.      /**
  424.      * Type enclosure element
  425.      *
  426.      * required
  427.      *
  428.      * @var        string 
  429.      * @access    public
  430.      */
  431.      var $type = "";
  432. }
  433.  
  434. /**
  435.  * JFeedImage is an internal class that stores feed image information
  436.  *
  437.  * @package     Joomla.Framework
  438.  * @subpackage        Document
  439.  * @since    1.5
  440.  */
  441. class JFeedImage extends JObject
  442. {
  443.     /**
  444.      * Title image attribute
  445.      *
  446.      * required
  447.      *
  448.      * @var        string 
  449.      * @access    public
  450.      */
  451.      var $title = "";
  452.  
  453.      /**
  454.      * URL image attribute
  455.      *
  456.      * required
  457.      *
  458.      * @var        string 
  459.      * @access    public
  460.      */
  461.     var $url = "";
  462.  
  463.     /**
  464.      * Link image attribute
  465.      *
  466.      * required
  467.      *
  468.      * @var        string 
  469.      * @access    public
  470.      */
  471.      var $link = "";
  472.  
  473.      /**
  474.      * witdh image attribute
  475.      *
  476.      * optional
  477.      *
  478.      * @var        string 
  479.      * @access    public
  480.      */
  481.      var $width;
  482.  
  483.      /**
  484.      * Title feed attribute
  485.      *
  486.      * optional
  487.      *
  488.      * @var        string 
  489.      * @access    public
  490.      */
  491.      var $height;
  492.  
  493.      /**
  494.      * Title feed attribute
  495.      *
  496.      * optional
  497.      *
  498.      * @var        string 
  499.      * @access    public
  500.      */
  501.      var $description;
  502. }

Documentation generated on Sat, 14 Nov 2009 11:12:43 +0000 by phpDocumentor 1.3.1