Example #1
0
 public function toHtml($_version)
 {
     if (!$this->hasRight('r')) {
         return '';
     }
     $sql = 'SELECT `value` FROM cache
 WHERE `key`="scenarioHtml' . $_version . $this->getId() . '"';
     $result = DB::Prepare($sql, array(), DB::FETCH_TYPE_ROW);
     if ($result['value'] != '') {
         return $result['value'];
     }
     $_version = jeedom::versionAlias($_version);
     $replace = array('#id#' => $this->getId(), '#state#' => $this->getState(), '#isActive#' => $this->getIsActive(), '#name#' => $this->getDisplay('name') != '' ? $this->getDisplay('name') : $this->getHumanName(), '#icon#' => $this->getIcon(), '#lastLaunch#' => $this->getLastLaunch(), '#scenarioLink#' => $this->getLinkToConfiguration());
     if (!isset(self::$_templateArray)) {
         self::$_templateArray = array();
     }
     if (!isset(self::$_templateArray[$_version])) {
         self::$_templateArray[$_version] = getTemplate('core', $_version, 'scenario');
     }
     $html = template_replace($replace, self::$_templateArray[$_version]);
     cache::set('scenarioHtml' . $_version . $this->getId(), $html, 0);
     return $html;
 }