From e5dd9906d16d97aed7ba3511b7e1132bd4da3761 Mon Sep 17 00:00:00 2001 From: capo Date: Mon, 16 Dec 2013 00:12:26 +0100 Subject: Added feature to be able to use simplepie rss module in the groups --- languages/es.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 languages/es.php (limited to 'languages/es.php') diff --git a/languages/es.php b/languages/es.php new file mode 100644 index 000000000..51b53e9f2 --- /dev/null +++ b/languages/es.php @@ -0,0 +1,16 @@ + 'Enlace RSS', + 'simplepie:description' => 'Agregar un blog externo', + 'simplepie:notset' => 'Enlace RSS no configurado', + 'simplepie:notfind' => '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', +); + +add_translation("en", $english); + -- cgit v1.2.3 From 74a2c0f73100209d1c10259a3f862d3645ab5dbb Mon Sep 17 00:00:00 2001 From: capo Date: Sun, 12 Jan 2014 18:21:24 +0100 Subject: review code from hellekin comments --- actions/simplepie/group_module.php | 8 -- languages/en.php | 4 +- languages/es.php | 24 +++--- start.php | 5 +- views/default/forms/simplepie/group_module.php | 35 -------- views/default/simplepie/group_module.php | 106 ++++++++++++------------- 6 files changed, 75 insertions(+), 107 deletions(-) delete mode 100644 actions/simplepie/group_module.php delete mode 100644 views/default/forms/simplepie/group_module.php (limited to 'languages/es.php') diff --git a/actions/simplepie/group_module.php b/actions/simplepie/group_module.php deleted file mode 100644 index 93fe353de..000000000 --- a/actions/simplepie/group_module.php +++ /dev/null @@ -1,8 +0,0 @@ -canEdit()) { - $group->feed_url = $feed_url; -} diff --git a/languages/en.php b/languages/en.php index 07ff02905..082b4c485 100644 --- a/languages/en.php +++ b/languages/en.php @@ -4,12 +4,14 @@ $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/languages/es.php b/languages/es.php index 51b53e9f2..85f24e4a5 100644 --- a/languages/es.php +++ b/languages/es.php @@ -1,16 +1,22 @@ 'Enlace RSS', - 'simplepie:description' => 'Agregar un blog externo', - 'simplepie:notset' => 'Enlace RSS no configurado', - 'simplepie:notfind' => '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: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/start.php b/start.php index 26c2e5017..34a7ced3f 100644 --- a/start.php +++ b/start.php @@ -25,6 +25,9 @@ function simplepie_init() { add_group_tool_option('rss', elgg_echo('simplepie:enablerss'), false); elgg_extend_view('groups/tool_latest', 'simplepie/group_module'); - elgg_register_action('simplepie/group_module', elgg_get_plugins_path() . 'simplepie/actions/simplepie/group_module.php'); + 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/views/default/forms/simplepie/group_module.php b/views/default/forms/simplepie/group_module.php deleted file mode 100644 index a7c1f6858..000000000 --- a/views/default/forms/simplepie/group_module.php +++ /dev/null @@ -1,35 +0,0 @@ - '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 << - $url_label - $url_textbox - $group_field - -
- $save_button -
-HTML; diff --git a/views/default/simplepie/group_module.php b/views/default/simplepie/group_module.php index 7d0a7bc2f..17b2dba0c 100644 --- a/views/default/simplepie/group_module.php +++ b/views/default/simplepie/group_module.php @@ -17,7 +17,7 @@ $feed_url = $group->feed_url; $content = ''; if ($group->canEdit()) { - $content .= elgg_view_form("simplepie/group_module", array( + $content .= elgg_view_form("simplepie/save_group_feed", array( 'id' => 'simplepie-form', 'class' => $feed_url ? 'hidden' : '', ), $vars); @@ -25,64 +25,66 @@ if ($group->canEdit()) { if ($feed_url) { - // get widget settings - $excerpt = true; - $post_date = true; +// 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); - } + $cache_location = elgg_get_data_path() . '/simplepie_cache/'; + if (!file_exists($cache_location)) { + mkdir($cache_location, 0777); + } - $feed = new SimplePie($feed_url, $cache_location); + $feed = new SimplePie($feed_url, $cache_location); - // doubles timeout if going through a proxy - //$feed->set_timeout(20); +// 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 .= '

' . elgg_echo('simplepie:notfind') . '

'; - } - } - // don't display more feed items than user requested - if ($num_items > $num_posts_in_feed) { - $num_items = $num_posts_in_feed; - } +// 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 .= '

' . elgg_echo('simplepie:notfound') . '

'; + } +} + +// 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 .= "

$feed_link

"; + $content .= '