From e79633358a5165bb68f6d0e1b8fe855d84cea8cc Mon Sep 17 00:00:00 2001 From: capo Date: Sun, 12 Jan 2014 18:55:35 +0100 Subject: fix identation --- actions/simplepie/save_group_feed.php | 14 +++ languages/en.php | 4 - languages/en.php~ | 14 +++ languages/es.php | 8 -- languages/es.php~ | 22 +++++ views/default/forms/simplepie/save_group_feed.php | 39 ++++++++ views/default/simplepie/group_module.php | 66 ++++++------- views/default/simplepie/group_module.php~ | 108 ++++++++++++++++++++++ 8 files changed, 227 insertions(+), 48 deletions(-) create mode 100644 actions/simplepie/save_group_feed.php create mode 100644 languages/en.php~ create mode 100644 languages/es.php~ create mode 100644 views/default/forms/simplepie/save_group_feed.php create mode 100644 views/default/simplepie/group_module.php~ diff --git a/actions/simplepie/save_group_feed.php b/actions/simplepie/save_group_feed.php new file mode 100644 index 000000000..556372f98 --- /dev/null +++ b/actions/simplepie/save_group_feed.php @@ -0,0 +1,14 @@ +canEdit() || !elgg_instanceof($group, 'group')) { + forward(REFERER); +} +$group->feed_url = $feed_url; diff --git a/languages/en.php b/languages/en.php index 082b4c485..a22316863 100644 --- a/languages/en.php +++ b/languages/en.php @@ -1,5 +1,4 @@ 'RSS Feed', 'simplepie:description' => 'Add an external blog to your profile', @@ -11,8 +10,5 @@ $english = array( '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/en.php~ b/languages/en.php~ new file mode 100644 index 000000000..a22316863 --- /dev/null +++ b/languages/en.php~ @@ -0,0 +1,14 @@ + 'RSS Feed', + 'simplepie:description' => 'Add an external blog to your profile', + 'simplepie:notset' => 'Feed url is not set', + '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 85f24e4a5..d9bd5d2d6 100644 --- a/languages/es.php +++ b/languages/es.php @@ -1,5 +1,4 @@ 'Enlace RSS', 'simplepie:description' => 'Agregar un blog externo', @@ -12,11 +11,4 @@ $spanish = array( 'simplepie:postedon' => 'Posted on', 'simplepie:invalid_url' => 'Url invalida, copiela desde la barra del navegador por favor', ); - add_translation("en", $english); - - - - - - diff --git a/languages/es.php~ b/languages/es.php~ new file mode 100644 index 000000000..85f24e4a5 --- /dev/null +++ b/languages/es.php~ @@ -0,0 +1,22 @@ + '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/views/default/forms/simplepie/save_group_feed.php b/views/default/forms/simplepie/save_group_feed.php new file mode 100644 index 000000000..a3f771586 --- /dev/null +++ b/views/default/forms/simplepie/save_group_feed.php @@ -0,0 +1,39 @@ + '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 << + + $url_textbox + $group_field + +
+ $save_button +
+HTML; + + + diff --git a/views/default/simplepie/group_module.php b/views/default/simplepie/group_module.php index 17b2dba0c..d9860d65f 100644 --- a/views/default/simplepie/group_module.php +++ b/views/default/simplepie/group_module.php @@ -29,68 +29,62 @@ if ($feed_url) { $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); + // doubles timeout if going through a proxy + //$feed->set_timeout(20); + // only display errors to profile owner - -// 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') . '

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

$feed_link

"; $content .= '"; - } elgg_pop_context(); diff --git a/views/default/simplepie/group_module.php~ b/views/default/simplepie/group_module.php~ new file mode 100644 index 000000000..bfba96f06 --- /dev/null +++ b/views/default/simplepie/group_module.php~ @@ -0,0 +1,108 @@ +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/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 .= '

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