Commit b543d6b4 authored by Evan Goldenberg's avatar Evan Goldenberg
Browse files

make the number of external feed items configurable (bug #547089)


Signed-off-by: default avatarEvan Goldenberg <evang@catalyst.net.nz>
parent 79fb1a92
......@@ -31,6 +31,8 @@ $string['title'] = 'External Feed';
$string['description'] = 'Embed an external RSS or ATOM feed';
$string['feedlocation'] = 'Feed location';
$string['feedlocationdesc'] = 'URL of a valid RSS or ATOM feed';
$string['itemstoshow'] = 'Items to show';
$string['itemstoshowdescription'] = 'Between 1 and 20';
$string['showfeeditemsinfull'] = 'Show feed items in full?';
$string['showfeeditemsinfulldesc'] = 'Whether to show a summary of the feed items, or show the description for each one too';
$string['invalidurl'] = 'That URL is invalid. You can only view feeds for http and https URLs.';
......
......@@ -61,6 +61,10 @@ class PluginBlocktypeExternalfeed extends SystemBlocktype {
$data->content = unserialize($data->content);
$data->image = unserialize($data->image);
// only keep the number of entries the user asked for
$chunks = array_chunk($data->content, $configdata['count']);
$data->content = $chunks[0];
// Attempt to fix relative URLs in the feeds
if (!empty($data->image['link'])) {
$data->description = preg_replace(
......@@ -125,6 +129,15 @@ class PluginBlocktypeExternalfeed extends SystemBlocktype {
'maxlength' => 2048, // See install.xml for this plugin - MySQL can only safely handle up to 255 chars
),
),
'count' => array(
'type' => 'text',
'title' => get_string('itemstoshow', 'blocktype.externalfeed'),
'description' => get_string('itemstoshowdescription', 'blocktype.externalfeed'),
'defaultvalue' => isset($configdata['count']) ? $configdata['count'] : 10,
'size' => 3,
'minvalue' => 1,
'maxvalue' => 20,
),
'full' => array(
'type' => 'checkbox',
'title' => get_string('showfeeditemsinfull', 'blocktype.externalfeed'),
......@@ -308,7 +321,7 @@ class PluginBlocktypeExternalfeed extends SystemBlocktype {
$data->content = array();
foreach ($feed as $count => $item) {
if ($count == 10) {
if ($count == 20) {
break;
}
$description = $item->content ? $item->content : ($item->description ? $item->description : ($item->summary ? $item->summary : null));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment