|
|
@@ -206,9 +206,10 @@ class SimplePie_Item
|
|
|
*
|
|
|
* @since Beta 2
|
|
|
* @param boolean $hash Should we force using a hash instead of the supplied ID?
|
|
|
- * @return string
|
|
|
+ * @param string|false $fn User-supplied function to generate an hash
|
|
|
+ * @return string|null
|
|
|
*/
|
|
|
- public function get_id($hash = false, $fn = '')
|
|
|
+ public function get_id($hash = false, $fn = 'md5')
|
|
|
{
|
|
|
if (!$hash)
|
|
|
{
|
|
|
@@ -237,7 +238,15 @@ class SimplePie_Item
|
|
|
return $this->sanitize($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about'], SIMPLEPIE_CONSTRUCT_TEXT);
|
|
|
}
|
|
|
}
|
|
|
- if ($fn === '' || !is_callable($fn)) $fn = 'md5';
|
|
|
+ if ($fn === false)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ elseif (!is_callable($fn))
|
|
|
+ {
|
|
|
+ trigger_error('User-supplied function $fn must be callable', E_USER_WARNING);
|
|
|
+ $fn = 'md5';
|
|
|
+ }
|
|
|
return call_user_func($fn,
|
|
|
$this->get_permalink().$this->get_title().$this->get_content());
|
|
|
}
|
|
|
@@ -307,41 +316,50 @@ class SimplePie_Item
|
|
|
*/
|
|
|
public function get_description($description_only = false)
|
|
|
{
|
|
|
- if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary'))
|
|
|
+ if (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary')) &&
|
|
|
+ ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0]))))
|
|
|
{
|
|
|
- return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
|
|
|
+ return $return;
|
|
|
}
|
|
|
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary'))
|
|
|
+ elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary')) &&
|
|
|
+ ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0]))))
|
|
|
{
|
|
|
- return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
|
|
|
+ return $return;
|
|
|
}
|
|
|
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description'))
|
|
|
+ elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) &&
|
|
|
+ ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($tags[0]))))
|
|
|
{
|
|
|
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
|
|
|
+ return $return;
|
|
|
}
|
|
|
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description'))
|
|
|
+ elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) &&
|
|
|
+ ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0]))))
|
|
|
{
|
|
|
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
|
|
|
+ return $return;
|
|
|
}
|
|
|
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description'))
|
|
|
+ elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) &&
|
|
|
+ ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)))
|
|
|
{
|
|
|
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
|
|
|
+ return $return;
|
|
|
}
|
|
|
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description'))
|
|
|
+ elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) &&
|
|
|
+ ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)))
|
|
|
{
|
|
|
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
|
|
|
+ return $return;
|
|
|
}
|
|
|
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary'))
|
|
|
+ elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) &&
|
|
|
+ ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0]))))
|
|
|
{
|
|
|
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
|
|
|
+ return $return;
|
|
|
}
|
|
|
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle'))
|
|
|
+ elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) &&
|
|
|
+ ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)))
|
|
|
{
|
|
|
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
|
|
|
+ return $return;
|
|
|
}
|
|
|
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description'))
|
|
|
+ elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) &&
|
|
|
+ ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML)))
|
|
|
{
|
|
|
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML);
|
|
|
+ return $return;
|
|
|
}
|
|
|
|
|
|
elseif (!$description_only)
|
|
|
@@ -370,17 +388,20 @@ class SimplePie_Item
|
|
|
*/
|
|
|
public function get_content($content_only = false)
|
|
|
{
|
|
|
- if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content'))
|
|
|
+ if (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content')) &&
|
|
|
+ ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_10_content_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0]))))
|
|
|
{
|
|
|
- return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_content_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
|
|
|
+ return $return;
|
|
|
}
|
|
|
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content'))
|
|
|
+ elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content')) &&
|
|
|
+ ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0]))))
|
|
|
{
|
|
|
- return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
|
|
|
+ return $return;
|
|
|
}
|
|
|
- elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded'))
|
|
|
+ elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded')) &&
|
|
|
+ ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0]))))
|
|
|
{
|
|
|
- return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
|
|
|
+ return $return;
|
|
|
}
|
|
|
elseif (!$content_only)
|
|
|
{
|
|
|
@@ -448,47 +469,50 @@ class SimplePie_Item
|
|
|
{
|
|
|
$categories = array();
|
|
|
|
|
|
- foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category)
|
|
|
+ $type = 'category';
|
|
|
+ foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, $type) as $category)
|
|
|
{
|
|
|
$term = null;
|
|
|
$scheme = null;
|
|
|
$label = null;
|
|
|
if (isset($category['attribs']['']['term']))
|
|
|
{
|
|
|
- $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT);
|
|
|
+ $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_HTML);
|
|
|
}
|
|
|
if (isset($category['attribs']['']['scheme']))
|
|
|
{
|
|
|
- $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
|
|
|
+ $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_HTML);
|
|
|
}
|
|
|
if (isset($category['attribs']['']['label']))
|
|
|
{
|
|
|
- $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
|
|
|
+ $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_HTML);
|
|
|
}
|
|
|
- $categories[] = $this->registry->create('Category', array($term, $scheme, $label));
|
|
|
+ $categories[] = $this->registry->create('Category', array($term, $scheme, $label, $type));
|
|
|
}
|
|
|
- foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category)
|
|
|
+ foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, $type) as $category)
|
|
|
{
|
|
|
// This is really the label, but keep this as the term also for BC.
|
|
|
// Label will also work on retrieving because that falls back to term.
|
|
|
- $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
|
|
|
+ $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_HTML);
|
|
|
if (isset($category['attribs']['']['domain']))
|
|
|
{
|
|
|
- $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT);
|
|
|
+ $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_HTML);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
$scheme = null;
|
|
|
}
|
|
|
- $categories[] = $this->registry->create('Category', array($term, $scheme, null));
|
|
|
+ $categories[] = $this->registry->create('Category', array($term, $scheme, null, $type));
|
|
|
}
|
|
|
- foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
|
|
|
+
|
|
|
+ $type = 'subject';
|
|
|
+ foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, $type) as $category)
|
|
|
{
|
|
|
- $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
|
|
|
+ $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_HTML), null, null, $type));
|
|
|
}
|
|
|
- foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category)
|
|
|
+ foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, $type) as $category)
|
|
|
{
|
|
|
- $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
|
|
|
+ $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_HTML), null, null, $type));
|
|
|
}
|
|
|
|
|
|
if (!empty($categories))
|
|
|
@@ -625,7 +649,7 @@ class SimplePie_Item
|
|
|
$email = null;
|
|
|
if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
|
|
|
{
|
|
|
- $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
|
|
|
+ $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_HTML);
|
|
|
}
|
|
|
if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
|
|
|
{
|
|
|
@@ -633,7 +657,7 @@ class SimplePie_Item
|
|
|
}
|
|
|
if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
|
|
|
{
|
|
|
- $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
|
|
|
+ $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_HTML);
|
|
|
}
|
|
|
if ($name !== null || $email !== null || $uri !== null)
|
|
|
{
|
|
|
@@ -647,7 +671,7 @@ class SimplePie_Item
|
|
|
$email = null;
|
|
|
if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
|
|
|
{
|
|
|
- $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
|
|
|
+ $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_HTML);
|
|
|
}
|
|
|
if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
|
|
|
{
|
|
|
@@ -655,7 +679,7 @@ class SimplePie_Item
|
|
|
}
|
|
|
if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
|
|
|
{
|
|
|
- $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
|
|
|
+ $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_HTML);
|
|
|
}
|
|
|
if ($name !== null || $email !== null || $url !== null)
|
|
|
{
|
|
|
@@ -664,19 +688,19 @@ class SimplePie_Item
|
|
|
}
|
|
|
if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'author'))
|
|
|
{
|
|
|
- $authors[] = $this->registry->create('Author', array(null, null, $this->sanitize($author[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)));
|
|
|
+ $authors[] = $this->registry->create('Author', array(null, null, $this->sanitize($author[0]['data'], SIMPLEPIE_CONSTRUCT_HTML)));
|
|
|
}
|
|
|
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author)
|
|
|
{
|
|
|
- $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
|
|
|
+ $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_HTML), null, null));
|
|
|
}
|
|
|
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author)
|
|
|
{
|
|
|
- $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
|
|
|
+ $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_HTML), null, null));
|
|
|
}
|
|
|
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author)
|
|
|
{
|
|
|
- $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
|
|
|
+ $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_HTML), null, null));
|
|
|
}
|
|
|
|
|
|
if (!empty($authors))
|
|
|
@@ -2802,9 +2826,17 @@ class SimplePie_Item
|
|
|
{
|
|
|
$length = ceil($link['attribs']['']['length']);
|
|
|
}
|
|
|
+ if (isset($link['attribs']['']['title']))
|
|
|
+ {
|
|
|
+ $title = $this->sanitize($link['attribs']['']['title'], SIMPLEPIE_CONSTRUCT_TEXT);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ $title = $title_parent;
|
|
|
+ }
|
|
|
|
|
|
// Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
|
|
|
- $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width));
|
|
|
+ $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title, $width));
|
|
|
}
|
|
|
}
|
|
|
|