Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: Joomla-Framework

License

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

Documentation generated on Tue, 29 Jan 2008 18:45:44 +0000 by phpDocumentor 1.3.1