File indexing completed on 2025-03-09 05:21:31
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_DublinCore_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->_setAuthors($this->_dom, $this->_base); 0057 if ($this->_called) { 0058 $this->_appendNamespaces(); 0059 } 0060 } 0061 0062 /** 0063 * Append namespaces to entry 0064 * 0065 * @return void 0066 */ 0067 protected function _appendNamespaces() 0068 { 0069 $this->getRootElement()->setAttribute('xmlns:dc', 0070 'http://purl.org/dc/elements/1.1/'); 0071 } 0072 0073 /** 0074 * Set entry author elements 0075 * 0076 * @param DOMDocument $dom 0077 * @param DOMElement $root 0078 * @return void 0079 */ 0080 protected function _setAuthors(DOMDocument $dom, DOMElement $root) 0081 { 0082 $authors = $this->getDataContainer()->getAuthors(); 0083 if (!$authors || empty($authors)) { 0084 return; 0085 } 0086 foreach ($authors as $data) { 0087 $author = $this->_dom->createElement('dc:creator'); 0088 if (array_key_exists('name', $data)) { 0089 $text = $dom->createTextNode($data['name']); 0090 $author->appendChild($text); 0091 $root->appendChild($author); 0092 } 0093 } 0094 $this->_called = true; 0095 } 0096 }