* @license PHP License * @package WB * @subpackage content */ /** * Load required class */ WBClass::load( 'WBContent' ); /** * Content component: Login * * @version 0.1.1 * @package WB * @subpackage content */ class WBContent_MyFeed extends WBContent { /** * my parameter list * @var array */ protected $config = array( 'url' => '' ); /** * table * @var WBDatasource_Table */ protected $table; /** * run * * run component * * @return array parameter list */ public function run() { if( !$this->user->isAuthenticated() ) { $this->loadTemplates( 'anon' ); return $this->config; } $this->table = WBClass::create( 'WBDatasource_Table' ); // fetch list of urls somewhere $skin = $this->table->get( 'skin', $this->user->getId() ); if( !empty( $skin ) ) { $url = trim( $skin[0]['feeds'] ); } if( empty( $url ) ) { $this->tmpl->addGlobalVar( 'url_source', 'config' ); $url = $this->config['url']; } if( empty( $url ) ) { $this->loadTemplates( 'empty' ); return $this->config; } $url = array_map( 'trim', explode( "\n", $url ) ); $cnt = array(); $c = array( 'limit' => 5, 'ttl' => 600, 'url' => '' ); $this->loadTemplates( 'list' ); $list = array(); for( $i = 0; $i < count( $url ); ++$i ) { $c['url'] = $url[$i]; // remove empty lines if( empty( $c['url'] ) ) { continue; } // add headlines if( strncmp( $c['url'], 'http://', 7 ) != 0 ) { $list[] = array( 'headline' => $c['url'] ); continue; } $cont = WBClass::create( 'WBContent_Rss' ); /* @var $cont WBContent_Rss */ $cont->configure( $this->part . '/' . $i, $c ); $cont->run(); $list[] = array( 'rss' => $cont->getString() ); } $this->tmpl->addRows( 'entry', $list ); return $this->config; } /** * receive output * * fetch output of this content component * * @return string */ public function getString() { return $this->tmpl->getParsedTemplate(); } } ?>