From 16da0ce0f606397012c65950b07262fbecb2fc84 Mon Sep 17 00:00:00 2001 From: cash Date: Sun, 4 Jul 2010 19:39:29 +0000 Subject: brought the simplepie plugin up to Elgg coding standards --- README | 28 +++++-- languages/en.php | 25 +++--- sp_compatibility_test.php | 6 +- start.php | 29 ++++--- views/default/settings/simplepie/edit.php | 8 +- views/default/widgets/feed_reader/edit.php | 119 ++++++++++++++++------------- views/default/widgets/feed_reader/view.php | 118 ++++++++++++++-------------- 7 files changed, 177 insertions(+), 156 deletions(-) diff --git a/README b/README index bbfb94635..81f5dcd7d 100644 --- a/README +++ b/README @@ -1,8 +1,20 @@ -Widget Title ---------------------------- -To change the widget title, edit the language file (en.php) and change the string simplepie:widget from Blog 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 simplepie/views/default/widgets/feed_reader/view.php. There you can just uncomment the line $feed->set_timeout(20); \ No newline at end of file +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 +simplepie/views/default/widgets/feed_reader/view.php. There you can just +uncomment the line $feed->set_timeout(20); + + +Images +-------------------------- +Currently, images are stripped from the feeds as they are likely larger +than the width of the widget and will cause display issues. To include +images, edit the widget view and add the img tag to the $allow_tags array. \ No newline at end of file diff --git a/languages/en.php b/languages/en.php index 83841088a..e6c66b27f 100644 --- a/languages/en.php +++ b/languages/en.php @@ -1,16 +1,15 @@ 'Blog', - '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:feed_url' => 'Feed URL', - 'simplepie:num_items' => 'Number of items', - 'simplepie:excerpt' => 'Include excerpt', - 'simplepie:post_date' => 'Include post date', - ); - - add_translation("en",$english); +$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:feed_url' => 'Feed URL', + 'simplepie:num_items' => 'Number of items', + 'simplepie:excerpt' => 'Include excerpt', + 'simplepie:post_date' => 'Include post date', +); + +add_translation("en", $english); -?> diff --git a/sp_compatibility_test.php b/sp_compatibility_test.php index 638a13cf0..0448aa01d 100644 --- a/sp_compatibility_test.php +++ b/sp_compatibility_test.php @@ -1,9 +1,9 @@ =')); $xml_ok = extension_loaded('xml'); diff --git a/start.php b/start.php index 5f138ff4d..538c5625c 100644 --- a/start.php +++ b/start.php @@ -1,17 +1,16 @@ +/** +* Simplepie Plugin +* +* Loads the simplepie feed parser library and provides a widget +**/ + +function simplepie_init() { + add_widget_type('feed_reader', elgg_echo('simplepie:widget'), elgg_echo('simplepie:description')); + + extend_view('css','feed_reader/css'); +} + +register_elgg_event_handler('plugins_boot', 'system', 'simplepie_init'); + diff --git a/views/default/settings/simplepie/edit.php b/views/default/settings/simplepie/edit.php index ae6cbf9de..4583394c3 100644 --- a/views/default/settings/simplepie/edit.php +++ b/views/default/settings/simplepie/edit.php @@ -1,8 +1,8 @@ wwwroot . 'mod/simplepie/sp_compatibility_test.php'; - $permit_url = $CONFIG->wwwroot . 'mod/simplepie/permissions.php'; +global $CONFIG; + +$compat_url = $CONFIG->wwwroot . 'mod/simplepie/sp_compatibility_test.php'; +$permit_url = $CONFIG->wwwroot . 'mod/simplepie/permissions.php'; ?> diff --git a/views/default/widgets/feed_reader/edit.php b/views/default/widgets/feed_reader/edit.php index 5fd987701..77355bfa4 100644 --- a/views/default/widgets/feed_reader/edit.php +++ b/views/default/widgets/feed_reader/edit.php @@ -1,55 +1,64 @@ -num_items; - if (!isset($num_items)) $num_items = 10; - - $excerpt = $vars['entity']->excerpt; - if (!isset($excerpt)) $excerpt = 0; - - $post_date = $vars['entity']->post_date; - if (!isset($post_date)) $post_date = 0; - -?> - -

- - -

- -

- - - 'params[num_items]', - 'options_values' => array( '3' => '3', - '5' => '5', - '8' => '8', - '10' => '10', - '12' => '12', - '15' => '15', - '20' => '20', - ), - 'value' => $num_items - )); -?> -

- -

- 'params[excerpt]', 'js' => 'id="params[excerpt]"', 'value' => $excerpt )); - echo ""; - echo ' ' . elgg_echo('simplepie:excerpt'); -?> -

- -

- 'params[post_date]', 'js' => 'id="params[post_date]"', 'value' => $post_date )); - echo ""; - echo ' ' . elgg_echo('simplepie:post_date'); -?> -

+num_items; + if (!isset($num_items)) { + $num_items = 10; + } + + $excerpt = $vars['entity']->excerpt; + if (!isset($excerpt)) { + $excerpt = 0; + } + + $post_date = $vars['entity']->post_date; + if (!isset($post_date)) { + $post_date = 0; + } +?> + +

+ + +

+ +

+ + + 'params[num_items]', + 'options_values' => array( '3' => '3', + '5' => '5', + '8' => '8', + '10' => '10', + '12' => '12', + '15' => '15', + '20' => '20', + ), + 'value' => $num_items + )); +?> +

+ +

+ 'params[excerpt]', 'js' => 'id="params[excerpt]"', 'value' => $excerpt )); +echo ""; +echo ' ' . elgg_echo('simplepie:excerpt'); +?> +

+ +

+ 'params[post_date]', 'js' => 'id="params[post_date]"', 'value' => $post_date )); +echo ""; +echo ' ' . elgg_echo('simplepie:post_date'); +?> +

diff --git a/views/default/widgets/feed_reader/view.php b/views/default/widgets/feed_reader/view.php index e689d3550..56bf4482d 100644 --- a/views/default/widgets/feed_reader/view.php +++ b/views/default/widgets/feed_reader/view.php @@ -1,70 +1,72 @@
pluginspath . '/simplepie/simplepie.inc'; - } - - $blog_tags = '


+ ' . elgg_echo('simplepie:notset') . '

'; - } +} else { + // display message only to owner + if (get_loggedin_userid() == page_owner()) { + echo '

' . elgg_echo('simplepie:notset') . '

'; + } +} ?> -- cgit v1.2.3