web/lib/Zend/Feed/Writer/Renderer/RendererAbstract.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    12  * obtain it through the world-wide-web, please send an email
    12  * obtain it through the world-wide-web, please send an email
    13  * to license@zend.com so we can send you a copy immediately.
    13  * to license@zend.com so we can send you a copy immediately.
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_Feed_Writer
    16  * @package    Zend_Feed_Writer
    17  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    17  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    18  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19  * @version    $Id: RendererAbstract.php 20096 2010-01-06 02:05:09Z bkarwin $
    19  * @version    $Id: RendererAbstract.php 24593 2012-01-05 20:35:02Z matthew $
    20  */
    20  */
    21  
    21 
    22 /** @see Zend_Feed_Writer */
    22 /** @see Zend_Feed_Writer */
    23 require_once 'Zend/Feed/Writer.php';
    23 require_once 'Zend/Feed/Writer.php';
    24 
    24 
    25 /** @see Zend_Version */
    25 /** @see Zend_Version */
    26 require_once 'Zend/Version.php';
    26 require_once 'Zend/Version.php';
    27  
    27 
    28 /**
    28 /**
    29  * @category   Zend
    29  * @category   Zend
    30  * @package    Zend_Feed_Writer
    30  * @package    Zend_Feed_Writer
    31  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    31  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    32  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    32  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    33  */
    33  */
    34 class Zend_Feed_Writer_Renderer_RendererAbstract
    34 class Zend_Feed_Writer_Renderer_RendererAbstract
    35 {
    35 {
    36     /**
    36     /**
    37      * Extensions
    37      * Extensions
    38      * @var array
    38      * @var array
    39      */
    39      */
    40     protected $_extensions = array();
    40     protected $_extensions = array();
    41     
    41 
    42     /**
    42     /**
    43      * @var mixed
    43      * @var mixed
    44      */
    44      */
    45     protected $_container = null;
    45     protected $_container = null;
    46 
    46 
    56 
    56 
    57     /**
    57     /**
    58      * @var array
    58      * @var array
    59      */
    59      */
    60     protected $_exceptions = array();
    60     protected $_exceptions = array();
    61     
    61 
    62     /**
    62     /**
    63      * Encoding of all text values
    63      * Encoding of all text values
    64      *
    64      *
    65      * @var string
    65      * @var string
    66      */
    66      */
    67     protected $_encoding = 'UTF-8';
    67     protected $_encoding = 'UTF-8';
    68     
    68 
    69     /**
    69     /**
    70      * Holds the value "atom" or "rss" depending on the feed type set when
    70      * Holds the value "atom" or "rss" depending on the feed type set when
    71      * when last exported.
    71      * when last exported.
    72      *
    72      *
    73      * @var string
    73      * @var string
    74      */
    74      */
    75     protected $_type = null;
    75     protected $_type = null;
    76     
    76 
    77     /**
    77     /**
    78      * @var DOMElement
    78      * @var DOMElement
    79      */
    79      */
    80     protected $_rootElement = null;
    80     protected $_rootElement = null;
    81 
    81 
    82     /**
    82     /**
    83      * Constructor
    83      * Constructor
    84      * 
    84      *
    85      * @param  mixed $container 
    85      * @param  mixed $container
    86      * @return void
    86      * @return void
    87      */
    87      */
    88     public function __construct($container)
    88     public function __construct($container)
    89     {
    89     {
    90         $this->_container = $container;
    90         $this->_container = $container;
    91         $this->setType($container->getType());
    91         $this->setType($container->getType());
    92         $this->_loadExtensions();
    92         $this->_loadExtensions();
    93     }
    93     }
    94     
    94 
    95     /**
    95     /**
    96      * Save XML to string
    96      * Save XML to string
    97      * 
    97      *
    98      * @return string
    98      * @return string
    99      */
    99      */
   100     public function saveXml()
   100     public function saveXml()
   101     {
   101     {
   102         return $this->getDomDocument()->saveXml();
   102         return $this->getDomDocument()->saveXml();
   103     }
   103     }
   104 
   104 
   105     /**
   105     /**
   106      * Get DOM document
   106      * Get DOM document
   107      * 
   107      *
   108      * @return DOMDocument
   108      * @return DOMDocument
   109      */
   109      */
   110     public function getDomDocument()
   110     public function getDomDocument()
   111     {
   111     {
   112         return $this->_dom;
   112         return $this->_dom;
   113     }
   113     }
   114 
   114 
   115     /**
   115     /**
   116      * Get document element from DOM
   116      * Get document element from DOM
   117      * 
   117      *
   118      * @return DOMElement
   118      * @return DOMElement
   119      */
   119      */
   120     public function getElement()
   120     public function getElement()
   121     {
   121     {
   122         return $this->getDomDocument()->documentElement;
   122         return $this->getDomDocument()->documentElement;
   123     }
   123     }
   124 
   124 
   125     /**
   125     /**
   126      * Get data container of items being rendered
   126      * Get data container of items being rendered
   127      * 
   127      *
   128      * @return mixed
   128      * @return mixed
   129      */
   129      */
   130     public function getDataContainer()
   130     public function getDataContainer()
   131     {
   131     {
   132         return $this->_container;
   132         return $this->_container;
   133     }
   133     }
   134     
   134 
   135     /**
   135     /**
   136      * Set feed encoding
   136      * Set feed encoding
   137      * 
   137      *
   138      * @param  string $enc 
   138      * @param  string $enc
   139      * @return Zend_Feed_Writer_Renderer_RendererAbstract
   139      * @return Zend_Feed_Writer_Renderer_RendererAbstract
   140      */
   140      */
   141     public function setEncoding($enc)
   141     public function setEncoding($enc)
   142     {
   142     {
   143         $this->_encoding = $enc;
   143         $this->_encoding = $enc;
   144         return $this;
   144         return $this;
   145     }
   145     }
   146     
   146 
   147     /**
   147     /**
   148      * Get feed encoding
   148      * Get feed encoding
   149      * 
   149      *
   150      * @return string
   150      * @return string
   151      */
   151      */
   152     public function getEncoding()
   152     public function getEncoding()
   153     {
   153     {
   154         return $this->_encoding;
   154         return $this->_encoding;
   155     }
   155     }
   156 
   156 
   157     /**
   157     /**
   158      * Indicate whether or not to ignore exceptions
   158      * Indicate whether or not to ignore exceptions
   159      * 
   159      *
   160      * @param  bool $bool 
   160      * @param  bool $bool
   161      * @return Zend_Feed_Writer_Renderer_RendererAbstract
   161      * @return Zend_Feed_Writer_Renderer_RendererAbstract
   162      */
   162      */
   163     public function ignoreExceptions($bool = true)
   163     public function ignoreExceptions($bool = true)
   164     {
   164     {
   165         if (!is_bool($bool)) {
   165         if (!is_bool($bool)) {
   170         return $this;
   170         return $this;
   171     }
   171     }
   172 
   172 
   173     /**
   173     /**
   174      * Get exception list
   174      * Get exception list
   175      * 
   175      *
   176      * @return array
   176      * @return array
   177      */
   177      */
   178     public function getExceptions()
   178     public function getExceptions()
   179     {
   179     {
   180         return $this->_exceptions;
   180         return $this->_exceptions;
   181     }
   181     }
   182     
   182 
   183     /**
   183     /**
   184      * Set the current feed type being exported to "rss" or "atom". This allows
   184      * Set the current feed type being exported to "rss" or "atom". This allows
   185      * other objects to gracefully choose whether to execute or not, depending
   185      * other objects to gracefully choose whether to execute or not, depending
   186      * on their appropriateness for the current type, e.g. renderers.
   186      * on their appropriateness for the current type, e.g. renderers.
   187      *
   187      *
   189      */
   189      */
   190     public function setType($type)
   190     public function setType($type)
   191     {
   191     {
   192         $this->_type = $type;
   192         $this->_type = $type;
   193     }
   193     }
   194     
   194 
   195     /**
   195     /**
   196      * Retrieve the current or last feed type exported.
   196      * Retrieve the current or last feed type exported.
   197      *
   197      *
   198      * @return string Value will be "rss" or "atom"
   198      * @return string Value will be "rss" or "atom"
   199      */
   199      */
   200     public function getType()
   200     public function getType()
   201     {
   201     {
   202         return $this->_type;
   202         return $this->_type;
   203     }
   203     }
   204     
   204 
   205     /**
   205     /**
   206      * Sets the absolute root element for the XML feed being generated. This
   206      * Sets the absolute root element for the XML feed being generated. This
   207      * helps simplify the appending of namespace declarations, but also ensures
   207      * helps simplify the appending of namespace declarations, but also ensures
   208      * namespaces are added to the root element - not scattered across the entire
   208      * namespaces are added to the root element - not scattered across the entire
   209      * XML file - may assist namespace unsafe parsers and looks pretty ;).
   209      * XML file - may assist namespace unsafe parsers and looks pretty ;).
   212      */
   212      */
   213     public function setRootElement(DOMElement $root)
   213     public function setRootElement(DOMElement $root)
   214     {
   214     {
   215         $this->_rootElement = $root;
   215         $this->_rootElement = $root;
   216     }
   216     }
   217     
   217 
   218     /**
   218     /**
   219      * Retrieve the absolute root element for the XML feed being generated.
   219      * Retrieve the absolute root element for the XML feed being generated.
   220      *
   220      *
   221      * @return DOMElement
   221      * @return DOMElement
   222      */
   222      */
   223     public function getRootElement()
   223     public function getRootElement()
   224     {
   224     {
   225         return $this->_rootElement;
   225         return $this->_rootElement;
   226     }
   226     }
   227     
   227 
   228     /**
   228     /**
   229      * Load extensions from Zend_Feed_Writer
   229      * Load extensions from Zend_Feed_Writer
   230      *
   230      *
   231      * @return void
   231      * @return void
   232      */
   232      */