web/Zend/Feed/Entry/Rss.php
changeset 0 4eba9c11703f
equal deleted inserted replaced
-1:000000000000 0:4eba9c11703f
       
     1 <?php
       
     2 
       
     3 /**
       
     4  * Zend Framework
       
     5  *
       
     6  * LICENSE
       
     7  *
       
     8  * This source file is subject to the new BSD license that is bundled
       
     9  * with this package in the file LICENSE.txt.
       
    10  * It is also available through the world-wide-web at this URL:
       
    11  * http://framework.zend.com/license/new-bsd
       
    12  * If you did not receive a copy of the license and are unable to
       
    13  * obtain it through the world-wide-web, please send an email
       
    14  * to license@zend.com so we can send you a copy immediately.
       
    15  *
       
    16  * @category   Zend
       
    17  * @package    Zend_Feed
       
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    20  * @version    $Id: Rss.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    21  */
       
    22 
       
    23 
       
    24 /**
       
    25  * @see Zend_Feed_Entry_Abstract
       
    26  */
       
    27 require_once 'Zend/Feed/Entry/Abstract.php';
       
    28 
       
    29 
       
    30 /**
       
    31  * Concrete class for working with RSS items.
       
    32  *
       
    33  * @category   Zend
       
    34  * @package    Zend_Feed
       
    35  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    36  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    37  */
       
    38 class Zend_Feed_Entry_Rss extends Zend_Feed_Entry_Abstract
       
    39 {
       
    40     /**
       
    41      * Root XML element for RSS items.
       
    42      *
       
    43      * @var string
       
    44      */
       
    45     protected $_rootElement = 'item';
       
    46 
       
    47     /**
       
    48      * Overwrites parent::_get method to enable read access
       
    49      * to content:encoded element.
       
    50      *
       
    51      * @param  string $var The property to access.
       
    52      * @return mixed
       
    53      */
       
    54     public function __get($var)
       
    55     {
       
    56         switch ($var) {
       
    57             case 'content':
       
    58                 $prefix = $this->_element->lookupPrefix('http://purl.org/rss/1.0/modules/content/');
       
    59                 return parent::__get("$prefix:encoded");
       
    60             default:
       
    61                 return parent::__get($var);
       
    62         }
       
    63     }
       
    64 
       
    65     /**
       
    66      * Overwrites parent::_set method to enable write access
       
    67      * to content:encoded element.
       
    68      *
       
    69      * @param  string $var The property to change.
       
    70      * @param  string $val The property's new value.
       
    71      * @return void
       
    72      */
       
    73     public function __set($var, $value)
       
    74     {
       
    75         switch ($var) {
       
    76             case 'content':
       
    77                 parent::__set('content:encoded', $value);
       
    78                 break;
       
    79             default:
       
    80                 parent::__set($var, $value);
       
    81         }
       
    82     }
       
    83 
       
    84     /**
       
    85      * Overwrites parent::_isset method to enable access
       
    86      * to content:encoded element.
       
    87      *
       
    88      * @param  string $var
       
    89      * @return boolean
       
    90      */
       
    91     public function __isset($var)
       
    92     {
       
    93         switch ($var) {
       
    94             case 'content':
       
    95                 // don't use other callback to prevent invalid returned value
       
    96                 return $this->content() !== null;
       
    97             default:
       
    98                 return parent::__isset($var);
       
    99         }
       
   100     }
       
   101 
       
   102     /**
       
   103      * Overwrites parent::_call method to enable read access
       
   104      * to content:encoded element.
       
   105      * Please note that method-style write access is not currently supported
       
   106      * by parent method, consequently this method doesn't as well.
       
   107      *
       
   108      * @param  string $var    The element to get the string value of.
       
   109      * @param  mixed  $unused This parameter is not used.
       
   110      * @return mixed The node's value, null, or an array of nodes.
       
   111      */
       
   112     public function __call($var, $unused)
       
   113     {
       
   114         switch ($var) {
       
   115             case 'content':
       
   116                 $prefix = $this->_element->lookupPrefix('http://purl.org/rss/1.0/modules/content/');
       
   117                 return parent::__call("$prefix:encoded", $unused);
       
   118             default:
       
   119                 return parent::__call($var, $unused);
       
   120         }
       
   121     }
       
   122 }