/** * Ajoute une clef à la config * @param string $_key nom de la clef * @param string $_value valeur de la clef * @return boolean vrai si ok faux sinon */ public static function save($_key, $_value, $_plugin = 'core') { if (is_object($_value) || is_array($_value)) { $_value = json_encode($_value, JSON_UNESCAPED_UNICODE); } if (isset(self::$cache[$_plugin . '::' . $_key])) { unset(self::$cache[$_plugin . '::' . $_key]); } $defaultConfiguration = self::getDefaultConfiguration($_plugin); if (isset($defaultConfiguration[$_plugin][$_key]) && $_value == $defaultConfiguration[$_plugin][$_key]) { self::remove($_key, $_plugin); return true; } $jeedomConfig = jeedom::getConfiguration($_key, true); if ($jeedomConfig != '' && $jeedomConfig == $_value) { self::remove($_key); return true; } $values = array('plugin' => $_plugin, 'key' => $_key, 'value' => $_value); $sql = 'REPLACE config SET `key`=:key, `value`=:value, plugin=:plugin'; return DB::Prepare($sql, $values, DB::FETCH_TYPE_ROW); }
<div class="col-sm-6"> <select class="eqLogicAttr form-control" data-l1key="object_id"> <option value="">{{Aucun}}</option> <?php foreach (object::all() as $object) { echo '<option value="' . $object->getId() . '">' . $object->getName() . '</option>'; } ?> </select> </div> </div> <div class="form-group"> <label class="col-sm-4 control-label">{{Catégorie}}</label> <div class="col-sm-8"> <?php foreach (jeedom::getConfiguration('eqLogic:category') as $key => $value) { echo '<label class="checkbox-inline">'; echo '<input type="checkbox" class="eqLogicAttr" data-l1key="category" data-l2key="' . $key . '" />' . $value['name']; echo '</label>'; } ?> </div> </div> <div class="form-group"> <label class="col-sm-4 control-label"></label> <div class="col-sm-8"> <input type="checkbox" class="eqLogicAttr bootstrapSwitch" data-label-text="{{Activer}}" data-l1key="isEnable" checked/> <input type="checkbox" class="eqLogicAttr bootstrapSwitch" data-label-text="{{Visible}}" data-l1key="isVisible" checked/> </div> </div> <div class="form-group expertModeVisible">
} if (init('action') == 'getBackupLog') { ajax::success(log::get('backup', 0, 3000)); } if (init('action') == 'getRestoreLog') { ajax::success(log::get('restore', 0, 3000)); } if (init('action') == 'removeBackup') { jeedom::removeBackup(init('backup')); ajax::success(); } if (init('action') == 'listBackup') { ajax::success(jeedom::listBackup()); } if (init('action') == 'getConfiguration') { ajax::success(jeedom::getConfiguration(init('key'), init('default'))); } if (init('action') == 'flushcache') { cache::flush(); ajax::success(); } if (init('action') == 'resetHwKey') { config::save('jeedom::installKey', ''); ajax::success(); } if (init('action') == 'backupupload') { $uploaddir = dirname(__FILE__) . '/../../backup'; if (!file_exists($uploaddir)) { mkdir($uploaddir); } if (!file_exists($uploaddir)) {
public function toHtml($_version = 'dashboard', $options = '', $_cmdColor = null, $_cache = 2) { $version = jeedom::versionAlias($_version); $html = ''; $template_name = 'cmd.' . $this->getType() . '.' . $this->getSubType() . '.' . $this->getTemplate($version, 'default'); $template = ''; if (!isset(self::$_templateArray[$version . '::' . $template_name])) { if ($this->getTemplate($version, 'default') != 'default') { if (config::byKey('active', 'widget') == 1) { $template = getTemplate('core', $version, $template_name, 'widget'); } if ($template == '') { foreach (plugin::listPlugin(true) as $plugin) { $template = getTemplate('core', $version, $template_name, $plugin->getId()); if ($template != '') { break; } } } if ($template == '') { $template_name = 'cmd.' . $this->getType() . '.' . $this->getSubType() . '.default'; $template = getTemplate('core', $version, $template_name); } } else { $template = getTemplate('core', $version, $template_name); } self::$_templateArray[$version . '::' . $template_name] = $template; } else { $template = self::$_templateArray[$version . '::' . $template_name]; } $replace = array('#id#' => $this->getId(), '#name#' => $this->getDisplay('icon') != '' ? $this->getDisplay('icon') : $this->getName(), '#name_display#' => $this->getDisplay('icon') != '' ? $this->getDisplay('icon') : $this->getName(), '#history#' => '', '#displayHistory#' => 'display : none;', '#unite#' => $this->getUnite(), '#minValue#' => $this->getConfiguration('minValue', 0), '#maxValue#' => $this->getConfiguration('maxValue', 100), '#logicalId#' => $this->getLogicalId()); if ($_cmdColor == null && $version != 'scenario') { $eqLogic = $this->getEqLogic(); $vcolor = $version == 'mobile' ? 'mcmdColor' : 'cmdColor'; if ($eqLogic->getPrimaryCategory() == '') { $replace['#cmdColor#'] = jeedom::getConfiguration('eqLogic:category:default:' . $vcolor); } else { $replace['#cmdColor#'] = jeedom::getConfiguration('eqLogic:category:' . $eqLogic->getPrimaryCategory() . ':' . $vcolor); } } else { $replace['#cmdColor#'] = $_cmdColor; } if ($this->getDisplay('doNotShowNameOnView') == 1 && ($_version == 'dview' || $_version == 'mview')) { $replace['#name_display#'] = ''; $replace['#name#'] = ''; } else { if ($this->getDisplay('doNotShowNameOnDashboard') == 1 && ($_version == 'mobile' || $_version == 'dashboard')) { $replace['#name_display#'] = ''; $replace['#name#'] = ''; } else { $replace['#name_display#'] .= '<br/>'; } } if ($this->getType() == 'info') { $replace['#state#'] = ''; $replace['#tendance#'] = ''; $replace['#state#'] = $this->execCmd(null, $_cache); if (strpos($replace['#state#'], 'error::') !== false) { $template = getTemplate('core', $version, 'cmd.error'); $replace['#state#'] = str_replace('error::', '', $replace['#state#']); } else { if ($this->getSubType() == 'binary' && $this->getDisplay('invertBinary') == 1) { $replace['#state#'] = $replace['#state#'] == 1 ? 0 : 1; } } if (method_exists($this, 'formatValueWidget')) { $replace['#state#'] = $this->formatValueWidget($replace['#state#']); } $replace['#collectDate#'] = $this->getCollectDate(); $replace['#valueDate#'] = $this->getValueDate(); if ($this->getIsHistorized() == 1) { $replace['#history#'] = 'history cursor'; if (config::byKey('displayStatsWidget') == 1 && strpos($template, '#displayHistory#') !== false) { $showStat = true; if ($this->getDisplay('doNotShowStatOnDashboard') == 1 && $_version == 'dashboard') { $showStat = false; } if ($this->getDisplay('doNotShowStatOnView') == 1 && ($_version == 'dview' || $_version == 'mview')) { $showStat = false; } if ($this->getDisplay('doNotShowStatOnMobile') == 1 && $_version == 'mobile') { $showStat = false; } if ($showStat) { $startHist = date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . ' -' . config::byKey('historyCalculPeriod') . ' hour')); $replace['#displayHistory#'] = ''; $historyStatistique = $this->getStatistique($startHist, date('Y-m-d H:i:s')); if ($historyStatistique['avg'] == 0 && $historyStatistique['min'] == 0 && $historyStatistique['max'] == 0) { $replace['#averageHistoryValue#'] = round($replace['#state#'], 1); $replace['#minHistoryValue#'] = round($replace['#state#'], 1); $replace['#maxHistoryValue#'] = round($replace['#state#'], 1); } else { $replace['#averageHistoryValue#'] = round($historyStatistique['avg'], 1); $replace['#minHistoryValue#'] = round($historyStatistique['min'], 1); $replace['#maxHistoryValue#'] = round($historyStatistique['max'], 1); } $startHist = date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . ' -' . config::byKey('historyCalculTendance') . ' hour')); $tendance = $this->getTendance($startHist, date('Y-m-d H:i:s')); if ($tendance > config::byKey('historyCalculTendanceThresholddMax')) { $replace['#tendance#'] = 'fa fa-arrow-up'; } else { if ($tendance < config::byKey('historyCalculTendanceThresholddMin')) { $replace['#tendance#'] = 'fa fa-arrow-down'; } else { $replace['#tendance#'] = 'fa fa-minus'; } } } } } $parameters = $this->getDisplay('parameters'); if (is_array($parameters)) { foreach ($parameters as $key => $value) { $replace['#' . $key . '#'] = $value; } } return template_replace($replace, $template); } else { $cmdValue = $this->getCmdValue(); if (is_object($cmdValue) && $cmdValue->getType() == 'info') { $replace['#state#'] = $cmdValue->execCmd(null, 2); $replace['#valueName#'] = $cmdValue->getName(); $replace['#unite#'] = $cmdValue->getUnite(); } else { $replace['#state#'] = $this->getLastValue() != null ? $this->getLastValue() : ''; $replace['#valueName#'] = $this->getName(); $replace['#unite#'] = $this->getUnite(); } $parameters = $this->getDisplay('parameters'); if (is_array($parameters)) { foreach ($parameters as $key => $value) { $replace['#' . $key . '#'] = $value; } } $replace['#valueName#'] .= '<br/>'; $html .= template_replace($replace, $template); if (trim($html) == '') { return $html; } if ($options != '') { $options = jeedom::toHumanReadable($options); if (is_json($options)) { $options = json_decode($options, true); } if (is_array($options)) { foreach ($options as $key => $value) { $replace['#' . $key . '#'] = $value; } } } if ($version == 'scenario' && $this->getType() == 'action' && $this->getSubtype() == 'message') { if (!isset($replace['#title#'])) { $replace['#title#'] = ''; } if (!isset($replace['#message#'])) { $replace['#message#'] = ''; } } if ($version == 'scenario' && $this->getType() == 'action' && $this->getSubtype() == 'slider' && !isset($replace['#slider#'])) { $replace['#slider#'] = ''; } if ($version == 'scenario' && $this->getType() == 'action' && $this->getSubtype() == 'slider' && !isset($replace['#color#'])) { $replace['#color#'] = ''; } $replace['#title_placeholder#'] = $this->getDisplay('title_placeholder', __('Titre', __FILE__)); $replace['#message_placeholder#'] = $this->getDisplay('message_placeholder', __('Message', __FILE__)); $replace['#message_disable#'] = $this->getDisplay('message_disable', 0); $replace['#title_disable#'] = $this->getDisplay('title_disable', 0); $replace['#title_possibility_list#'] = $this->getDisplay('title_possibility_list', ''); $replace['#slider_placeholder#'] = $this->getDisplay('slider_placeholder', __('Valeur', __FILE__)); $html = template_replace($replace, $html); return $html; } }
public function toHtml($_version = 'dashboard') { if ($this->getConfiguration('noSpecifyWidget', 0) == 1) { return parent::toHtml($_version); } if ($_version == '') { throw new Exception(__('La version demandée ne peut pas être vide (mobile, dashboard ou scénario)', __FILE__)); } if (!$this->hasRight('r')) { return ''; } $version = jeedom::versionAlias($_version); if ($this->getDisplay('hideOn' . $version) == 1) { return ''; } $cmd_html = ''; $version = jeedom::versionAlias($_version); $vcolor = 'cmdColor'; if ($version == 'mobile') { $vcolor = 'mcmdColor'; } if ($this->getPrimaryCategory() == '') { $cmdColor = ''; } else { $cmdColor = jeedom::getConfiguration('eqLogic:category:' . $this->getPrimaryCategory() . ':' . $vcolor); } $maps = array(); $dynamic = array(); $cmd_html = ''; if ($this->getIsEnable()) { foreach ($this->getCmd(null, null, true) as $cmd) { if ($cmd->getConfiguration('mode') == 'travelTime') { $from = $cmd->getConfiguration('from'); $to = $cmd->getConfiguration('to'); if (!isset($maps[$from . '_' . $to])) { $maps[$from . '_' . $to] = array(); } $maps[$from . '_' . $to]['travelTime'] = $cmd->execCmd(); } if ($cmd->getConfiguration('mode') == 'distance') { $from = $cmd->getConfiguration('from'); $to = $cmd->getConfiguration('to'); if (!isset($maps[$from . '_' . $to])) { $maps[$from . '_' . $to] = array(); } $maps[$from . '_' . $to]['distance'] = $cmd->execCmd(); } if ($cmd->getConfiguration('mode') == 'travelDistance') { $from = $cmd->getConfiguration('from'); $to = $cmd->getConfiguration('to'); if (!isset($maps[$from . '_' . $to])) { $maps[$from . '_' . $to] = array(); } $maps[$from . '_' . $to]['travelDistance'] = $cmd->execCmd(); } if ($cmd->getConfiguration('mode') == 'dynamic') { $dynamic[$cmd->getId()] = $cmd; } } } foreach ($maps as $key => $map) { $key = explode('_', $key); if (count($key) != 2) { continue; } foreach ($dynamic as $id => $cmd) { if (in_array($id, $key)) { unset($dynamic[$id]); } } $from_cmd = cmd::byId($key[0]); $to_cmd = cmd::byId($key[1]); if (!is_object($from_cmd) || !is_object($to_cmd)) { contine; } $from = $from_cmd->execCmd(); $to = $to_cmd->execCmd(); $replace = array('#name#' => $from_cmd->getName() . ' <i class="fa fa-arrow-right"></i> ' . $to_cmd->getName(), '#from#' => $from, '#collectDate#' => $from_cmd->getCollectDate() > $to_cmd->getCollectDate() ? $from_cmd->getCollectDate() : $to_cmd->getCollectDate(), '#to#' => $to, '#travelDistance#' => isset($map['travelDistance']) ? $map['travelDistance'] : __('Inconnue', __FILE__), '#distance#' => isset($map['distance']) ? $map['distance'] : __('Inconnue', __FILE__), '#travelTime#' => isset($map['travelTime']) ? $map['travelTime'] : __('Inconnue', __FILE__)); $cmd_html .= template_replace($replace, getTemplate('core', $version, 'geoloc', 'geoloc')); } foreach ($dynamic as $id => $cmd) { $replace = array('#state#' => $cmd->execCmd(), '#name#' => $cmd->getName(), '#collectDate#' => $cmd->getCollectDate(), '#id#' => $cmd->getId()); $cmd_html .= template_replace($replace, getTemplate('core', $_version, 'geoloc_single', 'geoloc')); } $replace = array('#id#' => $this->getId(), '#name#' => $this->getName(), '#eqLink#' => $this->hasRight('w') ? $this->getLinkToConfiguration() : '#', '#category#' => $this->getPrimaryCategory(), '#background_color#' => $this->getBackgroundColor($version), '#cmd#' => $cmd_html, '#style#' => '', '#noResize#' => 1, '#max_width#' => '650px', '#logicalId#' => $this->getLogicalId(), '#battery#' => $this->getConfiguration('batteryStatus', -2), '#batteryDatetime#' => $this->getConfiguration('batteryStatusDatetime', __('inconnue', __FILE__))); if (($_version == 'dview' || $_version == 'mview') && $this->getDisplay('doNotShowObjectNameOnView', 0) == 0) { $object = $this->getObject(); $replace['#object_name#'] = is_object($object) ? '(' . $object->getName() . ')' : ''; } else { $replace['#object_name#'] = ''; } if (($_version == 'dview' || $_version == 'mview') && $this->getDisplay('doNotShowNameOnView') == 1) { $replace['#name#'] = ''; } if (($_version == 'mobile' || $_version == 'dashboard') && $this->getDisplay('doNotShowNameOnDashboard') == 1) { $replace['#name#'] = ''; } if (($_version == 'dview' || $_version == 'mview') && $this->getDisplay('doNotDisplayBatteryLevelOnView') == 1) { $replace['#battery#'] = -1; } if ($_version == 'dashboard' && $this->getDisplay('doNotDisplayBatteryLevelOnDashboard') == 1) { $replace['#battery#'] = -1; } $parameters = $this->getDisplay('parameters'); if (is_array($parameters)) { foreach ($parameters as $key => $value) { $replace['#' . $key . '#'] = $value; } } return template_replace($replace, getTemplate('core', $version, 'eqLogic')); }
</div> </div> <div class="col-lg-10 col-md-9 col-sm-8 eqLogicThumbnailDisplay" style="border-left: solid 1px #EEE; padding-left: 25px;"> <legend>{{Mes mails}} </legend> <div class="eqLogicThumbnailContainer"> <div class="cursor eqLogicAction" data-action="add" style="background-color : #ffffff; height : 200px;margin-bottom : 10px;padding : 5px;border-radius: 2px;width : 160px;margin-left : 10px;" > <center> <i class="fa fa-plus-circle" style="font-size : 7em;color:#94ca02;"></i> </center> <span style="font-size : 1.1em;position:relative; top : 23px;word-break: break-all;white-space: pre-wrap;word-wrap: break-word;color:#94ca02"><center>Ajouter</center></span> </div> <?php foreach ($eqLogics as $eqLogic) { $opacity = $eqLogic->getIsEnable() ? '' : jeedom::getConfiguration('eqLogic:style:noactive'); echo '<div class="eqLogicDisplayCard cursor" data-eqLogic_id="' . $eqLogic->getId() . '" style="background-color : #ffffff; height : 200px;margin-bottom : 10px;padding : 5px;border-radius: 2px;width : 160px;margin-left : 10px;' . $opacity . '" >'; echo "<center>"; echo '<img src="plugins/mail/doc/images/mail_icon.png" height="105" width="95" />'; echo "</center>"; echo '<span style="font-size : 1.1em;position:relative; top : 15px;word-break: break-all;white-space: pre-wrap;word-wrap: break-word;"><center>' . $eqLogic->getHumanName(true, true) . '</center></span>'; echo '</div>'; } ?> </div> </div> <div class="col-lg-10 col-md-9 col-sm-8 eqLogic" style="border-left: solid 1px #EEE; padding-left: 25px;display: none;"> <div class='row'> <div class="col-sm-6">
public function getBackgroundColor($_version = 'dashboard') { $vcolor = $_version == 'mobile' ? 'mcolor' : 'color'; $category = $this->getPrimaryCategory(); if ($category != '') { return jeedom::getConfiguration('eqLogic:category:' . $category . ':' . $vcolor); } return jeedom::getConfiguration('eqLogic:category:default:' . $vcolor); }
foreach ($scenarios[-1] as $scenario) { $opacity = $scenario->getIsActive() ? '' : jeedom::getConfiguration('eqLogic:style:noactive'); echo '<div class="scenarioDisplayCard cursor" data-scenario_id="' . $scenario->getId() . '" style="background-color : #ffffff; height : 140px;margin-bottom : 10px;padding : 5px;border-radius: 2px;width : 160px;margin-left : 10px;' . $opacity . '" >'; echo "<center>"; echo '<img src="core/img/scenario.png" height="90" width="85" />'; echo "</center>"; echo '<span style="font-size : 1.1em;position:relative; top : 15px;word-break: break-all;white-space: pre-wrap;word-wrap: break-word;"><center>' . $scenario->getHumanName(true, true, true, true) . '</center></span>'; echo '</div>'; } echo '</div>'; foreach ($scenarioListGroup as $group) { if ($group['group'] != '') { echo '<legend>' . $group['group'] . '</legend>'; echo '<div class="scenarioListContainer">'; foreach ($scenarios[$group['group']] as $scenario) { $opacity = $scenario->getIsActive() ? '' : jeedom::getConfiguration('eqLogic:style:noactive'); echo '<div class="scenarioDisplayCard cursor" data-scenario_id="' . $scenario->getId() . '" style="background-color : #ffffff; height : 140px;margin-bottom : 10px;padding : 5px;border-radius: 2px;width : 160px;margin-left : 10px;' . $opacity . '" >'; echo "<center>"; echo '<img src="core/img/scenario.png" height="90" width="85" />'; echo "</center>"; echo '<span style="font-size : 1.1em;position:relative; top : 15px;word-break: break-all;white-space: pre-wrap;word-wrap: break-word;"><center>' . $scenario->getHumanName(true, true, true, true) . '</center></span>'; echo '</div>'; } echo '</div>'; } } } ?> </div> <div id="div_editScenario" style="display: none; border-left: solid 1px #EEE; padding-left: 25px;">
</div> </div> <div class="col-md-9 col-sm-8" id="div_resumePluginList" style="border-left: solid 1px #EEE; padding-left: 25px;"> <legend>{{Mes plugins}}</legend> <div class="pluginListContainer"> <div class="cursor" id="bt_displayMarket2" style="background-color : #ffffff; height : 140px;margin-bottom : 10px;padding : 5px;border-radius: 2px;width : 160px;margin-left : 10px;" > <center> <i class="fa fa-shopping-cart" style="font-size : 6em;color:#94ca02;margin-top:20px;"></i> </center> <span style="font-size : 1.1em;position:relative; top : 15px;word-break: break-all;white-space: pre-wrap;word-wrap: break-word;color:#94ca02"><center>{{Accéder au Market}}</center></span> </div> <?php foreach (plugin::listPlugin() as $plugin) { $opacity = $plugin->isActive() ? '' : jeedom::getConfiguration('eqLogic:style:noactive'); echo '<div class="pluginDisplayCard cursor" data-pluginPath="' . $plugin->getFilepath() . '" data-plugin_id="' . $plugin->getId() . '" style="background-color : #ffffff; height : 140px;margin-bottom : 10px;padding : 5px;border-radius: 2px;width : 160px;margin-left : 10px;' . $opacity . '" >'; echo "<center>"; if (file_exists(dirname(__FILE__) . '/../../' . $plugin->getPathImgIcon())) { echo '<img class="img-responsive" style="width : 120px;" src="' . $plugin->getPathImgIcon() . '" />'; echo "</center>"; } else { echo '<i class="' . $plugin->getIcon() . '" style="font-size : 6em;margin-top:20px;"></i>'; echo "</center>"; echo '<span style="font-size : 1.1em;position:relative; top : 15px;word-break: break-all;white-space: pre-wrap;word-wrap: break-word;"><center>' . $plugin->getName() . '</center></span>'; } echo '</div>'; } ?> </div> </div>
<div class="col-lg-1"> <input type="password" class="eqLogicAttr form-control" data-l1key="configuration" data-l2key="code" checked/> </div> </div> <div class="form-group"> <label class="col-lg-3 control-label">Nom de la commande</label> <div class="col-lg-3"> <input class="eqLogicAttr form-control" data-l1key="configuration" data-l2key="cmd_name" /> </div> </div> <div class="form-group"> <label class="col-lg-3 control-label">Sous-type de la commande</label> <div class="col-lg-3"> <select class="eqLogicAttr form-control" data-l1key="configuration" data-l2key="cmd_subtype" > <?php foreach (jeedom::getConfiguration('cmd:type:info:subtype') as $key => $value) { echo '<option value="' . $key . '" >' . $value['name'] . '</option>'; } ?> </select> </div> </div> <div class="form-group"> <label class="col-lg-3 control-label">Unité de la commande</label> <div class="col-lg-3"> <input class="eqLogicAttr form-control" data-l1key="configuration" data-l2key="cmd_unite" /> </div> </div> <div class="form-group"> <label class="col-lg-3 control-label">Afficher la commande</label> <div class="col-lg-1">