Edit File by line
/home/zeestwma/redstone.../wp-inclu.../SimplePi.../src
File: Source.php
<?php
[0] Fix | Delete
[1] Fix | Delete
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
[2] Fix | Delete
// SPDX-License-Identifier: BSD-3-Clause
[3] Fix | Delete
[4] Fix | Delete
declare(strict_types=1);
[5] Fix | Delete
[6] Fix | Delete
namespace SimplePie;
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Handles `<atom:source>`
[10] Fix | Delete
*
[11] Fix | Delete
* Used by {@see \SimplePie\Item::get_source()}
[12] Fix | Delete
*
[13] Fix | Delete
* This class can be overloaded with {@see \SimplePie::set_source_class()}
[14] Fix | Delete
*/
[15] Fix | Delete
class Source implements RegistryAware
[16] Fix | Delete
{
[17] Fix | Delete
/** @var Item */
[18] Fix | Delete
public $item;
[19] Fix | Delete
/** @var array<string, mixed> */
[20] Fix | Delete
public $data = [];
[21] Fix | Delete
/** @var Registry */
[22] Fix | Delete
protected $registry;
[23] Fix | Delete
[24] Fix | Delete
/**
[25] Fix | Delete
* @param array<string, mixed> $data
[26] Fix | Delete
*/
[27] Fix | Delete
public function __construct(Item $item, array $data)
[28] Fix | Delete
{
[29] Fix | Delete
$this->item = $item;
[30] Fix | Delete
$this->data = $data;
[31] Fix | Delete
}
[32] Fix | Delete
[33] Fix | Delete
/**
[34] Fix | Delete
* @return void
[35] Fix | Delete
*/
[36] Fix | Delete
public function set_registry(\SimplePie\Registry $registry)
[37] Fix | Delete
{
[38] Fix | Delete
$this->registry = $registry;
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* @return string
[43] Fix | Delete
*/
[44] Fix | Delete
public function __toString()
[45] Fix | Delete
{
[46] Fix | Delete
return md5(serialize($this->data));
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* @param string $namespace
[51] Fix | Delete
* @param string $tag
[52] Fix | Delete
* @return array<array<string, mixed>>|null
[53] Fix | Delete
*/
[54] Fix | Delete
public function get_source_tags(string $namespace, string $tag)
[55] Fix | Delete
{
[56] Fix | Delete
if (isset($this->data['child'][$namespace][$tag])) {
[57] Fix | Delete
return $this->data['child'][$namespace][$tag];
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
return null;
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
/**
[64] Fix | Delete
* @param array<string, mixed> $element
[65] Fix | Delete
* @return string
[66] Fix | Delete
*/
[67] Fix | Delete
public function get_base(array $element = [])
[68] Fix | Delete
{
[69] Fix | Delete
return $this->item->get_base($element);
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
/**
[73] Fix | Delete
* @param string $data
[74] Fix | Delete
* @param int-mask-of<SimplePie::CONSTRUCT_*> $type
[75] Fix | Delete
* @param string $base
[76] Fix | Delete
* @return string
[77] Fix | Delete
*/
[78] Fix | Delete
public function sanitize(string $data, $type, string $base = '')
[79] Fix | Delete
{
[80] Fix | Delete
return $this->item->sanitize($data, $type, $base);
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
/**
[84] Fix | Delete
* @return Item
[85] Fix | Delete
*/
[86] Fix | Delete
public function get_item()
[87] Fix | Delete
{
[88] Fix | Delete
return $this->item;
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
/**
[92] Fix | Delete
* @return string|null
[93] Fix | Delete
*/
[94] Fix | Delete
public function get_title()
[95] Fix | Delete
{
[96] Fix | Delete
if ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'title')) {
[97] Fix | Delete
return $this->sanitize($return[0]['data'], $this->registry->call(Misc::class, 'atom_10_construct_type', [$return[0]['attribs']]), $this->get_base($return[0]));
[98] Fix | Delete
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_03, 'title')) {
[99] Fix | Delete
return $this->sanitize($return[0]['data'], $this->registry->call(Misc::class, 'atom_03_construct_type', [$return[0]['attribs']]), $this->get_base($return[0]));
[100] Fix | Delete
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_RSS_10, 'title')) {
[101] Fix | Delete
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
[102] Fix | Delete
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_RSS_090, 'title')) {
[103] Fix | Delete
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
[104] Fix | Delete
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_RSS_20, 'title')) {
[105] Fix | Delete
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
[106] Fix | Delete
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_DC_11, 'title')) {
[107] Fix | Delete
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
[108] Fix | Delete
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_DC_10, 'title')) {
[109] Fix | Delete
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
return null;
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
/**
[116] Fix | Delete
* @param int $key
[117] Fix | Delete
* @return Category|null
[118] Fix | Delete
*/
[119] Fix | Delete
public function get_category(int $key = 0)
[120] Fix | Delete
{
[121] Fix | Delete
$categories = $this->get_categories();
[122] Fix | Delete
if (isset($categories[$key])) {
[123] Fix | Delete
return $categories[$key];
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
return null;
[127] Fix | Delete
}
[128] Fix | Delete
[129] Fix | Delete
/**
[130] Fix | Delete
* @return array<Category>|null
[131] Fix | Delete
*/
[132] Fix | Delete
public function get_categories()
[133] Fix | Delete
{
[134] Fix | Delete
$categories = [];
[135] Fix | Delete
[136] Fix | Delete
foreach ((array) $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'category') as $category) {
[137] Fix | Delete
$term = null;
[138] Fix | Delete
$scheme = null;
[139] Fix | Delete
$label = null;
[140] Fix | Delete
if (isset($category['attribs']['']['term'])) {
[141] Fix | Delete
$term = $this->sanitize($category['attribs']['']['term'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
[142] Fix | Delete
}
[143] Fix | Delete
if (isset($category['attribs']['']['scheme'])) {
[144] Fix | Delete
$scheme = $this->sanitize($category['attribs']['']['scheme'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
[145] Fix | Delete
}
[146] Fix | Delete
if (isset($category['attribs']['']['label'])) {
[147] Fix | Delete
$label = $this->sanitize($category['attribs']['']['label'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
[148] Fix | Delete
}
[149] Fix | Delete
$categories[] = $this->registry->create(Category::class, [$term, $scheme, $label]);
[150] Fix | Delete
}
[151] Fix | Delete
foreach ((array) $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_RSS_20, 'category') as $category) {
[152] Fix | Delete
// This is really the label, but keep this as the term also for BC.
[153] Fix | Delete
// Label will also work on retrieving because that falls back to term.
[154] Fix | Delete
$term = $this->sanitize($category['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
[155] Fix | Delete
if (isset($category['attribs']['']['domain'])) {
[156] Fix | Delete
$scheme = $this->sanitize($category['attribs']['']['domain'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
[157] Fix | Delete
} else {
[158] Fix | Delete
$scheme = null;
[159] Fix | Delete
}
[160] Fix | Delete
$categories[] = $this->registry->create(Category::class, [$term, $scheme, null]);
[161] Fix | Delete
}
[162] Fix | Delete
foreach ((array) $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_DC_11, 'subject') as $category) {
[163] Fix | Delete
$categories[] = $this->registry->create(Category::class, [$this->sanitize($category['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT), null, null]);
[164] Fix | Delete
}
[165] Fix | Delete
foreach ((array) $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_DC_10, 'subject') as $category) {
[166] Fix | Delete
$categories[] = $this->registry->create(Category::class, [$this->sanitize($category['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT), null, null]);
[167] Fix | Delete
}
[168] Fix | Delete
[169] Fix | Delete
if (!empty($categories)) {
[170] Fix | Delete
return array_unique($categories);
[171] Fix | Delete
}
[172] Fix | Delete
[173] Fix | Delete
return null;
[174] Fix | Delete
}
[175] Fix | Delete
[176] Fix | Delete
/**
[177] Fix | Delete
* @param int $key
[178] Fix | Delete
* @return Author|null
[179] Fix | Delete
*/
[180] Fix | Delete
public function get_author(int $key = 0)
[181] Fix | Delete
{
[182] Fix | Delete
$authors = $this->get_authors();
[183] Fix | Delete
if (isset($authors[$key])) {
[184] Fix | Delete
return $authors[$key];
[185] Fix | Delete
}
[186] Fix | Delete
[187] Fix | Delete
return null;
[188] Fix | Delete
}
[189] Fix | Delete
[190] Fix | Delete
/**
[191] Fix | Delete
* @return array<Author>|null
[192] Fix | Delete
*/
[193] Fix | Delete
public function get_authors()
[194] Fix | Delete
{
[195] Fix | Delete
$authors = [];
[196] Fix | Delete
foreach ((array) $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'author') as $author) {
[197] Fix | Delete
$name = null;
[198] Fix | Delete
$uri = null;
[199] Fix | Delete
$email = null;
[200] Fix | Delete
if (isset($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['name'][0]['data'])) {
[201] Fix | Delete
$name = $this->sanitize($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['name'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
[202] Fix | Delete
}
[203] Fix | Delete
if (isset($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'])) {
[204] Fix | Delete
$uri = $author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0];
[205] Fix | Delete
$uri = $this->sanitize($uri['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($uri));
[206] Fix | Delete
}
[207] Fix | Delete
if (isset($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'])) {
[208] Fix | Delete
$email = $this->sanitize($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
[209] Fix | Delete
}
[210] Fix | Delete
if ($name !== null || $email !== null || $uri !== null) {
[211] Fix | Delete
$authors[] = $this->registry->create(Author::class, [$name, $uri, $email]);
[212] Fix | Delete
}
[213] Fix | Delete
}
[214] Fix | Delete
if ($author = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_03, 'author')) {
[215] Fix | Delete
$name = null;
[216] Fix | Delete
$url = null;
[217] Fix | Delete
$email = null;
[218] Fix | Delete
if (isset($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['name'][0]['data'])) {
[219] Fix | Delete
$name = $this->sanitize($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['name'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
[220] Fix | Delete
}
[221] Fix | Delete
if (isset($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'])) {
[222] Fix | Delete
$url = $author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0];
[223] Fix | Delete
$url = $this->sanitize($url['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($url));
[224] Fix | Delete
}
[225] Fix | Delete
if (isset($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'])) {
[226] Fix | Delete
$email = $this->sanitize($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
[227] Fix | Delete
}
[228] Fix | Delete
if ($name !== null || $email !== null || $url !== null) {
[229] Fix | Delete
$authors[] = $this->registry->create(Author::class, [$name, $url, $email]);
[230] Fix | Delete
}
[231] Fix | Delete
}
[232] Fix | Delete
foreach ((array) $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_DC_11, 'creator') as $author) {
[233] Fix | Delete
$authors[] = $this->registry->create(Author::class, [$this->sanitize($author['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT), null, null]);
[234] Fix | Delete
}
[235] Fix | Delete
foreach ((array) $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_DC_10, 'creator') as $author) {
[236] Fix | Delete
$authors[] = $this->registry->create(Author::class, [$this->sanitize($author['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT), null, null]);
[237] Fix | Delete
}
[238] Fix | Delete
foreach ((array) $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'author') as $author) {
[239] Fix | Delete
$authors[] = $this->registry->create(Author::class, [$this->sanitize($author['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT), null, null]);
[240] Fix | Delete
}
[241] Fix | Delete
[242] Fix | Delete
if (!empty($authors)) {
[243] Fix | Delete
return array_unique($authors);
[244] Fix | Delete
}
[245] Fix | Delete
[246] Fix | Delete
return null;
[247] Fix | Delete
}
[248] Fix | Delete
[249] Fix | Delete
/**
[250] Fix | Delete
* @param int $key
[251] Fix | Delete
* @return Author|null
[252] Fix | Delete
*/
[253] Fix | Delete
public function get_contributor(int $key = 0)
[254] Fix | Delete
{
[255] Fix | Delete
$contributors = $this->get_contributors();
[256] Fix | Delete
if (isset($contributors[$key])) {
[257] Fix | Delete
return $contributors[$key];
[258] Fix | Delete
}
[259] Fix | Delete
[260] Fix | Delete
return null;
[261] Fix | Delete
}
[262] Fix | Delete
[263] Fix | Delete
/**
[264] Fix | Delete
* @return array<Author>|null
[265] Fix | Delete
*/
[266] Fix | Delete
public function get_contributors()
[267] Fix | Delete
{
[268] Fix | Delete
$contributors = [];
[269] Fix | Delete
foreach ((array) $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'contributor') as $contributor) {
[270] Fix | Delete
$name = null;
[271] Fix | Delete
$uri = null;
[272] Fix | Delete
$email = null;
[273] Fix | Delete
if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['name'][0]['data'])) {
[274] Fix | Delete
$name = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['name'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
[275] Fix | Delete
}
[276] Fix | Delete
if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'])) {
[277] Fix | Delete
$uri = $contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0];
[278] Fix | Delete
$uri = $this->sanitize($uri['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($uri));
[279] Fix | Delete
}
[280] Fix | Delete
if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'])) {
[281] Fix | Delete
$email = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
[282] Fix | Delete
}
[283] Fix | Delete
if ($name !== null || $email !== null || $uri !== null) {
[284] Fix | Delete
$contributors[] = $this->registry->create(Author::class, [$name, $uri, $email]);
[285] Fix | Delete
}
[286] Fix | Delete
}
[287] Fix | Delete
foreach ((array) $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_03, 'contributor') as $contributor) {
[288] Fix | Delete
$name = null;
[289] Fix | Delete
$url = null;
[290] Fix | Delete
$email = null;
[291] Fix | Delete
if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['name'][0]['data'])) {
[292] Fix | Delete
$name = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['name'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
[293] Fix | Delete
}
[294] Fix | Delete
if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'])) {
[295] Fix | Delete
$url = $contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0];
[296] Fix | Delete
$url = $this->sanitize($url['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($url));
[297] Fix | Delete
}
[298] Fix | Delete
if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'])) {
[299] Fix | Delete
$email = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
[300] Fix | Delete
}
[301] Fix | Delete
if ($name !== null || $email !== null || $url !== null) {
[302] Fix | Delete
$contributors[] = $this->registry->create(Author::class, [$name, $url, $email]);
[303] Fix | Delete
}
[304] Fix | Delete
}
[305] Fix | Delete
[306] Fix | Delete
if (!empty($contributors)) {
[307] Fix | Delete
return array_unique($contributors);
[308] Fix | Delete
}
[309] Fix | Delete
[310] Fix | Delete
return null;
[311] Fix | Delete
}
[312] Fix | Delete
[313] Fix | Delete
/**
[314] Fix | Delete
* @param int $key
[315] Fix | Delete
* @param string $rel
[316] Fix | Delete
* @return string|null
[317] Fix | Delete
*/
[318] Fix | Delete
public function get_link(int $key = 0, string $rel = 'alternate')
[319] Fix | Delete
{
[320] Fix | Delete
$links = $this->get_links($rel);
[321] Fix | Delete
if (isset($links[$key])) {
[322] Fix | Delete
return $links[$key];
[323] Fix | Delete
}
[324] Fix | Delete
[325] Fix | Delete
return null;
[326] Fix | Delete
}
[327] Fix | Delete
[328] Fix | Delete
/**
[329] Fix | Delete
* Added for parity between the parent-level and the item/entry-level.
[330] Fix | Delete
*
[331] Fix | Delete
* @return string|null
[332] Fix | Delete
*/
[333] Fix | Delete
public function get_permalink()
[334] Fix | Delete
{
[335] Fix | Delete
return $this->get_link(0);
[336] Fix | Delete
}
[337] Fix | Delete
[338] Fix | Delete
/**
[339] Fix | Delete
* @param string $rel
[340] Fix | Delete
* @return array<string>|null
[341] Fix | Delete
*/
[342] Fix | Delete
public function get_links(string $rel = 'alternate')
[343] Fix | Delete
{
[344] Fix | Delete
if (!isset($this->data['links'])) {
[345] Fix | Delete
$this->data['links'] = [];
[346] Fix | Delete
if ($links = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'link')) {
[347] Fix | Delete
foreach ($links as $link) {
[348] Fix | Delete
if (isset($link['attribs']['']['href'])) {
[349] Fix | Delete
$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
[350] Fix | Delete
$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($link));
[351] Fix | Delete
}
[352] Fix | Delete
}
[353] Fix | Delete
}
[354] Fix | Delete
if ($links = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_03, 'link')) {
[355] Fix | Delete
foreach ($links as $link) {
[356] Fix | Delete
if (isset($link['attribs']['']['href'])) {
[357] Fix | Delete
$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
[358] Fix | Delete
$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($link));
[359] Fix | Delete
}
[360] Fix | Delete
}
[361] Fix | Delete
}
[362] Fix | Delete
if ($links = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_RSS_10, 'link')) {
[363] Fix | Delete
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($links[0]));
[364] Fix | Delete
}
[365] Fix | Delete
if ($links = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_RSS_090, 'link')) {
[366] Fix | Delete
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($links[0]));
[367] Fix | Delete
}
[368] Fix | Delete
if ($links = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_RSS_20, 'link')) {
[369] Fix | Delete
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($links[0]));
[370] Fix | Delete
}
[371] Fix | Delete
[372] Fix | Delete
$keys = array_keys($this->data['links']);
[373] Fix | Delete
foreach ($keys as $key) {
[374] Fix | Delete
$key = (string) $key;
[375] Fix | Delete
[376] Fix | Delete
if ($this->registry->call(Misc::class, 'is_isegment_nz_nc', [$key])) {
[377] Fix | Delete
if (isset($this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key])) {
[378] Fix | Delete
$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]);
[379] Fix | Delete
$this->data['links'][$key] = &$this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key];
[380] Fix | Delete
} else {
[381] Fix | Delete
$this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key] = &$this->data['links'][$key];
[382] Fix | Delete
}
[383] Fix | Delete
} elseif (substr($key, 0, 41) === \SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY) {
[384] Fix | Delete
$this->data['links'][substr($key, 41)] = &$this->data['links'][$key];
[385] Fix | Delete
}
[386] Fix | Delete
$this->data['links'][$key] = array_unique($this->data['links'][$key]);
[387] Fix | Delete
}
[388] Fix | Delete
}
[389] Fix | Delete
[390] Fix | Delete
if (isset($this->data['links'][$rel])) {
[391] Fix | Delete
return $this->data['links'][$rel];
[392] Fix | Delete
}
[393] Fix | Delete
[394] Fix | Delete
return null;
[395] Fix | Delete
}
[396] Fix | Delete
[397] Fix | Delete
/**
[398] Fix | Delete
* @return string|null
[399] Fix | Delete
*/
[400] Fix | Delete
public function get_description()
[401] Fix | Delete
{
[402] Fix | Delete
if ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'subtitle')) {
[403] Fix | Delete
return $this->sanitize($return[0]['data'], $this->registry->call(Misc::class, 'atom_10_construct_type', [$return[0]['attribs']]), $this->get_base($return[0]));
[404] Fix | Delete
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_03, 'tagline')) {
[405] Fix | Delete
return $this->sanitize($return[0]['data'], $this->registry->call(Misc::class, 'atom_03_construct_type', [$return[0]['attribs']]), $this->get_base($return[0]));
[406] Fix | Delete
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_RSS_10, 'description')) {
[407] Fix | Delete
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
[408] Fix | Delete
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_RSS_090, 'description')) {
[409] Fix | Delete
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
[410] Fix | Delete
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_RSS_20, 'description')) {
[411] Fix | Delete
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
[412] Fix | Delete
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_DC_11, 'description')) {
[413] Fix | Delete
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
[414] Fix | Delete
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_DC_10, 'description')) {
[415] Fix | Delete
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
[416] Fix | Delete
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'summary')) {
[417] Fix | Delete
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_HTML, $this->get_base($return[0]));
[418] Fix | Delete
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'subtitle')) {
[419] Fix | Delete
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_HTML, $this->get_base($return[0]));
[420] Fix | Delete
}
[421] Fix | Delete
[422] Fix | Delete
return null;
[423] Fix | Delete
}
[424] Fix | Delete
[425] Fix | Delete
/**
[426] Fix | Delete
* @return string|null
[427] Fix | Delete
*/
[428] Fix | Delete
public function get_copyright()
[429] Fix | Delete
{
[430] Fix | Delete
if ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'rights')) {
[431] Fix | Delete
return $this->sanitize($return[0]['data'], $this->registry->call(Misc::class, 'atom_10_construct_type', [$return[0]['attribs']]), $this->get_base($return[0]));
[432] Fix | Delete
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_03, 'copyright')) {
[433] Fix | Delete
return $this->sanitize($return[0]['data'], $this->registry->call(Misc::class, 'atom_03_construct_type', [$return[0]['attribs']]), $this->get_base($return[0]));
[434] Fix | Delete
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_RSS_20, 'copyright')) {
[435] Fix | Delete
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
[436] Fix | Delete
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_DC_11, 'rights')) {
[437] Fix | Delete
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
[438] Fix | Delete
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_DC_10, 'rights')) {
[439] Fix | Delete
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
[440] Fix | Delete
}
[441] Fix | Delete
[442] Fix | Delete
return null;
[443] Fix | Delete
}
[444] Fix | Delete
[445] Fix | Delete
/**
[446] Fix | Delete
* @return string|null
[447] Fix | Delete
*/
[448] Fix | Delete
public function get_language()
[449] Fix | Delete
{
[450] Fix | Delete
if ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_RSS_20, 'language')) {
[451] Fix | Delete
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
[452] Fix | Delete
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_DC_11, 'language')) {
[453] Fix | Delete
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
[454] Fix | Delete
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_DC_10, 'language')) {
[455] Fix | Delete
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
[456] Fix | Delete
} elseif (isset($this->data['xml_lang'])) {
[457] Fix | Delete
return $this->sanitize($this->data['xml_lang'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
[458] Fix | Delete
}
[459] Fix | Delete
[460] Fix | Delete
return null;
[461] Fix | Delete
}
[462] Fix | Delete
[463] Fix | Delete
/**
[464] Fix | Delete
* @return float|null
[465] Fix | Delete
*/
[466] Fix | Delete
public function get_latitude()
[467] Fix | Delete
{
[468] Fix | Delete
if ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_W3C_BASIC_GEO, 'lat')) {
[469] Fix | Delete
return (float) $return[0]['data'];
[470] Fix | Delete
} 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)) {
[471] Fix | Delete
return (float) $match[1];
[472] Fix | Delete
}
[473] Fix | Delete
[474] Fix | Delete
return null;
[475] Fix | Delete
}
[476] Fix | Delete
[477] Fix | Delete
/**
[478] Fix | Delete
* @return float|null
[479] Fix | Delete
*/
[480] Fix | Delete
public function get_longitude()
[481] Fix | Delete
{
[482] Fix | Delete
if ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_W3C_BASIC_GEO, 'long')) {
[483] Fix | Delete
return (float) $return[0]['data'];
[484] Fix | Delete
} elseif ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_W3C_BASIC_GEO, 'lon')) {
[485] Fix | Delete
return (float) $return[0]['data'];
[486] Fix | Delete
} 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)) {
[487] Fix | Delete
return (float) $match[2];
[488] Fix | Delete
}
[489] Fix | Delete
[490] Fix | Delete
return null;
[491] Fix | Delete
}
[492] Fix | Delete
[493] Fix | Delete
/**
[494] Fix | Delete
* @return string|null
[495] Fix | Delete
*/
[496] Fix | Delete
public function get_image_url()
[497] Fix | Delete
{
[498] Fix | Delete
if ($return = $this->get_source_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'image')) {
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function