Mercurial > hg > isophonics-drupal-site
comparison vendor/zendframework/zend-feed/src/Writer/Renderer/Feed/Rss.php @ 12:7a779792577d
Update Drupal core to v8.4.5 (via Composer)
author | Chris Cannam |
---|---|
date | Fri, 23 Feb 2018 15:52:07 +0000 |
parents | 4c8ae668cc8c |
children |
comparison
equal
deleted
inserted
replaced
11:bfffd8d7479a | 12:7a779792577d |
---|---|
63 $this->_setCategories($this->dom, $channel); | 63 $this->_setCategories($this->dom, $channel); |
64 | 64 |
65 foreach ($this->extensions as $ext) { | 65 foreach ($this->extensions as $ext) { |
66 $ext->setType($this->getType()); | 66 $ext->setType($this->getType()); |
67 $ext->setRootElement($this->getRootElement()); | 67 $ext->setRootElement($this->getRootElement()); |
68 $ext->setDOMDocument($this->getDOMDocument(), $channel); | 68 $ext->setDomDocument($this->getDomDocument(), $channel); |
69 $ext->render(); | 69 $ext->render(); |
70 } | 70 } |
71 | 71 |
72 foreach ($this->container as $entry) { | 72 foreach ($this->container as $entry) { |
73 if ($this->getDataContainer()->getEncoding()) { | 73 if ($this->getDataContainer()->getEncoding()) { |
97 * | 97 * |
98 * @param DOMDocument $dom | 98 * @param DOMDocument $dom |
99 * @param DOMElement $root | 99 * @param DOMElement $root |
100 * @return void | 100 * @return void |
101 */ | 101 */ |
102 // @codingStandardsIgnoreStart | |
102 protected function _setLanguage(DOMDocument $dom, DOMElement $root) | 103 protected function _setLanguage(DOMDocument $dom, DOMElement $root) |
103 { | 104 { |
105 // @codingStandardsIgnoreEnd | |
104 $lang = $this->getDataContainer()->getLanguage(); | 106 $lang = $this->getDataContainer()->getLanguage(); |
105 if (!$lang) { | 107 if (! $lang) { |
106 return; | 108 return; |
107 } | 109 } |
108 $language = $dom->createElement('language'); | 110 $language = $dom->createElement('language'); |
109 $root->appendChild($language); | 111 $root->appendChild($language); |
110 $language->nodeValue = $lang; | 112 $language->nodeValue = $lang; |
116 * @param DOMDocument $dom | 118 * @param DOMDocument $dom |
117 * @param DOMElement $root | 119 * @param DOMElement $root |
118 * @return void | 120 * @return void |
119 * @throws Writer\Exception\InvalidArgumentException | 121 * @throws Writer\Exception\InvalidArgumentException |
120 */ | 122 */ |
123 // @codingStandardsIgnoreStart | |
121 protected function _setTitle(DOMDocument $dom, DOMElement $root) | 124 protected function _setTitle(DOMDocument $dom, DOMElement $root) |
122 { | 125 { |
123 if (!$this->getDataContainer()->getTitle()) { | 126 // @codingStandardsIgnoreEnd |
127 if (! $this->getDataContainer()->getTitle()) { | |
124 $message = 'RSS 2.0 feed elements MUST contain exactly one' | 128 $message = 'RSS 2.0 feed elements MUST contain exactly one' |
125 . ' title element but a title has not been set'; | 129 . ' title element but a title has not been set'; |
126 $exception = new Writer\Exception\InvalidArgumentException($message); | 130 $exception = new Writer\Exception\InvalidArgumentException($message); |
127 if (!$this->ignoreExceptions) { | 131 if (! $this->ignoreExceptions) { |
128 throw $exception; | 132 throw $exception; |
129 } else { | 133 } else { |
130 $this->exceptions[] = $exception; | 134 $this->exceptions[] = $exception; |
131 return; | 135 return; |
132 } | 136 } |
144 * @param DOMDocument $dom | 148 * @param DOMDocument $dom |
145 * @param DOMElement $root | 149 * @param DOMElement $root |
146 * @return void | 150 * @return void |
147 * @throws Writer\Exception\InvalidArgumentException | 151 * @throws Writer\Exception\InvalidArgumentException |
148 */ | 152 */ |
153 // @codingStandardsIgnoreStart | |
149 protected function _setDescription(DOMDocument $dom, DOMElement $root) | 154 protected function _setDescription(DOMDocument $dom, DOMElement $root) |
150 { | 155 { |
151 if (!$this->getDataContainer()->getDescription()) { | 156 // @codingStandardsIgnoreEnd |
157 if (! $this->getDataContainer()->getDescription()) { | |
152 $message = 'RSS 2.0 feed elements MUST contain exactly one' | 158 $message = 'RSS 2.0 feed elements MUST contain exactly one' |
153 . ' description element but one has not been set'; | 159 . ' description element but one has not been set'; |
154 $exception = new Writer\Exception\InvalidArgumentException($message); | 160 $exception = new Writer\Exception\InvalidArgumentException($message); |
155 if (!$this->ignoreExceptions) { | 161 if (! $this->ignoreExceptions) { |
156 throw $exception; | 162 throw $exception; |
157 } else { | 163 } else { |
158 $this->exceptions[] = $exception; | 164 $this->exceptions[] = $exception; |
159 return; | 165 return; |
160 } | 166 } |
170 * | 176 * |
171 * @param DOMDocument $dom | 177 * @param DOMDocument $dom |
172 * @param DOMElement $root | 178 * @param DOMElement $root |
173 * @return void | 179 * @return void |
174 */ | 180 */ |
181 // @codingStandardsIgnoreStart | |
175 protected function _setDateModified(DOMDocument $dom, DOMElement $root) | 182 protected function _setDateModified(DOMDocument $dom, DOMElement $root) |
176 { | 183 { |
177 if (!$this->getDataContainer()->getDateModified()) { | 184 // @codingStandardsIgnoreEnd |
185 if (! $this->getDataContainer()->getDateModified()) { | |
178 return; | 186 return; |
179 } | 187 } |
180 | 188 |
181 $updated = $dom->createElement('pubDate'); | 189 $updated = $dom->createElement('pubDate'); |
182 $root->appendChild($updated); | 190 $root->appendChild($updated); |
191 * | 199 * |
192 * @param DOMDocument $dom | 200 * @param DOMDocument $dom |
193 * @param DOMElement $root | 201 * @param DOMElement $root |
194 * @return void | 202 * @return void |
195 */ | 203 */ |
204 // @codingStandardsIgnoreStart | |
196 protected function _setGenerator(DOMDocument $dom, DOMElement $root) | 205 protected function _setGenerator(DOMDocument $dom, DOMElement $root) |
197 { | 206 { |
198 if (!$this->getDataContainer()->getGenerator()) { | 207 // @codingStandardsIgnoreEnd |
208 if (! $this->getDataContainer()->getGenerator()) { | |
199 $this->getDataContainer()->setGenerator( | 209 $this->getDataContainer()->setGenerator( |
200 'Zend_Feed_Writer', | 210 'Zend_Feed_Writer', |
201 Version::VERSION, | 211 Version::VERSION, |
202 'http://framework.zend.com' | 212 'http://framework.zend.com' |
203 ); | 213 ); |
223 * @param DOMDocument $dom | 233 * @param DOMDocument $dom |
224 * @param DOMElement $root | 234 * @param DOMElement $root |
225 * @return void | 235 * @return void |
226 * @throws Writer\Exception\InvalidArgumentException | 236 * @throws Writer\Exception\InvalidArgumentException |
227 */ | 237 */ |
238 // @codingStandardsIgnoreStart | |
228 protected function _setLink(DOMDocument $dom, DOMElement $root) | 239 protected function _setLink(DOMDocument $dom, DOMElement $root) |
229 { | 240 { |
241 // @codingStandardsIgnoreEnd | |
230 $value = $this->getDataContainer()->getLink(); | 242 $value = $this->getDataContainer()->getLink(); |
231 if (!$value) { | 243 if (! $value) { |
232 $message = 'RSS 2.0 feed elements MUST contain exactly one' | 244 $message = 'RSS 2.0 feed elements MUST contain exactly one' |
233 . ' link element but one has not been set'; | 245 . ' link element but one has not been set'; |
234 $exception = new Writer\Exception\InvalidArgumentException($message); | 246 $exception = new Writer\Exception\InvalidArgumentException($message); |
235 if (!$this->ignoreExceptions) { | 247 if (! $this->ignoreExceptions) { |
236 throw $exception; | 248 throw $exception; |
237 } else { | 249 } else { |
238 $this->exceptions[] = $exception; | 250 $this->exceptions[] = $exception; |
239 return; | 251 return; |
240 } | 252 } |
241 } | 253 } |
242 $link = $dom->createElement('link'); | 254 $link = $dom->createElement('link'); |
243 $root->appendChild($link); | 255 $root->appendChild($link); |
244 $text = $dom->createTextNode($value); | 256 $text = $dom->createTextNode($value); |
245 $link->appendChild($text); | 257 $link->appendChild($text); |
246 if (!Uri::factory($value)->isValid()) { | 258 if (! Uri::factory($value)->isValid()) { |
247 $link->setAttribute('isPermaLink', 'false'); | 259 $link->setAttribute('isPermaLink', 'false'); |
248 } | 260 } |
249 } | 261 } |
250 | 262 |
251 /** | 263 /** |
253 * | 265 * |
254 * @param DOMDocument $dom | 266 * @param DOMDocument $dom |
255 * @param DOMElement $root | 267 * @param DOMElement $root |
256 * @return void | 268 * @return void |
257 */ | 269 */ |
270 // @codingStandardsIgnoreStart | |
258 protected function _setAuthors(DOMDocument $dom, DOMElement $root) | 271 protected function _setAuthors(DOMDocument $dom, DOMElement $root) |
259 { | 272 { |
273 // @codingStandardsIgnoreEnd | |
260 $authors = $this->getDataContainer()->getAuthors(); | 274 $authors = $this->getDataContainer()->getAuthors(); |
261 if (!$authors || empty($authors)) { | 275 if (! $authors || empty($authors)) { |
262 return; | 276 return; |
263 } | 277 } |
264 foreach ($authors as $data) { | 278 foreach ($authors as $data) { |
265 $author = $this->dom->createElement('author'); | 279 $author = $this->dom->createElement('author'); |
266 $name = $data['name']; | 280 $name = $data['name']; |
278 * | 292 * |
279 * @param DOMDocument $dom | 293 * @param DOMDocument $dom |
280 * @param DOMElement $root | 294 * @param DOMElement $root |
281 * @return void | 295 * @return void |
282 */ | 296 */ |
297 // @codingStandardsIgnoreStart | |
283 protected function _setCopyright(DOMDocument $dom, DOMElement $root) | 298 protected function _setCopyright(DOMDocument $dom, DOMElement $root) |
284 { | 299 { |
300 // @codingStandardsIgnoreEnd | |
285 $copyright = $this->getDataContainer()->getCopyright(); | 301 $copyright = $this->getDataContainer()->getCopyright(); |
286 if (!$copyright) { | 302 if (! $copyright) { |
287 return; | 303 return; |
288 } | 304 } |
289 $copy = $dom->createElement('copyright'); | 305 $copy = $dom->createElement('copyright'); |
290 $root->appendChild($copy); | 306 $root->appendChild($copy); |
291 $text = $dom->createTextNode($copyright); | 307 $text = $dom->createTextNode($copyright); |
298 * @param DOMDocument $dom | 314 * @param DOMDocument $dom |
299 * @param DOMElement $root | 315 * @param DOMElement $root |
300 * @return void | 316 * @return void |
301 * @throws Writer\Exception\InvalidArgumentException | 317 * @throws Writer\Exception\InvalidArgumentException |
302 */ | 318 */ |
319 // @codingStandardsIgnoreStart | |
303 protected function _setImage(DOMDocument $dom, DOMElement $root) | 320 protected function _setImage(DOMDocument $dom, DOMElement $root) |
304 { | 321 { |
322 // @codingStandardsIgnoreEnd | |
305 $image = $this->getDataContainer()->getImage(); | 323 $image = $this->getDataContainer()->getImage(); |
306 if (!$image) { | 324 if (! $image) { |
307 return; | 325 return; |
308 } | 326 } |
309 | 327 |
310 if (!isset($image['title']) || empty($image['title']) | 328 if (! isset($image['title']) || empty($image['title']) |
311 || !is_string($image['title']) | 329 || ! is_string($image['title']) |
312 ) { | 330 ) { |
313 $message = 'RSS 2.0 feed images must include a title'; | 331 $message = 'RSS 2.0 feed images must include a title'; |
314 $exception = new Writer\Exception\InvalidArgumentException($message); | 332 $exception = new Writer\Exception\InvalidArgumentException($message); |
315 if (!$this->ignoreExceptions) { | 333 if (! $this->ignoreExceptions) { |
316 throw $exception; | 334 throw $exception; |
317 } else { | 335 } else { |
318 $this->exceptions[] = $exception; | 336 $this->exceptions[] = $exception; |
319 return; | 337 return; |
320 } | 338 } |
321 } | 339 } |
322 | 340 |
323 if (empty($image['link']) || !is_string($image['link']) | 341 if (empty($image['link']) || ! is_string($image['link']) |
324 || !Uri::factory($image['link'])->isValid() | 342 || ! Uri::factory($image['link'])->isValid() |
325 ) { | 343 ) { |
326 $message = 'Invalid parameter: parameter \'link\'' | 344 $message = 'Invalid parameter: parameter \'link\'' |
327 . ' must be a non-empty string and valid URI/IRI'; | 345 . ' must be a non-empty string and valid URI/IRI'; |
328 $exception = new Writer\Exception\InvalidArgumentException($message); | 346 $exception = new Writer\Exception\InvalidArgumentException($message); |
329 if (!$this->ignoreExceptions) { | 347 if (! $this->ignoreExceptions) { |
330 throw $exception; | 348 throw $exception; |
331 } else { | 349 } else { |
332 $this->exceptions[] = $exception; | 350 $this->exceptions[] = $exception; |
333 return; | 351 return; |
334 } | 352 } |
352 $img->appendChild($url); | 370 $img->appendChild($url); |
353 $img->appendChild($title); | 371 $img->appendChild($title); |
354 $img->appendChild($link); | 372 $img->appendChild($link); |
355 | 373 |
356 if (isset($image['height'])) { | 374 if (isset($image['height'])) { |
357 if (!ctype_digit((string) $image['height']) || $image['height'] > 400) { | 375 if (! ctype_digit((string) $image['height']) || $image['height'] > 400) { |
358 $message = 'Invalid parameter: parameter \'height\'' | 376 $message = 'Invalid parameter: parameter \'height\'' |
359 . ' must be an integer not exceeding 400'; | 377 . ' must be an integer not exceeding 400'; |
360 $exception = new Writer\Exception\InvalidArgumentException($message); | 378 $exception = new Writer\Exception\InvalidArgumentException($message); |
361 if (!$this->ignoreExceptions) { | 379 if (! $this->ignoreExceptions) { |
362 throw $exception; | 380 throw $exception; |
363 } else { | 381 } else { |
364 $this->exceptions[] = $exception; | 382 $this->exceptions[] = $exception; |
365 return; | 383 return; |
366 } | 384 } |
369 $text = $dom->createTextNode($image['height']); | 387 $text = $dom->createTextNode($image['height']); |
370 $height->appendChild($text); | 388 $height->appendChild($text); |
371 $img->appendChild($height); | 389 $img->appendChild($height); |
372 } | 390 } |
373 if (isset($image['width'])) { | 391 if (isset($image['width'])) { |
374 if (!ctype_digit((string) $image['width']) || $image['width'] > 144) { | 392 if (! ctype_digit((string) $image['width']) || $image['width'] > 144) { |
375 $message = 'Invalid parameter: parameter \'width\'' | 393 $message = 'Invalid parameter: parameter \'width\'' |
376 . ' must be an integer not exceeding 144'; | 394 . ' must be an integer not exceeding 144'; |
377 $exception = new Writer\Exception\InvalidArgumentException($message); | 395 $exception = new Writer\Exception\InvalidArgumentException($message); |
378 if (!$this->ignoreExceptions) { | 396 if (! $this->ignoreExceptions) { |
379 throw $exception; | 397 throw $exception; |
380 } else { | 398 } else { |
381 $this->exceptions[] = $exception; | 399 $this->exceptions[] = $exception; |
382 return; | 400 return; |
383 } | 401 } |
386 $text = $dom->createTextNode($image['width']); | 404 $text = $dom->createTextNode($image['width']); |
387 $width->appendChild($text); | 405 $width->appendChild($text); |
388 $img->appendChild($width); | 406 $img->appendChild($width); |
389 } | 407 } |
390 if (isset($image['description'])) { | 408 if (isset($image['description'])) { |
391 if (empty($image['description']) || !is_string($image['description'])) { | 409 if (empty($image['description']) || ! is_string($image['description'])) { |
392 $message = 'Invalid parameter: parameter \'description\'' | 410 $message = 'Invalid parameter: parameter \'description\'' |
393 . ' must be a non-empty string'; | 411 . ' must be a non-empty string'; |
394 $exception = new Writer\Exception\InvalidArgumentException($message); | 412 $exception = new Writer\Exception\InvalidArgumentException($message); |
395 if (!$this->ignoreExceptions) { | 413 if (! $this->ignoreExceptions) { |
396 throw $exception; | 414 throw $exception; |
397 } else { | 415 } else { |
398 $this->exceptions[] = $exception; | 416 $this->exceptions[] = $exception; |
399 return; | 417 return; |
400 } | 418 } |
411 * | 429 * |
412 * @param DOMDocument $dom | 430 * @param DOMDocument $dom |
413 * @param DOMElement $root | 431 * @param DOMElement $root |
414 * @return void | 432 * @return void |
415 */ | 433 */ |
434 // @codingStandardsIgnoreStart | |
416 protected function _setDateCreated(DOMDocument $dom, DOMElement $root) | 435 protected function _setDateCreated(DOMDocument $dom, DOMElement $root) |
417 { | 436 { |
418 if (!$this->getDataContainer()->getDateCreated()) { | 437 // @codingStandardsIgnoreEnd |
419 return; | 438 if (! $this->getDataContainer()->getDateCreated()) { |
420 } | 439 return; |
421 if (!$this->getDataContainer()->getDateModified()) { | 440 } |
441 if (! $this->getDataContainer()->getDateModified()) { | |
422 $this->getDataContainer()->setDateModified( | 442 $this->getDataContainer()->setDateModified( |
423 $this->getDataContainer()->getDateCreated() | 443 $this->getDataContainer()->getDateCreated() |
424 ); | 444 ); |
425 } | 445 } |
426 } | 446 } |
430 * | 450 * |
431 * @param DOMDocument $dom | 451 * @param DOMDocument $dom |
432 * @param DOMElement $root | 452 * @param DOMElement $root |
433 * @return void | 453 * @return void |
434 */ | 454 */ |
455 // @codingStandardsIgnoreStart | |
435 protected function _setLastBuildDate(DOMDocument $dom, DOMElement $root) | 456 protected function _setLastBuildDate(DOMDocument $dom, DOMElement $root) |
436 { | 457 { |
437 if (!$this->getDataContainer()->getLastBuildDate()) { | 458 // @codingStandardsIgnoreEnd |
459 if (! $this->getDataContainer()->getLastBuildDate()) { | |
438 return; | 460 return; |
439 } | 461 } |
440 | 462 |
441 $lastBuildDate = $dom->createElement('lastBuildDate'); | 463 $lastBuildDate = $dom->createElement('lastBuildDate'); |
442 $root->appendChild($lastBuildDate); | 464 $root->appendChild($lastBuildDate); |
451 * | 473 * |
452 * @param DOMDocument $dom | 474 * @param DOMDocument $dom |
453 * @param DOMElement $root | 475 * @param DOMElement $root |
454 * @return void | 476 * @return void |
455 */ | 477 */ |
478 // @codingStandardsIgnoreStart | |
456 protected function _setBaseUrl(DOMDocument $dom, DOMElement $root) | 479 protected function _setBaseUrl(DOMDocument $dom, DOMElement $root) |
457 { | 480 { |
481 // @codingStandardsIgnoreEnd | |
458 $baseUrl = $this->getDataContainer()->getBaseUrl(); | 482 $baseUrl = $this->getDataContainer()->getBaseUrl(); |
459 if (!$baseUrl) { | 483 if (! $baseUrl) { |
460 return; | 484 return; |
461 } | 485 } |
462 $root->setAttribute('xml:base', $baseUrl); | 486 $root->setAttribute('xml:base', $baseUrl); |
463 } | 487 } |
464 | 488 |
467 * | 491 * |
468 * @param DOMDocument $dom | 492 * @param DOMDocument $dom |
469 * @param DOMElement $root | 493 * @param DOMElement $root |
470 * @return void | 494 * @return void |
471 */ | 495 */ |
496 // @codingStandardsIgnoreStart | |
472 protected function _setCategories(DOMDocument $dom, DOMElement $root) | 497 protected function _setCategories(DOMDocument $dom, DOMElement $root) |
473 { | 498 { |
499 // @codingStandardsIgnoreEnd | |
474 $categories = $this->getDataContainer()->getCategories(); | 500 $categories = $this->getDataContainer()->getCategories(); |
475 if (!$categories) { | 501 if (! $categories) { |
476 return; | 502 return; |
477 } | 503 } |
478 foreach ($categories as $cat) { | 504 foreach ($categories as $cat) { |
479 $category = $dom->createElement('category'); | 505 $category = $dom->createElement('category'); |
480 if (isset($cat['scheme'])) { | 506 if (isset($cat['scheme'])) { |