public function mainpage() { $oTemplate = new Templater('forecast.html'); $proxyFactory = new \Factory\Proxy(); $oTemplate->add('proxyForecast', $proxyFactory->create('Forecast')->get()); return (string) $oTemplate; }
public function render(array $aParams, \General\Templater $template) { if (empty($aParams['type'])) { $aParams['type'] = 'chart'; } $oView = new \View\Forecast($aParams); $template->add('menu-active-forecast', 'active'); $template->add('mainContent', $oView->mainpage()); }
/** * render average temperature chart head for google charts * @return string */ public function chartHead() { $t = \Translate\Controller::getDefault(); $oTemplate = new Templater('chartHead.html'); /** * Data from OpenWeatherMap.org */ $oOpenWeatherMap = new \Model\OpenWeatherMap(); $aHistory = $oOpenWeatherMap->getHourAggregate(168, "ASC"); $oChartHourPressure = new \General\GoogleChart(); $oChartHourPressure->setTitle($t->get('Pressure') . " [hPa]"); $oChartHourPressure->setDomID('chartHourPressure'); $oChartHourPressure->add('Hour', array()); $oChartHourPressure->add('Min', array()); foreach ($aHistory as $oReadout) { $oChartHourPressure->push('Hour', Formater::formatTime($oReadout['Date'])); $oChartHourPressure->push('Min', number_format($oReadout['MinPressure'], 2, '.', '')); } $oTemplate->add('chartHourPressure', $oChartHourPressure->getHead()); $oChartHourWindSpeed = new \General\GoogleChart(); $oChartHourWindSpeed->setTitle($t->get('Wind speed') . " [m/s]"); $oChartHourWindSpeed->setDomID('chartHourWindSpeed'); $oChartHourWindSpeed->add('Hour', array()); $oChartHourWindSpeed->add('Min', array()); foreach ($aHistory as $oReadout) { $oChartHourWindSpeed->push('Hour', Formater::formatTime($oReadout['Date'])); $oChartHourWindSpeed->push('Min', number_format($oReadout['WindSpeed'], 2, '.', '')); } $oTemplate->add('chartHourWindSpeed', $oChartHourWindSpeed->getHead()); /* * Hour Aggregate charts */ $aHistory = $this->model->getHourAggregate(168, "ASC"); $oChartHourTemperature = new \General\GoogleChart(); $oChartHourTemperature->setTitle($t->get('Temperature') . " [C]"); $oChartHourTemperature->setDomID('chartHourTemperature'); $oChartHourTemperature->add('Hour', array()); $oChartHourTemperature->add('Avg', array()); $oChartHourHumidity = new \General\GoogleChart(); $oChartHourHumidity->setTitle($t->get('Humidity') . " [%]"); $oChartHourHumidity->setDomID('chartHourHumidity'); $oChartHourHumidity->add('Hour', array()); $oChartHourHumidity->add('Avg', array()); foreach ($aHistory as $oReadout) { $oChartHourTemperature->push('Hour', Formater::formatTime($oReadout['Date'])); $oChartHourTemperature->push('Avg', number_format($oReadout['Temperature'], 2)); $oChartHourHumidity->push('Hour', Formater::formatTime($oReadout['Date'])); $oChartHourHumidity->push('Avg', number_format($oReadout['Humidity'], 2)); } $oTemplate->add('chartHourTemperature', $oChartHourTemperature->getHead()); $oTemplate->add('chartHourHumidity', $oChartHourHumidity->getHead()); return (string) $oTemplate; }
public function render(array $aParams, \General\Templater $template) { if (empty($aParams['type'])) { $aParams['type'] = 'chart'; } $oView = new \View\Overview($aParams); $template->add('menu-active-overview', 'active'); $template->add('mainContent', $oView->mainpage()); switch ($aParams['type']) { case 'table': $template->add('pageContent', $oView->tables()); $template->add('submenu-active-table', 'active'); break; case 'chart': default: $template->add('chartHead', $oView->chartHead()); $template->add('pageContent', $oView->charts()); $template->add('submenu-active-chart', 'active'); break; } }
/** * Rejestracja listenera * @param array $aParams * @param \General\Templater $template */ public function register(array &$aParams, \General\Templater $template) { $aArray = $this->get(); if (empty($aArray)) { return; } $sHtml = ''; foreach ($aArray as $aMessage) { $sHtml .= $this->render($aMessage); } $template->add('listeners', $sHtml); $this->clear(); }
/** * render average temperature chart head for google charts * @return string */ public function chartHead() { $t = \Translate\Controller::getDefault(); $oTemplate = new Templater('history-chartHead.html'); $oChartDailyPressure = new \General\GoogleChart(); $oChartDailyPressure->setTitle($t->get('Pressure')); $oChartDailyPressure->setDomID('chartDailyPressure'); $oChartDailyPressure->add('Hour', array()); $oChartDailyPressure->add('Avg', array()); $oChartDailyPressure->add('Max', array()); $oChartDailyPressure->add('Min', array()); foreach ($this->externalData as $oReadout) { $oChartDailyPressure->push('Hour', Formater::formatDate($oReadout['Date'])); $oChartDailyPressure->push('Avg', number_format($oReadout['Pressure'], 2, '.', '')); $oChartDailyPressure->push('Max', number_format($oReadout['MaxPressure'], 2, '.', '')); $oChartDailyPressure->push('Min', number_format($oReadout['MinPressure'], 2, '.', '')); } $oTemplate->add('chartDailyPressure', $oChartDailyPressure->getHead()); /* * Day aggregate charts */ $oChartDailyTemperature = new \General\GoogleChart(); $oChartDailyTemperature->setTitle($t->get('Temperature')); $oChartDailyTemperature->setDomID('chartDailyTemperature'); $oChartDailyTemperature->add('Day', array()); $oChartDailyTemperature->add('Avg', array()); $oChartDailyTemperature->add('Max', array()); $oChartDailyTemperature->add('Min', array()); $oChartDailyHumidity = new \General\GoogleChart(); $oChartDailyHumidity->setTitle($t->get('Humidity')); $oChartDailyHumidity->setDomID('chartDailyHumidity'); $oChartDailyHumidity->add('Day', array()); $oChartDailyHumidity->add('Avg', array()); $oChartDailyHumidity->add('Min', array()); foreach ($this->internalData as $oReadout) { $oChartDailyTemperature->push('Day', Formater::formatDate($oReadout['Date'])); $oChartDailyTemperature->push('Avg', number_format($oReadout['Temperature'], 2)); $oChartDailyTemperature->push('Max', number_format($oReadout['MaxTemperature'], 2)); $oChartDailyTemperature->push('Min', number_format($oReadout['MinTemperature'], 2)); $oChartDailyHumidity->push('Day', Formater::formatDate($oReadout['Date'])); $oChartDailyHumidity->push('Avg', number_format($oReadout['Humidity'], 2)); $oChartDailyHumidity->push('Min', number_format($oReadout['MinHumidity'], 2)); } $oTemplate->add('chartDailyTemperature', $oChartDailyTemperature->getHead()); $oTemplate->add('chartDailyHumidity', $oChartDailyHumidity->getHead()); return (string) $oTemplate; }
/** * render average temperature chart head for google charts * @return string */ public function chartHead() { $oTemplate = new Templater('chartHead.html'); /* * Hour Aggregate charts */ $aHistory = $this->model->getHourAggregate(72, "ASC"); $oChartHourTemperature = new \General\GoogleChart(); $oChartHourTemperature->setTitle('Temperature'); $oChartHourTemperature->setDomID('chartHourTemperature'); $oChartHourTemperature->add('Hour', array()); $oChartHourTemperature->add('Avg', array()); $oChartHourTemperature->add('Max', array()); $oChartHourTemperature->add('Min', array()); $oChartHourHumidity = new \General\GoogleChart(); $oChartHourHumidity->setTitle('Humidity'); $oChartHourHumidity->setDomID('chartHourHumidity'); $oChartHourHumidity->add('Hour', array()); $oChartHourHumidity->add('Avg', array()); $oChartHourHumidity->add('Max', array()); $oChartHourHumidity->add('Min', array()); foreach ($aHistory as $iIndex => $oReadout) { $oChartHourTemperature->push('Hour', Formater::formatTime($oReadout['Date'])); $oChartHourTemperature->push('Avg', number_format($oReadout['Temperature'], 2)); $oChartHourTemperature->push('Max', number_format($oReadout['MaxTemperature'], 2)); $oChartHourTemperature->push('Min', number_format($oReadout['MinTemperature'], 2)); $oChartHourHumidity->push('Hour', Formater::formatTime($oReadout['Date'])); $oChartHourHumidity->push('Avg', number_format($oReadout['Humidity'], 2)); $oChartHourHumidity->push('Max', number_format($oReadout['MaxHumidity'], 2)); $oChartHourHumidity->push('Min', number_format($oReadout['MinHumidity'], 2)); } $oTemplate->add('chartHourTemperature', $oChartHourTemperature->getHead()); $oTemplate->add('chartHourHumidity', $oChartHourHumidity->getHead()); /* * Day aggregate charts */ $aHistory = $this->model->getDayAggregate(14, "ASC"); $oChartDailyTemperature = new \General\GoogleChart(); $oChartDailyTemperature->setTitle('Temperature'); $oChartDailyTemperature->setDomID('chartDailyTemperature'); $oChartDailyTemperature->add('Day', array()); $oChartDailyTemperature->add('Avg', array()); $oChartDailyTemperature->add('Max', array()); $oChartDailyTemperature->add('Min', array()); $oChartDailyHumidity = new \General\GoogleChart(); $oChartDailyHumidity->setTitle('Humidity'); $oChartDailyHumidity->setDomID('chartDailyHumidity'); $oChartDailyHumidity->add('Day', array()); $oChartDailyHumidity->add('Avg', array()); $oChartDailyHumidity->add('Max', array()); $oChartDailyHumidity->add('Min', array()); foreach ($aHistory as $iIndex => $oReadout) { $oChartDailyTemperature->push('Day', Formater::formatDate($oReadout['Date'])); $oChartDailyTemperature->push('Avg', number_format($oReadout['Temperature'], 2)); $oChartDailyTemperature->push('Max', number_format($oReadout['MaxTemperature'], 2)); $oChartDailyTemperature->push('Min', number_format($oReadout['MinTemperature'], 2)); $oChartDailyHumidity->push('Day', Formater::formatDate($oReadout['Date'])); $oChartDailyHumidity->push('Avg', number_format($oReadout['Humidity'], 2)); $oChartDailyHumidity->push('Max', number_format($oReadout['MaxHumidity'], 2)); $oChartDailyHumidity->push('Min', number_format($oReadout['MinHumidity'], 2)); } $oTemplate->add('chartDailyTemperature', $oChartDailyTemperature->getHead()); $oTemplate->add('chartDailyHumidity', $oChartDailyHumidity->getHead()); return (string) $oTemplate; }