File indexing completed on 2024-12-29 05:27:37
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Feed_Writer 0017 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0018 * @license http://framework.zend.com/license/new-bsd New BSD License 0019 * @version $Id$ 0020 */ 0021 0022 /** 0023 * @see Zend_Feed_Writer_Extension_RendererAbstract 0024 */ 0025 // require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php'; 0026 0027 /** 0028 * @category Zend 0029 * @package Zend_Feed_Writer 0030 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0031 * @license http://framework.zend.com/license/new-bsd New BSD License 0032 */ 0033 class Zend_Feed_Writer_Extension_Content_Renderer_Entry 0034 extends Zend_Feed_Writer_Extension_RendererAbstract 0035 { 0036 0037 /** 0038 * Set to TRUE if a rendering method actually renders something. This 0039 * is used to prevent premature appending of a XML namespace declaration 0040 * until an element which requires it is actually appended. 0041 * 0042 * @var bool 0043 */ 0044 protected $_called = false; 0045 0046 /** 0047 * Render entry 0048 * 0049 * @return void 0050 */ 0051 public function render() 0052 { 0053 if (strtolower($this->getType()) == 'atom') { 0054 return; 0055 } 0056 $this->_setContent($this->_dom, $this->_base); 0057 if ($this->_called) { 0058 $this->_appendNamespaces(); 0059 } 0060 } 0061 0062 /** 0063 * Append namespaces to root element 0064 * 0065 * @return void 0066 */ 0067 protected function _appendNamespaces() 0068 { 0069 $this->getRootElement()->setAttribute('xmlns:content', 0070 'http://purl.org/rss/1.0/modules/content/'); 0071 } 0072 0073 /** 0074 * Set entry content 0075 * 0076 * @param DOMDocument $dom 0077 * @param DOMElement $root 0078 * @return void 0079 */ 0080 protected function _setContent(DOMDocument $dom, DOMElement $root) 0081 { 0082 $content = $this->getDataContainer()->getContent(); 0083 if (!$content) { 0084 return; 0085 } 0086 $element = $dom->createElement('content:encoded'); 0087 $root->appendChild($element); 0088 $cdata = $dom->createCDATASection($content); 0089 $element->appendChild($cdata); 0090 $this->_called = true; 0091 } 0092 }