aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--manifest.xml42
-rw-r--r--sp_compatibility_test.php277
-rw-r--r--start.php26
-rw-r--r--vendors/simplepie.inc (renamed from simplepie.inc)1592
-rw-r--r--views/default/feed_reader/css.php27
-rw-r--r--views/default/settings/simplepie/edit.php10
-rw-r--r--views/default/simplepie/css.php17
-rw-r--r--views/default/widgets/feed_reader/content.php81
-rw-r--r--views/default/widgets/feed_reader/edit.php119
-rw-r--r--views/default/widgets/feed_reader/view.php82
10 files changed, 1150 insertions, 1123 deletions
diff --git a/manifest.xml b/manifest.xml
index 5cb43fa7e..78597744b 100644
--- a/manifest.xml
+++ b/manifest.xml
@@ -1,10 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
-<plugin_manifest>
- <field key="author" value="Cash Costello" />
- <field key="version" value="0.3" />
- <field key="description" value="SimplePie Feed Integrator" />
- <field key="website" value="http://www.cashcostello.com/" />
- <field key="copyright" value="Cash Costello 2009-2010" />
- <field key="licence" value="GNU General Public License version 2" />
- <field key="elgg_version" value="2009022701" />
+<plugin_manifest xmlns="http://www.elgg.org/plugin_manifest/1.8">
+ <name>SimplePie RSS Feed Integration</name>
+ <author>Cash Costello</author>
+ <version>0.4</version>
+ <category>widget</category>
+ <description>Provides a widget that pulls in RSS feeds</description>
+ <website>http://www.cashcostello.com/</website>
+ <copyright>Cash Costello 2009-2011</copyright>
+ <license>GNU General Public License version 2</license>
+ <requires>
+ <type>elgg_release</type>
+ <version>1.8</version>
+ </requires>
+ <requires>
+ <type>php_extension</type>
+ <name>xml</name>
+ </requires>
+ <requires>
+ <type>php_extension</type>
+ <name>pcre</name>
+ </requires>
+ <suggests>
+ <type>php_extension</type>
+ <name>mbstring</name>
+ </suggests>
+ <suggests>
+ <type>php_extension</type>
+ <name>iconv</name>
+ </suggests>
+ <provides>
+ <type>plugin</type>
+ <name>simplepie_api</name>
+ <version>1.2.1</version>
+ </provides>
</plugin_manifest>
diff --git a/sp_compatibility_test.php b/sp_compatibility_test.php
deleted file mode 100644
index 0448aa01d..000000000
--- a/sp_compatibility_test.php
+++ /dev/null
@@ -1,277 +0,0 @@
-<?php
-
-// this is a quick hack of the compatibility script included with simple pie
-
-// Load Elgg engine
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
-$php_ok = (function_exists('version_compare') && version_compare(phpversion(), '4.3.0', '>='));
-$xml_ok = extension_loaded('xml');
-$pcre_ok = extension_loaded('pcre');
-$curl_ok = function_exists('curl_exec');
-$zlib_ok = extension_loaded('zlib');
-$mbstring_ok = extension_loaded('mbstring');
-$iconv_ok = extension_loaded('iconv');
-
-ob_start();
-
-?>
-
-<style type="text/css">
-body {
-}
-
-#site {
- width:550px;
- margin:20px auto 0 auto;
- font:14px/1.4em "Lucida Grande", Verdana, Arial, Helvetica, Clean, Sans, sans-serif;
- letter-spacing:0px;
- color:#333;
- margin:0;
- padding:0;
-}
-
-#site a {
- color:#000;
- text-decoration:underline;
- padding:0 1px;
-}
-
-#site a:hover {
- color:#fff;
- background-color:#333;
- text-decoration:none;
- padding:0 1px;
-}
-
-#site p {
- margin:0;
- padding:5px 0;
-}
-
-#site em {
- font-style:normal;
- background-color:#ffc;
-}
-
-#site ul, ol {
- margin:10px 0 10px 20px;
- padding:0 0 0 15px;
-}
-
-#site ul li, ol li {
- margin:0 0 7px 0;
- padding:0 0 0 3px;
-}
-
-#site h2 {
- font-size:18px;
- padding:0;
- margin:30px 0 10px 0;
-}
-
-#site h3 {
- font-size:16px;
- padding:0;
- margin:20px 0 5px 0;
-}
-
-#site h4 {
- font-size:14px;
- padding:0;
- margin:15px 0 5px 0;
-}
-
-#site code {
- font-size:1.1em;
- background-color:#f3f3ff;
- color:#000;
-}
-
-#site em strong {
- text-transform: uppercase;
-}
-
-table#chart {
- border-collapse:collapse;
-}
-
-table#chart th {
- background-color:#eee;
- padding:2px 3px;
- border:1px solid #fff;
-}
-
-table#chart td {
- text-align:center;
- padding:2px 3px;
- border:1px solid #eee;
-}
-
-table#chart tr.enabled td {
- /* Leave this alone */
-}
-
-table#chart tr.disabled td,
-table#chart tr.disabled td a {
- color:#999;
- font-style:italic;
-}
-
-table#chart tr.disabled td a {
- text-decoration:underline;
-}
-
-.chunk {
- margin:20px 0 0 0;
- padding:0 0 10px 0;
- border-bottom:1px solid #ccc;
-}
-
-.footnote,
-.footnote a {
- font:10px/12px verdana, sans-serif;
- color:#aaa;
-}
-
-.footnote em {
- background-color:transparent;
- font-style:italic;
-}
-</style>
-
-
- <div class="contentWrapper" style="margin:0;">
-
-<div id="elggreturn">
- <a href="javascript:history.go(-1)">Return to Tools Administration</a>
-</div>
-
-<div id="site">
- <div id="content">
- <div class="chunk">
- <h2 style="text-align:center;">SimplePie Compatibility Test</h2>
- <table cellpadding="0" cellspacing="0" border="0" width="100%" id="chart">
- <thead>
- <tr>
- <th>Test</th>
- <th>Should Be</th>
- <th>What You Have</th>
- </tr>
- </thead>
- <tbody>
- <tr class="<?php echo ($php_ok) ? 'enabled' : 'disabled'; ?>">
- <td>PHP&sup1;</td>
- <td>4.3.0 or higher</td>
- <td><?php echo phpversion(); ?></td>
- </tr>
- <tr class="<?php echo ($xml_ok) ? 'enabled' : 'disabled'; ?>">
- <td><a href="http://php.net/xml">XML</a></td>
- <td>Enabled</td>
- <td><?php echo ($xml_ok) ? 'Enabled' : 'Disabled'; ?></td>
- </tr>
- <tr class="<?php echo ($pcre_ok) ? 'enabled' : 'disabled'; ?>">
- <td><a href="http://php.net/pcre">PCRE</a>&sup2;</td>
- <td>Enabled</td>
- <td><?php echo ($pcre_ok) ? 'Enabled' : 'Disabled'; ?></td>
- </tr>
- <tr class="<?php echo ($curl_ok) ? 'enabled' : 'disabled'; ?>">
- <td><a href="http://php.net/curl">cURL</a></td>
- <td>Enabled</td>
- <td><?php echo (extension_loaded('curl')) ? 'Enabled' : 'Disabled'; ?></td>
- </tr>
- <tr class="<?php echo ($zlib_ok) ? 'enabled' : 'disabled'; ?>">
- <td><a href="http://php.net/zlib">Zlib</a></td>
- <td>Enabled</td>
- <td><?php echo ($zlib_ok) ? 'Enabled' : 'Disabled'; ?></td>
- </tr>
- <tr class="<?php echo ($mbstring_ok) ? 'enabled' : 'disabled'; ?>">
- <td><a href="http://php.net/mbstring">mbstring</a></td>
- <td>Enabled</td>
- <td><?php echo ($mbstring_ok) ? 'Enabled' : 'Disabled'; ?></td>
- </tr>
- <tr class="<?php echo ($iconv_ok) ? 'enabled' : 'disabled'; ?>">
- <td><a href="http://php.net/iconv">iconv</a></td>
- <td>Enabled</td>
- <td><?php echo ($iconv_ok) ? 'Enabled' : 'Disabled'; ?></td>
- </tr>
- </tbody>
- </table>
- </div>
-
- <div class="chunk">
- <h3>What does this mean?</h3>
- <ol>
- <?php if ($php_ok && $xml_ok && $pcre_ok && $mbstring_ok && $iconv_ok && $curl_ok && $zlib_ok): ?>
- <li><em>You have everything you need to run SimplePie properly! Congratulations!</em></li>
- <?php else: ?>
- <?php if ($php_ok): ?>
- <li><strong>PHP:</strong> You are running a supported version of PHP. <em>No problems here.</em></li>
- <?php if ($xml_ok): ?>
- <li><strong>XML:</strong> You have XML support installed. <em>No problems here.</em></li>
- <?php if ($pcre_ok): ?>
- <li><strong>PCRE:</strong> You have PCRE support installed. <em>No problems here.</em></li>
- <?php if ($curl_ok): ?>
- <li><strong>cURL:</strong> You have <code>cURL</code> support installed. <em>No problems here.</em></li>
- <?php else: ?>
- <li><strong>cURL:</strong> The <code>cURL</code> extension is not available. SimplePie will use <code>fsockopen()</code> instead.</li>
- <?php endif; ?>
-
- <?php if ($zlib_ok): ?>
- <li><strong>Zlib:</strong> You have <code>Zlib</code> enabled. This allows SimplePie to support GZIP-encoded feeds. <em>No problems here.</em></li>
- <?php else: ?>
- <li><strong>Zlib:</strong> The <code>Zlib</code> extension is not available. SimplePie will ignore any GZIP-encoding, and instead handle feeds as uncompressed text.</li>
- <?php endif; ?>
-
- <?php if ($mbstring_ok && $iconv_ok): ?>
- <li><strong>mbstring and iconv:</strong> You have both <code>mbstring</code> and <code>iconv</code> installed! This will allow SimplePie to handle the greatest number of languages. Check the <a href="http://simplepie.org/wiki/faq/supported_character_encodings">Supported Character Encodings</a> chart to see what's supported on your webhost.</li>
- <?php elseif ($mbstring_ok): ?>
- <li><strong>mbstring:</strong> <code>mbstring</code> is installed, but <code>iconv</code> is not. Check the <a href="http://simplepie.org/wiki/faq/supported_character_encodings">Supported Character Encodings</a> chart to see what's supported on your webhost.</li>
- <?php elseif ($iconv_ok): ?>
- <li><strong>iconv:</strong> <code>iconv</code> is installed, but <code>mbstring</code> is not. Check the <a href="http://simplepie.org/wiki/faq/supported_character_encodings">Supported Character Encodings</a> chart to see what's supported on your webhost.</li>
- <?php else: ?>
- <li><strong>mbstring and iconv:</strong> <em>You do not have either of the extensions installed.</em> This will significantly impair your ability to read non-English feeds, as well as even some English ones. Check the <a href="http://simplepie.org/wiki/faq/supported_character_encodings">Supported Character Encodings</a> chart to see what's supported on your webhost.</li>
- <?php endif; ?>
- <?php else: ?>
- <li><strong>PCRE:</strong> Your PHP installation doesn't support Perl-Compatible Regular Expressions. <em>SimplePie is a no-go at the moment.</em></li>
- <?php endif; ?>
- <?php else: ?>
- <li><strong>XML:</strong> Your PHP installation doesn't support XML parsing. <em>SimplePie is a no-go at the moment.</em></li>
- <?php endif; ?>
- <?php else: ?>
- <li><strong>PHP:</strong> You are running an unsupported version of PHP. <em>SimplePie is a no-go at the moment.</em></li>
- <?php endif; ?>
- <?php endif; ?>
- </ol>
- </div>
-
- <div class="chunk">
- <?php if ($php_ok && $xml_ok && $pcre_ok && $mbstring_ok && $iconv_ok) { ?>
- <h3>Bottom Line: Yes, you can!</h3>
- <p><em>Your webhost has its act together!</em></p>
- <p class="footnote"><em><strong>Note</strong></em>: Passing this test does not guarantee that SimplePie will run on your webhost &mdash; it only ensures that the basic requirements have been addressed.</p>
- <?php } else if ($php_ok && $xml_ok && $pcre_ok) { ?>
- <h3>Bottom Line: Yes, you can!</h3>
- <p><em>For most feeds, it'll run with no problems.</em> There are <a href="http://simplepie.org/wiki/faq/supported_character_encodings">certain languages</a> that you might have a hard time with though.</p>
- <p class="footnote"><em><strong>Note</strong></em>: Passing this test does not guarantee that SimplePie will run on your webhost &mdash; it only ensures that the basic requirements have been addressed.</p>
- <?php } else { ?>
- <h3>Bottom Line: We're sorry…</h3>
- <p><em>Your webhost does not support the minimum requirements for SimplePie.</em> It may be a good idea to contact your webhost, and ask them to install a more recent version of PHP as well as the <code>xml</code>, <code>mbstring</code>, <code>iconv</code>, <code>curl</code>, and <code>zlib</code> extensions.</p>
- <?php } ?>
- </div>
-
- <div class="chunk">
- <p class="footnote">&sup1; &mdash; SimplePie 2 will not support PHP 4.x. The core PHP team has discontinued PHP 4.x patches and support. <a href="http://simplepie.org/blog/2007/07/13/simplepie-is-going-php5-only/">Read the announcement.</a></p>
- <p class="footnote">&sup2; &mdash; Some recent versions of the PCRE (PERL-Compatible Regular Expression) engine compiled into PHP have been buggy, and are the source of PHP segmentation faults (e.g. crashes) which cause random things like blank, white screens. Check the <a href="http://simplepie.org/support/">Support Forums</a> for the latest information on patches and ongoing fixes.</p>
- </div>
-
- </div>
-
-</div>
-</div>
-
-<?php
- $content = ob_get_clean();
- $body = elgg_view_layout('one_column', $content);
- echo page_draw(null, $body);
-?>
diff --git a/start.php b/start.php
index 12acb74f9..20adc7545 100644
--- a/start.php
+++ b/start.php
@@ -1,15 +1,23 @@
<?php
-
/**
-* Simplepie Plugin
-*
-* Loads the simplepie feed parser library and provides a widget
-**/
+ * Simplepie Plugin
+ *
+ * Loads the simplepie feed parser library and provides a widget
+ */
+
+elgg_register_event_handler('init', 'system', 'simplepie_init');
function simplepie_init() {
- add_widget_type('feed_reader', elgg_echo('simplepie:widget'), elgg_echo('simplepie:description'));
- elgg_extend_view('css', 'feed_reader/css');
-}
+ elgg_register_widget_type(
+ 'feed_reader',
+ elgg_echo('simplepie:widget'),
+ elgg_echo('simplepie:description'),
+ 'all',
+ true
+ );
-register_elgg_event_handler('plugins_boot', 'system', 'simplepie_init');
+ elgg_extend_view('css/elgg', 'simplepie/css');
+ $lib = elgg_get_plugins_path() . 'simplepie/vendors/simplepie.inc';
+ elgg_register_library('simplepie', $lib);
+}
diff --git a/simplepie.inc b/vendors/simplepie.inc
index 45c33c86e..c2e9509ef 100644
--- a/simplepie.inc
+++ b/vendors/simplepie.inc
@@ -5,7 +5,7 @@
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
- * Copyright (c) 2004-2009, Ryan Parman and Geoffrey Sneddon
+ * Copyright (c) 2004-2011, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
@@ -33,10 +33,11 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
- * @version 1.2
- * @copyright 2004-2009 Ryan Parman, Geoffrey Sneddon
+ * @version 1.2.1
+ * @copyright 2004-2011 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
+ * @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @link http://simplepie.org/support/ Please submit all bug reports and feature requests to the SimplePie forums
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
@@ -51,12 +52,12 @@ define('SIMPLEPIE_NAME', 'SimplePie');
/**
* SimplePie Version
*/
-define('SIMPLEPIE_VERSION', '1.2');
+define('SIMPLEPIE_VERSION', '1.2.1-dev');
/**
* SimplePie Build
*/
-define('SIMPLEPIE_BUILD', '20090627192103');
+define('SIMPLEPIE_BUILD', '20111015034325');
/**
* SimplePie Website URL
@@ -1671,7 +1672,7 @@ class SimplePie
$this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD);
if (!$cache->save($this))
{
- trigger_error("$this->cache_location is not writeable", E_USER_WARNING);
+ trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
}
$cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc');
}
@@ -1679,7 +1680,7 @@ class SimplePie
}
else
{
- $this->error = "A feed could not be found at $this->feed_url";
+ $this->error = "A feed could not be found at $this->feed_url. A feed with an invalid mime type may fall victim to this error, or " . SIMPLEPIE_NAME . " was unable to auto-discover it.. Use force_feed() if you are certain this URL is a real feed.";
SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
return false;
}
@@ -1776,27 +1777,27 @@ class SimplePie
// Cache the file if caching is enabled
if ($cache && !$cache->save($this))
{
- trigger_error("$cache->name is not writeable", E_USER_WARNING);
+ trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
}
return true;
}
else
{
- $this->error = "A feed could not be found at $this->feed_url";
+ $this->error = "A feed could not be found at $this->feed_url. This does not appear to be a valid RSS or Atom feed.";
SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
return false;
}
}
}
}
- if(isset($parser))
+ if (isset($parser))
{
// We have an error, just set SimplePie_Misc::error to it and quit
- $this->error = sprintf('XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column());
+ $this->error = sprintf('This XML document is invalid, likely due to invalid characters. XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column());
}
else
{
- $this->error = 'The data could not be converted to UTF-8';
+ $this->error = 'The data could not be converted to UTF-8. You MUST have either the iconv or mbstring extension installed. Upgrading to PHP 5.x (which includes iconv) is highly recommended.';
}
SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
return false;
@@ -1983,7 +1984,7 @@ class SimplePie
}
else
{
- trigger_error("$cache->name is not writeable", E_USER_WARNING);
+ trigger_error("$cache->name is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI);
}
}
@@ -2773,11 +2774,12 @@ class SimplePie
function get_latitude()
{
+
if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
{
return (float) $return[0]['data'];
}
- elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
+ elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
{
return (float) $match[1];
}
@@ -2797,7 +2799,7 @@ class SimplePie
{
return (float) $return[0]['data'];
}
- elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
+ elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
{
return (float) $match[2];
}
@@ -3277,6 +3279,11 @@ class SimplePie_Item
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
+ elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description'))
+ {
+ return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML);
+ }
+
elseif (!$description_only)
{
return $this->get_content(true);
@@ -3641,7 +3648,7 @@ class SimplePie_Item
{
return $this->sanitize($this->get_date(''), SIMPLEPIE_CONSTRUCT_TEXT);
}
- elseif (($date = $this->get_date('U')) !== null)
+ elseif (($date = $this->get_date('U')) !== null && $date !== false)
{
return strftime($date_format, $date);
}
@@ -4066,16 +4073,16 @@ class SimplePie_Item
$temp = explode(':', $this->sanitize($duration_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
if (sizeof($temp) > 0)
{
- (int) $seconds = array_pop($temp);
+ $seconds = (int) array_pop($temp);
}
if (sizeof($temp) > 0)
{
- (int) $minutes = array_pop($temp);
+ $minutes = (int) array_pop($temp);
$seconds += $minutes * 60;
}
if (sizeof($temp) > 0)
{
- (int) $hours = array_pop($temp);
+ $hours = (int) array_pop($temp);
$seconds += $hours * 3600;
}
unset($temp);
@@ -4427,621 +4434,624 @@ class SimplePie_Item
// If we have media:group tags, loop through them.
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group') as $group)
{
- // If we have media:content tags, loop through them.
- foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
- {
- if (isset($content['attribs']['']['url']))
- {
- // Attributes
- $bitrate = null;
- $channels = null;
- $duration = null;
- $expression = null;
- $framerate = null;
- $height = null;
- $javascript = null;
- $lang = null;
- $length = null;
- $medium = null;
- $samplingrate = null;
- $type = null;
- $url = null;
- $width = null;
-
- // Elements
- $captions = null;
- $categories = null;
- $copyrights = null;
- $credits = null;
- $description = null;
- $hashes = null;
- $keywords = null;
- $player = null;
- $ratings = null;
- $restrictions = null;
- $thumbnails = null;
- $title = null;
+ if(isset($group['child']) && isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content']))
+ {
+ // If we have media:content tags, loop through them.
+ foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
+ {
+ if (isset($content['attribs']['']['url']))
+ {
+ // Attributes
+ $bitrate = null;
+ $channels = null;
+ $duration = null;
+ $expression = null;
+ $framerate = null;
+ $height = null;
+ $javascript = null;
+ $lang = null;
+ $length = null;
+ $medium = null;
+ $samplingrate = null;
+ $type = null;
+ $url = null;
+ $width = null;
+
+ // Elements
+ $captions = null;
+ $categories = null;
+ $copyrights = null;
+ $credits = null;
+ $description = null;
+ $hashes = null;
+ $keywords = null;
+ $player = null;
+ $ratings = null;
+ $restrictions = null;
+ $thumbnails = null;
+ $title = null;
+
+ // Start checking the attributes of media:content
+ if (isset($content['attribs']['']['bitrate']))
+ {
+ $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($content['attribs']['']['channels']))
+ {
+ $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($content['attribs']['']['duration']))
+ {
+ $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ else
+ {
+ $duration = $duration_parent;
+ }
+ if (isset($content['attribs']['']['expression']))
+ {
+ $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($content['attribs']['']['framerate']))
+ {
+ $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($content['attribs']['']['height']))
+ {
+ $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($content['attribs']['']['lang']))
+ {
+ $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($content['attribs']['']['fileSize']))
+ {
+ $length = ceil($content['attribs']['']['fileSize']);
+ }
+ if (isset($content['attribs']['']['medium']))
+ {
+ $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($content['attribs']['']['samplingrate']))
+ {
+ $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($content['attribs']['']['type']))
+ {
+ $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($content['attribs']['']['width']))
+ {
+ $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
- // Start checking the attributes of media:content
- if (isset($content['attribs']['']['bitrate']))
- {
- $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($content['attribs']['']['channels']))
- {
- $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($content['attribs']['']['duration']))
- {
- $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- else
- {
- $duration = $duration_parent;
- }
- if (isset($content['attribs']['']['expression']))
- {
- $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($content['attribs']['']['framerate']))
- {
- $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($content['attribs']['']['height']))
- {
- $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($content['attribs']['']['lang']))
- {
- $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($content['attribs']['']['fileSize']))
- {
- $length = ceil($content['attribs']['']['fileSize']);
- }
- if (isset($content['attribs']['']['medium']))
- {
- $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($content['attribs']['']['samplingrate']))
- {
- $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($content['attribs']['']['type']))
- {
- $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($content['attribs']['']['width']))
- {
- $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
+ // Checking the other optional media: elements. Priority: media:content, media:group, item, channel
- // Checking the other optional media: elements. Priority: media:content, media:group, item, channel
-
- // CAPTIONS
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
- {
- foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
+ // CAPTIONS
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
{
- $caption_type = null;
- $caption_lang = null;
- $caption_startTime = null;
- $caption_endTime = null;
- $caption_text = null;
- if (isset($caption['attribs']['']['type']))
- {
- $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($caption['attribs']['']['lang']))
+ foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
{
- $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $caption_type = null;
+ $caption_lang = null;
+ $caption_startTime = null;
+ $caption_endTime = null;
+ $caption_text = null;
+ if (isset($caption['attribs']['']['type']))
+ {
+ $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($caption['attribs']['']['lang']))
+ {
+ $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($caption['attribs']['']['start']))
+ {
+ $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($caption['attribs']['']['end']))
+ {
+ $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($caption['data']))
+ {
+ $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ $captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
}
- if (isset($caption['attribs']['']['start']))
+ if (is_array($captions))
{
- $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $captions = array_values(SimplePie_Misc::array_unique($captions));
}
- if (isset($caption['attribs']['']['end']))
+ }
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
+ {
+ foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
{
- $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $caption_type = null;
+ $caption_lang = null;
+ $caption_startTime = null;
+ $caption_endTime = null;
+ $caption_text = null;
+ if (isset($caption['attribs']['']['type']))
+ {
+ $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($caption['attribs']['']['lang']))
+ {
+ $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($caption['attribs']['']['start']))
+ {
+ $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($caption['attribs']['']['end']))
+ {
+ $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($caption['data']))
+ {
+ $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ $captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
}
- if (isset($caption['data']))
+ if (is_array($captions))
{
- $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $captions = array_values(SimplePie_Misc::array_unique($captions));
}
- $captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
}
- if (is_array($captions))
+ else
{
- $captions = array_values(SimplePie_Misc::array_unique($captions));
+ $captions = $captions_parent;
}
- }
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
- {
- foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
+
+ // CATEGORIES
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
{
- $caption_type = null;
- $caption_lang = null;
- $caption_startTime = null;
- $caption_endTime = null;
- $caption_text = null;
- if (isset($caption['attribs']['']['type']))
+ foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
{
- $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($caption['attribs']['']['lang']))
- {
- $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($caption['attribs']['']['start']))
- {
- $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($caption['attribs']['']['end']))
- {
- $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $term = null;
+ $scheme = null;
+ $label = null;
+ if (isset($category['data']))
+ {
+ $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($category['attribs']['']['scheme']))
+ {
+ $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ else
+ {
+ $scheme = 'http://search.yahoo.com/mrss/category_schema';
+ }
+ if (isset($category['attribs']['']['label']))
+ {
+ $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ $categories[] =& new $this->feed->category_class($term, $scheme, $label);
}
- if (isset($caption['data']))
+ }
+ if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
+ {
+ foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
{
- $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $term = null;
+ $scheme = null;
+ $label = null;
+ if (isset($category['data']))
+ {
+ $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($category['attribs']['']['scheme']))
+ {
+ $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ else
+ {
+ $scheme = 'http://search.yahoo.com/mrss/category_schema';
+ }
+ if (isset($category['attribs']['']['label']))
+ {
+ $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ $categories[] =& new $this->feed->category_class($term, $scheme, $label);
}
- $captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
}
- if (is_array($captions))
+ if (is_array($categories) && is_array($categories_parent))
{
- $captions = array_values(SimplePie_Misc::array_unique($captions));
+ $categories = array_values(SimplePie_Misc::array_unique(array_merge($categories, $categories_parent)));
+ }
+ elseif (is_array($categories))
+ {
+ $categories = array_values(SimplePie_Misc::array_unique($categories));
+ }
+ elseif (is_array($categories_parent))
+ {
+ $categories = array_values(SimplePie_Misc::array_unique($categories_parent));
}
- }
- else
- {
- $captions = $captions_parent;
- }
- // CATEGORIES
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
- {
- foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
+ // COPYRIGHTS
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
{
- $term = null;
- $scheme = null;
- $label = null;
- if (isset($category['data']))
+ $copyright_url = null;
+ $copyright_label = null;
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
{
- $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
}
- if (isset($category['attribs']['']['scheme']))
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
{
- $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
- else
+ $copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label);
+ }
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
+ {
+ $copyright_url = null;
+ $copyright_label = null;
+ if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
{
- $scheme = 'http://search.yahoo.com/mrss/category_schema';
+ $copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
}
- if (isset($category['attribs']['']['label']))
+ if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
{
- $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
- $categories[] =& new $this->feed->category_class($term, $scheme, $label);
+ $copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label);
}
- }
- if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
- {
- foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
+ else
{
- $term = null;
- $scheme = null;
- $label = null;
- if (isset($category['data']))
+ $copyrights = $copyrights_parent;
+ }
+
+ // CREDITS
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
+ {
+ foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
{
- $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $credit_role = null;
+ $credit_scheme = null;
+ $credit_name = null;
+ if (isset($credit['attribs']['']['role']))
+ {
+ $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($credit['attribs']['']['scheme']))
+ {
+ $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ else
+ {
+ $credit_scheme = 'urn:ebu';
+ }
+ if (isset($credit['data']))
+ {
+ $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ $credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
}
- if (isset($category['attribs']['']['scheme']))
+ if (is_array($credits))
{
- $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $credits = array_values(SimplePie_Misc::array_unique($credits));
}
- else
+ }
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
+ {
+ foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
{
- $scheme = 'http://search.yahoo.com/mrss/category_schema';
+ $credit_role = null;
+ $credit_scheme = null;
+ $credit_name = null;
+ if (isset($credit['attribs']['']['role']))
+ {
+ $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($credit['attribs']['']['scheme']))
+ {
+ $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ else
+ {
+ $credit_scheme = 'urn:ebu';
+ }
+ if (isset($credit['data']))
+ {
+ $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ $credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
}
- if (isset($category['attribs']['']['label']))
+ if (is_array($credits))
{
- $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $credits = array_values(SimplePie_Misc::array_unique($credits));
}
- $categories[] =& new $this->feed->category_class($term, $scheme, $label);
}
- }
- if (is_array($categories) && is_array($categories_parent))
- {
- $categories = array_values(SimplePie_Misc::array_unique(array_merge($categories, $categories_parent)));
- }
- elseif (is_array($categories))
- {
- $categories = array_values(SimplePie_Misc::array_unique($categories));
- }
- elseif (is_array($categories_parent))
- {
- $categories = array_values(SimplePie_Misc::array_unique($categories_parent));
- }
-
- // COPYRIGHTS
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
- {
- $copyright_url = null;
- $copyright_label = null;
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
+ else
{
- $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $credits = $credits_parent;
}
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
+
+ // DESCRIPTION
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
{
- $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
- $copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label);
- }
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
- {
- $copyright_url = null;
- $copyright_label = null;
- if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
{
- $copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
- if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
+ else
{
- $copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $description = $description_parent;
}
- $copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label);
- }
- else
- {
- $copyrights = $copyrights_parent;
- }
- // CREDITS
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
- {
- foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
+ // HASHES
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
{
- $credit_role = null;
- $credit_scheme = null;
- $credit_name = null;
- if (isset($credit['attribs']['']['role']))
+ foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
{
- $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $value = null;
+ $algo = null;
+ if (isset($hash['data']))
+ {
+ $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($hash['attribs']['']['algo']))
+ {
+ $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ else
+ {
+ $algo = 'md5';
+ }
+ $hashes[] = $algo.':'.$value;
}
- if (isset($credit['attribs']['']['scheme']))
+ if (is_array($hashes))
{
- $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $hashes = array_values(SimplePie_Misc::array_unique($hashes));
}
- else
+ }
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
+ {
+ foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
{
- $credit_scheme = 'urn:ebu';
+ $value = null;
+ $algo = null;
+ if (isset($hash['data']))
+ {
+ $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($hash['attribs']['']['algo']))
+ {
+ $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ else
+ {
+ $algo = 'md5';
+ }
+ $hashes[] = $algo.':'.$value;
}
- if (isset($credit['data']))
+ if (is_array($hashes))
{
- $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $hashes = array_values(SimplePie_Misc::array_unique($hashes));
}
- $credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
}
- if (is_array($credits))
+ else
{
- $credits = array_values(SimplePie_Misc::array_unique($credits));
+ $hashes = $hashes_parent;
}
- }
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
- {
- foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
+
+ // KEYWORDS
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
{
- $credit_role = null;
- $credit_scheme = null;
- $credit_name = null;
- if (isset($credit['attribs']['']['role']))
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
{
- $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
+ foreach ($temp as $word)
+ {
+ $keywords[] = trim($word);
+ }
+ unset($temp);
}
- if (isset($credit['attribs']['']['scheme']))
+ if (is_array($keywords))
{
- $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $keywords = array_values(SimplePie_Misc::array_unique($keywords));
}
- else
+ }
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
+ {
+ if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
{
- $credit_scheme = 'urn:ebu';
+ $temp = explode(',', $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
+ foreach ($temp as $word)
+ {
+ $keywords[] = trim($word);
+ }
+ unset($temp);
}
- if (isset($credit['data']))
+ if (is_array($keywords))
{
- $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $keywords = array_values(SimplePie_Misc::array_unique($keywords));
}
- $credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
}
- if (is_array($credits))
+ else
{
- $credits = array_values(SimplePie_Misc::array_unique($credits));
+ $keywords = $keywords_parent;
}
- }
- else
- {
- $credits = $credits_parent;
- }
- // DESCRIPTION
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
- {
- $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
- {
- $description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- else
- {
- $description = $description_parent;
- }
-
- // HASHES
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
- {
- foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
+ // PLAYER
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
{
- $value = null;
- $algo = null;
- if (isset($hash['data']))
- {
- $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($hash['attribs']['']['algo']))
- {
- $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- else
- {
- $algo = 'md5';
- }
- $hashes[] = $algo.':'.$value;
+ $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
}
- if (is_array($hashes))
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
{
- $hashes = array_values(SimplePie_Misc::array_unique($hashes));
+ $player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
}
- }
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
- {
- foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
+ else
{
- $value = null;
- $algo = null;
- if (isset($hash['data']))
- {
- $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($hash['attribs']['']['algo']))
+ $player = $player_parent;
+ }
+
+ // RATINGS
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
+ {
+ foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
{
- $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $rating_scheme = null;
+ $rating_value = null;
+ if (isset($rating['attribs']['']['scheme']))
+ {
+ $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ else
+ {
+ $rating_scheme = 'urn:simple';
+ }
+ if (isset($rating['data']))
+ {
+ $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ $ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
}
- else
+ if (is_array($ratings))
{
- $algo = 'md5';
+ $ratings = array_values(SimplePie_Misc::array_unique($ratings));
}
- $hashes[] = $algo.':'.$value;
}
- if (is_array($hashes))
- {
- $hashes = array_values(SimplePie_Misc::array_unique($hashes));
- }
- }
- else
- {
- $hashes = $hashes_parent;
- }
-
- // KEYWORDS
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
- {
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
{
- $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
- foreach ($temp as $word)
+ foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
{
- $keywords[] = trim($word);
+ $rating_scheme = null;
+ $rating_value = null;
+ if (isset($rating['attribs']['']['scheme']))
+ {
+ $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ else
+ {
+ $rating_scheme = 'urn:simple';
+ }
+ if (isset($rating['data']))
+ {
+ $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ $ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
}
- unset($temp);
- }
- if (is_array($keywords))
- {
- $keywords = array_values(SimplePie_Misc::array_unique($keywords));
- }
- }
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
- {
- if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
- {
- $temp = explode(',', $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
- foreach ($temp as $word)
+ if (is_array($ratings))
{
- $keywords[] = trim($word);
+ $ratings = array_values(SimplePie_Misc::array_unique($ratings));
}
- unset($temp);
}
- if (is_array($keywords))
+ else
{
- $keywords = array_values(SimplePie_Misc::array_unique($keywords));
+ $ratings = $ratings_parent;
}
- }
- else
- {
- $keywords = $keywords_parent;
- }
-
- // PLAYER
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
- {
- $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
- }
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
- {
- $player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
- }
- else
- {
- $player = $player_parent;
- }
- // RATINGS
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
- {
- foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
+ // RESTRICTIONS
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
{
- $rating_scheme = null;
- $rating_value = null;
- if (isset($rating['attribs']['']['scheme']))
+ foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
{
- $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- else
- {
- $rating_scheme = 'urn:simple';
+ $restriction_relationship = null;
+ $restriction_type = null;
+ $restriction_value = null;
+ if (isset($restriction['attribs']['']['relationship']))
+ {
+ $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($restriction['attribs']['']['type']))
+ {
+ $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($restriction['data']))
+ {
+ $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ $restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
}
- if (isset($rating['data']))
+ if (is_array($restrictions))
{
- $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
}
- $ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
- }
- if (is_array($ratings))
- {
- $ratings = array_values(SimplePie_Misc::array_unique($ratings));
}
- }
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
- {
- foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
{
- $rating_scheme = null;
- $rating_value = null;
- if (isset($rating['attribs']['']['scheme']))
- {
- $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- else
+ foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
{
- $rating_scheme = 'urn:simple';
+ $restriction_relationship = null;
+ $restriction_type = null;
+ $restriction_value = null;
+ if (isset($restriction['attribs']['']['relationship']))
+ {
+ $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($restriction['attribs']['']['type']))
+ {
+ $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ if (isset($restriction['data']))
+ {
+ $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ }
+ $restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
}
- if (isset($rating['data']))
+ if (is_array($restrictions))
{
- $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
}
- $ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
}
- if (is_array($ratings))
+ else
{
- $ratings = array_values(SimplePie_Misc::array_unique($ratings));
+ $restrictions = $restrictions_parent;
}
- }
- else
- {
- $ratings = $ratings_parent;
- }
- // RESTRICTIONS
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
- {
- foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
+ // THUMBNAILS
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
{
- $restriction_relationship = null;
- $restriction_type = null;
- $restriction_value = null;
- if (isset($restriction['attribs']['']['relationship']))
+ foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
{
- $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
}
- if (isset($restriction['attribs']['']['type']))
+ if (is_array($thumbnails))
{
- $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
}
- if (isset($restriction['data']))
- {
- $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- $restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
}
- if (is_array($restrictions))
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
{
- $restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
- }
- }
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
- {
- foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
- {
- $restriction_relationship = null;
- $restriction_type = null;
- $restriction_value = null;
- if (isset($restriction['attribs']['']['relationship']))
- {
- $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- if (isset($restriction['attribs']['']['type']))
+ foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
{
- $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
}
- if (isset($restriction['data']))
+ if (is_array($thumbnails))
{
- $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+ $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
}
- $restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
}
- if (is_array($restrictions))
+ else
{
- $restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
+ $thumbnails = $thumbnails_parent;
}
- }
- else
- {
- $restrictions = $restrictions_parent;
- }
- // THUMBNAILS
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
- {
- foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
+ // TITLES
+ if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
{
- $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
+ $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
- if (is_array($thumbnails))
+ elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
{
- $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
+ $title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
}
- }
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
- {
- foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
- {
- $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
- }
- if (is_array($thumbnails))
+ else
{
- $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
+ $title = $title_parent;
}
- }
- else
- {
- $thumbnails = $thumbnails_parent;
- }
- // TITLES
- if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
- {
- $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
- {
- $title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
- }
- else
- {
- $title = $title_parent;
+ $this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width);
}
-
- $this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width);
}
}
}
@@ -5051,7 +5061,7 @@ class SimplePie_Item
{
foreach ((array) $this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
{
- if (isset($content['attribs']['']['url']))
+ if (isset($content['attribs']['']['url']) || isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
{
// Attributes
$bitrate = null;
@@ -5136,8 +5146,10 @@ class SimplePie_Item
{
$width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
}
- $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
-
+ if (isset($content['attribs']['']['url']))
+ {
+ $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
+ }
// Checking the other optional media: elements. Priority: media:content, media:group, item, channel
// CAPTIONS
@@ -5579,7 +5591,7 @@ class SimplePie_Item
{
return (float) $return[0]['data'];
}
- elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
+ elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
{
return (float) $match[1];
}
@@ -5599,7 +5611,7 @@ class SimplePie_Item
{
return (float) $return[0]['data'];
}
- elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
+ elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
{
return (float) $match[2];
}
@@ -6222,7 +6234,7 @@ class SimplePie_Source
{
return (float) $return[0]['data'];
}
- elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
+ elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
{
return (float) $match[1];
}
@@ -6242,7 +6254,7 @@ class SimplePie_Source
{
return (float) $return[0]['data'];
}
- elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
+ elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
{
return (float) $match[2];
}
@@ -7726,16 +7738,17 @@ class SimplePie_File
{
$this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN;
$url_parts = parse_url($url);
+ $socket_host = $url_parts['host'];
if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https')
{
- $url_parts['host'] = "ssl://$url_parts[host]";
+ $socket_host = "ssl://$url_parts[host]";
$url_parts['port'] = 443;
}
if (!isset($url_parts['port']))
{
$url_parts['port'] = 80;
}
- $fp = @fsockopen($url_parts['host'], $url_parts['port'], $errno, $errstr, $timeout);
+ $fp = @fsockopen($socket_host, $url_parts['port'], $errno, $errstr, $timeout);
if (!$fp)
{
$this->error = 'fsockopen error: ' . $errstr;
@@ -8481,7 +8494,7 @@ class SimplePie_gzdecode
// Get the length of the extra field
$len = current(unpack('v', substr($this->compressed_data, $this->position, 2)));
- $position += 2;
+ $this->position += 2;
// Check the length of the string is still valid
$this->min_compressed_size += $len + 4;
@@ -9233,8 +9246,25 @@ class SimplePie_Misc
$note = 'Unknown Error';
break;
}
- error_log("$note: $message in $file on line $line", 0);
+
+ $log_error = true;
+ if (!function_exists('error_log'))
+ {
+ $log_error = false;
+ }
+
+ $log_file = @ini_get('error_log');
+ if (!empty($log_file) && ('syslog' != $log_file) && !@is_writable($log_file))
+ {
+ $log_error = false;
+ }
+
+ if ($log_error)
+ {
+ @error_log("$note: $message in $file on line $line", 0);
+ }
}
+
return $message;
}
@@ -9426,12 +9456,12 @@ class SimplePie_Misc
}
// This is first, as behaviour of this is completely predictable
- if ($input === 'Windows-1252' && $output === 'UTF-8')
+ if ($input === 'windows-1252' && $output === 'UTF-8')
{
return SimplePie_Misc::windows_1252_to_utf8($data);
}
// This is second, as behaviour of this varies only with PHP version (the middle part of this expression checks the encoding is supported).
- elseif (function_exists('mb_convert_encoding') && @mb_convert_encoding("\x80", 'UTF-16BE', $input) !== "\x00\x80" && ($return = @mb_convert_encoding($data, $output, $input)))
+ elseif (function_exists('mb_convert_encoding') && @mb_convert_encoding("\x80", 'UTF-16BE', $input) !== "\x00\x80" && in_array($input, mb_list_encodings()) && ($return = @mb_convert_encoding($data, $output, $input)))
{
return $return;
}
@@ -9447,6 +9477,17 @@ class SimplePie_Misc
}
}
+ /**
+ * Normalize an encoding name
+ *
+ * This is automatically generated by create.php
+ *
+ * To generate it, run `php create.php` on the command line, and copy the
+ * output to replace this function.
+ *
+ * @param string $charset Character set to standardise
+ * @return string Standardised name
+ */
function encoding($charset)
{
// Normalization from UTS #22
@@ -9480,7 +9521,6 @@ class SimplePie_Misc
case 'big5':
case 'csbig5':
- case 'xxbig5':
return 'Big5';
case 'big5hkscs':
@@ -9636,14 +9676,14 @@ class SimplePie_Misc
case 'isoir85':
return 'ES2';
- case 'cseucfixwidjapanese':
- case 'extendedunixcodefixedwidthforjapanese':
- return 'Extended_UNIX_Code_Fixed_Width_for_Japanese';
-
case 'cseucpkdfmtjapanese':
case 'eucjp':
case 'extendedunixcodepackedformatforjapanese':
- return 'Extended_UNIX_Code_Packed_Format_for_Japanese';
+ return 'EUC-JP';
+
+ case 'cseucfixwidjapanese':
+ case 'extendedunixcodefixedwidthforjapanese':
+ return 'Extended_UNIX_Code_Fixed_Width_for_Japanese';
case 'gb18030':
return 'GB18030';
@@ -9722,80 +9762,6 @@ class SimplePie_Misc
case 'ibmthai':
return 'IBM-Thai';
- case 'ccsid858':
- case 'cp858':
- case 'ibm858':
- case 'pcmultilingual850euro':
- return 'IBM00858';
-
- case 'ccsid924':
- case 'cp924':
- case 'ebcdiclatin9euro':
- case 'ibm924':
- return 'IBM00924';
-
- case 'ccsid1140':
- case 'cp1140':
- case 'ebcdicus37euro':
- case 'ibm1140':
- return 'IBM01140';
-
- case 'ccsid1141':
- case 'cp1141':
- case 'ebcdicde273euro':
- case 'ibm1141':
- return 'IBM01141';
-
- case 'ccsid1142':
- case 'cp1142':
- case 'ebcdicdk277euro':
- case 'ebcdicno277euro':
- case 'ibm1142':
- return 'IBM01142';
-
- case 'ccsid1143':
- case 'cp1143':
- case 'ebcdicfi278euro':
- case 'ebcdicse278euro':
- case 'ibm1143':
- return 'IBM01143';
-
- case 'ccsid1144':
- case 'cp1144':
- case 'ebcdicit280euro':
- case 'ibm1144':
- return 'IBM01144';
-
- case 'ccsid1145':
- case 'cp1145':
- case 'ebcdices284euro':
- case 'ibm1145':
- return 'IBM01145';
-
- case 'ccsid1146':
- case 'cp1146':
- case 'ebcdicgb285euro':
- case 'ibm1146':
- return 'IBM01146';
-
- case 'ccsid1147':
- case 'cp1147':
- case 'ebcdicfr297euro':
- case 'ibm1147':
- return 'IBM01147';
-
- case 'ccsid1148':
- case 'cp1148':
- case 'ebcdicinternational500euro':
- case 'ibm1148':
- return 'IBM01148';
-
- case 'ccsid1149':
- case 'cp1149':
- case 'ebcdicis871euro':
- case 'ibm1149':
- return 'IBM01149';
-
case 'cp37':
case 'csibm37':
case 'ebcdiccpca':
@@ -9943,6 +9909,12 @@ class SimplePie_Misc
case 'ibm857':
return 'IBM857';
+ case 'ccsid858':
+ case 'cp858':
+ case 'ibm858':
+ case 'pcmultilingual850euro':
+ return 'IBM00858';
+
case '860':
case 'cp860':
case 'csibm860':
@@ -10045,6 +10017,12 @@ class SimplePie_Misc
case 'ibm918':
return 'IBM918';
+ case 'ccsid924':
+ case 'cp924':
+ case 'ebcdiclatin9euro':
+ case 'ibm924':
+ return 'IBM00924';
+
case 'cp1026':
case 'csibm1026':
case 'ibm1026':
@@ -10053,6 +10031,68 @@ class SimplePie_Misc
case 'ibm1047':
return 'IBM1047';
+ case 'ccsid1140':
+ case 'cp1140':
+ case 'ebcdicus37euro':
+ case 'ibm1140':
+ return 'IBM01140';
+
+ case 'ccsid1141':
+ case 'cp1141':
+ case 'ebcdicde273euro':
+ case 'ibm1141':
+ return 'IBM01141';
+
+ case 'ccsid1142':
+ case 'cp1142':
+ case 'ebcdicdk277euro':
+ case 'ebcdicno277euro':
+ case 'ibm1142':
+ return 'IBM01142';
+
+ case 'ccsid1143':
+ case 'cp1143':
+ case 'ebcdicfi278euro':
+ case 'ebcdicse278euro':
+ case 'ibm1143':
+ return 'IBM01143';
+
+ case 'ccsid1144':
+ case 'cp1144':
+ case 'ebcdicit280euro':
+ case 'ibm1144':
+ return 'IBM01144';
+
+ case 'ccsid1145':
+ case 'cp1145':
+ case 'ebcdices284euro':
+ case 'ibm1145':
+ return 'IBM01145';
+
+ case 'ccsid1146':
+ case 'cp1146':
+ case 'ebcdicgb285euro':
+ case 'ibm1146':
+ return 'IBM01146';
+
+ case 'ccsid1147':
+ case 'cp1147':
+ case 'ebcdicfr297euro':
+ case 'ibm1147':
+ return 'IBM01147';
+
+ case 'ccsid1148':
+ case 'cp1148':
+ case 'ebcdicinternational500euro':
+ case 'ibm1148':
+ return 'IBM01148';
+
+ case 'ccsid1149':
+ case 'cp1149':
+ case 'ebcdicis871euro':
+ case 'ibm1149':
+ return 'IBM01149';
+
case 'csiso143iecp271':
case 'iecp271':
case 'isoir143':
@@ -10595,11 +10635,6 @@ class SimplePie_Misc
case 'sen850200c':
return 'SEN_850200_C';
- case 'csshiftjis':
- case 'mskanji':
- case 'shiftjis':
- return 'Shift_JIS';
-
case 'csiso102t617bit':
case 'isoir102':
case 't617bit':
@@ -10698,7 +10733,10 @@ class SimplePie_Misc
case 'viscii':
return 'VISCII';
+ case 'csshiftjis':
case 'cswindows31j':
+ case 'mskanji':
+ case 'shiftjis':
case 'windows31j':
return 'Windows-31J';
@@ -11359,6 +11397,58 @@ function embed_wmedia(width, height, link) {
}
<?php
}
+
+
+
+ /**
+ * Format debugging information
+ */
+ function debug($sp)
+ {
+ $info = 'SimplePie ' . SIMPLEPIE_VERSION . ' Build ' . SIMPLEPIE_BUILD . "\n";
+ $info .= 'PHP ' . PHP_VERSION . "\n";
+ if ($sp->error() !== null)
+ {
+ $info .= 'Error occurred: ' . $sp->error() . "\n";
+ }
+ else
+ {
+ $info .= "No error found.\n";
+ }
+ $info .= "Extensions:\n";
+ $extensions = array('pcre', 'curl', 'zlib', 'mbstring', 'iconv', 'xmlreader', 'xml');
+ foreach ($extensions as $ext)
+ {
+ if (extension_loaded($ext))
+ {
+ $info .= " $ext loaded\n";
+ switch ($ext)
+ {
+ case 'pcre':
+ $info .= ' Version ' . PCRE_VERSION . "\n";
+ break;
+ case 'curl':
+ $version = curl_version();
+ $info .= ' Version ' . $version['version'] . "\n";
+ break;
+ case 'mbstring':
+ $info .= ' Overloading: ' . mb_get_info('func_overload') . "\n";
+ break;
+ case 'iconv':
+ $info .= ' Version ' . ICONV_VERSION . "\n";
+ break;
+ case 'xml':
+ $info .= ' Version ' . LIBXML_DOTTED_VERSION . "\n";
+ break;
+ }
+ }
+ else
+ {
+ $info .= " $ext not loaded\n";
+ }
+ }
+ return $info;
+ }
}
/**
@@ -11830,14 +11920,135 @@ class SimplePie_IRI
/**
* Replace invalid character with percent encoding
*
- * @access private
* @param string $string Input string
* @param string $valid_chars Valid characters
* @param int $case Normalise case
* @return string
*/
- function replace_invalid_with_pct_encoding($string, $valid_chars, $case = SIMPLEPIE_SAME_CASE)
+ function replace_invalid_with_pct_encoding($string, $valid_chars, $case = SIMPLEPIE_SAME_CASE, $iprivate = false)
{
+ // Normalize as many pct-encoded sections as possible
+ $string = preg_replace_callback('/(?:%[A-Fa-f0-9]{2})+/', array(&$this, 'remove_iunreserved_percent_encoded'), $string);
+
+ // Replace invalid percent characters
+ $string = preg_replace('/%(?![A-Fa-f0-9]{2})/', '%25', $string);
+
+ // Add unreserved and % to $valid_chars (the latter is safe because all
+ // pct-encoded sections are now valid).
+ $valid_chars .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~%';
+
+ // Now replace any bytes that aren't allowed with their pct-encoded versions
+ $position = 0;
+ $strlen = strlen($string);
+ while (($position += strspn($string, $valid_chars, $position)) < $strlen)
+ {
+ $value = ord($string[$position]);
+
+ // Start position
+ $start = $position;
+
+ // By default we are valid
+ $valid = true;
+
+ // No one byte sequences are valid due to the while.
+ // Two byte sequence:
+ if (($value & 0xE0) === 0xC0)
+ {
+ $character = ($value & 0x1F) << 6;
+ $length = 2;
+ $remaining = 1;
+ }
+ // Three byte sequence:
+ elseif (($value & 0xF0) === 0xE0)
+ {
+ $character = ($value & 0x0F) << 12;
+ $length = 3;
+ $remaining = 2;
+ }
+ // Four byte sequence:
+ elseif (($value & 0xF8) === 0xF0)
+ {
+ $character = ($value & 0x07) << 18;
+ $length = 4;
+ $remaining = 3;
+ }
+ // Invalid byte:
+ else
+ {
+ $valid = false;
+ $length = 1;
+ $remaining = 0;
+ }
+
+ if ($remaining)
+ {
+ if ($position + $length <= $strlen)
+ {
+ for ($position++; $remaining; $position++)
+ {
+ $value = ord($string[$position]);
+
+ // Check that the byte is valid, then add it to the character:
+ if (($value & 0xC0) === 0x80)
+ {
+ $character |= ($value & 0x3F) << (--$remaining * 6);
+ }
+ // If it is invalid, count the sequence as invalid and reprocess the current byte:
+ else
+ {
+ $valid = false;
+ $position--;
+ break;
+ }
+ }
+ }
+ else
+ {
+ $position = $strlen - 1;
+ $valid = false;
+ }
+ }
+
+ // Percent encode anything invalid or not in ucschar
+ if (
+ // Invalid sequences
+ !$valid
+ // Non-shortest form sequences are invalid
+ || $length > 1 && $character <= 0x7F
+ || $length > 2 && $character <= 0x7FF
+ || $length > 3 && $character <= 0xFFFF
+ // Outside of range of ucschar codepoints
+ // Noncharacters
+ || ($character & 0xFFFE) === 0xFFFE
+ || $character >= 0xFDD0 && $character <= 0xFDEF
+ || (
+ // Everything else not in ucschar
+ $character > 0xD7FF && $character < 0xF900
+ || $character < 0xA0
+ || $character > 0xEFFFD
+ )
+ && (
+ // Everything not in iprivate, if it applies
+ !$iprivate
+ || $character < 0xE000
+ || $character > 0x10FFFD
+ )
+ )
+ {
+ // If we were a character, pretend we weren't, but rather an error.
+ if ($valid)
+ $position--;
+
+ for ($j = $start; $j <= $position; $j++)
+ {
+ $string = substr_replace($string, sprintf('%%%02X', ord($string[$j])), $j, 1);
+ $j += 2;
+ $position += 2;
+ $strlen += 2;
+ }
+ }
+ }
+
// Normalise case
if ($case & SIMPLEPIE_LOWERCASE)
{
@@ -11848,61 +12059,148 @@ class SimplePie_IRI
$string = strtoupper($string);
}
- // Store position and string length (to avoid constantly recalculating this)
- $position = 0;
- $strlen = strlen($string);
+ return $string;
+ }
- // Loop as long as we have invalid characters, advancing the position to the next invalid character
- while (($position += strspn($string, $valid_chars, $position)) < $strlen)
+ /**
+ * Callback function for preg_replace_callback.
+ *
+ * Removes sequences of percent encoded bytes that represent UTF-8
+ * encoded characters in iunreserved
+ *
+ * @access private
+ * @param array $match PCRE match
+ * @return string Replacement
+ */
+ function remove_iunreserved_percent_encoded($match)
+ {
+ // As we just have valid percent encoded sequences we can just explode
+ // and ignore the first member of the returned array (an empty string).
+ $bytes = explode('%', $match[0]);
+
+ // Initialize the new string (this is what will be returned) and that
+ // there are no bytes remaining in the current sequence (unsurprising
+ // at the first byte!).
+ $string = '';
+ $remaining = 0;
+
+ // Loop over each and every byte, and set $value to its value
+ for ($i = 1, $len = count($bytes); $i < $len; $i++)
{
- // If we have a % character
- if ($string[$position] === '%')
+ $value = hexdec($bytes[$i]);
+
+ // If we're the first byte of sequence:
+ if (!$remaining)
{
- // If we have a pct-encoded section
- if ($position + 2 < $strlen && strspn($string, '0123456789ABCDEFabcdef', $position + 1, 2) === 2)
- {
- // Get the the represented character
- $chr = chr(hexdec(substr($string, $position + 1, 2)));
+ // Start position
+ $start = $i;
- // If the character is valid, replace the pct-encoded with the actual character while normalising case
- if (strpos($valid_chars, $chr) !== false)
- {
- if ($case & SIMPLEPIE_LOWERCASE)
- {
- $chr = strtolower($chr);
- }
- elseif ($case & SIMPLEPIE_UPPERCASE)
- {
- $chr = strtoupper($chr);
- }
- $string = substr_replace($string, $chr, $position, 3);
- $strlen -= 2;
- $position++;
- }
+ // By default we are valid
+ $valid = true;
- // Otherwise just normalise the pct-encoded to uppercase
- else
+ // One byte sequence:
+ if ($value <= 0x7F)
+ {
+ $character = $value;
+ $length = 1;
+ }
+ // Two byte sequence:
+ elseif (($value & 0xE0) === 0xC0)
+ {
+ $character = ($value & 0x1F) << 6;
+ $length = 2;
+ $remaining = 1;
+ }
+ // Three byte sequence:
+ elseif (($value & 0xF0) === 0xE0)
+ {
+ $character = ($value & 0x0F) << 12;
+ $length = 3;
+ $remaining = 2;
+ }
+ // Four byte sequence:
+ elseif (($value & 0xF8) === 0xF0)
+ {
+ $character = ($value & 0x07) << 18;
+ $length = 4;
+ $remaining = 3;
+ }
+ // Invalid byte:
+ else
+ {
+ $valid = false;
+ $remaining = 0;
+ }
+ }
+ // Continuation byte:
+ else
+ {
+ // Check that the byte is valid, then add it to the character:
+ if (($value & 0xC0) === 0x80)
+ {
+ $remaining--;
+ $character |= ($value & 0x3F) << ($remaining * 6);
+ }
+ // If it is invalid, count the sequence as invalid and reprocess the current byte as the start of a sequence:
+ else
+ {
+ $valid = false;
+ $remaining = 0;
+ $i--;
+ }
+ }
+
+ // If we've reached the end of the current byte sequence, append it to Unicode::$data
+ if (!$remaining)
+ {
+ // Percent encode anything invalid or not in iunreserved
+ if (
+ // Invalid sequences
+ !$valid
+ // Non-shortest form sequences are invalid
+ || $length > 1 && $character <= 0x7F
+ || $length > 2 && $character <= 0x7FF
+ || $length > 3 && $character <= 0xFFFF
+ // Outside of range of iunreserved codepoints
+ || $character < 0x2D
+ || $character > 0xEFFFD
+ // Noncharacters
+ || ($character & 0xFFFE) === 0xFFFE
+ || $character >= 0xFDD0 && $character <= 0xFDEF
+ // Everything else not in iunreserved (this is all BMP)
+ || $character === 0x2F
+ || $character > 0x39 && $character < 0x41
+ || $character > 0x5A && $character < 0x61
+ || $character > 0x7A && $character < 0x7E
+ || $character > 0x7E && $character < 0xA0
+ || $character > 0xD7FF && $character < 0xF900
+ )
+ {
+ for ($j = $start; $j <= $i; $j++)
{
- $string = substr_replace($string, strtoupper(substr($string, $position + 1, 2)), $position + 1, 2);
- $position += 3;
+ $string .= '%' . strtoupper($bytes[$j]);
}
}
- // If we don't have a pct-encoded section, just replace the % with its own esccaped form
else
{
- $string = substr_replace($string, '%25', $position, 1);
- $strlen += 2;
- $position += 3;
+ for ($j = $start; $j <= $i; $j++)
+ {
+ $string .= chr(hexdec($bytes[$j]));
+ }
}
}
- // If we have an invalid character, change into its pct-encoded form
- else
+ }
+
+ // If we have any bytes left over they are invalid (i.e., we are
+ // mid-way through a multi-byte sequence)
+ if ($remaining)
+ {
+ for ($j = $start; $j < $len; $j++)
{
- $replacement = sprintf("%%%02X", ord($string[$position]));
- $string = str_replace($string[$position], $replacement, $string);
- $strlen = strlen($string);
+ $string .= '%' . strtoupper($bytes[$j]);
}
}
+
return $string;
}
@@ -12129,7 +12427,7 @@ class SimplePie_IRI
}
else
{
- $this->query = $this->replace_invalid_with_pct_encoding($query, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=:@/?');
+ $this->query = $this->replace_invalid_with_pct_encoding($query, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$\'()*+,;:@/?&=');
}
$this->valid[__FUNCTION__] = true;
return true;
@@ -13932,7 +14230,7 @@ class SimplePie_XML_Declaration_Parser
}
else
{
- $this->state = 'standalone_name';
+ $this->state = false;
}
}
@@ -13946,7 +14244,7 @@ class SimplePie_XML_Declaration_Parser
}
else
{
- $this->state = false;
+ $this->state = 'standalone_name';
}
}
@@ -14424,7 +14722,7 @@ class SimplePie_Parser
case constant('XMLReader::END_ELEMENT'):
if ($xml->namespaceURI !== '')
{
- $tagName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}";
+ $tagName = $xml->namespaceURI . $this->separator . $xml->localName;
}
else
{
@@ -14436,7 +14734,7 @@ class SimplePie_Parser
$empty = $xml->isEmptyElement;
if ($xml->namespaceURI !== '')
{
- $tagName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}";
+ $tagName = $xml->namespaceURI . $this->separator . $xml->localName;
}
else
{
@@ -14447,7 +14745,7 @@ class SimplePie_Parser
{
if ($xml->namespaceURI !== '')
{
- $attrName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}";
+ $attrName = $xml->namespaceURI . $this->separator . $xml->localName;
}
else
{
@@ -14912,7 +15210,7 @@ class SimplePie_Sanitize
}
else
{
- trigger_error("$this->cache_location is not writeable", E_USER_WARNING);
+ trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
}
}
}
diff --git a/views/default/feed_reader/css.php b/views/default/feed_reader/css.php
deleted file mode 100644
index 7bd8d74d3..000000000
--- a/views/default/feed_reader/css.php
+++ /dev/null
@@ -1,27 +0,0 @@
-/*-------------------------------
-SIMPLEPIE FEED WIDGET
--------------------------------*/
-.simplepie_blog_title {
- text-align: center;
- margin-bottom: 15px;
-}
-
-.simplepie_item {
- margin-bottom: 12px;
-}
-
-.simplepie_title {
- margin-bottom: 4px;
-}
-
-.simplepie_excerpt {
- margin-bottom: 4px;
-}
-
-.simplepie_date {
- font-size: 70%;
-}
-
-.simplepie_excerpt img {
- width: 170px;
-}
diff --git a/views/default/settings/simplepie/edit.php b/views/default/settings/simplepie/edit.php
deleted file mode 100644
index d67034aa4..000000000
--- a/views/default/settings/simplepie/edit.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-global $CONFIG;
-
-$compat_url = $CONFIG->wwwroot . 'mod/simplepie/sp_compatibility_test.php';
-
-?>
-
-<p>
-<a href="<?php echo $compat_url; ?>">Compatibility Test</a>
-</p>
diff --git a/views/default/simplepie/css.php b/views/default/simplepie/css.php
new file mode 100644
index 000000000..32cec16a6
--- /dev/null
+++ b/views/default/simplepie/css.php
@@ -0,0 +1,17 @@
+<?php
+/**
+ * Simple CSS
+ */
+?>
+
+/* ***************************************
+ SIMPLIE
+*************************************** */
+.simplepie-heading {
+ text-align: center;
+ margin-bottom: 8px;
+}
+
+.simplepie-list img {
+ max-width: 100%;
+}
diff --git a/views/default/widgets/feed_reader/content.php b/views/default/widgets/feed_reader/content.php
new file mode 100644
index 000000000..f13b00fe7
--- /dev/null
+++ b/views/default/widgets/feed_reader/content.php
@@ -0,0 +1,81 @@
+<?php
+/**
+ * View a feed in a widget
+ */
+
+elgg_load_library('simplepie');
+
+$allowed_tags = '<a><p><br><b><i><em><del><pre><strong><ul><ol><li><img>';
+$feed_url = $vars['entity']->feed_url;
+if ($feed_url) {
+
+ // get widget settings
+ $excerpt = $vars['entity']->excerpt;
+ $num_items = $vars['entity']->num_items;
+ $post_date = $vars['entity']->post_date;
+
+ $cache_location = elgg_get_data_path() . '/simplepie_cache/';
+ if (!file_exists($cache_location)) {
+ mkdir($cache_location, 0777);
+ }
+
+ $feed = new SimplePie($feed_url, $cache_location);
+
+ // doubles timeout if going through a proxy
+ //$feed->set_timeout(20);
+
+ // only display errors to profile owner
+ $num_posts_in_feed = $feed->get_item_quantity();
+ if (!$num_posts_in_feed) {
+ if (elgg_get_logged_in_user_guid() == elgg_get_page_owner_guid()) {
+ echo '<p>' . elgg_echo('simplepie:notfind') . '</p>';
+ }
+ }
+
+ // don't display more feed items than user requested
+ if ($num_items > $num_posts_in_feed) {
+ $num_items = $num_posts_in_feed;
+ }
+
+ $feed_link = elgg_view('output/url', array(
+ 'href' => $feed->get_permalink(),
+ 'text' => $feed->get_title(),
+ ));
+
+ // need to center
+ echo "<h2 class=\"simplepie-heading\">$feed_link</h2>";
+ echo '<ul class="simplepie-list">';
+ foreach ($feed->get_items(0, $num_items) as $item) {
+ $item_link = elgg_view('output/url', array(
+ 'href' => $item->get_permalink(),
+ 'text' => $item->get_title(),
+ ));
+
+ if ($excerpt) {
+ $text = strip_tags($item->get_description(true), $allowed_tags);
+ $excerpt = $text;
+ }
+
+ if ($post_date) {
+ $item_date_label = elgg_echo('simplepie:postedon');
+ $item_date = $item->get_date('j F Y | g:i a');
+ $post_date = "$item_date_label $item_date";
+ }
+
+ echo <<<HTML
+<li class="mbm">
+ <h4 class="mbs">$item_link</h4>
+ <div class="mbs clearfix">$excerpt</div>
+ <p class="elgg-subtext">$post_date</p>
+</li>
+HTML;
+
+ }
+ echo "</ul>";
+
+} else {
+ // display message only to owner
+ if (elgg_get_logged_in_user_guid() == elgg_get_page_owner_guid()) {
+ echo '<p>' . elgg_echo('simplepie:notset') . '</p>';
+ }
+}
diff --git a/views/default/widgets/feed_reader/edit.php b/views/default/widgets/feed_reader/edit.php
index a721f0e8a..83218dcbb 100644
--- a/views/default/widgets/feed_reader/edit.php
+++ b/views/default/widgets/feed_reader/edit.php
@@ -1,69 +1,62 @@
<?php
- $num_items = $vars['entity']->num_items;
- if (!isset($num_items)) {
- $num_items = 10;
- }
+/**
+ * Simplepie feed reader widget settings
+ */
- $excerpt = $vars['entity']->excerpt;
- if (!isset($excerpt)) {
- $excerpt = 0;
- }
-
- $post_date = $vars['entity']->post_date;
- if (!isset($post_date)) {
- $post_date = 0;
- }
-?>
-
-<p>
- <?php echo elgg_echo("simplepie:feed_url"); ?>
- <input type="text" onclick="this.select();" name="params[feed_url]" value="<?php echo htmlentities($vars['entity']->feed_url); ?>" />
-</p>
-
-<p>
-<?php echo elgg_echo('simplepie:num_items'); ?>
-
-<?php
- echo elgg_view('input/pulldown', array(
- 'internalname' => 'params[num_items]',
- 'options_values' => array( '3' => '3',
- '5' => '5',
- '8' => '8',
- '10' => '10',
- '12' => '12',
- '15' => '15',
- '20' => '20',
- ),
- 'value' => $num_items
- ));
-?>
-</p>
+// set default value
+if (!isset($vars['entity']->num_items)) {
+ $vars['entity']->num_items = 10;
+}
-<p>
-<?php
-// used a hidden input field so that something is always sent unlike a checkbox
-echo elgg_view('input/hidden', array('internalname' => 'params[excerpt]',
- 'js' => 'id="params[excerpt]"',
- 'value' => $excerpt ));
-echo "<input class='input-checkboxes' type='checkbox' value='' name='excerptcheckbox' onclick=\"document.getElementById('params[excerpt]').value = 1 - document.getElementById('params[excerpt]').value;\" ";
-if ($excerpt) {
- echo "checked='yes'";
+if (!isset($vars['entity']->excerpt)) {
+ $vars['entity']->excerpt = false;
}
-echo " />";
-echo ' ' . elgg_echo('simplepie:excerpt');
-?>
-</p>
-<p>
-<?php
-echo elgg_view('input/hidden', array('internalname' => 'params[post_date]',
- 'js' => 'id="params[post_date]"',
- 'value' => $post_date ));
-echo "<input class='input-checkboxes' type='checkbox' value='' name='post_datecheckbox' onclick=\"document.getElementById('params[post_date]').value = 1 - document.getElementById('params[post_date]').value;\" ";
-if ($post_date) {
- echo "checked='yes'";
+if (!isset($vars['entity']->post_date)) {
+ $vars['entity']->post_date = false;
}
-echo " />";
-echo ' ' . elgg_echo('simplepie:post_date');
-?>
-</p>
+
+$url_label = elgg_echo("simplepie:feed_url");
+$url_textbox = elgg_view('input/text', array(
+ 'name' => 'params[feed_url]',
+ 'value' => $vars['entity']->feed_url,
+ 'onclick' => 'this.select();',
+));
+
+$num_items_label = elgg_echo('simplepie:num_items');
+$num_items_select = elgg_view('input/dropdown', array(
+ 'name' => 'params[num_items]',
+ 'value' => $vars['entity']->num_items,
+ 'options' => array(3, 5, 8, 10, 12, 15, 20),
+));
+
+$excerpt_label = elgg_echo('simplepie:excerpt');
+$excerpt_checkbox = elgg_view('input/checkbox', array(
+ 'name' => 'params[excerpt]',
+ 'value' => true,
+ 'checked' => $vars['entity']->excerpt ? 'checked' : '',
+));
+
+$post_date_label = elgg_echo('simplepie:post_date');
+$post_date_checkbox = elgg_view('input/checkbox', array(
+ 'name' => 'params[post_date]',
+ 'value' => true,
+ 'checked' => $vars['entity']->post_date ? 'checked' : '',
+));
+
+echo <<<HTML
+<div>
+ $url_label
+ $url_textbox
+</div>
+<div>
+ $num_items_label
+ $num_items_select
+</div>
+<div>
+ $excerpt_checkbox $excerpt_label
+</div>
+<div>
+ $post_date_checkbox $post_date_label
+</div>
+HTML;
diff --git a/views/default/widgets/feed_reader/view.php b/views/default/widgets/feed_reader/view.php
deleted file mode 100644
index 329b2fb98..000000000
--- a/views/default/widgets/feed_reader/view.php
+++ /dev/null
@@ -1,82 +0,0 @@
-<div class="contentWrapper">
-<?php
-global $CONFIG;
-
-if (!class_exists('SimplePie')) {
- require_once $CONFIG->pluginspath . '/simplepie/simplepie.inc';
-}
-
-$allow_tags = '<a><p><br><b><i><em><del><pre><strong><ul><ol><li>';
-$feed_url = $vars['entity']->feed_url;
-if ($feed_url) {
-
- // get widget settings
- $excerpt = $vars['entity']->excerpt;
- $num_items = $vars['entity']->num_items;
- $post_date = $vars['entity']->post_date;
-
- $cache_location = $CONFIG->dataroot . '/simplepie_cache/';
- if (!file_exists($cache_location)) {
- mkdir($cache_location, 0777);
- }
-
- $feed = new SimplePie($feed_url, $cache_location);
-
- // doubles timeout if going through a proxy
- //$feed->set_timeout(20);
-
- $num_posts_in_feed = $feed->get_item_quantity();
-
- // only display errors to profile owner
- if (get_loggedin_userid() == page_owner()) {
- if (!$num_posts_in_feed) {
- echo '<p>' . elgg_echo('simplepie:notfind') . '</p>';
- }
- }
-?>
-<div class="simplepie_blog_title">
- <h2><a href="<?php echo $feed->get_permalink(); ?>"><?php echo $feed->get_title(); ?></a></h2>
-</div>
-<?php
- // don't display more feed items than user requested
- if ($num_items > $num_posts_in_feed) {
- $num_items = $num_posts_in_feed;
- }
-
- foreach ($feed->get_items(0, $num_items) as $item):
-?>
- <div class="simplepie_item">
- <div class="simplepie_title">
- <h4><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h4>
- </div>
-<?php
- if ($excerpt) {
-?>
- <div class="simplepie_excerpt">
- <?php echo strip_tags($item->get_description(true), $allow_tags); ?>
- </div>
-<?php
- }
-
- if ($post_date) {
-?>
- <div class="simplepie_date">
- <?php echo elgg_echo('simplepie:postedon'); ?>
- <?php echo $item->get_date('j F Y | g:i a'); ?>
- </div>
-<?php
- }
-?>
- </div>
-
- <?php endforeach; ?>
-
-<?php
-} else {
- // display message only to owner
- if (get_loggedin_userid() == page_owner()) {
- echo '<p>' . elgg_echo('simplepie:notset') . '</p>';
- }
-}
-?>
-</div>