diff options
author | capo <capo@riseup.net> | 2014-01-12 18:21:24 +0100 |
---|---|---|
committer | capo <capo@riseup.net> | 2014-01-12 18:21:24 +0100 |
commit | 74a2c0f73100209d1c10259a3f862d3645ab5dbb (patch) | |
tree | 66ecee1dbe7d9c5fdc45a5d1aeb4ca29e87d40ba /views | |
parent | e5dd9906d16d97aed7ba3511b7e1132bd4da3761 (diff) | |
download | elgg-74a2c0f73100209d1c10259a3f862d3645ab5dbb.tar.gz elgg-74a2c0f73100209d1c10259a3f862d3645ab5dbb.tar.bz2 |
review code from hellekin comments
Diffstat (limited to 'views')
-rw-r--r-- | views/default/forms/simplepie/group_module.php | 35 | ||||
-rw-r--r-- | views/default/simplepie/group_module.php | 106 |
2 files changed, 53 insertions, 88 deletions
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 @@ -<?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', - '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> - $url_label - $url_textbox - $group_field -</div> -<div> - $save_button -</div> -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 .= '<p>' . elgg_echo('simplepie:notfind') . '</p>'; - } - } - // 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 .= '<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 - $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> + <h4 class="mbs">$item_link</h4> + <p class="elgg-subtext">$post_date</p> + <div class="elgg-content">$excerpt</div> </li> HTML; @@ -91,8 +93,6 @@ HTML; } - - elgg_pop_context(); if (!$content) { |