public function prepare(CM_Frontend_Environment $environment, CM_Frontend_ViewResponse $viewResponse) { $level = $this->_params->has('level') ? $this->_params->getInt('level') : null; if (null !== $level && !CM_Log_Logger::hasLevel($level)) { throw new CM_Exception_InvalidParam('Invalid `level` param'); } $levelList = $level ? [$level] : null; $type = $this->_params->has('type') ? $this->_params->getInt('type') : null; if (null !== $type && !CM_Paging_Log::isValidType($type)) { throw new CM_Exception_InvalidParam('Invalid `type` param'); } $aggregate = $this->_params->has('aggregate') ? $this->_params->getInt('aggregate') : null; $urlPage = $this->_params->has('urlPage') ? $this->_params->getString('urlPage') : null; $urlParams = $this->_params->has('urlParams') ? $this->_params->getArray('urlParams') : null; $aggregationPeriod = $aggregate; if (0 === $aggregationPeriod) { $deployStamp = CM_App::getInstance()->getDeployVersion(); $aggregationPeriod = time() - $deployStamp; } $logList = new CM_Paging_Log($levelList, $type, (bool) $aggregationPeriod, $aggregationPeriod); $logList->setPage($this->_params->getPage(), $this->_params->getInt('count', 50)); $viewResponse->setData(['level' => $level, 'type' => $type, 'logList' => $logList, 'aggregate' => $aggregate, 'aggregationPeriod' => $aggregationPeriod, 'aggregationPeriodList' => array(3600, 86400, 7 * 86400, 31 * 86400), 'urlPage' => $urlPage, 'urlParams' => $urlParams, 'levelMap' => array_flip(CM_Log_Logger::getLevels())]); $viewResponse->getJs()->setProperty('level', $level); $viewResponse->getJs()->setProperty('type', $type); }
public function prepare(CM_Frontend_Environment $environment, CM_Frontend_ViewResponse $viewResponse) { $foo = $this->_params->getString('foo', 'value1'); $colorStyles = $this->_getColorStyles(); $icons = $this->_getIcons(); $viewResponse->setData(array('now' => time(), 'foo' => $foo, 'colorStyles' => $colorStyles, 'icons' => $icons)); $viewResponse->getJs()->setProperty('uname', 'uname'); }
public function prepare(CM_Frontend_Environment $environment, CM_Frontend_ViewResponse $viewResponse) { $type = $this->_params->getInt('type'); $aggregate = $this->_params->has('aggregate') ? $this->_params->getInt('aggregate') : null; $urlPage = $this->_params->has('urlPage') ? $this->_params->getString('urlPage') : null; $urlParams = $this->_params->has('urlParams') ? $this->_params->getArray('urlParams') : null; $aggregationPeriod = $aggregate; if (0 === $aggregationPeriod) { $deployStamp = CM_App::getInstance()->getDeployVersion(); $aggregationPeriod = time() - $deployStamp; } $logList = CM_Paging_Log_Abstract::factory($type, (bool) $aggregationPeriod, $aggregationPeriod); $logList->setPage($this->_params->getPage(), $this->_params->getInt('count', 50)); $viewResponse->setData(['type' => $type, 'logList' => $logList, 'aggregate' => $aggregate, 'aggregationPeriod' => $aggregationPeriod, 'aggregationPeriodList' => array(3600, 86400, 7 * 86400, 31 * 86400), 'urlPage' => $urlPage, 'urlParams' => $urlParams]); $viewResponse->getJs()->setProperty('type', $type); }