* @license PHP License * @package WB * @subpackage content */ /** * Load base class */ WBClass::load('WBContent'); /** * Content component: Static * * @version 0.1.5 * @package WB * @subpackage content */ class WBContent_Static extends WBContent { /** * My Parameter List * * - tmpl: named template file to display * - string: simple string as alternative to template * - deniedtmpl: template file when access is denied * - requiremaster: (0) check for master mandator user in combination with requiredgroup * - requiredgroup: (tableeditor) * * @var array */ protected $config = array( 'tmpl' => 'blank', 'string' => '', 'responsestatus'=> 200, 'requiremaster' => 0, 'requiredgroup' => parent::GROUP_ANON, 'deniedtmpl' => 'accessDenied', ); /** * This Content Component is Cachable * @var bool */ protected $cachable = true; /** * Run * * Run Component * * @return array parameter list */ public function run() { // configurable status code $this->setStatusCode(intval($this->config['responsestatus'])); if (!empty($this->config['string'])) { return $this->config; } if ($this->user->isAuthenticated() && !empty($this->config['requiremaster']) && !$this->user->isMaster()) { $tmpl = $this->config['deniedtmpl']; $this->setStatusCode(403); } $tmpl = $this->config['tmpl']; if (!$this->isUserInGroup($this->config['requiredgroup'])) { $tmpl = $this->config['deniedtmpl']; $this->setStatusCode(403); } $this->loadTemplates($tmpl); $this->addGlobalVars($this->getBubbles()); $this->addConfigAsGlobalVars(); return $this->config; } /** * receive output * * fetch output of this content component * * @return string */ public function getString() { if (!empty($this->config['string'])) { return $this->config['string']; } return $this->tmpl->getParsedTemplate(); } }