aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcash <cash.costello@gmail.com>2010-07-04 19:39:29 +0000
committercash <cash.costello@gmail.com>2010-07-04 19:39:29 +0000
commit16da0ce0f606397012c65950b07262fbecb2fc84 (patch)
tree4d504a62f679c3b0d307e95ca8d7a91634215afa
parent14025a5462c77d841801e00b2eda993bba62264d (diff)
downloadelgg-16da0ce0f606397012c65950b07262fbecb2fc84.tar.gz
elgg-16da0ce0f606397012c65950b07262fbecb2fc84.tar.bz2
brought the simplepie plugin up to Elgg coding standards
-rw-r--r--README28
-rw-r--r--languages/en.php25
-rw-r--r--sp_compatibility_test.php6
-rw-r--r--start.php29
-rw-r--r--views/default/settings/simplepie/edit.php8
-rw-r--r--views/default/widgets/feed_reader/edit.php119
-rw-r--r--views/default/widgets/feed_reader/view.php118
7 files changed, 177 insertions, 156 deletions
diff --git a/README b/README
index bbfb94635..81f5dcd7d 100644
--- a/README
+++ b/README
@@ -1,8 +1,20 @@
-Widget Title
----------------------------
-To change the widget title, edit the language file (en.php) and change the string simplepie:widget from Blog to whatever you desire.
-
-
-Proxy Server
-----------------------------
-If your site is going through a proxy server to get to the feeds, you may want to increase the timeout on the feeds (though this is unlikely as the default timeout is 10 seconds). You can do this by editing simplepie/views/default/widgets/feed_reader/view.php. There you can just uncomment the line $feed->set_timeout(20); \ No newline at end of file
+Widget Title
+---------------------------
+To change the widget title, edit the language file (en.php) and change the
+string 'simplepie:widget' from 'RSS Feed' to whatever you desire.
+
+
+Proxy Server
+----------------------------
+If your site is going through a proxy server to get to the feeds, you may
+want to increase the timeout on the feeds (though this is unlikely as the
+default timeout is 10 seconds). You can do this by editing
+simplepie/views/default/widgets/feed_reader/view.php. There you can just
+uncomment the line $feed->set_timeout(20);
+
+
+Images
+--------------------------
+Currently, images are stripped from the feeds as they are likely larger
+than the width of the widget and will cause display issues. To include
+images, edit the widget view and add the img tag to the $allow_tags array. \ No newline at end of file
diff --git a/languages/en.php b/languages/en.php
index 83841088a..e6c66b27f 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -1,16 +1,15 @@
<?php
- $english = array(
- 'simplepie:widget' => 'Blog',
- 'simplepie:description' => 'Add an external blog to your profile',
- 'simplepie:notset' => 'Feed url is not set',
- 'simplepie:notfind' => 'Cannot find feed. Check the feed url.',
- 'simplepie:feed_url' => 'Feed URL',
- 'simplepie:num_items' => 'Number of items',
- 'simplepie:excerpt' => 'Include excerpt',
- 'simplepie:post_date' => 'Include post date',
- );
-
- add_translation("en",$english);
+$english = array(
+ 'simplepie:widget' => 'RSS Feed',
+ 'simplepie:description' => 'Add an external blog to your profile',
+ 'simplepie:notset' => 'Feed url is not set',
+ 'simplepie:notfind' => 'Cannot find feed. Check the feed url.',
+ 'simplepie:feed_url' => 'Feed URL',
+ 'simplepie:num_items' => 'Number of items',
+ 'simplepie:excerpt' => 'Include excerpt',
+ 'simplepie:post_date' => 'Include post date',
+);
+
+add_translation("en", $english);
-?>
diff --git a/sp_compatibility_test.php b/sp_compatibility_test.php
index 638a13cf0..0448aa01d 100644
--- a/sp_compatibility_test.php
+++ b/sp_compatibility_test.php
@@ -1,9 +1,9 @@
<?php
- // this is a quick hack of the compatibility script included with simple pie
+// 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");
+// 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');
diff --git a/start.php b/start.php
index 5f138ff4d..538c5625c 100644
--- a/start.php
+++ b/start.php
@@ -1,17 +1,16 @@
<?php
- /**
- * Simplepie Plugin
- *
- * Loads the simplepie feed parser library
- **/
-
- function simplepie_init()
- {
- add_widget_type('feed_reader', elgg_echo('simplepie:widget'), elgg_echo('simplepie:description'));
-
- extend_view('css','feed_reader/css');
- }
-
- register_elgg_event_handler('plugins_boot', 'system', 'simplepie_init');
-?>
+/**
+* Simplepie Plugin
+*
+* Loads the simplepie feed parser library and provides a widget
+**/
+
+function simplepie_init() {
+ add_widget_type('feed_reader', elgg_echo('simplepie:widget'), elgg_echo('simplepie:description'));
+
+ extend_view('css','feed_reader/css');
+}
+
+register_elgg_event_handler('plugins_boot', 'system', 'simplepie_init');
+
diff --git a/views/default/settings/simplepie/edit.php b/views/default/settings/simplepie/edit.php
index ae6cbf9de..4583394c3 100644
--- a/views/default/settings/simplepie/edit.php
+++ b/views/default/settings/simplepie/edit.php
@@ -1,8 +1,8 @@
<?php
- global $CONFIG;
-
- $compat_url = $CONFIG->wwwroot . 'mod/simplepie/sp_compatibility_test.php';
- $permit_url = $CONFIG->wwwroot . 'mod/simplepie/permissions.php';
+global $CONFIG;
+
+$compat_url = $CONFIG->wwwroot . 'mod/simplepie/sp_compatibility_test.php';
+$permit_url = $CONFIG->wwwroot . 'mod/simplepie/permissions.php';
?>
diff --git a/views/default/widgets/feed_reader/edit.php b/views/default/widgets/feed_reader/edit.php
index 5fd987701..77355bfa4 100644
--- a/views/default/widgets/feed_reader/edit.php
+++ b/views/default/widgets/feed_reader/edit.php
@@ -1,55 +1,64 @@
-<?php
- $num_items = $vars['entity']->num_items;
- if (!isset($num_items)) $num_items = 10;
-
- $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>
-
- <p>
-<?php
- 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'";
- 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'";
- echo " />";
- echo ' ' . elgg_echo('simplepie:post_date');
-?>
- </p>
+<?php
+ $num_items = $vars['entity']->num_items;
+ if (!isset($num_items)) {
+ $num_items = 10;
+ }
+
+ $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>
+
+<p>
+<?php
+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'";
+}
+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'";
+}
+echo " />";
+echo ' ' . elgg_echo('simplepie:post_date');
+?>
+</p>
diff --git a/views/default/widgets/feed_reader/view.php b/views/default/widgets/feed_reader/view.php
index e689d3550..56bf4482d 100644
--- a/views/default/widgets/feed_reader/view.php
+++ b/views/default/widgets/feed_reader/view.php
@@ -1,70 +1,72 @@
<div class="contentWrapper">
<?php
- global $CONFIG;
-
- if (!class_exists('SimplePie'))
- {
- require_once $CONFIG->pluginspath . '/simplepie/simplepie.inc';
- }
-
- $blog_tags = '<a><p><br><b><i><em><del><pre><strong><ul><ol><li>';
- $feed_url = $vars['entity']->feed_url;
- if($feed_url){
+global $CONFIG;
- $excerpt = $vars['entity']->excerpt;
- $num_items = $vars['entity']->num_items;
- $post_date = $vars['entity']->post_date;
-
- $cache_loc = $CONFIG->pluginspath . '/simplepie/cache';
-
- $feed = new SimplePie($feed_url, $cache_loc);
-
- // 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>';
- }
+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_loc = $CONFIG->pluginspath . '/simplepie/cache';
+
+ $feed = new SimplePie($feed_url, $cache_loc);
+
+ // 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>
+<div class="simplepie_blog_title">
+ <h2><a href="<?php echo $feed->get_permalink(); ?>"><?php echo $feed->get_title(); ?></a></h2>
+</div>
<?php
- 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)
- {
- echo '<div class="simplepie_excerpt">' . strip_tags($item->get_description(true),$blog_tags) . '</div>';
- }
+ // don't display more feed items than user requested
+ if ($num_items > $num_posts_in_feed) {
+ $num_items = $num_posts_in_feed;
+ }
- if ($post_date)
- {
- ?>
- <div class="simplepie_date">Posted on <?php echo $item->get_date('j F Y | g:i a'); ?></div>
- <?php } ?>
+ 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) {
+ echo '<div class="simplepie_excerpt">' . strip_tags($item->get_description(true), $allow_tags) . '</div>';
+ }
+
+ if ($post_date) {
+?>
+ <div class="simplepie_date">Posted on <?php echo $item->get_date('j F Y | g:i a'); ?></div>
+<?php
+ }
+?>
+ </div>
+
<?php endforeach; ?>
<?php
- } else {
-
- if (get_loggedin_userid() == page_owner())
- echo '<p>' . elgg_echo('simplepie:notset') . '</p>';
- }
+} else {
+ // display message only to owner
+ if (get_loggedin_userid() == page_owner()) {
+ echo '<p>' . elgg_echo('simplepie:notset') . '</p>';
+ }
+}
?>
</div>