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/feed.php

Documentation is available at feed.php

  1. <?php
  2. /**
  3. @version        $Id: feed.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. /**
  19.  * DocumentFeed class, provides an easy interface to parse and display any feed document
  20.  *
  21.  * @author        Johan Janssens <[email protected]>
  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 $mainframe$option;
  200.  
  201.         $format        = isset($params['format']$params['format''RSS';
  202.         $cache        0;
  203.         $cache_time 3600;
  204.         $cache_path JPATH_BASE.DS.'cache';
  205.  
  206.         // set filename for rss feeds
  207.         $file strtolowerstr_replace'.'''$format ) );
  208.         $file $cache_path.'/'$file .'_'$option .'.xml';
  209.  
  210.         $renderer $this->loadRenderer($format);
  211.         $this->setMimeEncoding($renderer->getContentType());
  212.  
  213.         //output
  214.         // Generate prolog
  215.         $data    "<?xml version=\"1.0\" encoding=\"".$this->_charset."\"?>\n";
  216.         $data    .= "<!-- generator=\"".$this->getGenerator()."\" -->\n";
  217.  
  218.          // Generate stylesheet links
  219.         foreach ($this->_styleSheets as $src => $attr {
  220.             $data .= "<?xml-stylesheet href=\"$src\" type=\"".$attr['mime']."\"?>\n";
  221.         }
  222.  
  223.         // Render the feed
  224.         $data .= $renderer->render();
  225.  
  226.         parent::render();
  227.         return $data;
  228.     }
  229.  
  230.     /**
  231.      * Adds an JFeedItem to the feed.
  232.      *
  233.      * @param object JFeedItem $item The feeditem to add to the feed.
  234.      * @access public
  235.      */
  236.     function addItem&$item )
  237.     {
  238.         $item->source $this->link;
  239.         $this->items[$item;
  240.     }
  241. }
  242.  
  243. /**
  244.  * JFeedItem is an internal class that stores feed item information
  245.  *
  246.  * @author        Johan Janssens <[email protected]>
  247.  * @package     Joomla.Framework
  248.  * @subpackage        Document
  249.  * @since    1.5
  250.  */
  251. class JFeedItem extends JObject
  252. {
  253.     /**
  254.      * Title item element
  255.      *
  256.      * required
  257.      *
  258.      * @var        string 
  259.      * @access    public
  260.      */
  261.     var $title;
  262.  
  263.     /**
  264.      * Link item element
  265.      *
  266.      * required
  267.      *
  268.      * @var        string 
  269.      * @access    public
  270.      */
  271.     var $link;
  272.  
  273.     /**
  274.      * Description item element
  275.      *
  276.      * required
  277.      *
  278.      * @var        string 
  279.      * @access    public
  280.      */
  281.      var $description;
  282.  
  283.     /**
  284.      * Author item element
  285.      *
  286.      * optional
  287.      *
  288.      * @var        string 
  289.      * @access    public
  290.      */
  291.      var $author;
  292.  
  293.      /**
  294.      * Author email element
  295.      *
  296.      * optional
  297.      *
  298.      * @var        string 
  299.      * @access    public
  300.      */
  301.      var $authorEmail;
  302.  
  303.  
  304.     /**
  305.      * Category element
  306.      *
  307.      * optional
  308.      *
  309.      * @var        string 
  310.      * @access    public
  311.      */
  312.      var $category;
  313.  
  314.      /**
  315.      * Comments element
  316.      *
  317.      * optional
  318.      *
  319.      * @var        string 
  320.      * @access    public
  321.      */
  322.      var $comments;
  323.  
  324.      /**
  325.      * Enclosure element
  326.      *
  327.      * @var        object 
  328.      * @access    public
  329.      */
  330.      var $enclosure =  null;
  331.  
  332.      /**
  333.      * Guid element
  334.      *
  335.      * optional
  336.      *
  337.      * @var        string 
  338.      * @access    public
  339.      */
  340.      var $guid;
  341.  
  342.     /**
  343.      * Published date
  344.      *
  345.      * optional
  346.      *
  347.      *  May be in one of the following formats:
  348.      *
  349.      *    RFC 822:
  350.      *    "Mon, 20 Jan 03 18:05:41 +0400"
  351.      *    "20 Jan 03 18:05:41 +0000"
  352.      *
  353.      *    ISO 8601:
  354.      *    "2003-01-20T18:05:41+04:00"
  355.      *
  356.      *    Unix:
  357.      *    1043082341
  358.      *
  359.      * @var        string 
  360.      * @access    public
  361.      */
  362.      var $pubDate;
  363.  
  364.      /**
  365.      * Source element
  366.      *
  367.      * optional
  368.      *
  369.      * @var        string 
  370.      * @access    public
  371.      */
  372.      var $source;
  373.  
  374.  
  375.      /**
  376.      * Set the JFeedEnclosure for this item
  377.      *
  378.      * @access public
  379.      * @param object $enclosure The JFeedItem to add to the feed.
  380.      */
  381.      function setEnclosure($enclosure)    {
  382.          $this->enclosure = $enclosure;
  383.      }
  384. }
  385.  
  386. /**
  387.  * JFeedEnclosure is an internal class that stores feed enclosure information
  388.  *
  389.  * @author        Johan Janssens <[email protected]>
  390.  * @package     Joomla.Framework
  391.  * @subpackage        Document
  392.  * @since    1.5
  393.  */
  394. class JFeedEnclosure extends JObject
  395. {
  396.     /**
  397.      * URL enclosure element
  398.      *
  399.      * required
  400.      *
  401.      * @var        string 
  402.      * @access    public
  403.      */
  404.      var $url = "";
  405.  
  406.     /**
  407.      * Lenght enclosure element
  408.      *
  409.      * required
  410.      *
  411.      * @var        string 
  412.      * @access    public
  413.      */
  414.      var $length = "";
  415.  
  416.      /**
  417.      * Type enclosure element
  418.      *
  419.      * required
  420.      *
  421.      * @var        string 
  422.      * @access    public
  423.      */
  424.      var $type = "";
  425. }
  426.  
  427. /**
  428.  * JFeedImage is an internal class that stores feed image information
  429.  *
  430.  * @author        Johan Janssens <[email protected]>
  431.  * @package     Joomla.Framework
  432.  * @subpackage        Document
  433.  * @since    1.5
  434.  */
  435. class JFeedImage extends JObject
  436. {
  437.     /**
  438.      * Title image attribute
  439.      *
  440.      * required
  441.      *
  442.      * @var        string 
  443.      * @access    public
  444.      */
  445.      var $title = "";
  446.  
  447.      /**
  448.      * URL image attribute
  449.      *
  450.      * required
  451.      *
  452.      * @var        string 
  453.      * @access    public
  454.      */
  455.     var $url = "";
  456.  
  457.     /**
  458.      * Link image attribute
  459.      *
  460.      * required
  461.      *
  462.      * @var        string 
  463.      * @access    public
  464.      */
  465.      var $link = "";
  466.  
  467.      /**
  468.      * witdh image attribute
  469.      *
  470.      * optional
  471.      *
  472.      * @var        string 
  473.      * @access    public
  474.      */
  475.      var $width;
  476.  
  477.      /**
  478.      * Title feed attribute
  479.      *
  480.      * optional
  481.      *
  482.      * @var        string 
  483.      * @access    public
  484.      */
  485.      var $height;
  486.  
  487.      /**
  488.      * Title feed attribute
  489.      *
  490.      * optional
  491.      *
  492.      * @var        string 
  493.      * @access    public
  494.      */
  495.      var $description;
  496. }
  497. ?>

Documentation generated on Mon, 05 Mar 2007 20:58:10 +0000 by phpDocumentor 1.3.1