Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Feed / Writer / Extension / DublinCore / Renderer / Feed.php
blobceb3fac3f3d3e7c311e641539996973e65f1e31e
1 <?php
2 /**
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
8 */
10 namespace Zend\Feed\Writer\Extension\DublinCore\Renderer;
12 use DOMDocument;
13 use DOMElement;
14 use Zend\Feed\Writer\Extension;
16 /**
18 class Feed extends Extension\AbstractRenderer
21 /**
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.
26 * @var bool
28 protected $called = false;
30 /**
31 * Render feed
33 * @return void
35 public function render()
37 if (strtolower($this->getType()) == 'atom') {
38 return;
40 $this->_setAuthors($this->dom, $this->base);
41 if ($this->called) {
42 $this->_appendNamespaces();
46 /**
47 * Append namespaces to feed element
49 * @return void
51 protected function _appendNamespaces()
53 $this->getRootElement()->setAttribute('xmlns:dc',
54 'http://purl.org/dc/elements/1.1/');
57 /**
58 * Set feed authors
60 * @param DOMDocument $dom
61 * @param DOMElement $root
62 * @return void
64 protected function _setAuthors(DOMDocument $dom, DOMElement $root)
66 $authors = $this->getDataContainer()->getAuthors();
67 if (!$authors || empty($authors)) {
68 return;
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);
78 $this->called = true;