aboutsummaryrefslogtreecommitdiff
path: root/mod/simplepie
diff options
context:
space:
mode:
authorSem <sembrestels@riseup.net>2014-01-22 04:05:47 +0100
committerSem <sembrestels@riseup.net>2014-01-22 04:05:47 +0100
commit68614b769f4ae4f28c3f395f47b68baba7c48c64 (patch)
tree2c5a744a3859d27883f92b72aef9cf81f1a947d0 /mod/simplepie
parent69e2d8c5d8732042c9319aef1fdea45a82b63e42 (diff)
parentc0295c275d6edbca6c6c8bb51dc199150d0d5fc3 (diff)
downloadelgg-68614b769f4ae4f28c3f395f47b68baba7c48c64.tar.gz
elgg-68614b769f4ae4f28c3f395f47b68baba7c48c64.tar.bz2
Merge branch 'release/1.8.1'
Diffstat (limited to 'mod/simplepie')
-rw-r--r--mod/simplepie/README8
-rw-r--r--mod/simplepie/actions/simplepie/save_group_feed.php14
-rw-r--r--mod/simplepie/languages/en.php6
-rw-r--r--mod/simplepie/languages/es.php14
-rw-r--r--mod/simplepie/manifest.xml2
-rw-r--r--mod/simplepie/start.php10
-rw-r--r--mod/simplepie/views/default/forms/simplepie/save_group_feed.php39
-rw-r--r--mod/simplepie/views/default/simplepie/group_module.php109
8 files changed, 193 insertions, 9 deletions
diff --git a/mod/simplepie/README b/mod/simplepie/README
index 24591c3e1..29a9f38aa 100644
--- a/mod/simplepie/README
+++ b/mod/simplepie/README
@@ -1,11 +1,11 @@
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
@@ -14,6 +14,6 @@ uncomment the line $feed->set_timeout(20);
HTML tags in feeds
---------------------------
+=================
The widget allows the following tags: `<a><p><br><b><i><em><del><pre><strong><ul><ol><li><img>`.
-Other tags are stripped to avoid problems with the display of your site. \ No newline at end of file
+Other tags are stripped to avoid problems with the display of your site.
diff --git a/mod/simplepie/actions/simplepie/save_group_feed.php b/mod/simplepie/actions/simplepie/save_group_feed.php
new file mode 100644
index 000000000..8dc2ffd78
--- /dev/null
+++ b/mod/simplepie/actions/simplepie/save_group_feed.php
@@ -0,0 +1,14 @@
+<?php
+
+$group = get_entity((int)get_input('group_guid'));
+$feed_url = get_input('feed_url');
+
+if (!simplepie_is_url($feed_url)) {
+ register_error (elgg_echo("simplepie:invalid_url"));
+ forward(REFERER);
+}
+
+if (!elgg_instanceof($group, 'group') || !$group->canEdit()) {
+ forward(REFERER);
+}
+$group->feed_url = $feed_url;
diff --git a/mod/simplepie/languages/en.php b/mod/simplepie/languages/en.php
index 07ff02905..a22316863 100644
--- a/mod/simplepie/languages/en.php
+++ b/mod/simplepie/languages/en.php
@@ -1,16 +1,14 @@
<?php
-
$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:notfound' => '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',
'simplepie:postedon' => 'Posted on',
+ 'simplepie:invalid_url' => 'Invalid url, copy it from the navigation bar please',
);
-
add_translation("en", $english);
-
diff --git a/mod/simplepie/languages/es.php b/mod/simplepie/languages/es.php
new file mode 100644
index 000000000..d9bd5d2d6
--- /dev/null
+++ b/mod/simplepie/languages/es.php
@@ -0,0 +1,14 @@
+<?php
+$spanish = array(
+ 'simplepie:widget' => 'Enlace RSS',
+ 'simplepie:description' => 'Agregar un blog externo',
+ 'simplepie:notset' => 'Enlace RSS no configurado',
+ 'simplepie:notfound' => 'no se encontro el feed. Revisa el feed url.',
+ 'simplepie:feed_url' => 'Feed URL',
+ 'simplepie:num_items' => 'Numero de items',
+ 'simplepie:excerpt' => 'Incluir contenido',
+ 'simplepie:post_date' => 'Incluir fecha del post',
+ 'simplepie:postedon' => 'Posted on',
+ 'simplepie:invalid_url' => 'Url invalida, copiela desde la barra del navegador por favor',
+);
+add_translation("en", $english);
diff --git a/mod/simplepie/manifest.xml b/mod/simplepie/manifest.xml
index 94b8a4b42..eff9681d2 100644
--- a/mod/simplepie/manifest.xml
+++ b/mod/simplepie/manifest.xml
@@ -2,7 +2,7 @@
<plugin_manifest xmlns="http://www.elgg.org/plugin_manifest/1.8">
<name>SimplePie RSS Feed Integration</name>
<author>Cash Costello</author>
- <version>1.8.0</version>
+ <version>1.8.1.1</version>
<category>widget</category>
<description>Provides a widget that pulls in RSS feeds</description>
<website>http://www.cashcostello.com/</website>
diff --git a/mod/simplepie/start.php b/mod/simplepie/start.php
index 20adc7545..34a7ced3f 100644
--- a/mod/simplepie/start.php
+++ b/mod/simplepie/start.php
@@ -20,4 +20,14 @@ function simplepie_init() {
$lib = elgg_get_plugins_path() . 'simplepie/vendors/simplepie.inc';
elgg_register_library('simplepie', $lib);
+
+ // Add group option
+ add_group_tool_option('rss', elgg_echo('simplepie:enablerss'), false);
+ elgg_extend_view('groups/tool_latest', 'simplepie/group_module');
+
+ elgg_register_action('simplepie/save_group_feed', elgg_get_plugins_path() . 'simplepie/actions/simplepie/save_group_feed.php');
+}
+
+function simplepie_is_url($url) {
+ return preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $url);
}
diff --git a/mod/simplepie/views/default/forms/simplepie/save_group_feed.php b/mod/simplepie/views/default/forms/simplepie/save_group_feed.php
new file mode 100644
index 000000000..a3f771586
--- /dev/null
+++ b/mod/simplepie/views/default/forms/simplepie/save_group_feed.php
@@ -0,0 +1,39 @@
+<?php
+/**
+ * Simplepie feed reader widget settings
+ */
+
+// set default value
+
+$url_label = elgg_echo("simplepie:feed_url");
+$url_textbox = elgg_view('input/text', array(
+ 'name' => 'feed_url',
+ 'id'=> 'feed_url',
+ 'value' => $vars['entity']->feed_url,
+));
+
+$group_field = elgg_view('input/hidden', array(
+ 'name' => 'group_guid',
+ 'value' => $vars['entity']->guid,
+));
+
+$save_button = elgg_view('input/submit', array(
+ 'value' => elgg_echo('save'),
+));
+
+
+
+
+echo <<<HTML
+<div>
+ <label for="feed_url">$url_label</label>
+ $url_textbox
+ $group_field
+</div>
+<div>
+ $save_button
+</div>
+HTML;
+
+
+
diff --git a/mod/simplepie/views/default/simplepie/group_module.php b/mod/simplepie/views/default/simplepie/group_module.php
new file mode 100644
index 000000000..90c017a86
--- /dev/null
+++ b/mod/simplepie/views/default/simplepie/group_module.php
@@ -0,0 +1,109 @@
+<?php
+/**
+ * Group simplepie:rss module
+ */
+elgg_load_library('simplepie');
+
+$group = elgg_get_page_owner_entity();
+
+if ($group->rss_enable != "yes") {
+ return true;
+}
+
+elgg_push_context('widgets');
+
+$allowed_tags = '<a><p><br><b><i><em><del><pre><strong><ul><ol><li><img>';
+$feed_url = $group->feed_url;
+$content = '';
+
+if ($group->canEdit()) {
+ $content .= elgg_view_form("simplepie/save_group_feed", array(
+ 'id' => 'simplepie-form',
+ 'class' => $feed_url ? 'hidden' : '',
+ ), $vars);
+}
+
+if ($feed_url) {
+
+// get widget settings
+ $excerpt = true;
+ $post_date = true;
+ $num_items = 7;
+ $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()) {
+ $content .= '<p>' . elgg_echo('simplepie:notfound') . '</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
+ $content .= "<h2 class=\"simplepie-heading\">$feed_link</h2>";
+ $content .= '<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 = elgg_get_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";
+ }
+
+ $content .= <<<HTML
+<li class="mbm elgg-item">
+ <h4 class="mbs">$item_link</h4>
+ <p class="elgg-subtext">$post_date</p>
+ <div class="elgg-content">$excerpt</div>
+</li>
+HTML;
+ }
+ $content .= "</ul>";
+}
+
+elgg_pop_context();
+
+if (!$content) {
+ $content = '<p>' . elgg_echo('simplepie:none') . '</p>';
+}
+if ($group->canEdit()) {
+ $edit = elgg_view('output/url', array(
+ 'href' => '#simplepie-form',
+ 'text' => elgg_echo('edit'),
+ 'rel' => 'toggle'
+ ));
+} else {
+ $edit = false;
+}
+
+echo elgg_view('groups/profile/module', array(
+ 'title' => elgg_echo('RSS Group'),
+ 'content' => $content,
+ 'all_link' => $edit,
+));