* @copyright 2005 by http://wombat.exit0.net * @package wombatModule * @subpackage Blogger */ /** * Del.icio.us RSS feed reader * * @version 1.1.0 * @package wombatModule * @subpackage Blogger */ class wbModule_Rss extends wbModule { /** * Del.icio.us * * -tmpldir location of template files * * @access private * @var array $_params */ var $_params = array( 'tmpldir' => 'module/Rss', 'url' => 'http://del.icio.us/rss', ); /** * some request defaults * * @access private * @var array $_params */ var $_requestDefaults = array( 'action' => 'list', ); /** * location of cache folder * @access private * @var string $_cacheDir */ var $_cacheDir = null; /** * load required objects * * @access public * @return boolean $result true on success */ function __construct() { wbFactory::includeClass( 'wbFile' ); $this->_cacheDir = wbFactory::getParam( 'baseDir' ) . '/' .wbFactory::getParam( 'varDir' ) . '/cache/module/Rss'; } /** * constructor wrapper for PHP4 * * @access public * @see __construct() */ function wbModule_Delicious() { $this->__construct(); } /** * recieve content * * * * @return string $html */ function getHtml() { $check = $this->_checkRequiredParams( array( 'url', 'tmpldir' ) ); if( patErrorManager::isError( $check ) ) { return $check; } $url = $this->_params['url']; $cache = $this->_cacheDir . '/' . md5( $url ); if( wbFile::isNewer( $cache, 3600, false ) ) { $data = unserialize( wbFile::load( $cache ) ); } else { $data = $this->_loadRss( $url ); wbFile::save( $cache, serialize( $data ) ); } $this->_loadTemplates( 'list' ); $this->_tmpl->addVars( 'wbModule_Rss', $data['channel'], 'CHANNEL_' ); $this->_tmpl->addRows( 'item_entry', $data['items'] ); return $this->_tmpl->getParsedTemplate( 'wbModule_Rss' ); return "
" . print_r( $data, true ) . ""; } /** * download url * * @access private * @param string $url * @return string $html */ function _loadRss( $url ) { $data = array(); wbFactory::includeClass( 'XML_RSS' ); $rss =& new XML_RSS( $url ); $rss->parse(); $data['channel'] = $rss->getChannelInfo(); $data['items'] = $rss->getItems(); // $data['images'] = $rss->getImages(); return $data; } } ?>