From ef9ba51af2774d90af5feaa256c9dae85841e5cd Mon Sep 17 00:00:00 2001 From: Michael Haschke Date: Sun, 13 Nov 2011 16:57:45 +0100 Subject: [PATCH] [mod] update Delicious service class - add Service method to get config values for config keys - adjust standard content of a Delicious service item - using new Feed service as Delicious parent service --- lib/Services/Delicious.php | 54 ++++++++++++++++++++++++++------------ lib/Services/Feed.php | 2 +- lib/Services/Service.php | 12 +++++++++ 3 files changed, 50 insertions(+), 18 deletions(-) diff --git a/lib/Services/Delicious.php b/lib/Services/Delicious.php index b47c9d8..431159f 100644 --- a/lib/Services/Delicious.php +++ b/lib/Services/Delicious.php @@ -1,23 +1,43 @@ setItemTemplate('
  • {{{title}}}
  • '."\n"); - } + public function __construct( $config ){ + $config['link'] = 'http://delicious.com/'.$config['username'].'/'; + $config['url'] = sprintf( 'http://feeds.delicious.com/v2/rss/%s?count=%s', $config['username'], $config['total'] ); + parent::__construct( $config ); + $this->setItemTemplate( + '
  • + {{{title}}} + ({{{date}}}) + {{#category}} + {{{category}}} + {{/category}} +
  • '."\n" + ); + } - } + /** + * @return array + * @since 20110531 + */ + public function processDataItem( $item ) { + $item = parent::processDataItem($item); + $item['service_link'] = $this->getConfigValue('link'); + return $item; + } +} diff --git a/lib/Services/Feed.php b/lib/Services/Feed.php index 7a2006b..8566543 100644 --- a/lib/Services/Feed.php +++ b/lib/Services/Feed.php @@ -86,7 +86,7 @@ public function populateItemTemplate( &$item ) { * @return array * @since 20110531 */ - public function processDataItem( &$item ) { + public function processDataItem( $item ) { // meta diff --git a/lib/Services/Service.php b/lib/Services/Service.php index 4d1de2d..9d3dbdb 100644 --- a/lib/Services/Service.php +++ b/lib/Services/Service.php @@ -62,6 +62,18 @@ public function __construct( $config=array() ) { } } + /** + * @since 2011-11-13 + */ + public function getConfigValue($key) + { + if (isset($this->configuration[$key])) { + return $this->configuration[$key]; + } + + return null; + } + /** * Use timeshift factor to randomize range of cache invalidation time. * Default: 0.5 (with 1h cache it means 0.5h to 1.5h)