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 / ITunes / Renderer / Entry.php
blobb46d10c5373c57a4b4dad14cca62ceb51ec78a42
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\ITunes\Renderer;
12 use DOMDocument;
13 use DOMElement;
14 use Zend\Feed\Writer\Extension;
16 /**
18 class Entry extends Extension\AbstractRenderer
20 /**
21 * Set to TRUE if a rendering method actually renders something. This
22 * is used to prevent premature appending of a XML namespace declaration
23 * until an element which requires it is actually appended.
25 * @var bool
27 protected $called = false;
29 /**
30 * Render entry
32 * @return void
34 public function render()
36 $this->_setAuthors($this->dom, $this->base);
37 $this->_setBlock($this->dom, $this->base);
38 $this->_setDuration($this->dom, $this->base);
39 $this->_setExplicit($this->dom, $this->base);
40 $this->_setKeywords($this->dom, $this->base);
41 $this->_setSubtitle($this->dom, $this->base);
42 $this->_setSummary($this->dom, $this->base);
43 if ($this->called) {
44 $this->_appendNamespaces();
48 /**
49 * Append namespaces to entry root
51 * @return void
53 protected function _appendNamespaces()
55 $this->getRootElement()->setAttribute('xmlns:itunes',
56 'http://www.itunes.com/dtds/podcast-1.0.dtd');
59 /**
60 * Set entry authors
62 * @param DOMDocument $dom
63 * @param DOMElement $root
64 * @return void
66 protected function _setAuthors(DOMDocument $dom, DOMElement $root)
68 $authors = $this->getDataContainer()->getItunesAuthors();
69 if (!$authors || empty($authors)) {
70 return;
72 foreach ($authors as $author) {
73 $el = $dom->createElement('itunes:author');
74 $text = $dom->createTextNode($author);
75 $el->appendChild($text);
76 $root->appendChild($el);
77 $this->called = true;
81 /**
82 * Set itunes block
84 * @param DOMDocument $dom
85 * @param DOMElement $root
86 * @return void
88 protected function _setBlock(DOMDocument $dom, DOMElement $root)
90 $block = $this->getDataContainer()->getItunesBlock();
91 if ($block === null) {
92 return;
94 $el = $dom->createElement('itunes:block');
95 $text = $dom->createTextNode($block);
96 $el->appendChild($text);
97 $root->appendChild($el);
98 $this->called = true;
102 * Set entry duration
104 * @param DOMDocument $dom
105 * @param DOMElement $root
106 * @return void
108 protected function _setDuration(DOMDocument $dom, DOMElement $root)
110 $duration = $this->getDataContainer()->getItunesDuration();
111 if (!$duration) {
112 return;
114 $el = $dom->createElement('itunes:duration');
115 $text = $dom->createTextNode($duration);
116 $el->appendChild($text);
117 $root->appendChild($el);
118 $this->called = true;
122 * Set explicit flag
124 * @param DOMDocument $dom
125 * @param DOMElement $root
126 * @return void
128 protected function _setExplicit(DOMDocument $dom, DOMElement $root)
130 $explicit = $this->getDataContainer()->getItunesExplicit();
131 if ($explicit === null) {
132 return;
134 $el = $dom->createElement('itunes:explicit');
135 $text = $dom->createTextNode($explicit);
136 $el->appendChild($text);
137 $root->appendChild($el);
138 $this->called = true;
142 * Set entry keywords
144 * @param DOMDocument $dom
145 * @param DOMElement $root
146 * @return void
148 protected function _setKeywords(DOMDocument $dom, DOMElement $root)
150 $keywords = $this->getDataContainer()->getItunesKeywords();
151 if (!$keywords || empty($keywords)) {
152 return;
154 $el = $dom->createElement('itunes:keywords');
155 $text = $dom->createTextNode(implode(',', $keywords));
156 $el->appendChild($text);
157 $root->appendChild($el);
158 $this->called = true;
162 * Set entry subtitle
164 * @param DOMDocument $dom
165 * @param DOMElement $root
166 * @return void
168 protected function _setSubtitle(DOMDocument $dom, DOMElement $root)
170 $subtitle = $this->getDataContainer()->getItunesSubtitle();
171 if (!$subtitle) {
172 return;
174 $el = $dom->createElement('itunes:subtitle');
175 $text = $dom->createTextNode($subtitle);
176 $el->appendChild($text);
177 $root->appendChild($el);
178 $this->called = true;
182 * Set entry summary
184 * @param DOMDocument $dom
185 * @param DOMElement $root
186 * @return void
188 protected function _setSummary(DOMDocument $dom, DOMElement $root)
190 $summary = $this->getDataContainer()->getItunesSummary();
191 if (!$summary) {
192 return;
194 $el = $dom->createElement('itunes:summary');
195 $text = $dom->createTextNode($summary);
196 $el->appendChild($text);
197 $root->appendChild($el);
198 $this->called = true;