Alpha Framework alpha--util--feeds
[ class tree: alpha--util--feeds ] [ index: alpha--util--feeds ] [ all elements ]

Source for file RSS.inc

Documentation is available at RSS.inc

  1. <?php
  2.  
  3. require_once $config->get('sysRoot').'alpha/util/feeds/AlphaFeed.inc';
  4.  
  5. /**
  6.  * RSS 1.0 class for synication
  7.  * 
  8.  * @package alpha::util::feeds
  9.  * @since 1.0
  10.  * @author John Collins <dev@alphaframework.org>
  11.  * @version $Id: RSS.inc 1341 2011-03-17 15:02:02Z johnc $
  12.  * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
  13.  * @copyright Copyright (c) 2011, John Collins (founder of Alpha Framework).
  14.  *  All rights reserved.
  15.  * 
  16.  *  <pre>
  17.  *  Redistribution and use in source and binary forms, with or
  18.  *  without modification, are permitted provided that the
  19.  *  following conditions are met:
  20.  * 
  21.  *  * Redistributions of source code must retain the above
  22.  *    copyright notice, this list of conditions and the
  23.  *    following disclaimer.
  24.  *  * Redistributions in binary form must reproduce the above
  25.  *    copyright notice, this list of conditions and the
  26.  *    following disclaimer in the documentation and/or other
  27.  *    materials provided with the distribution.
  28.  *  * Neither the name of the Alpha Framework nor the names
  29.  *    of its contributors may be used to endorse or promote
  30.  *    products derived from this software without specific
  31.  *    prior written permission.
  32.  *   
  33.  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  34.  *  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  35.  *  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  36.  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  37.  *  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  38.  *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  39.  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  40.  *  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  41.  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  42.  *  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  43.  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  44.  *  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  45.  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  46.  *  </pre>
  47.  *  
  48.  */
  49. class RSS extends AlphaFeed {
  50.     /**
  51.      * The XML namespace
  52.      * 
  53.      * @var string 
  54.      * @since 1.0
  55.      */
  56.     protected $nameSpace = 'http://purl.org/rss/1.0/';
  57.     
  58.     /**
  59.      * The RDF namespace
  60.      * 
  61.      * @var string 
  62.      * @since 1.0
  63.      */
  64.     private $rdfns 'http://www.w3.org/1999/02/22-rdf-syntax-ns#';
  65.     
  66.     /**
  67.      * The actual root tag used in each feed type
  68.      * 
  69.      * @var string 
  70.      * @since 1.0
  71.      */
  72.     protected $rootTag = '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" />';
  73.     
  74.     /**
  75.      * Add a URL to feed item
  76.      * 
  77.      * @param $url 
  78.      * @since 1.0
  79.      */
  80.     private function addToItems($url{
  81.         if($this->items == null{
  82.             $container $this->createFeedElement('items');
  83.             $this->root->appendChild($container);
  84.             $this->items = $this->rssDoc->createElementNS($this->rdfns'Seq');
  85.             $container->appendChild($this->items);
  86.         }
  87.         
  88.         $item $this->rssDoc->createElementNS($this->rdfns'li');
  89.         $this->items->appendChild($item);
  90.         $item->setAttribute('resource'$url);
  91.     }
  92.     
  93.     /**
  94.      * (non-PHPdoc)
  95.      * @see alpha/util/feeds/AlphaFeed::addItem()
  96.      */
  97.     protected function addItem($title$link$description null$pubDate null$id null{
  98.         parent::addItem($title$link$description$pubDate$id);
  99.         $this->addToItems($link);
  100.     }
  101.     
  102.     /**
  103.      * (non-PHPdoc)
  104.      * @see alpha/util/feeds/AlphaFeed::createRSSNode()
  105.      */
  106.     protected function createRSSNode($type$parent$title$url$description$pubDate null{
  107.         $parent->setAttributeNS($this->rdfns'rdf:about'$url);
  108.         parent::createRSSNode($type$parent$title$url$description$pubDate);
  109.     }    
  110. }
  111.  
  112. ?>

Documentation generated on Thu, 17 Mar 2011 16:44:46 +0000 by phpDocumentor 1.4.3