/**
  * Konstruktor
  * @param string $language
  * @param string $file
  */
 public function __construct($language, $file = 'translations.php')
 {
     $this->language = $language;
     if (!self::$useCache || !Cache::getInstance()->check('translationList', $this->language)) {
         require dirname(__FILE__) . '/../../translations/' . $file;
         $this->table = $translationTable[$this->language];
         unset($translationTable);
         if (self::$useCache) {
             Cache::getInstance()->set('translationList', $this->language, $this->table, 86400);
         }
     } else {
         $this->table = Cache::getInstance()->get('translationList', $this->language);
     }
 }
 /**
  * Metoda pobiera dane obiektu do właściwości dataObject
  * @throws \Exception
  */
 protected function loadDataObject()
 {
     $oCache = \Cache\Factory::getInstance();
     if (empty($this->aParams['id'])) {
         throw new \Exception('{T:Nie podano identyfikatora obiektu}');
     }
     $sModule = get_class($this) . '::loadDataObject';
     $sProperty = $this->aParams['id'];
     if (!$this->bUseCache || !$oCache->check($sModule, $sProperty)) {
         $sQuery = "SELECT\n\t\t\t{$this->selectList}\n\t\t\t\tFROM\n\t\t\t\t{$this->tableList}\n\t\t\t\tWHERE\n\t\t\t\t{$this->registryIdField}={$this->loadDataObjectEncapsulate($this->aParams['id'])}\n\t\t\t\tLIMIT 1";
         $rQuery = Database::getInstance()->execute($sQuery);
         $this->dataObject = Database::getInstance()->fetch($rQuery);
         $oCache->set($sModule, $sProperty, $this->dataObject);
     } else {
         $this->dataObject = $oCache->get($sModule, $sProperty);
     }
 }
 /**
  * Template load
  *
  */
 private function load()
 {
     $module = 'Templater::load';
     $property = md5(realpath('') . '|' . $this->fileName);
     if (!self::$useCache || !Cache::getInstance()->check($module, $property)) {
         try {
             if (file_exists($this->fileName)) {
                 $tFile = fopen($this->fileName, 'r');
                 flock($tFile, LOCK_SH);
                 $this->template = fread($tFile, filesize($this->fileName));
                 flock($tFile, LOCK_UN);
                 fclose($tFile);
                 Cache::getInstance()->set($module, $property, $this->template, 86400);
             } else {
                 throw new \Exception('Brak pliku w ścieżce: "' . $this->fileName . '"');
             }
         } catch (Exception $e) {
             throw new \Exception('Błąd otwarcia szablonu');
         }
     } else {
         $this->template = Cache::getInstance()->get($module, $property);
     }
 }
 public function getHourAggregate($hours = 24, $orderBy = "DESC")
 {
     $retVal = array();
     $cache = \Cache\Factory::getInstance();
     $sModule = get_class($this) . '::getHourAggregate';
     $sProperty = $hours . '|' . $orderBy;
     if (!$cache->check($sModule, $sProperty)) {
         $db = \Database\Factory::getInstance();
         $rResult = $db->execute("select\r\n\t\t\t\t\tstrftime('%Y-%m-%d %H:00:00', `Date`) Date\n\t\t\t\t\t, AVG(Temperature) Temperature\r\n\t\t\t\t\t, AVG(Humidity) Humidity\r\n\t\t\t\t\t, MIN(Temperature) MinTemperature\r\n\t\t\t\t\t, MAX(Temperature) MaxTemperature\r\n\t\t\t\t\t, MIN(Humidity) MinHumidity\r\n\t\t\t\t\t, MAX(Humidity) MaxHumidity\r\n\t\t\t\t\tFROM\r\n\t\t\t\t\t\t{$this->tableName}\r\n\t\t\t\t\twhere\r\n\t\t\t\t\t\tdatetime(`Date`)>(SELECT DATETIME('now', '-{$hours} hour'))\r\n\t\t\t\t\tgroup by\r\n\t\t\t\t\t\tstrftime('%Y-%m-%d %H:00:00', `Date`)\r\n\t\t\t\t\tORDER BY\r\n\t\t\t\t\t\tdatetime(`Date`) {$orderBy}\r\n\t\t\t\t\t");
         while ($tResult = $db->fetchAssoc($rResult)) {
             array_push($retVal, $tResult);
         }
         $cache->set($sModule, $sProperty, $retVal, 3600);
     } else {
         $retVal = $cache->get($sModule, $sProperty);
     }
     return $retVal;
 }