home/abhiramc/public_html/newsroom/wp-includes/SimplePie/src/Item.php 0000644 00000400572 15021200651 0021734 0 ustar 00 feed = $feed;
$this->data = $data;
}
/**
* Set the registry handler
*
* This is usually used by {@see \SimplePie\Registry::create}
*
* @since 1.3
* @param \SimplePie\Registry $registry
*/
public function set_registry(\SimplePie\Registry $registry)/* : void */
{
$this->registry = $registry;
}
/**
* Get a string representation of the item
*
* @return string
*/
public function __toString()
{
return md5(serialize($this->data));
}
/**
* Remove items that link back to this before destroying this object
*/
public function __destruct()
{
if (!gc_enabled()) {
unset($this->feed);
}
}
/**
* Get data for an item-level element
*
* This method allows you to get access to ANY element/attribute that is a
* sub-element of the item/entry tag.
*
* See {@see \SimplePie\SimplePie::get_feed_tags()} for a description of the return value
*
* @since 1.0
* @see http://simplepie.org/wiki/faq/supported_xml_namespaces
* @param string $namespace The URL of the XML namespace of the elements you're trying to access
* @param string $tag Tag name
* @return array
*/
public function get_item_tags($namespace, $tag)
{
if (isset($this->data['child'][$namespace][$tag])) {
return $this->data['child'][$namespace][$tag];
}
return null;
}
/**
* Get the base URL value.
* Uses ``, or item link, or feed base URL.
*
* @param array $element
* @return string
*/
public function get_base($element = [])
{
if (!empty($element['xml_base_explicit']) && isset($element['xml_base'])) {
return $element['xml_base'];
}
$link = $this->get_permalink();
if ($link != null) {
return $link;
}
return $this->feed->get_base($element);
}
/**
* Sanitize feed data
*
* @access private
* @see \SimplePie\SimplePie::sanitize()
* @param string $data Data to sanitize
* @param int $type One of the \SimplePie\SimplePie::CONSTRUCT_* constants
* @param string $base Base URL to resolve URLs against
* @return string Sanitized data
*/
public function sanitize($data, $type, $base = '')
{
return $this->feed->sanitize($data, $type, $base);
}
/**
* Get the parent feed
*
* Note: this may not work as you think for multifeeds!
*
* @link http://simplepie.org/faq/typical_multifeed_gotchas#missing_data_from_feed
* @since 1.0
* @return \SimplePie\SimplePie
*/
public function get_feed()
{
return $this->feed;
}
/**
* Get the unique identifier for the item
*
* This is usually used when writing code to check for new items in a feed.
*
* Uses ``, ``, `` or the `about` attribute
* for RDF. If none of these are supplied (or `$hash` is true), creates an
* MD5 hash based on the permalink, title and content.
*
* @since Beta 2
* @param boolean $hash Should we force using a hash instead of the supplied ID?
* @param string|false $fn User-supplied function to generate an hash
* @return string|null
*/
public function get_id($hash = false, $fn = 'md5')
{
if (!$hash) {
if ($return = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'id')) {
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
} elseif ($return = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_03, 'id')) {
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
} elseif ($return = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_RSS_20, 'guid')) {
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
} elseif ($return = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_DC_11, 'identifier')) {
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
} elseif ($return = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_DC_10, 'identifier')) {
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
} elseif (isset($this->data['attribs'][\SimplePie\SimplePie::NAMESPACE_RDF]['about']