Skip to content

Commit

Permalink
More minor updates for the demo. Added a parameter to SimplePie::get_…
Browse files Browse the repository at this point in the history
…title() and SimplePie_Item::get_title() that allows users to choose whether they want to decode titles or not.
  • Loading branch information
Ryan Parman committed Jun 29, 2007
1 parent 6e0ce45 commit f16656a
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 18 deletions.
4 changes: 2 additions & 2 deletions demo/index.php
Expand Up @@ -99,7 +99,7 @@
do centered floats purely with CSS. The table box model allows for a dynamic width while centered, while the
CSS box model for DIVs doesn't allow for it. :( -->
<table cellpadding="0" cellspacing="0" border="0"><tbody><tr><td>
<ul><li id="demo"><a href="">SimplePie Demo</a></li><li><a href="http://simplepie.org/wiki/faq/start">FAQ/Troubleshooting</a></li><li><a href="http://simplepie.org/support/">Support Forums</a></li><li><a href="http://simplepie.org/wiki/reference/start">API Reference</a></li><li><a href="http://simplepie.org/blog/">Weblog</a></li><li><a href="../test/test.php">Unit Tests</a></li></ul>
<ul><li id="demo"><a href="./">SimplePie Demo</a></li><li><a href="http://simplepie.org/wiki/faq/start">FAQ/Troubleshooting</a></li><li><a href="http://simplepie.org/support/">Support Forums</a></li><li><a href="http://simplepie.org/wiki/reference/start">API Reference</a></li><li><a href="http://simplepie.org/blog/">Weblog</a></li><li><a href="../test/test.php">Unit Tests</a></li></ul>

<div class="clearLeft"></div>
</td></tr></tbody></table>
Expand Down Expand Up @@ -230,7 +230,7 @@
?>

<!-- If the item has a permalink back to the original post (which 99% of them do), link the item's title to it. -->
<h4><img src="<?php echo $favicon; ?>" alt="Favicon" class="favicon" /><?php if ($item->get_permalink()) echo '<a href="' . $item->get_permalink() . '">'; echo $item->get_title(); if ($item->get_permalink()) echo '</a>'; ?>&nbsp;<span class="footnote"><?php echo $item->get_date('j M Y, g:i a'); ?></span></h4>
<h4><img src="<?php echo $favicon; ?>" alt="Favicon" class="favicon" /><?php if ($item->get_permalink()) echo '<a href="' . $item->get_permalink() . '">'; echo $item->get_title(true); if ($item->get_permalink()) echo '</a>'; ?>&nbsp;<span class="footnote"><?php echo $item->get_date('j M Y, g:i a'); ?></span></h4>

<!-- Display the item's primary content. -->
<?php echo $item->get_content(); ?>
Expand Down
130 changes: 114 additions & 16 deletions simplepie.inc
Expand Up @@ -2164,35 +2164,84 @@ function embed_wmedia(width, height, link) {
return $this->sanitize->sanitize($data, $type, $base);
}

function get_title()
function get_title($decode = false)
{
if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title'))
{
return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
if ($decode)
{
return $this->sanitize(html_entity_decode($return[0]['data'], ENT_QUOTES, 'UTF-8'), SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
}
else
{
return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
}
}
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title'))
{
return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
if ($decode)
{
return $this->sanitize(html_entity_decode($return[0]['data'], ENT_QUOTES, 'UTF-8'), SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
}
else
{
return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
}
}
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
if ($decode)
{
return $this->sanitize(html_entity_decode($return[0]['data'], ENT_QUOTES, 'UTF-8'), SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
}
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
if ($decode)
{
return $this->sanitize(html_entity_decode($return[0]['data'], ENT_QUOTES, 'UTF-8'), SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
}
elseif ($return = $this->get_channel_tags('', 'title'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
if ($decode)
{
return $this->sanitize(html_entity_decode($return[0]['data'], ENT_QUOTES, 'UTF-8'), SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
}
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
if ($decode)
{
return $this->sanitize(html_entity_decode($return[0]['data'], ENT_QUOTES, 'UTF-8'), SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
}
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
if ($decode)
{
return $this->sanitize(html_entity_decode($return[0]['data'], ENT_QUOTES, 'UTF-8'), SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
}
else
{
Expand Down Expand Up @@ -2806,35 +2855,84 @@ class SimplePie_Item
}
}

function get_title()
function get_title($decode = false)
{
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title'))
{
return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
if ($decode)
{
return $this->sanitize(html_entity_decode($return[0]['data'], ENT_QUOTES, 'UTF-8'), SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
}
else
{
return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
}
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title'))
{
return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
if ($decode)
{
return $this->sanitize(html_entity_decode($return[0]['data'], ENT_QUOTES, 'UTF-8'), SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
}
else
{
return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
}
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
if ($decode)
{
return $this->sanitize(html_entity_decode($return[0]['data'], ENT_QUOTES, 'UTF-8'), SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
if ($decode)
{
return $this->sanitize(html_entity_decode($return[0]['data'], ENT_QUOTES, 'UTF-8'), SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
}
elseif ($return = $this->get_item_tags('', 'title'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
if ($decode)
{
return $this->sanitize(html_entity_decode($return[0]['data'], ENT_QUOTES, 'UTF-8'), SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
if ($decode)
{
return $this->sanitize(html_entity_decode($return[0]['data'], ENT_QUOTES, 'UTF-8'), SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
}
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
if ($decode)
{
return $this->sanitize(html_entity_decode($return[0]['data'], ENT_QUOTES, 'UTF-8'), SIMPLEPIE_CONSTRUCT_TEXT);
}
else
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
}
else
{
Expand Down

0 comments on commit f16656a

Please sign in to comment.