Mercurial > hg > cmmr2012-drupal-site
comparison vendor/zendframework/zend-feed/src/Reader/Feed/Rss.php @ 2:5311817fb629
Theme updates
author | Chris Cannam |
---|---|
date | Tue, 10 Jul 2018 13:19:18 +0000 |
parents | c75dbcec494b |
children |
comparison
equal
deleted
inserted
replaced
1:0b0e5f3b1e83 | 2:5311817fb629 |
---|---|
83 return $this->data['authors']; | 83 return $this->data['authors']; |
84 } | 84 } |
85 | 85 |
86 $authors = []; | 86 $authors = []; |
87 $authorsDc = $this->getExtension('DublinCore')->getAuthors(); | 87 $authorsDc = $this->getExtension('DublinCore')->getAuthors(); |
88 if (!empty($authorsDc)) { | 88 if (! empty($authorsDc)) { |
89 foreach ($authorsDc as $author) { | 89 foreach ($authorsDc as $author) { |
90 $authors[] = [ | 90 $authors[] = [ |
91 'name' => $author['name'] | 91 'name' => $author['name'] |
92 ]; | 92 ]; |
93 } | 93 } |
151 if ($this->getType() !== Reader\Reader::TYPE_RSS_10 && | 151 if ($this->getType() !== Reader\Reader::TYPE_RSS_10 && |
152 $this->getType() !== Reader\Reader::TYPE_RSS_090) { | 152 $this->getType() !== Reader\Reader::TYPE_RSS_090) { |
153 $copyright = $this->xpath->evaluate('string(/rss/channel/copyright)'); | 153 $copyright = $this->xpath->evaluate('string(/rss/channel/copyright)'); |
154 } | 154 } |
155 | 155 |
156 if (!$copyright && $this->getExtension('DublinCore') !== null) { | 156 if (! $copyright && $this->getExtension('DublinCore') !== null) { |
157 $copyright = $this->getExtension('DublinCore')->getCopyright(); | 157 $copyright = $this->getExtension('DublinCore')->getCopyright(); |
158 } | 158 } |
159 | 159 |
160 if (empty($copyright)) { | 160 if (empty($copyright)) { |
161 $copyright = $this->getExtension('Atom')->getCopyright(); | 161 $copyright = $this->getExtension('Atom')->getCopyright(); |
162 } | 162 } |
163 | 163 |
164 if (!$copyright) { | 164 if (! $copyright) { |
165 $copyright = null; | 165 $copyright = null; |
166 } | 166 } |
167 | 167 |
168 $this->data['copyright'] = $copyright; | 168 $this->data['copyright'] = $copyright; |
169 | 169 |
171 } | 171 } |
172 | 172 |
173 /** | 173 /** |
174 * Get the feed creation date | 174 * Get the feed creation date |
175 * | 175 * |
176 * @return string|null | 176 * @return DateTime|null |
177 */ | 177 */ |
178 public function getDateCreated() | 178 public function getDateCreated() |
179 { | 179 { |
180 return $this->getDateModified(); | 180 return $this->getDateModified(); |
181 } | 181 } |
195 $date = null; | 195 $date = null; |
196 | 196 |
197 if ($this->getType() !== Reader\Reader::TYPE_RSS_10 && | 197 if ($this->getType() !== Reader\Reader::TYPE_RSS_10 && |
198 $this->getType() !== Reader\Reader::TYPE_RSS_090) { | 198 $this->getType() !== Reader\Reader::TYPE_RSS_090) { |
199 $dateModified = $this->xpath->evaluate('string(/rss/channel/pubDate)'); | 199 $dateModified = $this->xpath->evaluate('string(/rss/channel/pubDate)'); |
200 if (!$dateModified) { | 200 if (! $dateModified) { |
201 $dateModified = $this->xpath->evaluate('string(/rss/channel/lastBuildDate)'); | 201 $dateModified = $this->xpath->evaluate('string(/rss/channel/lastBuildDate)'); |
202 } | 202 } |
203 if ($dateModified) { | 203 if ($dateModified) { |
204 $dateModifiedParsed = strtotime($dateModified); | 204 $dateModifiedParsed = strtotime($dateModified); |
205 if ($dateModifiedParsed) { | 205 if ($dateModifiedParsed) { |
215 if ($standard === null) { | 215 if ($standard === null) { |
216 throw new Exception\RuntimeException( | 216 throw new Exception\RuntimeException( |
217 'Could not load date due to unrecognised' | 217 'Could not load date due to unrecognised' |
218 .' format (should follow RFC 822 or 2822):' | 218 .' format (should follow RFC 822 or 2822):' |
219 . $e->getMessage(), | 219 . $e->getMessage(), |
220 0, $e | 220 0, |
221 $e | |
221 ); | 222 ); |
222 } | 223 } |
223 } | 224 } |
224 } | 225 } |
225 } | 226 } |
226 } | 227 } |
227 } | 228 } |
228 | 229 |
229 if (!$date) { | 230 if (! $date) { |
230 $date = $this->getExtension('DublinCore')->getDate(); | 231 $date = $this->getExtension('DublinCore')->getDate(); |
231 } | 232 } |
232 | 233 |
233 if (!$date) { | 234 if (! $date) { |
234 $date = $this->getExtension('Atom')->getDateModified(); | 235 $date = $this->getExtension('Atom')->getDateModified(); |
235 } | 236 } |
236 | 237 |
237 if (!$date) { | 238 if (! $date) { |
238 $date = null; | 239 $date = null; |
239 } | 240 } |
240 | 241 |
241 $this->data['datemodified'] = $date; | 242 $this->data['datemodified'] = $date; |
242 | 243 |
275 if ($standard === null) { | 276 if ($standard === null) { |
276 throw new Exception\RuntimeException( | 277 throw new Exception\RuntimeException( |
277 'Could not load date due to unrecognised' | 278 'Could not load date due to unrecognised' |
278 .' format (should follow RFC 822 or 2822):' | 279 .' format (should follow RFC 822 or 2822):' |
279 . $e->getMessage(), | 280 . $e->getMessage(), |
280 0, $e | 281 0, |
282 $e | |
281 ); | 283 ); |
282 } | 284 } |
283 } | 285 } |
284 } | 286 } |
285 } | 287 } |
286 } | 288 } |
287 } | 289 } |
288 | 290 |
289 if (!$date) { | 291 if (! $date) { |
290 $date = null; | 292 $date = null; |
291 } | 293 } |
292 | 294 |
293 $this->data['lastBuildDate'] = $date; | 295 $this->data['lastBuildDate'] = $date; |
294 | 296 |
311 $description = $this->xpath->evaluate('string(/rss/channel/description)'); | 313 $description = $this->xpath->evaluate('string(/rss/channel/description)'); |
312 } else { | 314 } else { |
313 $description = $this->xpath->evaluate('string(/rdf:RDF/rss:channel/rss:description)'); | 315 $description = $this->xpath->evaluate('string(/rdf:RDF/rss:channel/rss:description)'); |
314 } | 316 } |
315 | 317 |
316 if (!$description && $this->getExtension('DublinCore') !== null) { | 318 if (! $description && $this->getExtension('DublinCore') !== null) { |
317 $description = $this->getExtension('DublinCore')->getDescription(); | 319 $description = $this->getExtension('DublinCore')->getDescription(); |
318 } | 320 } |
319 | 321 |
320 if (empty($description)) { | 322 if (empty($description)) { |
321 $description = $this->getExtension('Atom')->getDescription(); | 323 $description = $this->getExtension('Atom')->getDescription(); |
322 } | 324 } |
323 | 325 |
324 if (!$description) { | 326 if (! $description) { |
325 $description = null; | 327 $description = null; |
326 } | 328 } |
327 | 329 |
328 $this->data['description'] = $description; | 330 $this->data['description'] = $description; |
329 | 331 |
346 if ($this->getType() !== Reader\Reader::TYPE_RSS_10 && | 348 if ($this->getType() !== Reader\Reader::TYPE_RSS_10 && |
347 $this->getType() !== Reader\Reader::TYPE_RSS_090) { | 349 $this->getType() !== Reader\Reader::TYPE_RSS_090) { |
348 $id = $this->xpath->evaluate('string(/rss/channel/guid)'); | 350 $id = $this->xpath->evaluate('string(/rss/channel/guid)'); |
349 } | 351 } |
350 | 352 |
351 if (!$id && $this->getExtension('DublinCore') !== null) { | 353 if (! $id && $this->getExtension('DublinCore') !== null) { |
352 $id = $this->getExtension('DublinCore')->getId(); | 354 $id = $this->getExtension('DublinCore')->getId(); |
353 } | 355 } |
354 | 356 |
355 if (empty($id)) { | 357 if (empty($id)) { |
356 $id = $this->getExtension('Atom')->getId(); | 358 $id = $this->getExtension('Atom')->getId(); |
357 } | 359 } |
358 | 360 |
359 if (!$id) { | 361 if (! $id) { |
360 if ($this->getLink()) { | 362 if ($this->getLink()) { |
361 $id = $this->getLink(); | 363 $id = $this->getLink(); |
362 } elseif ($this->getTitle()) { | 364 } elseif ($this->getTitle()) { |
363 $id = $this->getTitle(); | 365 $id = $this->getTitle(); |
364 } else { | 366 } else { |
441 if ($this->getType() !== Reader\Reader::TYPE_RSS_10 && | 443 if ($this->getType() !== Reader\Reader::TYPE_RSS_10 && |
442 $this->getType() !== Reader\Reader::TYPE_RSS_090) { | 444 $this->getType() !== Reader\Reader::TYPE_RSS_090) { |
443 $language = $this->xpath->evaluate('string(/rss/channel/language)'); | 445 $language = $this->xpath->evaluate('string(/rss/channel/language)'); |
444 } | 446 } |
445 | 447 |
446 if (!$language && $this->getExtension('DublinCore') !== null) { | 448 if (! $language && $this->getExtension('DublinCore') !== null) { |
447 $language = $this->getExtension('DublinCore')->getLanguage(); | 449 $language = $this->getExtension('DublinCore')->getLanguage(); |
448 } | 450 } |
449 | 451 |
450 if (empty($language)) { | 452 if (empty($language)) { |
451 $language = $this->getExtension('Atom')->getLanguage(); | 453 $language = $this->getExtension('Atom')->getLanguage(); |
452 } | 454 } |
453 | 455 |
454 if (!$language) { | 456 if (! $language) { |
455 $language = $this->xpath->evaluate('string(//@xml:lang[1])'); | 457 $language = $this->xpath->evaluate('string(//@xml:lang[1])'); |
456 } | 458 } |
457 | 459 |
458 if (!$language) { | 460 if (! $language) { |
459 $language = null; | 461 $language = null; |
460 } | 462 } |
461 | 463 |
462 $this->data['language'] = $language; | 464 $this->data['language'] = $language; |
463 | 465 |
484 | 486 |
485 if (empty($link)) { | 487 if (empty($link)) { |
486 $link = $this->getExtension('Atom')->getLink(); | 488 $link = $this->getExtension('Atom')->getLink(); |
487 } | 489 } |
488 | 490 |
489 if (!$link) { | 491 if (! $link) { |
490 $link = null; | 492 $link = null; |
491 } | 493 } |
492 | 494 |
493 $this->data['link'] = $link; | 495 $this->data['link'] = $link; |
494 | 496 |
533 if ($this->getType() !== Reader\Reader::TYPE_RSS_10 && | 535 if ($this->getType() !== Reader\Reader::TYPE_RSS_10 && |
534 $this->getType() !== Reader\Reader::TYPE_RSS_090) { | 536 $this->getType() !== Reader\Reader::TYPE_RSS_090) { |
535 $generator = $this->xpath->evaluate('string(/rss/channel/generator)'); | 537 $generator = $this->xpath->evaluate('string(/rss/channel/generator)'); |
536 } | 538 } |
537 | 539 |
538 if (!$generator) { | 540 if (! $generator) { |
539 if ($this->getType() !== Reader\Reader::TYPE_RSS_10 && | 541 if ($this->getType() !== Reader\Reader::TYPE_RSS_10 && |
540 $this->getType() !== Reader\Reader::TYPE_RSS_090) { | 542 $this->getType() !== Reader\Reader::TYPE_RSS_090) { |
541 $generator = $this->xpath->evaluate('string(/rss/channel/atom:generator)'); | 543 $generator = $this->xpath->evaluate('string(/rss/channel/atom:generator)'); |
542 } else { | 544 } else { |
543 $generator = $this->xpath->evaluate('string(/rdf:RDF/rss:channel/atom:generator)'); | 545 $generator = $this->xpath->evaluate('string(/rdf:RDF/rss:channel/atom:generator)'); |
546 | 548 |
547 if (empty($generator)) { | 549 if (empty($generator)) { |
548 $generator = $this->getExtension('Atom')->getGenerator(); | 550 $generator = $this->getExtension('Atom')->getGenerator(); |
549 } | 551 } |
550 | 552 |
551 if (!$generator) { | 553 if (! $generator) { |
552 $generator = null; | 554 $generator = null; |
553 } | 555 } |
554 | 556 |
555 $this->data['generator'] = $generator; | 557 $this->data['generator'] = $generator; |
556 | 558 |
573 $title = $this->xpath->evaluate('string(/rss/channel/title)'); | 575 $title = $this->xpath->evaluate('string(/rss/channel/title)'); |
574 } else { | 576 } else { |
575 $title = $this->xpath->evaluate('string(/rdf:RDF/rss:channel/rss:title)'); | 577 $title = $this->xpath->evaluate('string(/rdf:RDF/rss:channel/rss:title)'); |
576 } | 578 } |
577 | 579 |
578 if (!$title && $this->getExtension('DublinCore') !== null) { | 580 if (! $title && $this->getExtension('DublinCore') !== null) { |
579 $title = $this->getExtension('DublinCore')->getTitle(); | 581 $title = $this->getExtension('DublinCore')->getTitle(); |
580 } | 582 } |
581 | 583 |
582 if (!$title) { | 584 if (! $title) { |
583 $title = $this->getExtension('Atom')->getTitle(); | 585 $title = $this->getExtension('Atom')->getTitle(); |
584 } | 586 } |
585 | 587 |
586 if (!$title) { | 588 if (! $title) { |
587 $title = null; | 589 $title = null; |
588 } | 590 } |
589 | 591 |
590 $this->data['title'] = $title; | 592 $this->data['title'] = $title; |
591 | 593 |