* @license PHP License * @package WB * @subpackage content */ /** * Load base class */ WBClass::load('WBContent' , 'WBContent_Data'); /** * Content component: Data_Table * * Show records from database * * @version 0.1.0 * @package WB * @subpackage content */ class WBContent_Data_Table extends WBContent_Data { /** * Current Config * * - table: name of table * - id: primary key to load record * - requiredgroup: access control * * @var array */ protected $config = array( 'table' => '', 'id' => '', 'requiredgroup' => parent::GROUP_ANON, ); /** * Table * @var WBDatasource_Table */ protected $table; /** * 2nd constructor * * Called after configuration was done. Initialize table object */ protected function init() { $this->table = WBClass::create('WBDatasource_Table'); } /** * run * * run component * * @return array parameter list */ public function run() { $this->addConfigAsGlobalVars(); if (empty($this->config['table'])) { $args = array( 'msg' => 'Config value "table" missing!', 'code' => 1, 'class' => __CLASS__ ); throw WBClass::create('WBException_Config', $args); } if (!$this->isUserInGroup($this->config['requiredgroup'])) { $this->loadTemplates('accessDenied'); return $this->config; } $list = $this->table->get($this->config['table'], $this->config['id']); if (empty($list)) { $this->loadTemplates($this->config['table'] . '/notFound'); return $this->config; } $list = $list[0]; $this->tmpl->addGlobalVars($list); $this->loadTemplates($this->config['table'] . '/record'); return $this->config; } }