Example #1
0
 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);
 }
Example #2
0
 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');
 }
Example #3
0
 public function prepare(CM_Frontend_Environment $environment, CM_Frontend_ViewResponse $viewResponse)
 {
     $debug = CM_Service_Manager::getInstance()->getDebug();
     $stats = $debug->getStats();
     ksort($stats);
     $viewResponse->set('stats', $stats);
     $cacheNames = array('CM_Cache_Storage_Memcache', 'CM_Cache_Storage_Apc', 'CM_Cache_Storage_File');
     $viewResponse->getJs()->setProperty('cacheNames', $cacheNames);
     $viewResponse->set('cacheNames', $cacheNames);
 }
Example #4
0
 public function prepare(CM_Frontend_Environment $environment, CM_Frontend_ViewResponse $viewResponse)
 {
     $email = $this->_params->get('email');
     if (!$email instanceof CM_Mail_Mailable) {
         throw new CM_Exception_InvalidParam('Invalid `email` param');
     }
     list($subject, $html, $plainText) = $email->render();
     $viewResponse->set('plainText', $plainText);
     $viewResponse->getJs()->setProperty('html', $html);
 }
Example #5
0
 public function prepare(CM_Frontend_Environment $environment, CM_Frontend_ViewResponse $viewResponse)
 {
     $xmode = $this->_params->has('xmode') ? $this->_params->get('xmode') : 'time';
     $stack = $this->_params->has('stack') ? $this->_params->get('stack') : false;
     $legend = $this->_params->has('legend') ? $this->_params->get('legend') : true;
     $series = $this->_params->get('series');
     $numPoints = 0;
     $valueMin = 0;
     foreach ($series as &$serie) {
         $serie['label'] = (string) $serie['label'];
         foreach ($serie['data'] as $key => &$value) {
             $value = (double) $value;
             $valueMin = min($valueMin, $value);
         }
         $numPoints = max($numPoints, count($serie['data']));
     }
     $flotOptions = array();
     $flotOptions['series'] = array();
     $flotOptions['xaxis'] = array();
     $flotOptions['yaxis'] = array('min' => $valueMin);
     $flotOptions['points'] = array('show' => true, 'radius' => 1.5);
     $flotOptions['series']['lines'] = array('show' => true);
     $flotOptions['legend'] = array('position' => 'nw', 'show' => $legend);
     if ($stack) {
         $flotOptions['series']['lines']['fill'] = 0.7;
         $flotOptions['series']['stack'] = 'stack';
     }
     if ($xmode == 'time') {
         $flotOptions['xaxis']['mode'] = 'time';
     }
     if ($numPoints > 0 && 700 / $numPoints < 10) {
         $flotOptions['points']['show'] = false;
     }
     $viewResponse->getJs()->setProperty('series', $series);
     $viewResponse->getJs()->setProperty('flotOptions', $flotOptions);
 }
Example #6
0
 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);
 }