comparison vendor/zendframework/zend-feed/src/Reader/Entry/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 af1871eacc83
comparison
equal deleted inserted replaced
11:bfffd8d7479a 12:7a779792577d
39 * @param string $type 39 * @param string $type
40 */ 40 */
41 public function __construct(DOMElement $entry, $entryKey, $type = null) 41 public function __construct(DOMElement $entry, $entryKey, $type = null)
42 { 42 {
43 parent::__construct($entry, $entryKey, $type); 43 parent::__construct($entry, $entryKey, $type);
44 $this->xpathQueryRss = '//item[' . ($this->entryKey+1) . ']'; 44 $this->xpathQueryRss = '//item[' . ($this->entryKey + 1) . ']';
45 $this->xpathQueryRdf = '//rss:item[' . ($this->entryKey+1) . ']'; 45 $this->xpathQueryRdf = '//rss:item[' . ($this->entryKey + 1) . ']';
46 46
47 $manager = Reader\Reader::getExtensionManager(); 47 $manager = Reader\Reader::getExtensionManager();
48 $extensions = [ 48 $extensions = [
49 'DublinCore\Entry', 49 'DublinCore\Entry',
50 'Content\Entry', 50 'Content\Entry',
90 return $this->data['authors']; 90 return $this->data['authors'];
91 } 91 }
92 92
93 $authors = []; 93 $authors = [];
94 $authorsDc = $this->getExtension('DublinCore')->getAuthors(); 94 $authorsDc = $this->getExtension('DublinCore')->getAuthors();
95 if (!empty($authorsDc)) { 95 if (! empty($authorsDc)) {
96 foreach ($authorsDc as $author) { 96 foreach ($authorsDc as $author) {
97 $authors[] = [ 97 $authors[] = [
98 'name' => $author['name'] 98 'name' => $author['name']
99 ]; 99 ];
100 } 100 }
149 return $this->data['content']; 149 return $this->data['content'];
150 } 150 }
151 151
152 $content = $this->getExtension('Content')->getContent(); 152 $content = $this->getExtension('Content')->getContent();
153 153
154 if (!$content) { 154 if (! $content) {
155 $content = $this->getDescription(); 155 $content = $this->getDescription();
156 } 156 }
157 157
158 if (empty($content)) { 158 if (empty($content)) {
159 $content = $this->getExtension('Atom')->getContent(); 159 $content = $this->getExtension('Atom')->getContent();
207 if ($standard === null) { 207 if ($standard === null) {
208 throw new Exception\RuntimeException( 208 throw new Exception\RuntimeException(
209 'Could not load date due to unrecognised' 209 'Could not load date due to unrecognised'
210 .' format (should follow RFC 822 or 2822):' 210 .' format (should follow RFC 822 or 2822):'
211 . $e->getMessage(), 211 . $e->getMessage(),
212 0, $e 212 0,
213 $e
213 ); 214 );
214 } 215 }
215 } 216 }
216 } 217 }
217 } 218 }
218 } 219 }
219 } 220 }
220 221
221 if (!$date) { 222 if (! $date) {
222 $date = $this->getExtension('DublinCore')->getDate(); 223 $date = $this->getExtension('DublinCore')->getDate();
223 } 224 }
224 225
225 if (!$date) { 226 if (! $date) {
226 $date = $this->getExtension('Atom')->getDateModified(); 227 $date = $this->getExtension('Atom')->getDateModified();
227 } 228 }
228 229
229 if (!$date) { 230 if (! $date) {
230 $date = null; 231 $date = null;
231 } 232 }
232 233
233 $this->data['datemodified'] = $date; 234 $this->data['datemodified'] = $date;
234 235
254 $description = $this->xpath->evaluate('string(' . $this->xpathQueryRss . '/description)'); 255 $description = $this->xpath->evaluate('string(' . $this->xpathQueryRss . '/description)');
255 } else { 256 } else {
256 $description = $this->xpath->evaluate('string(' . $this->xpathQueryRdf . '/rss:description)'); 257 $description = $this->xpath->evaluate('string(' . $this->xpathQueryRdf . '/rss:description)');
257 } 258 }
258 259
259 if (!$description) { 260 if (! $description) {
260 $description = $this->getExtension('DublinCore')->getDescription(); 261 $description = $this->getExtension('DublinCore')->getDescription();
261 } 262 }
262 263
263 if (empty($description)) { 264 if (empty($description)) {
264 $description = $this->getExtension('Atom')->getDescription(); 265 $description = $this->getExtension('Atom')->getDescription();
265 } 266 }
266 267
267 if (!$description) { 268 if (! $description) {
268 $description = null; 269 $description = null;
269 } 270 }
270 271
271 $this->data['description'] = $description; 272 $this->data['description'] = $description;
272 273
294 $enclosure->length = $nodeList->item(0)->getAttribute('length'); 295 $enclosure->length = $nodeList->item(0)->getAttribute('length');
295 $enclosure->type = $nodeList->item(0)->getAttribute('type'); 296 $enclosure->type = $nodeList->item(0)->getAttribute('type');
296 } 297 }
297 } 298 }
298 299
299 if (!$enclosure) { 300 if (! $enclosure) {
300 $enclosure = $this->getExtension('Atom')->getEnclosure(); 301 $enclosure = $this->getExtension('Atom')->getEnclosure();
301 } 302 }
302 303
303 $this->data['enclosure'] = $enclosure; 304 $this->data['enclosure'] = $enclosure;
304 305
322 && $this->getType() !== Reader\Reader::TYPE_RSS_090 323 && $this->getType() !== Reader\Reader::TYPE_RSS_090
323 ) { 324 ) {
324 $id = $this->xpath->evaluate('string(' . $this->xpathQueryRss . '/guid)'); 325 $id = $this->xpath->evaluate('string(' . $this->xpathQueryRss . '/guid)');
325 } 326 }
326 327
327 if (!$id) { 328 if (! $id) {
328 $id = $this->getExtension('DublinCore')->getId(); 329 $id = $this->getExtension('DublinCore')->getId();
329 } 330 }
330 331
331 if (empty($id)) { 332 if (empty($id)) {
332 $id = $this->getExtension('Atom')->getId(); 333 $id = $this->getExtension('Atom')->getId();
333 } 334 }
334 335
335 if (!$id) { 336 if (! $id) {
336 if ($this->getPermalink()) { 337 if ($this->getPermalink()) {
337 $id = $this->getPermalink(); 338 $id = $this->getPermalink();
338 } elseif ($this->getTitle()) { 339 } elseif ($this->getTitle()) {
339 $id = $this->getTitle(); 340 $id = $this->getTitle();
340 } else { 341 } else {
353 * @param int $index 354 * @param int $index
354 * @return string 355 * @return string
355 */ 356 */
356 public function getLink($index = 0) 357 public function getLink($index = 0)
357 { 358 {
358 if (!array_key_exists('links', $this->data)) { 359 if (! array_key_exists('links', $this->data)) {
359 $this->getLinks(); 360 $this->getLinks();
360 } 361 }
361 362
362 if (isset($this->data['links'][$index])) { 363 if (isset($this->data['links'][$index])) {
363 return $this->data['links'][$index]; 364 return $this->data['links'][$index];
384 $list = $this->xpath->query($this->xpathQueryRss . '//link'); 385 $list = $this->xpath->query($this->xpathQueryRss . '//link');
385 } else { 386 } else {
386 $list = $this->xpath->query($this->xpathQueryRdf . '//rss:link'); 387 $list = $this->xpath->query($this->xpathQueryRdf . '//rss:link');
387 } 388 }
388 389
389 if (!$list->length) { 390 if (! $list->length) {
390 $links = $this->getExtension('Atom')->getLinks(); 391 $links = $this->getExtension('Atom')->getLinks();
391 } else { 392 } else {
392 foreach ($list as $link) { 393 foreach ($list as $link) {
393 $links[] = $link->nodeValue; 394 $links[] = $link->nodeValue;
394 } 395 }
468 $title = $this->xpath->evaluate('string(' . $this->xpathQueryRss . '/title)'); 469 $title = $this->xpath->evaluate('string(' . $this->xpathQueryRss . '/title)');
469 } else { 470 } else {
470 $title = $this->xpath->evaluate('string(' . $this->xpathQueryRdf . '/rss:title)'); 471 $title = $this->xpath->evaluate('string(' . $this->xpathQueryRdf . '/rss:title)');
471 } 472 }
472 473
473 if (!$title) { 474 if (! $title) {
474 $title = $this->getExtension('DublinCore')->getTitle(); 475 $title = $this->getExtension('DublinCore')->getTitle();
475 } 476 }
476 477
477 if (!$title) { 478 if (! $title) {
478 $title = $this->getExtension('Atom')->getTitle(); 479 $title = $this->getExtension('Atom')->getTitle();
479 } 480 }
480 481
481 if (!$title) { 482 if (! $title) {
482 $title = null; 483 $title = null;
483 } 484 }
484 485
485 $this->data['title'] = $title; 486 $this->data['title'] = $title;
486 487
498 return $this->data['commentcount']; 499 return $this->data['commentcount'];
499 } 500 }
500 501
501 $commentcount = $this->getExtension('Slash')->getCommentCount(); 502 $commentcount = $this->getExtension('Slash')->getCommentCount();
502 503
503 if (!$commentcount) { 504 if (! $commentcount) {
504 $commentcount = $this->getExtension('Thread')->getCommentCount(); 505 $commentcount = $this->getExtension('Thread')->getCommentCount();
505 } 506 }
506 507
507 if (!$commentcount) { 508 if (! $commentcount) {
508 $commentcount = $this->getExtension('Atom')->getCommentCount(); 509 $commentcount = $this->getExtension('Atom')->getCommentCount();
509 } 510 }
510 511
511 if (!$commentcount) { 512 if (! $commentcount) {
512 $commentcount = null; 513 $commentcount = null;
513 } 514 }
514 515
515 $this->data['commentcount'] = $commentcount; 516 $this->data['commentcount'] = $commentcount;
516 517
534 && $this->getType() !== Reader\Reader::TYPE_RSS_090 535 && $this->getType() !== Reader\Reader::TYPE_RSS_090
535 ) { 536 ) {
536 $commentlink = $this->xpath->evaluate('string(' . $this->xpathQueryRss . '/comments)'); 537 $commentlink = $this->xpath->evaluate('string(' . $this->xpathQueryRss . '/comments)');
537 } 538 }
538 539
539 if (!$commentlink) { 540 if (! $commentlink) {
540 $commentlink = $this->getExtension('Atom')->getCommentLink(); 541 $commentlink = $this->getExtension('Atom')->getCommentLink();
541 } 542 }
542 543
543 if (!$commentlink) { 544 if (! $commentlink) {
544 $commentlink = null; 545 $commentlink = null;
545 } 546 }
546 547
547 $this->data['commentlink'] = $commentlink; 548 $this->data['commentlink'] = $commentlink;
548 549
560 return $this->data['commentfeedlink']; 561 return $this->data['commentfeedlink'];
561 } 562 }
562 563
563 $commentfeedlink = $this->getExtension('WellFormedWeb')->getCommentFeedLink(); 564 $commentfeedlink = $this->getExtension('WellFormedWeb')->getCommentFeedLink();
564 565
565 if (!$commentfeedlink) { 566 if (! $commentfeedlink) {
566 $commentfeedlink = $this->getExtension('Atom')->getCommentFeedLink('rss'); 567 $commentfeedlink = $this->getExtension('Atom')->getCommentFeedLink('rss');
567 } 568 }
568 569
569 if (!$commentfeedlink) { 570 if (! $commentfeedlink) {
570 $commentfeedlink = $this->getExtension('Atom')->getCommentFeedLink('rdf'); 571 $commentfeedlink = $this->getExtension('Atom')->getCommentFeedLink('rdf');
571 } 572 }
572 573
573 if (!$commentfeedlink) { 574 if (! $commentfeedlink) {
574 $commentfeedlink = null; 575 $commentfeedlink = null;
575 } 576 }
576 577
577 $this->data['commentfeedlink'] = $commentfeedlink; 578 $this->data['commentfeedlink'] = $commentfeedlink;
578 579