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 --- views/default/simplepie/group_module.php | 113 +++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 views/default/simplepie/group_module.php (limited to 'views/default/simplepie/group_module.php') diff --git a/views/default/simplepie/group_module.php b/views/default/simplepie/group_module.php new file mode 100644 index 000000000..7d0a7bc2f --- /dev/null +++ b/views/default/simplepie/group_module.php @@ -0,0 +1,113 @@ +rss_enable != "yes") { + return true; +} + +elgg_push_context('widgets'); + +$allowed_tags = '


    1. '; +$feed_url = $group->feed_url; +$content = ''; + +if ($group->canEdit()) { + $content .= elgg_view_form("simplepie/group_module", 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 .= '

      ' . 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; + } + + $feed_link = elgg_view('output/url', array( + 'href' => $feed->get_permalink(), + 'text' => $feed->get_title(), + )); + + // need to center + $content .= "

      $feed_link

      "; + $content .= '
        '; + 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 .= << +

        $item_link

        +

        $post_date

        +
        $excerpt
        + +HTML; + + } + $content .= "
      "; + +} + + + +elgg_pop_context(); + +if (!$content) { + $content = '

      ' . elgg_echo('simplepie:none') . '

      '; +} + +$edit = elgg_view('output/url', array( + 'href' => '#simplepie-form', + 'text' => elgg_echo('edit'), + 'rel' => 'toggle' +)); + +echo elgg_view('groups/profile/module', array( + 'title' => elgg_echo('RSS Group'), + 'content' => $content, + 'all_link' => $edit, +)); + -- cgit v1.2.3