1 |
efrain |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
declare(strict_types=1);
|
|
|
4 |
/**
|
|
|
5 |
* SimplePie
|
|
|
6 |
*
|
|
|
7 |
* A PHP-Based RSS and Atom Feed Framework.
|
|
|
8 |
* Takes the hard work out of managing a complete RSS/Atom solution.
|
|
|
9 |
*
|
|
|
10 |
* Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
|
|
|
11 |
* All rights reserved.
|
|
|
12 |
*
|
|
|
13 |
* Redistribution and use in source and binary forms, with or without modification, are
|
|
|
14 |
* permitted provided that the following conditions are met:
|
|
|
15 |
*
|
|
|
16 |
* * Redistributions of source code must retain the above copyright notice, this list of
|
|
|
17 |
* conditions and the following disclaimer.
|
|
|
18 |
*
|
|
|
19 |
* * Redistributions in binary form must reproduce the above copyright notice, this list
|
|
|
20 |
* of conditions and the following disclaimer in the documentation and/or other materials
|
|
|
21 |
* provided with the distribution.
|
|
|
22 |
*
|
|
|
23 |
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
|
|
|
24 |
* to endorse or promote products derived from this software without specific prior
|
|
|
25 |
* written permission.
|
|
|
26 |
*
|
|
|
27 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
|
|
|
28 |
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
|
29 |
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
|
|
|
30 |
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
31 |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
32 |
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
33 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
34 |
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
35 |
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
36 |
*
|
|
|
37 |
* @package SimplePie
|
|
|
38 |
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
|
|
|
39 |
* @author Ryan Parman
|
|
|
40 |
* @author Sam Sneddon
|
|
|
41 |
* @author Ryan McCue
|
|
|
42 |
* @link http://simplepie.org/ SimplePie
|
|
|
43 |
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
|
|
44 |
*/
|
|
|
45 |
|
|
|
46 |
namespace SimplePie;
|
|
|
47 |
|
|
|
48 |
/**
|
|
|
49 |
* Handles `<atom:source>`
|
|
|
50 |
*
|
|
|
51 |
* Used by {@see \SimplePie\Item::get_source()}
|
|
|
52 |
*
|
|
|
53 |
* This class can be overloaded with {@see \SimplePie::set_source_class()}
|
|
|
54 |
*
|
|
|
55 |
* @package SimplePie
|
|
|
56 |
* @subpackage API
|
|
|
57 |
*/
|
|
|
58 |
class Source implements RegistryAware
|
|
|
59 |
{
|
|
|
60 |
public $item;
|
|
|
61 |
public $data = [];
|
|
|
62 |
protected $registry;
|
|
|
63 |
|
|
|
64 |
public function __construct($item, $data)
|
|
|
65 |
{
|
|
|
66 |
$this->item = $item;
|
|
|
67 |
$this->data = $data;
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
public function set_registry(\SimplePie\Registry $registry)/* : void */
|
|
|
71 |
{
|
|
|
72 |
$this->registry = $registry;
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
public function __toString()
|
|
|
76 |
{
|
|
|
77 |
return md5(serialize($this->data));
|
|
|
78 |
}
|
|
|
79 |
|
|
|
80 |
public function get_source_tags($namespace, $tag)
|
|
|
81 |
{
|
|
|
82 |
if (isset($this->data['child'][$namespace][$tag])) {
|
|
|
83 |
return $this->data['child'][$namespace][$tag];
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
return null;
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
public function get_base($element = [])
|
|
|
90 |
{
|
|
|
91 |
return $this->item->get_base($element);
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
public function sanitize($data, $type, $base = '')
|
|
|
95 |
{
|
|
|
96 |
return $this->item->sanitize($data, $type, $base);
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
public function get_item()
|
|
|
100 |
{
|
|
|
101 |
return $this->item;
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
public function get_title()
|
|
|
105 |
{
|
|
|
106 |
if ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'title')) {
|
|
|
107 |
return $this->sanitize($return[0]['data'], $this->registry->call(Misc::class, 'atom_10_construct_type', [$return[0]['attribs']]), $this->get_base($return[0]));
|
|
|
108 |
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_03, 'title')) {
|
|
|
109 |
return $this->sanitize($return[0]['data'], $this->registry->call(Misc::class, 'atom_03_construct_type', [$return[0]['attribs']]), $this->get_base($return[0]));
|
|
|
110 |
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_RSS_10, 'title')) {
|
|
|
111 |
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
|
|
|
112 |
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_RSS_090, 'title')) {
|
|
|
113 |
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
|
|
|
114 |
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_RSS_20, 'title')) {
|
|
|
115 |
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
|
|
|
116 |
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_DC_11, 'title')) {
|
|
|
117 |
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
|
|
|
118 |
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_DC_10, 'title')) {
|
|
|
119 |
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
|
|
|
120 |
}
|
|
|
121 |
|
|
|
122 |
return null;
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
public function get_category($key = 0)
|
|
|
126 |
{
|
|
|
127 |
$categories = $this->get_categories();
|
|
|
128 |
if (isset($categories[$key])) {
|
|
|
129 |
return $categories[$key];
|
|
|
130 |
}
|
|
|
131 |
|
|
|
132 |
return null;
|
|
|
133 |
}
|
|
|
134 |
|
|
|
135 |
public function get_categories()
|
|
|
136 |
{
|
|
|
137 |
$categories = [];
|
|
|
138 |
|
|
|
139 |
foreach ((array) $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'category') as $category) {
|
|
|
140 |
$term = null;
|
|
|
141 |
$scheme = null;
|
|
|
142 |
$label = null;
|
|
|
143 |
if (isset($category['attribs']['']['term'])) {
|
|
|
144 |
$term = $this->sanitize($category['attribs']['']['term'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
|
|
|
145 |
}
|
|
|
146 |
if (isset($category['attribs']['']['scheme'])) {
|
|
|
147 |
$scheme = $this->sanitize($category['attribs']['']['scheme'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
|
|
|
148 |
}
|
|
|
149 |
if (isset($category['attribs']['']['label'])) {
|
|
|
150 |
$label = $this->sanitize($category['attribs']['']['label'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
|
|
|
151 |
}
|
|
|
152 |
$categories[] = $this->registry->create(Category::class, [$term, $scheme, $label]);
|
|
|
153 |
}
|
|
|
154 |
foreach ((array) $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_RSS_20, 'category') as $category) {
|
|
|
155 |
// This is really the label, but keep this as the term also for BC.
|
|
|
156 |
// Label will also work on retrieving because that falls back to term.
|
|
|
157 |
$term = $this->sanitize($category['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
|
|
|
158 |
if (isset($category['attribs']['']['domain'])) {
|
|
|
159 |
$scheme = $this->sanitize($category['attribs']['']['domain'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
|
|
|
160 |
} else {
|
|
|
161 |
$scheme = null;
|
|
|
162 |
}
|
|
|
163 |
$categories[] = $this->registry->create(Category::class, [$term, $scheme, null]);
|
|
|
164 |
}
|
|
|
165 |
foreach ((array) $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_DC_11, 'subject') as $category) {
|
|
|
166 |
$categories[] = $this->registry->create(Category::class, [$this->sanitize($category['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT), null, null]);
|
|
|
167 |
}
|
|
|
168 |
foreach ((array) $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_DC_10, 'subject') as $category) {
|
|
|
169 |
$categories[] = $this->registry->create(Category::class, [$this->sanitize($category['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT), null, null]);
|
|
|
170 |
}
|
|
|
171 |
|
|
|
172 |
if (!empty($categories)) {
|
|
|
173 |
return array_unique($categories);
|
|
|
174 |
}
|
|
|
175 |
|
|
|
176 |
return null;
|
|
|
177 |
}
|
|
|
178 |
|
|
|
179 |
public function get_author($key = 0)
|
|
|
180 |
{
|
|
|
181 |
$authors = $this->get_authors();
|
|
|
182 |
if (isset($authors[$key])) {
|
|
|
183 |
return $authors[$key];
|
|
|
184 |
}
|
|
|
185 |
|
|
|
186 |
return null;
|
|
|
187 |
}
|
|
|
188 |
|
|
|
189 |
public function get_authors()
|
|
|
190 |
{
|
|
|
191 |
$authors = [];
|
|
|
192 |
foreach ((array) $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'author') as $author) {
|
|
|
193 |
$name = null;
|
|
|
194 |
$uri = null;
|
|
|
195 |
$email = null;
|
|
|
196 |
if (isset($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['name'][0]['data'])) {
|
|
|
197 |
$name = $this->sanitize($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['name'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
|
|
|
198 |
}
|
|
|
199 |
if (isset($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'])) {
|
|
|
200 |
$uri = $this->sanitize($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]));
|
|
|
201 |
}
|
|
|
202 |
if (isset($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'])) {
|
|
|
203 |
$email = $this->sanitize($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
|
|
|
204 |
}
|
|
|
205 |
if ($name !== null || $email !== null || $uri !== null) {
|
|
|
206 |
$authors[] = $this->registry->create(Author::class, [$name, $uri, $email]);
|
|
|
207 |
}
|
|
|
208 |
}
|
|
|
209 |
if ($author = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_03, 'author')) {
|
|
|
210 |
$name = null;
|
|
|
211 |
$url = null;
|
|
|
212 |
$email = null;
|
|
|
213 |
if (isset($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['name'][0]['data'])) {
|
|
|
214 |
$name = $this->sanitize($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['name'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
|
|
|
215 |
}
|
|
|
216 |
if (isset($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'])) {
|
|
|
217 |
$url = $this->sanitize($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]));
|
|
|
218 |
}
|
|
|
219 |
if (isset($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'])) {
|
|
|
220 |
$email = $this->sanitize($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
|
|
|
221 |
}
|
|
|
222 |
if ($name !== null || $email !== null || $url !== null) {
|
|
|
223 |
$authors[] = $this->registry->create(Author::class, [$name, $url, $email]);
|
|
|
224 |
}
|
|
|
225 |
}
|
|
|
226 |
foreach ((array) $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_DC_11, 'creator') as $author) {
|
|
|
227 |
$authors[] = $this->registry->create(Author::class, [$this->sanitize($author['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT), null, null]);
|
|
|
228 |
}
|
|
|
229 |
foreach ((array) $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_DC_10, 'creator') as $author) {
|
|
|
230 |
$authors[] = $this->registry->create(Author::class, [$this->sanitize($author['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT), null, null]);
|
|
|
231 |
}
|
|
|
232 |
foreach ((array) $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'author') as $author) {
|
|
|
233 |
$authors[] = $this->registry->create(Author::class, [$this->sanitize($author['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT), null, null]);
|
|
|
234 |
}
|
|
|
235 |
|
|
|
236 |
if (!empty($authors)) {
|
|
|
237 |
return array_unique($authors);
|
|
|
238 |
}
|
|
|
239 |
|
|
|
240 |
return null;
|
|
|
241 |
}
|
|
|
242 |
|
|
|
243 |
public function get_contributor($key = 0)
|
|
|
244 |
{
|
|
|
245 |
$contributors = $this->get_contributors();
|
|
|
246 |
if (isset($contributors[$key])) {
|
|
|
247 |
return $contributors[$key];
|
|
|
248 |
}
|
|
|
249 |
|
|
|
250 |
return null;
|
|
|
251 |
}
|
|
|
252 |
|
|
|
253 |
public function get_contributors()
|
|
|
254 |
{
|
|
|
255 |
$contributors = [];
|
|
|
256 |
foreach ((array) $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'contributor') as $contributor) {
|
|
|
257 |
$name = null;
|
|
|
258 |
$uri = null;
|
|
|
259 |
$email = null;
|
|
|
260 |
if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['name'][0]['data'])) {
|
|
|
261 |
$name = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['name'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
|
|
|
262 |
}
|
|
|
263 |
if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'])) {
|
|
|
264 |
$uri = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]));
|
|
|
265 |
}
|
|
|
266 |
if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'])) {
|
|
|
267 |
$email = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
|
|
|
268 |
}
|
|
|
269 |
if ($name !== null || $email !== null || $uri !== null) {
|
|
|
270 |
$contributors[] = $this->registry->create(Author::class, [$name, $uri, $email]);
|
|
|
271 |
}
|
|
|
272 |
}
|
|
|
273 |
foreach ((array) $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_03, 'contributor') as $contributor) {
|
|
|
274 |
$name = null;
|
|
|
275 |
$url = null;
|
|
|
276 |
$email = null;
|
|
|
277 |
if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['name'][0]['data'])) {
|
|
|
278 |
$name = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['name'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
|
|
|
279 |
}
|
|
|
280 |
if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'])) {
|
|
|
281 |
$url = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]));
|
|
|
282 |
}
|
|
|
283 |
if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'])) {
|
|
|
284 |
$email = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
|
|
|
285 |
}
|
|
|
286 |
if ($name !== null || $email !== null || $url !== null) {
|
|
|
287 |
$contributors[] = $this->registry->create(Author::class, [$name, $url, $email]);
|
|
|
288 |
}
|
|
|
289 |
}
|
|
|
290 |
|
|
|
291 |
if (!empty($contributors)) {
|
|
|
292 |
return array_unique($contributors);
|
|
|
293 |
}
|
|
|
294 |
|
|
|
295 |
return null;
|
|
|
296 |
}
|
|
|
297 |
|
|
|
298 |
public function get_link($key = 0, $rel = 'alternate')
|
|
|
299 |
{
|
|
|
300 |
$links = $this->get_links($rel);
|
|
|
301 |
if (isset($links[$key])) {
|
|
|
302 |
return $links[$key];
|
|
|
303 |
}
|
|
|
304 |
|
|
|
305 |
return null;
|
|
|
306 |
}
|
|
|
307 |
|
|
|
308 |
/**
|
|
|
309 |
* Added for parity between the parent-level and the item/entry-level.
|
|
|
310 |
*/
|
|
|
311 |
public function get_permalink()
|
|
|
312 |
{
|
|
|
313 |
return $this->get_link(0);
|
|
|
314 |
}
|
|
|
315 |
|
|
|
316 |
public function get_links($rel = 'alternate')
|
|
|
317 |
{
|
|
|
318 |
if (!isset($this->data['links'])) {
|
|
|
319 |
$this->data['links'] = [];
|
|
|
320 |
if ($links = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'link')) {
|
|
|
321 |
foreach ($links as $link) {
|
|
|
322 |
if (isset($link['attribs']['']['href'])) {
|
|
|
323 |
$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
|
|
|
324 |
$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($link));
|
|
|
325 |
}
|
|
|
326 |
}
|
|
|
327 |
}
|
|
|
328 |
if ($links = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_03, 'link')) {
|
|
|
329 |
foreach ($links as $link) {
|
|
|
330 |
if (isset($link['attribs']['']['href'])) {
|
|
|
331 |
$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
|
|
|
332 |
$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($link));
|
|
|
333 |
}
|
|
|
334 |
}
|
|
|
335 |
}
|
|
|
336 |
if ($links = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_RSS_10, 'link')) {
|
|
|
337 |
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($links[0]));
|
|
|
338 |
}
|
|
|
339 |
if ($links = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_RSS_090, 'link')) {
|
|
|
340 |
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($links[0]));
|
|
|
341 |
}
|
|
|
342 |
if ($links = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_RSS_20, 'link')) {
|
|
|
343 |
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($links[0]));
|
|
|
344 |
}
|
|
|
345 |
|
|
|
346 |
$keys = array_keys($this->data['links']);
|
|
|
347 |
foreach ($keys as $key) {
|
|
|
348 |
if ($this->registry->call(Misc::class, 'is_isegment_nz_nc', [$key])) {
|
|
|
349 |
if (isset($this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key])) {
|
|
|
350 |
$this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key]);
|
|
|
351 |
$this->data['links'][$key] =& $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key];
|
|
|
352 |
} else {
|
|
|
353 |
$this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
|
|
|
354 |
}
|
|
|
355 |
} elseif (substr($key, 0, 41) === \SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY) {
|
|
|
356 |
$this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
|
|
|
357 |
}
|
|
|
358 |
$this->data['links'][$key] = array_unique($this->data['links'][$key]);
|
|
|
359 |
}
|
|
|
360 |
}
|
|
|
361 |
|
|
|
362 |
if (isset($this->data['links'][$rel])) {
|
|
|
363 |
return $this->data['links'][$rel];
|
|
|
364 |
}
|
|
|
365 |
|
|
|
366 |
return null;
|
|
|
367 |
}
|
|
|
368 |
|
|
|
369 |
public function get_description()
|
|
|
370 |
{
|
|
|
371 |
if ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'subtitle')) {
|
|
|
372 |
return $this->sanitize($return[0]['data'], $this->registry->call(Misc::class, 'atom_10_construct_type', [$return[0]['attribs']]), $this->get_base($return[0]));
|
|
|
373 |
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_03, 'tagline')) {
|
|
|
374 |
return $this->sanitize($return[0]['data'], $this->registry->call(Misc::class, 'atom_03_construct_type', [$return[0]['attribs']]), $this->get_base($return[0]));
|
|
|
375 |
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_RSS_10, 'description')) {
|
|
|
376 |
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
|
|
|
377 |
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_RSS_090, 'description')) {
|
|
|
378 |
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
|
|
|
379 |
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_RSS_20, 'description')) {
|
|
|
380 |
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
|
|
|
381 |
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_DC_11, 'description')) {
|
|
|
382 |
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
|
|
|
383 |
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_DC_10, 'description')) {
|
|
|
384 |
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
|
|
|
385 |
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'summary')) {
|
|
|
386 |
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_HTML, $this->get_base($return[0]));
|
|
|
387 |
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'subtitle')) {
|
|
|
388 |
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_HTML, $this->get_base($return[0]));
|
|
|
389 |
}
|
|
|
390 |
|
|
|
391 |
return null;
|
|
|
392 |
}
|
|
|
393 |
|
|
|
394 |
public function get_copyright()
|
|
|
395 |
{
|
|
|
396 |
if ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'rights')) {
|
|
|
397 |
return $this->sanitize($return[0]['data'], $this->registry->call(Misc::class, 'atom_10_construct_type', [$return[0]['attribs']]), $this->get_base($return[0]));
|
|
|
398 |
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_03, 'copyright')) {
|
|
|
399 |
return $this->sanitize($return[0]['data'], $this->registry->call(Misc::class, 'atom_03_construct_type', [$return[0]['attribs']]), $this->get_base($return[0]));
|
|
|
400 |
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_RSS_20, 'copyright')) {
|
|
|
401 |
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
|
|
|
402 |
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_DC_11, 'rights')) {
|
|
|
403 |
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
|
|
|
404 |
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_DC_10, 'rights')) {
|
|
|
405 |
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
|
|
|
406 |
}
|
|
|
407 |
|
|
|
408 |
return null;
|
|
|
409 |
}
|
|
|
410 |
|
|
|
411 |
public function get_language()
|
|
|
412 |
{
|
|
|
413 |
if ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_RSS_20, 'language')) {
|
|
|
414 |
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
|
|
|
415 |
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_DC_11, 'language')) {
|
|
|
416 |
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
|
|
|
417 |
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_DC_10, 'language')) {
|
|
|
418 |
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
|
|
|
419 |
} elseif (isset($this->data['xml_lang'])) {
|
|
|
420 |
return $this->sanitize($this->data['xml_lang'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
|
|
|
421 |
}
|
|
|
422 |
|
|
|
423 |
return null;
|
|
|
424 |
}
|
|
|
425 |
|
|
|
426 |
public function get_latitude()
|
|
|
427 |
{
|
|
|
428 |
if ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_W3C_BASIC_GEO, 'lat')) {
|
|
|
429 |
return (float) $return[0]['data'];
|
|
|
430 |
} elseif (($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) {
|
|
|
431 |
return (float) $match[1];
|
|
|
432 |
}
|
|
|
433 |
|
|
|
434 |
return null;
|
|
|
435 |
}
|
|
|
436 |
|
|
|
437 |
public function get_longitude()
|
|
|
438 |
{
|
|
|
439 |
if ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_W3C_BASIC_GEO, 'long')) {
|
|
|
440 |
return (float) $return[0]['data'];
|
|
|
441 |
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_W3C_BASIC_GEO, 'lon')) {
|
|
|
442 |
return (float) $return[0]['data'];
|
|
|
443 |
} elseif (($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) {
|
|
|
444 |
return (float) $match[2];
|
|
|
445 |
}
|
|
|
446 |
|
|
|
447 |
return null;
|
|
|
448 |
}
|
|
|
449 |
|
|
|
450 |
public function get_image_url()
|
|
|
451 |
{
|
|
|
452 |
if ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'image')) {
|
|
|
453 |
return $this->sanitize($return[0]['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI);
|
|
|
454 |
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'logo')) {
|
|
|
455 |
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($return[0]));
|
|
|
456 |
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'icon')) {
|
|
|
457 |
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($return[0]));
|
|
|
458 |
}
|
|
|
459 |
|
|
|
460 |
return null;
|
|
|
461 |
}
|
|
|
462 |
}
|
|
|
463 |
|
|
|
464 |
class_alias('SimplePie\Source', 'SimplePie_Source');
|