Mercurial > hg > cmmr2012-drupal-site
comparison vendor/zendframework/zend-feed/src/Reader/Extension/Atom/Entry.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 |
---|---|
49 } | 49 } |
50 | 50 |
51 $authors = []; | 51 $authors = []; |
52 $list = $this->getXpath()->query($this->getXpathPrefix() . '//atom:author'); | 52 $list = $this->getXpath()->query($this->getXpathPrefix() . '//atom:author'); |
53 | 53 |
54 if (!$list->length) { | 54 if (! $list->length) { |
55 /** | 55 /** |
56 * TODO: Limit query to feed level els only! | 56 * TODO: Limit query to feed level els only! |
57 */ | 57 */ |
58 $list = $this->getXpath()->query('//atom:author'); | 58 $list = $this->getXpath()->query('//atom:author'); |
59 } | 59 } |
60 | 60 |
61 if ($list->length) { | 61 if ($list->length) { |
62 foreach ($list as $author) { | 62 foreach ($list as $author) { |
63 $author = $this->getAuthorFromElement($author); | 63 $author = $this->getAuthorFromElement($author); |
64 if (!empty($author)) { | 64 if (! empty($author)) { |
65 $authors[] = $author; | 65 $authors[] = $author; |
66 } | 66 } |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
119 ); | 119 ); |
120 break; | 120 break; |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 if (!$content) { | 124 if (! $content) { |
125 $content = $this->getDescription(); | 125 $content = $this->getDescription(); |
126 } | 126 } |
127 | 127 |
128 $this->data['content'] = trim($content); | 128 $this->data['content'] = trim($content); |
129 | 129 |
137 * @param $prefix | 137 * @param $prefix |
138 * @return mixed | 138 * @return mixed |
139 */ | 139 */ |
140 protected function collectXhtml($xhtml, $prefix) | 140 protected function collectXhtml($xhtml, $prefix) |
141 { | 141 { |
142 if (!empty($prefix)) { | 142 if (! empty($prefix)) { |
143 $prefix = $prefix . ':'; | 143 $prefix = $prefix . ':'; |
144 } | 144 } |
145 $matches = [ | 145 $matches = [ |
146 "/<\?xml[^<]*>[^<]*<" . $prefix . "div[^<]*/", | 146 "/<\?xml[^<]*>[^<]*<" . $prefix . "div[^<]*/", |
147 "/<\/" . $prefix . "div>\s*$/" | 147 "/<\/" . $prefix . "div>\s*$/" |
148 ]; | 148 ]; |
149 $xhtml = preg_replace($matches, '', $xhtml); | 149 $xhtml = preg_replace($matches, '', $xhtml); |
150 if (!empty($prefix)) { | 150 if (! empty($prefix)) { |
151 $xhtml = preg_replace("/(<[\/]?)" . $prefix . "([a-zA-Z]+)/", '$1$2', $xhtml); | 151 $xhtml = preg_replace("/(<[\/]?)" . $prefix . "([a-zA-Z]+)/", '$1$2', $xhtml); |
152 } | 152 } |
153 return $xhtml; | 153 return $xhtml; |
154 } | 154 } |
155 | 155 |
220 return $this->data['description']; | 220 return $this->data['description']; |
221 } | 221 } |
222 | 222 |
223 $description = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:summary)'); | 223 $description = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:summary)'); |
224 | 224 |
225 if (!$description) { | 225 if (! $description) { |
226 $description = null; | 226 $description = null; |
227 } | 227 } |
228 | 228 |
229 $this->data['description'] = $description; | 229 $this->data['description'] = $description; |
230 | 230 |
269 return $this->data['id']; | 269 return $this->data['id']; |
270 } | 270 } |
271 | 271 |
272 $id = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:id)'); | 272 $id = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:id)'); |
273 | 273 |
274 if (!$id) { | 274 if (! $id) { |
275 if ($this->getPermalink()) { | 275 if ($this->getPermalink()) { |
276 $id = $this->getPermalink(); | 276 $id = $this->getPermalink(); |
277 } elseif ($this->getTitle()) { | 277 } elseif ($this->getTitle()) { |
278 $id = $this->getTitle(); | 278 $id = $this->getTitle(); |
279 } else { | 279 } else { |
302 . $this->getXpathPrefix() | 302 . $this->getXpathPrefix() |
303 . '/@xml:base[1]' | 303 . '/@xml:base[1]' |
304 . ')' | 304 . ')' |
305 ); | 305 ); |
306 | 306 |
307 if (!$baseUrl) { | 307 if (! $baseUrl) { |
308 $baseUrl = $this->getXpath()->evaluate('string(//@xml:base[1])'); | 308 $baseUrl = $this->getXpath()->evaluate('string(//@xml:base[1])'); |
309 } | 309 } |
310 | 310 |
311 if (!$baseUrl) { | 311 if (! $baseUrl) { |
312 $baseUrl = null; | 312 $baseUrl = null; |
313 } | 313 } |
314 | 314 |
315 $this->data['baseUrl'] = $baseUrl; | 315 $this->data['baseUrl'] = $baseUrl; |
316 | 316 |
323 * @param int $index | 323 * @param int $index |
324 * @return string | 324 * @return string |
325 */ | 325 */ |
326 public function getLink($index = 0) | 326 public function getLink($index = 0) |
327 { | 327 { |
328 if (!array_key_exists('links', $this->data)) { | 328 if (! array_key_exists('links', $this->data)) { |
329 $this->getLinks(); | 329 $this->getLinks(); |
330 } | 330 } |
331 | 331 |
332 if (isset($this->data['links'][$index])) { | 332 if (isset($this->data['links'][$index])) { |
333 return $this->data['links'][$index]; | 333 return $this->data['links'][$index]; |
386 return $this->data['title']; | 386 return $this->data['title']; |
387 } | 387 } |
388 | 388 |
389 $title = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:title)'); | 389 $title = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:title)'); |
390 | 390 |
391 if (!$title) { | 391 if (! $title) { |
392 $title = null; | 392 $title = null; |
393 } | 393 } |
394 | 394 |
395 $this->data['title'] = $title; | 395 $this->data['title'] = $title; |
396 | 396 |
552 * @param $link | 552 * @param $link |
553 * @return string | 553 * @return string |
554 */ | 554 */ |
555 protected function absolutiseUri($link) | 555 protected function absolutiseUri($link) |
556 { | 556 { |
557 if (!Uri::factory($link)->isAbsolute()) { | 557 if (! Uri::factory($link)->isAbsolute()) { |
558 if ($this->getBaseUrl() !== null) { | 558 if ($this->getBaseUrl() !== null) { |
559 $link = $this->getBaseUrl() . $link; | 559 $link = $this->getBaseUrl() . $link; |
560 if (!Uri::factory($link)->isValid()) { | 560 if (! Uri::factory($link)->isValid()) { |
561 $link = null; | 561 $link = null; |
562 } | 562 } |
563 } | 563 } |
564 } | 564 } |
565 return $link; | 565 return $link; |
621 { | 621 { |
622 $dom = $this->getDomDocument(); | 622 $dom = $this->getDomDocument(); |
623 $prefixAtom03 = $dom->lookupPrefix(Reader\Reader::NAMESPACE_ATOM_03); | 623 $prefixAtom03 = $dom->lookupPrefix(Reader\Reader::NAMESPACE_ATOM_03); |
624 $prefixAtom10 = $dom->lookupPrefix(Reader\Reader::NAMESPACE_ATOM_10); | 624 $prefixAtom10 = $dom->lookupPrefix(Reader\Reader::NAMESPACE_ATOM_10); |
625 if ($dom->isDefaultNamespace(Reader\Reader::NAMESPACE_ATOM_03) | 625 if ($dom->isDefaultNamespace(Reader\Reader::NAMESPACE_ATOM_03) |
626 || !empty($prefixAtom03)) { | 626 || ! empty($prefixAtom03)) { |
627 return Reader\Reader::TYPE_ATOM_03; | 627 return Reader\Reader::TYPE_ATOM_03; |
628 } | 628 } |
629 if ($dom->isDefaultNamespace(Reader\Reader::NAMESPACE_ATOM_10) | 629 if ($dom->isDefaultNamespace(Reader\Reader::NAMESPACE_ATOM_10) |
630 || !empty($prefixAtom10)) { | 630 || ! empty($prefixAtom10)) { |
631 return Reader\Reader::TYPE_ATOM_10; | 631 return Reader\Reader::TYPE_ATOM_10; |
632 } | 632 } |
633 } | 633 } |
634 } | 634 } |