Mercurial > hg > cmmr2012-drupal-site
comparison vendor/zendframework/zend-feed/src/Reader/Extension/Podcast/Feed.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children | 5311817fb629 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
1 <?php | |
2 /** | |
3 * Zend Framework (http://framework.zend.com/) | |
4 * | |
5 * @link http://github.com/zendframework/zf2 for the canonical source repository | |
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) | |
7 * @license http://framework.zend.com/license/new-bsd New BSD License | |
8 */ | |
9 | |
10 namespace Zend\Feed\Reader\Extension\Podcast; | |
11 | |
12 use DOMText; | |
13 use Zend\Feed\Reader\Extension; | |
14 | |
15 /** | |
16 */ | |
17 class Feed extends Extension\AbstractFeed | |
18 { | |
19 /** | |
20 * Get the entry author | |
21 * | |
22 * @return string | |
23 */ | |
24 public function getCastAuthor() | |
25 { | |
26 if (isset($this->data['author'])) { | |
27 return $this->data['author']; | |
28 } | |
29 | |
30 $author = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:author)'); | |
31 | |
32 if (!$author) { | |
33 $author = null; | |
34 } | |
35 | |
36 $this->data['author'] = $author; | |
37 | |
38 return $this->data['author']; | |
39 } | |
40 | |
41 /** | |
42 * Get the entry block | |
43 * | |
44 * @return string | |
45 */ | |
46 public function getBlock() | |
47 { | |
48 if (isset($this->data['block'])) { | |
49 return $this->data['block']; | |
50 } | |
51 | |
52 $block = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:block)'); | |
53 | |
54 if (!$block) { | |
55 $block = null; | |
56 } | |
57 | |
58 $this->data['block'] = $block; | |
59 | |
60 return $this->data['block']; | |
61 } | |
62 | |
63 /** | |
64 * Get the entry category | |
65 * | |
66 * @return array|null | |
67 */ | |
68 public function getItunesCategories() | |
69 { | |
70 if (isset($this->data['categories'])) { | |
71 return $this->data['categories']; | |
72 } | |
73 | |
74 $categoryList = $this->xpath->query($this->getXpathPrefix() . '/itunes:category'); | |
75 | |
76 $categories = []; | |
77 | |
78 if ($categoryList->length > 0) { | |
79 foreach ($categoryList as $node) { | |
80 $children = null; | |
81 | |
82 if ($node->childNodes->length > 0) { | |
83 $children = []; | |
84 | |
85 foreach ($node->childNodes as $childNode) { | |
86 if (!($childNode instanceof DOMText)) { | |
87 $children[$childNode->getAttribute('text')] = null; | |
88 } | |
89 } | |
90 } | |
91 | |
92 $categories[$node->getAttribute('text')] = $children; | |
93 } | |
94 } | |
95 | |
96 if (!$categories) { | |
97 $categories = null; | |
98 } | |
99 | |
100 $this->data['categories'] = $categories; | |
101 | |
102 return $this->data['categories']; | |
103 } | |
104 | |
105 /** | |
106 * Get the entry explicit | |
107 * | |
108 * @return string | |
109 */ | |
110 public function getExplicit() | |
111 { | |
112 if (isset($this->data['explicit'])) { | |
113 return $this->data['explicit']; | |
114 } | |
115 | |
116 $explicit = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:explicit)'); | |
117 | |
118 if (!$explicit) { | |
119 $explicit = null; | |
120 } | |
121 | |
122 $this->data['explicit'] = $explicit; | |
123 | |
124 return $this->data['explicit']; | |
125 } | |
126 | |
127 /** | |
128 * Get the entry image | |
129 * | |
130 * @return string | |
131 */ | |
132 public function getItunesImage() | |
133 { | |
134 if (isset($this->data['image'])) { | |
135 return $this->data['image']; | |
136 } | |
137 | |
138 $image = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:image/@href)'); | |
139 | |
140 if (!$image) { | |
141 $image = null; | |
142 } | |
143 | |
144 $this->data['image'] = $image; | |
145 | |
146 return $this->data['image']; | |
147 } | |
148 | |
149 /** | |
150 * Get the entry keywords | |
151 * | |
152 * @return string | |
153 */ | |
154 public function getKeywords() | |
155 { | |
156 if (isset($this->data['keywords'])) { | |
157 return $this->data['keywords']; | |
158 } | |
159 | |
160 $keywords = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:keywords)'); | |
161 | |
162 if (!$keywords) { | |
163 $keywords = null; | |
164 } | |
165 | |
166 $this->data['keywords'] = $keywords; | |
167 | |
168 return $this->data['keywords']; | |
169 } | |
170 | |
171 /** | |
172 * Get the entry's new feed url | |
173 * | |
174 * @return string | |
175 */ | |
176 public function getNewFeedUrl() | |
177 { | |
178 if (isset($this->data['new-feed-url'])) { | |
179 return $this->data['new-feed-url']; | |
180 } | |
181 | |
182 $newFeedUrl = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:new-feed-url)'); | |
183 | |
184 if (!$newFeedUrl) { | |
185 $newFeedUrl = null; | |
186 } | |
187 | |
188 $this->data['new-feed-url'] = $newFeedUrl; | |
189 | |
190 return $this->data['new-feed-url']; | |
191 } | |
192 | |
193 /** | |
194 * Get the entry owner | |
195 * | |
196 * @return string | |
197 */ | |
198 public function getOwner() | |
199 { | |
200 if (isset($this->data['owner'])) { | |
201 return $this->data['owner']; | |
202 } | |
203 | |
204 $owner = null; | |
205 | |
206 $email = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:owner/itunes:email)'); | |
207 $name = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:owner/itunes:name)'); | |
208 | |
209 if (!empty($email)) { | |
210 $owner = $email . (empty($name) ? '' : ' (' . $name . ')'); | |
211 } elseif (!empty($name)) { | |
212 $owner = $name; | |
213 } | |
214 | |
215 if (!$owner) { | |
216 $owner = null; | |
217 } | |
218 | |
219 $this->data['owner'] = $owner; | |
220 | |
221 return $this->data['owner']; | |
222 } | |
223 | |
224 /** | |
225 * Get the entry subtitle | |
226 * | |
227 * @return string | |
228 */ | |
229 public function getSubtitle() | |
230 { | |
231 if (isset($this->data['subtitle'])) { | |
232 return $this->data['subtitle']; | |
233 } | |
234 | |
235 $subtitle = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:subtitle)'); | |
236 | |
237 if (!$subtitle) { | |
238 $subtitle = null; | |
239 } | |
240 | |
241 $this->data['subtitle'] = $subtitle; | |
242 | |
243 return $this->data['subtitle']; | |
244 } | |
245 | |
246 /** | |
247 * Get the entry summary | |
248 * | |
249 * @return string | |
250 */ | |
251 public function getSummary() | |
252 { | |
253 if (isset($this->data['summary'])) { | |
254 return $this->data['summary']; | |
255 } | |
256 | |
257 $summary = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:summary)'); | |
258 | |
259 if (!$summary) { | |
260 $summary = null; | |
261 } | |
262 | |
263 $this->data['summary'] = $summary; | |
264 | |
265 return $this->data['summary']; | |
266 } | |
267 | |
268 /** | |
269 * Register iTunes namespace | |
270 * | |
271 */ | |
272 protected function registerNamespaces() | |
273 { | |
274 $this->xpath->registerNamespace('itunes', 'http://www.itunes.com/dtds/podcast-1.0.dtd'); | |
275 } | |
276 } |