Skip to content

Commit

Permalink
[mod] update Delicious service class
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
haschek committed Nov 13, 2011
1 parent e296475 commit ef9ba51
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 18 deletions.
54 changes: 37 additions & 17 deletions lib/Services/Delicious.php
@@ -1,23 +1,43 @@
<?php
defined('PUBWICH') or die('No direct access allowed.');
defined('PUBWICH') or die('No direct access allowed.');

/**
* @classname Delicious
* @description Fetch Del.icio.us bookmarks
* @version 1.1 (20090929)
* @author Rémi Prévost (exomel.com)
* @methods None
*/
/**
* Delicious Service
*
* Fetch Delicious bookmarks.
*
* @version 1.1 (20090929)
* @author Rémi Prévost (exomel.com)
* @author Michael Haschke, http://michael.haschke.biz/
* @methods None
*/

Pubwich::requireServiceFile( 'RSS' );
class Delicious extends RSS {
Pubwich::requireServiceFile( 'Feed' );
class Delicious extends Feed {

public function __construct( $config ){
$config['link'] = 'http://del.icio.us/'.$config['username'].'/';
$config['url'] = sprintf( 'http://feeds.delicious.com/v2/rss/%s?count=%s', $config['username'], $config['total'] );
parent::__construct( $config );
$this->setItemTemplate('<li><a href="{{{link}}}">{{{title}}}</a></li>'."\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(
'<li>
<a href="{{{link}}}">{{{title}}}</a>
({{{date}}})
{{#category}}
<em><a href="{{{service_link}}}{{{category}}}">{{{category}}}</a></em>
{{/category}}
</li>'."\n"
);
}

}
/**
* @return array
* @since 20110531
*/
public function processDataItem( $item ) {
$item = parent::processDataItem($item);
$item['service_link'] = $this->getConfigValue('link');
return $item;
}
}

2 changes: 1 addition & 1 deletion lib/Services/Feed.php
Expand Up @@ -86,7 +86,7 @@ public function populateItemTemplate( &$item ) {
* @return array
* @since 20110531
*/
public function processDataItem( &$item ) {
public function processDataItem( $item ) {

// meta

Expand Down
12 changes: 12 additions & 0 deletions lib/Services/Service.php
Expand Up @@ -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)
Expand Down

0 comments on commit ef9ba51

Please sign in to comment.