3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Feed\Writer\Extension\DublinCore\Renderer
;
14 use Zend\Feed\Writer\Extension
;
18 class Feed
extends Extension\AbstractRenderer
22 * Set to TRUE if a rendering method actually renders something. This
23 * is used to prevent premature appending of a XML namespace declaration
24 * until an element which requires it is actually appended.
28 protected $called = false;
35 public function render()
37 if (strtolower($this->getType()) == 'atom') {
40 $this->_setAuthors($this->dom
, $this->base
);
42 $this->_appendNamespaces();
47 * Append namespaces to feed element
51 protected function _appendNamespaces()
53 $this->getRootElement()->setAttribute('xmlns:dc',
54 'http://purl.org/dc/elements/1.1/');
60 * @param DOMDocument $dom
61 * @param DOMElement $root
64 protected function _setAuthors(DOMDocument
$dom, DOMElement
$root)
66 $authors = $this->getDataContainer()->getAuthors();
67 if (!$authors ||
empty($authors)) {
70 foreach ($authors as $data) {
71 $author = $this->dom
->createElement('dc:creator');
72 if (array_key_exists('name', $data)) {
73 $text = $dom->createTextNode($data['name']);
74 $author->appendChild($text);
75 $root->appendChild($author);