Source for file jResponseRss20.class.php

Documentation is available at jResponseRss20.class.php

  1. <?php
  2. /**
  3. @package     jelix
  4. @subpackage  core_response
  5. @author      Loic Mathaud
  6. @author      Yannick Le Guédart
  7. @contributor Laurent Jouanneau
  8. @copyright   2005-2006 Loic Mathaud
  9. @copyright   2006 Yannick Le Guédart
  10. @copyright   2006-2010 Laurent Jouanneau
  11. @link        http://www.jelix.org
  12. @licence     GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
  13. */
  14.  
  15. /**
  16. *
  17. */
  18. require_once(JELIX_LIB_PATH.'tpl/jTpl.class.php');
  19. require_once(JELIX_LIB_CORE_PATH.'response/jResponseXmlFeed.class.php');
  20.  
  21. /**
  22. * Rss2.0 response
  23. @package  jelix
  24. @subpackage core_response
  25. @link http://blogs.law.harvard.edu/tech/rss
  26. @link http://www.stervinou.com/projets/rss/
  27. @since 1.0b1
  28. */
  29. class jResponseRss20 extends jResponseXMLFeed {
  30.     protected $_type = 'rss2.0';
  31.  
  32.     /**
  33.      * Class constructor
  34.      */
  35.     function __construct ({
  36.         $this->_template     new jTpl();
  37.         $this->_mainTpl     'jelix~rss20';
  38.  
  39.         $this->infos = new jRSS20Info ();
  40.  
  41.         parent::__construct ();
  42.         $this->infos->language $this->lang;
  43.     }
  44.  
  45.     /**
  46.      * Generate the content and send it.
  47.      * @return boolean true if generation is ok, else false
  48.      */
  49.     final public function output (){
  50.  
  51.         $this->_httpHeaders['Content-Type'=
  52.                 'application/xml;charset=' $this->charset;
  53.  
  54.         // let's generate the content
  55.         $this->_template->assign ('rss'$this->infos);
  56.         $this->_template->assign ('items'$this->itemList);
  57.         $content $this->_template->fetch ($this->_mainTpl);
  58.  
  59.         // no errors, we can send it
  60.         $this->sendHttpHeaders ();
  61.         echo '<?xml version="1.0" encoding="'$this->charset .'"?>'"\n";
  62.         $this->_outputXmlHeader ();
  63.         echo $content;
  64.         return true;
  65.     }
  66.  
  67.     /**
  68.      * create a new item
  69.      * @param string $title the item title
  70.      * @param string $link  the link
  71.      * @param string $date  the date of the item
  72.      * @return jXMLFeedItem 
  73.      */
  74.     public function createItem($title,$link$date){
  75.         $item new jRSSItem();
  76.         $item->title $title;
  77.         $item->id $item->link $link;
  78.         $item->published $date;
  79.         return $item;
  80.     }
  81. }
  82.  
  83. /**
  84.  * meta data of the channel
  85.  * @package    jelix
  86.  * @subpackage core_response
  87.  * @since 1.0b1
  88.  */
  89. class jRSS20Info extends jXMLFeedInfo{
  90.     /**
  91.      * lang of the channel
  92.      * @var string 
  93.      */
  94.     public $language;
  95.     /**
  96.      * email of the content manager
  97.      * @var string 
  98.      */
  99.     public $managingEditor;
  100.     /**
  101.      * email of technical responsible
  102.      * @var string 
  103.      */
  104.     public $webMaster;
  105.     /**
  106.      * publication date
  107.      * format:  yyyy-mm-dd hh:mm:ss
  108.      * @var string 
  109.      */
  110.     public $published;
  111.     /**
  112.      * specification url
  113.      * example : http://blogs.law.harvard.edu/tech/rss
  114.      * @var string 
  115.      */
  116.     public $docs='';
  117.     /**
  118.      * not implemented
  119.      * @var string 
  120.      */
  121.     public $cloud// indicates a webservice from which the user can register to the server
  122.                   // to be aware of modifications
  123.                   //=array('domain'=>'','path'=>'','port'=>'','registerProcedure'=>'', 'protocol'=>'');
  124.     /**
  125.      * time to live of the cache, in minutes
  126.      * @var string 
  127.      */
  128.     public $ttl;
  129.     /**
  130.      * image title
  131.      * @var string 
  132.      */
  133.     public $imageTitle;
  134.     /**
  135.      * web site url corresponding to the image
  136.      * @var string 
  137.      */
  138.     public $imageLink;
  139.     /**
  140.      * width of the image
  141.      * @var string 
  142.      */
  143.     public $imageWidth;
  144.     /**
  145.      * height of the image
  146.      * @var string 
  147.      */
  148.     public $imageHeight;
  149.     /**
  150.      * Description of the image (= title attribute for the img tag)
  151.      * @var string 
  152.      */
  153.     public $imageDescription;
  154.  
  155.     /**
  156.      * Pics rate for this channel
  157.      * @var string 
  158.      */
  159.     public $rating;
  160.     /**
  161.      * field form for the channel
  162.      * it is an array('title'=>'','description'=>'','name'=>'','link'=>'')
  163.      * @var array 
  164.      */
  165.     public $textInput;
  166.     /**
  167.      * list of hours that agregator should ignore
  168.      * ex (10, 21)
  169.      * @var array 
  170.      */
  171.     public $skipHours;
  172.     /**
  173.      * list of day that agregator should ignore
  174.      * ex ('monday', 'tuesday')
  175.      * @var array 
  176.      */
  177.     public $skipDays;
  178.  
  179.     function __construct ({
  180.             $this->_mandatory = array 'title''webSiteUrl''description');
  181.     }
  182. }
  183.  
  184. /**
  185.  * content of an item in a syndication channel
  186.  * @package    jelix
  187.  * @subpackage core_response
  188.  * @since 1.0b1
  189.  */
  190. class jRSSItem extends jXMLFeedItem {
  191.  
  192.     /**
  193.      * comments url
  194.      * @var string 
  195.      */
  196.     public $comments;
  197.     /**
  198.      * media description, attached to the item
  199.      * the array should contain this keys :  'url', 'size', 'mimetype'
  200.      * @var array 
  201.      */
  202.     public $enclosure;
  203.     /**
  204.      * says if the id is a permanent link
  205.      * @var boolean 
  206.      */
  207.     public $idIsPermalink;
  208.     /**
  209.      * url of  rss channel of the information source
  210.      * @var string 
  211.      */
  212.     public $sourceUrl;
  213.     /**
  214.      * Title of the information source
  215.      * @var string 
  216.      */
  217.     public $sourceTitle;
  218. }

Documentation generated on Wed, 24 Sep 2014 22:01:37 +0200 by phpDocumentor 1.4.3