* @license PHP License * @package WB * @subpackage content */ /** * Load base class */ WBClass::load('WBContent' , 'WBContent_Data' , 'WBContent_Data_Table' ); /** * Content component: Data_Table_Banner * * Show banner or teaser record * * @version 0.2.0 * @package WB * @subpackage content */ class WBContent_Data_Table_Banner extends WBContent_Data_Table { /** * Current Config * * - table: name of table * - selectby: "url" or "id" * - id: primary key to load record * - requiredgroup: access control * * @var array */ protected $config = array( 'table' => 'banner', 'id' => '', 'requiredgroup' => parent::GROUP_ANON, 'title' => '{TITLE}', 'selectby' => 'url', 'namespace' => '' ); /** * Get List of Database Records * * @return array */ protected function getList() { if ('url' != $this->config['selectby']) { $list = $this->getListById(); if (1 == count($list)) { $this->bubbles['title'] = WBString::populate($this->config['title'], $list[0]); } return $list; } $option = array('limit' => 1); $clause = array(); $clause[] = array( 'field' => 'namespace', 'value' => $this->config['namespace'] ); /** @var WBDictionary_URL */ $dict = WBClass::create('WBDictionary_URL'); $url = WBString::replaceSuperPlaceholders('[[SELF]][[PATH]]', $this->req->path); if (!$dict->lookupWord($url)) { return array(); } $clause[] = array( 'field' => $dict->getIdentifier(), 'value' => $dict->getId() ); $list = $this->table->get($this->config['table'], null, null, $clause, $option); if (1 == count($list)) { $this->bubbles['title'] = WBString::populate($this->config['title'], $list[0]); } return $list; } }