public function _initAccount() { $accountId = $this->_getRequestParam('account_id'); $account = $this->getXhbSession()->getModel()->getAccount($accountId); if (empty($account)) { $message = 'Missing or invalid account ID.'; Log::instance()->log($message . ' (' . $this->getFullActionName() . ')'); $this->_error($message); $this->_redirectReferer(); } $this->_fw->set('current_account', $account); }
protected function _toHtml() { if (!($template = $this->getTemplate())) { Log::instance()->log('No template defined for chart with ID "' . $this->getId() . '", skipping.', LOG_ERR); return; } $fw = \Base::instance(); if ($this->getEscapeHives() != $fw->get('ESCAPE')) { $esc = $fw->get('ESCAPE'); $fw->set('ESCAPE', $this->getEscapeHives()); } $html = View::instance()->render($template, $this->getMimetype(), $this->getData()); if ($this->getEscapeHives()) { $fw->set('ESCAPE', $esc); } return $html; }
/** * Render block using cache placeholder if available. * * @param $blockName * @param string $mime * @param array $hive * @param int $ttl * @return string */ public function renderBlockWithoutCache($blockName, $mime = 'text/html', array $hive = null, $ttl = 0) { $hasPlaceholder = $this->getBlockCachePlaceholder($blockName) ? true : false; $blockConfig = $this->getBlockConfig($blockName); $output = ''; try { if (!isset($blockConfig['template']) || !$blockConfig['template']) { throw new \Exception('Missing template for block "' . $blockName . '".'); } $mime = isset($blockConfig['mime']) && $blockConfig['mime'] ? $blockConfig['mime'] : 'text/html'; //TODO Data should be moved to block's config $hive = $hive !== null ? array_merge($this->getData(), $hive) : $this->getData(); $hive['_BLOCKNAME'] = $blockName; $output = $this->render($blockConfig['template'], $mime, $hive, $ttl); if ($hasPlaceholder) { $output = $this->_wrapBlockPlaceholder($blockName, $output, $mime); } } catch (\Exception $e) { /*if ($mime == 'text/html') { $exClass = get_class($e); $output = "<!-- {$exClass} [{$e->getCode()}] {$e->getMessage()} -->"; }*/ if (\Base::instance()->get('DEBUG') > 1) { Log::instance()->logException($e); } } return $output; }
function __call($name, $arguments) { if (strcasecmp(substr($name, -6), 'action') === 0) { // Tried to call an undefined action, return 404 (instead of 405 from standard) if ($this->_fw->get('DEBUG') > 1) { Log::instance()->log('Invalid action requested "' . $name . '" for controller "' . get_class($this) . '".', LOG_INFO); } $this->_fw->error(404); return false; } }