Example #1
0
 public function export()
 {
     $return = '';
     if ($this->getType() == 'element') {
         $element = scenarioElement::byId($this->getExpression());
         if (is_object($element)) {
             $exports = explode("\n", $element->export());
             foreach ($exports as $export) {
                 $return .= "    " . $export . "\n";
             }
         }
         return rtrim($return);
     }
     $options = $this->getOptions();
     if ($this->getType() == 'action') {
         if ($this->getExpression() == 'icon') {
             return '';
         } else {
             if ($this->getExpression() == 'sleep') {
                 return '(sleep) Pause de  : ' . $options['duration'];
             } else {
                 if ($this->getExpression() == 'stop') {
                     return '(stop) Arret du scenario';
                 } else {
                     if ($this->getExpression() == 'scenario') {
                         $actionScenario = scenario::byId($this->getOptions('scenario_id'));
                         if (is_object($actionScenario)) {
                             return '(scenario) ' . $this->getOptions('action') . ' de ' . $actionScenario->getHumanName();
                         }
                     } else {
                         if ($this->getExpression() == 'variable') {
                             return '(variable) Affectation de la variable : ' . $this->getOptions('name') . ' à ' . $this->getOptions('value');
                         } else {
                             $return = jeedom::toHumanReadable($this->getExpression());
                             if (is_array($options) && count($options) != 0) {
                                 $return .= ' - Options : ' . print_r(jeedom::toHumanReadable($options), true);
                             }
                             return $return;
                         }
                     }
                 }
             }
         }
     } else {
         if ($this->getType() == 'condition') {
             return jeedom::toHumanReadable($this->getExpression());
         }
     }
     if ($this->getType() == 'code') {
     }
 }
Example #2
0
 public function executeAlertCmdAction()
 {
     if ($this->getConfiguration('jeedomCheckCmdActionType') == 'cmd') {
         $cmd = cmd::byId(str_replace('#', '', $this->getConfiguration('jeedomCheckCmdCmdActionId')));
         if (!is_object($cmd)) {
             return;
         }
         $cmd->execCmd($this->getConfiguration('jeedomCheckCmdCmdActionOption'));
         return;
     }
     if ($this->getConfiguration('jeedomCheckCmdActionType') == 'scenario') {
         $scenario = scenario::byId($this->getConfiguration('jeedomCheckCmdScenarioActionId'));
         if (!is_object($scenario)) {
             return;
         }
         switch ($this->getConfiguration('jeedomCheckCmdScenarioActionMode')) {
             case 'start':
                 $scenario->launch(false, __('Lancement direct provoqué par le scénario  : ', __FILE__) . $this->getHumanName());
                 break;
             case 'stop':
                 $scenario->stop();
                 break;
             case 'deactivate':
                 $scenario->setIsActive(0);
                 $scenario->save();
                 break;
             case 'activate':
                 $scenario->setIsActive(1);
                 $scenario->save();
                 break;
         }
     }
 }
Example #3
0
 }
 if (init('action') == 'save') {
     if (!isConnect('admin')) {
         throw new Exception(__('401 - Accès non autorisé', __FILE__));
     }
     $time_dependance = 0;
     $time_keyword = array('#time#', '#seconde#', '#heure#', '#minute#', '#jour#', '#mois#', '#annee#', '#timestamp#', '#date#', '#semaine#', '#sjour#', '#njour#', '#smois#');
     foreach ($time_keyword as $keyword) {
         if (strpos(init('scenario'), $keyword) !== false) {
             $time_dependance = 1;
             break;
         }
     }
     $scenario_ajax = json_decode(init('scenario'), true);
     if (isset($scenario_ajax['id'])) {
         $scenario_db = scenario::byId($scenario_ajax['id']);
     }
     if (!isset($scenario_db) || !is_object($scenario_db)) {
         $scenario_db = new scenario();
     } else {
         if (!$scenario_db->hasRight('w')) {
             throw new Exception(__('Vous n\'etês pas autorisé à faire cette action', __FILE__));
         }
     }
     $scenario_db->setTrigger(array());
     $scenario_db->setSchedule(array());
     utils::a2o($scenario_db, $scenario_ajax);
     $scenario_db->setConfiguration('timeDependency', $time_dependance);
     $scenario_db->save();
     $scenario_element_list = array();
     if (isset($scenario_ajax['elements'])) {
<?php

if (!isConnect()) {
    throw new Exception('{{401 - Accès non autorisé}}');
}
$scenario = scenario::byId(init('scenario_id'));
if (!is_object($scenario)) {
    throw new Exception(__('Aucun scénario ne correspondant à : ', __FILE__) . init('scenario_id'));
}
sendVarToJs('scenarioLog_scenario_id', init('scenario_id'));
?>
<div style="display: none;width : 100%" id="div_alertScenarioLog"></div>
<a class="btn btn-danger pull-right" id="bt_scenarioLogEmpty"><i class="fa fa-trash"></i> {{Vider les logs}}</a>
<a class="btn btn-success pull-right" id="bt_scenarioLogDownload"><i class="fa fa-cloud-download"></i> {{Télécharger}}</a>
<a class="btn btn-primary pull-right" id="bt_scenarioLogRefresh"><i class="fa fa-refresh"></i> {{Rafraîchir}}</a>
<br/><br/>
<?php 
if (file_exists(dirname(__FILE__) . '/../../log/scenarioLog/scenario' . init('scenario_id') . '.log')) {
    echo '<pre id="pre_logScenarioDisplay">' . trim(file_get_contents(dirname(__FILE__) . '/../../log/scenarioLog/scenario' . init('scenario_id') . '.log')) . '</pre>';
} else {
    echo "{{Aucun log n'existe pour votre scénario : }}" . dirname(__FILE__) . '/../../log/scenarioLog/scenario' . init('scenario_id') . '.log.';
}
?>
<script>
    $('#bt_scenarioLogEmpty').on('click', function () {
     jeedom.scenario.emptyLog({
        id: <?php 
echo init('scenario_id');
?>
,
        error: function (error) {
Example #5
0
     $return['reply'] = $reply;
 }
 if ($interactQuery->getLink_type() == 'whatDoYouKnow') {
     $object = object::byId($interactQuery->getLink_id());
     if (is_object($object)) {
         $reply = interactQuery::whatDoYouKnow($object);
         if (trim($reply) == '') {
             $return['reply'] = __('Je ne sais rien sur ', __FILE__) . $object->getName();
         }
         $return['reply'] = $reply;
     }
     $return['reply'] = interactQuery::whatDoYouKnow();
 }
 if ($interactQuery->getLink_type() == 'scenario') {
     $return['scenario'] = '';
     $scenario = scenario::byId($interactQuery->getLink_id());
     if (!is_object($scenario)) {
         $return['scenario'] = __('Impossible de trouver le scénario correspondant', __FILE__);
     }
     $return['scenario'] = '#' . $scenario->getHumanName() . '#';
     switch ($interactDef->getOptions('scenario_action')) {
         case 'start':
             $return['action'] = __('lancer', __FILE__);
             break;
         case 'stop':
             $return['action'] = __('arrêter', __FILE__);
             break;
         case 'activate':
             $return['action'] = __('activer', __FILE__);
             break;
         case 'deactivate':
Example #6
0
 public function executeAndReply($_parameters)
 {
     $interactDef = interactDef::byId($this->getInteractDef_id());
     if (!is_object($interactDef)) {
         return __('Inconsistance de la base de données', __FILE__);
     }
     if (isset($_parameters['profile']) && trim($interactDef->getPerson()) != '') {
         $person = strtolower($interactDef->getPerson());
         $person = explode('|', $person);
         if (!in_array($_parameters['profile'], $person)) {
             return __('Vous n\'êtes pas autorisé à exécuter cette action', __FILE__);
         }
     }
     if ($this->getLink_type() == 'whatDoYouKnow') {
         $object = object::byId($this->getLink_id());
         if (is_object($object)) {
             $reply = self::whatDoYouKnow($object);
             if (trim($reply) == '') {
                 return __('Je ne sais rien sur ', __FILE__) . $object->getName();
             }
             return $reply;
         }
         return self::whatDoYouKnow();
     }
     if ($this->getLink_type() == 'scenario') {
         $scenario = scenario::byId($this->getLink_id());
         if (!is_object($scenario)) {
             return __('Impossible de trouver le scénario correspondant', __FILE__);
         }
         log::add('interact', 'debug', 'Execution du scénario : ' . $scenario->getHumanName() . ' => ' . $interactDef->getOptions('scenario_action'));
         $interactDef = $this->getInteractDef();
         if (!is_object($interactDef)) {
             return __('Impossible de trouver la définition de l\'interaction', __FILE__);
         }
         $reply = $interactDef->selectReply();
         if (trim($reply) == '') {
             $reply = self::replyOk();
         }
         $replace = array();
         $replace['#profile#'] = isset($_parameters['profile']) ? $_parameters['profile'] : '';
         $reply = scenarioExpression::setTags(str_replace(array_keys($replace), $replace, $reply));
         switch ($interactDef->getOptions('scenario_action')) {
             case 'start':
                 $scenario->setTags(array('#query#' => $this->getQuery(), '#profile#' => $replace['#profile#']));
                 $return = $scenario->launch(false, 'interact', __('Scénario exécuté sur interaction (S.A.R.A.H, SMS...)', __FILE__), 1);
                 if (is_string($return) && $return != '') {
                     $return = str_replace(array_keys($replace), $replace, $return);
                     return $return;
                 }
                 return $reply;
             case 'stop':
                 $scenario->stop();
                 return $reply;
             case 'activate':
                 $scenario->setIsActive(1);
                 $scenario->save();
                 return $reply;
             case 'deactivate':
                 $scenario->setIsActive(0);
                 $scenario->save();
                 return $reply;
             default:
                 return __('Aucune action n\'est définie dans l\'interaction sur le scénario : ', __FILE__) . $scenario->getHumanName();
         }
     }
     $reply = $interactDef->selectReply();
     $synonymes = array();
     if ($interactDef->getOptions('synonymes') != '') {
         foreach (explode('|', $interactDef->getOptions('synonymes')) as $value) {
             $values = explode('=', $value);
             $synonymes[strtolower($values[0])] = explode(',', $values[1]);
         }
     }
     $replace = array();
     $replace['#profile#'] = isset($_parameters['profile']) ? $_parameters['profile'] : '';
     if ($this->getLink_type() == 'cmd') {
         foreach (explode('&&', $this->getLink_id()) as $cmd_id) {
             $cmd = cmd::byId($cmd_id);
             if (!is_object($cmd)) {
                 continue;
             }
             $replace['#commande#'] = $cmd->getName();
             if (isset($synonymes[strtolower($cmd->getName())])) {
                 $replace['#commande#'] = $synonymes[strtolower($cmd->getName())][rand(0, count($synonymes[strtolower($cmd->getName())]) - 1)];
             }
             $replace['#objet#'] = '';
             $replace['#equipement#'] = '';
             $eqLogic = $cmd->getEqLogic();
             if (is_object($eqLogic)) {
                 $replace['#equipement#'] = $eqLogic->getName();
                 $object = $eqLogic->getObject();
                 if (is_object($object)) {
                     $replace['#objet#'] = $object->getName();
                 }
             }
             $replace['#unite#'] = $cmd->getUnite();
             if ($cmd->getType() == 'action') {
                 $options = null;
                 if ($cmd->getSubType() == 'slider') {
                     preg_match_all("/([0-9]*)/", $_parameters['dictation'], $matches);
                     foreach ($matches[1] as $number) {
                         if (is_numeric($number)) {
                             $options['slider'] = $number;
                         }
                     }
                 }
                 if ($cmd->getSubType() == 'color') {
                     $colors = config::byKey('convertColor');
                     foreach (explode(' ', $_parameters['dictation']) as $word) {
                         if (isset($colors[strtolower($word)])) {
                             $options['color'] = $colors[strtolower($word)];
                         }
                     }
                 }
                 try {
                     log::add('interact', 'debug', 'Execution de la commande : ' . $cmd->getHumanName() . ' => ' . print_r($options, true));
                     if ($cmd->execCmd($options) === false) {
                         return __('Impossible d\'exécuter la commande', __FILE__);
                     }
                 } catch (Exception $exc) {
                     return $exc->getMessage();
                 }
                 if ($options != null) {
                     foreach ($options as $key => $value) {
                         $replace['#' . $key . '#'] = $value;
                     }
                 }
             }
             if ($cmd->getType() == 'info') {
                 $value = $cmd->execCmd();
                 if ($value === null) {
                     return __('Impossible de récupérer la valeur de la commande', __FILE__);
                 } else {
                     $replace['#valeur#'] = $value;
                     if ($cmd->getSubType() == 'binary' && $interactDef->getOptions('convertBinary') != '') {
                         $convertBinary = $interactDef->getOptions('convertBinary');
                         $convertBinary = explode('|', $convertBinary);
                         $replace['#valeur#'] = $convertBinary[$replace['#valeur#']];
                     }
                 }
             }
         }
     }
     return scenarioExpression::setTags(str_replace(array_keys($replace), $replace, $reply));
 }
Example #7
0
 public function getLink()
 {
     if ($this->getLink_type() == 'eqLogic') {
         $eqLogic = eqLogic::byId($this->getLink_id());
         return $eqLogic;
     } else {
         if ($this->getLink_type() == 'scenario') {
             $scenario = scenario::byId($this->getLink_id());
             return $scenario;
         }
     }
     return null;
 }
Example #8
0
 public function execute($_trigger = '', $_message = '')
 {
     if ($this->getIsActive() != 1) {
         $this->setLog(__('Impossible d\'exécuter le scénario : ', __FILE__) . $this->getHumanName() . __(' sur : ', __FILE__) . $_message . __(' car il est désactivé', __FILE__));
         $this->persistLog();
         return;
     }
     if ($this->getConfiguration('timeDependency', 0) == 1 && !jeedom::isDateOk()) {
         $this->setLog(__('Lancement du scénario : ', __FILE__) . $this->getHumanName() . __(' annulé car il utilise une condition de type temporelle et que la date système n\'est pas OK', __FILE__));
         $this->persistLog();
         return;
     }
     $cmd = cmd::byId(str_replace('#', '', $_trigger));
     if (is_object($cmd)) {
         log::add('event', 'event', __('Exécution du scénario ', __FILE__) . $this->getHumanName() . __(' déclenché par : ', __FILE__) . $cmd->getHumanName());
     } else {
         log::add('event', 'event', __('Exécution du scénario ', __FILE__) . $this->getHumanName() . __(' déclenché par : ', __FILE__) . $_trigger);
     }
     $this->setLog(__('Début d\'exécution du scénario : ', __FILE__) . $this->getHumanName() . '. ' . $_message);
     $this->setLastLaunch(date('Y-m-d H:i:s'));
     if ($this->getConfiguration('speedPriority', 0) == 0) {
         $this->setDisplay('icon', '');
         $this->setState('in progress');
         $this->setPID(getmypid());
         $this->save();
     }
     $this->setRealTrigger($_trigger);
     foreach ($this->getElement() as $element) {
         $element->execute($this);
     }
     if ($this->getConfiguration('speedPriority', 0) == 0) {
         $this->setState('stop');
         $this->setPID('');
     }
     $this->setLog(__('Fin correcte du scénario', __FILE__));
     $this->persistLog();
     $scenario = scenario::byId($this->getId());
     if ($scenario->getIsActive() != $this->getIsActive()) {
         $this->setIsActive($scenario->getIsActive());
     }
     $this->save();
     if ($this->getReturn() != '') {
         return $this->getReturn();
     }
     return true;
 }
Example #9
0
     }
     $jsonrpc->makeSuccess(utils::o2a($cmd->getHistory($params['startTime'], $params['endTime'])));
 }
 /*             * ************************Scénario*************************** */
 if ($jsonrpc->getMethod() == 'scenario::all') {
     $jsonrpc->makeSuccess(utils::o2a(scenario::all()));
 }
 if ($jsonrpc->getMethod() == 'scenario::byId') {
     $scenario = scenario::byId($params['id']);
     if (!is_object($scenario)) {
         throw new Exception('Scenario introuvable : ' . $params['id'], -32703);
     }
     $jsonrpc->makeSuccess(utils::o2a($scenario));
 }
 if ($jsonrpc->getMethod() == 'scenario::changeState') {
     $scenario = scenario::byId($params['id']);
     if (!is_object($scenario)) {
         throw new Exception('Scenario introuvable : ' . $params['id'], -32702);
     }
     if ($params['state'] == 'stop') {
         $jsonrpc->makeSuccess($scenario->stop());
     }
     if ($params['state'] == 'run') {
         $jsonrpc->makeSuccess($scenario->launch(false, __('Scénario exécuté sur appel API', __FILE__)));
     }
     if ($params['state'] == 'enable') {
         $scenario->setIsActive(1);
         $jsonrpc->makeSuccess($scenario->save());
     }
     if ($params['state'] == 'disable') {
         $scenario->setIsActive(0);
 /**
  * Format le Widget "gCalendar"
  * @return void
  */
 public function toHtml($_version)
 {
     log::add('gCalendar', 'debug', '[' . $this->getId() . '] toHtml(' . $_version . ') start ...');
     // utilisation du widget "standard" jeedom //
     if ($this->getConfiguration('widgetOther') == '1') {
         log::add('gCalendar', 'debug', '[' . $this->getId() . '] toHtml(' . $_version . ') use jeedom widget (no plugin widget).');
         return parent::toHtml($_version);
     }
     // utilisation du widget du plugin //
     $_version = jeedom::versionAlias($_version);
     $mc = cache::byKey('gcalendarWidget' . $_version . $this->getId());
     if ($mc->getValue() != '') {
         log::add('gCalendar', 'debug', '[' . $this->getId() . '] toHtml(' . $_version . ') aborded !');
         return $mc->getValue();
     }
     $_sToday = $this->getConfiguration('hideDateDashboard') == 1 ? '' : __("aujourd'hui", __FILE__) . " : " . $this->getToday();
     $replace = array('#id#' => $this->getId(), '#name#' => $this->getIsEnable() ? $this->getName() : '<del>' . $this->getName() . '</del>', '#background_color#' => $this->getBackgroundColor($_version), '#today#' => $_version == 'mobile' ? date('d') : $_sToday, '#gCalArray#' => '0');
     if ($_version != 'mobile') {
         $replace['#eqLink#'] = $this->getLinkToConfiguration();
         $replace['#refreshDate#'] = !empty($this->_sRefreshDate) ? $this->_sRefreshDate : date('Y-m-d H:i:s');
         $replace['#txtView#'] = __("affichage", __FILE__);
         $replace['#txtGotoAG#'] = __("voir Agenda Google", __FILE__);
         $replace['#txtDay#'] = __("journée", __FILE__);
         $replace['#txtNextHour#'] = __("prochaine heure", __FILE__);
         $replace['#txtNow#'] = __("instantané", __FILE__);
     }
     // action sur l'affichage du nom //
     if (($_version == 'dview' || $_version == 'mview') && $this->getDisplay('doNotShowNameOnView') == 1) {
         $replace['#name#'] = '';
     }
     if ($_version == 'dashboard' && $this->getDisplay('doNotShowNameOnDashboard') == 1) {
         $replace['#name#'] = '';
     }
     if ($_version == 'mobile' && $this->getDisplay('doNotShowNameOnMobile') == 1) {
         $replace['#name#'] = '';
     }
     // pour chaque calendrier du widget //
     // tableau JS >> 0:nom jeedom / 1:type de vue / 2:date de mise à jour / 3:valeur affichée / 4:titre google / 5:url / 6:nb évènement //
     $nbCalRefresh = 0;
     foreach ($this->getCmd('info') as $cmdGCal) {
         if ($cmdGCal->getIsVisible()) {
             if (($_sEvents = $cmdGCal->execCmd()) != '') {
                 // génère le format en fonction de la vue //
                 if ($cmdGCal->getConfiguration('viewStyle') != 'current_titleOnly') {
                     $_aEvents = explode('||', $_sEvents);
                     $nbEvent = $cmdGCal->getConfiguration('defaultValue', GCALENDAR_TXT_DV) != $_sEvents ? count($_aEvents) : 0;
                     if ($nbEvent > 0) {
                         // pour chaque événement //
                         for ($i = 0; $i < count($_aEvents); $i++) {
                             $_aOneEvent = explode(';', $_aEvents[$i]);
                             // définit les valeurs à afficher : heure //
                             $_sEventHours = "<span class='gCalendar_hour'>(" . $_aOneEvent[0] . "-" . $_aOneEvent[1] . ")</span>";
                             if ($cmdGCal->getConfiguration('showHour') == 0) {
                                 $_sEventHours = "";
                             } else {
                                 if ($cmdGCal->getConfiguration('showHour24H') == 0 && $_aOneEvent[0] == "00:00" && $_aOneEvent[1] == "23:59") {
                                     $_sEventHours = "";
                                 }
                             }
                             // état //
                             if ($_aOneEvent[2] == 'DA') {
                                 $_sEventState = " <i class='fa fa-plus-circle' title='" . __('évènement actif: 1ère minute', __FILE__) . "' style='color:#FF0000;'></i>";
                             } elseif ($_aOneEvent[2] == 'FA') {
                                 $_sEventState = " <i class='fa fa-ban' title='" . __('évènement actif: dernière minute', __FILE__) . "' style='color:#FF0000;'></i>";
                             } elseif ($_aOneEvent[2] == 'A') {
                                 $_sEventState = " <i class='fa fa-check-circle-o' title='" . __('évènement actif', __FILE__) . "' style='color:#0000FF;'></i>";
                             } else {
                                 $_sEventState = "";
                             }
                             // titre //
                             $_sEventTxt = $_aOneEvent[3];
                             // gestion des scénarios //
                             if ($this->getConfiguration('acceptLaunchSc') == '1') {
                                 if ($_aOneEvent[4] == 'S' && $_aOneEvent[3] >= 1) {
                                     $_oSc = scenario::byId($_aOneEvent[3]);
                                     //log::add('gCalendar', 'debug', '[' . $this->getId() . '] toHtml() object scenario='.print_r($_oSc,true));
                                     if ($_oSc !== false) {
                                         $_aOneEvent[5] = $_aOneEvent[5] != '' ? ' (' . $_aOneEvent[5] . ')' : '';
                                         $_aOneEvent[7] = $_aOneEvent[7] != '' ? __('1er min', __FILE__) . '=' . $_aOneEvent[7] . ' | ' : '';
                                         $_aOneEvent[8] = $_aOneEvent[8] != '' ? __('dern. min', __FILE__) . '=' . $_aOneEvent[8] : '';
                                         if ($_version == 'mobile') {
                                             $_sIcon = "<i class='fa fa-cogs'></i> ";
                                         } else {
                                             $_sIcon = "<a href='index.php?v=d&p=scenario&id=" . $_aOneEvent[3] . "'><i class='fa fa-cogs' title='" . __('éditer le scénario', __FILE__) . "'></i></a> ";
                                         }
                                         $_sEventTxt = $_sIcon . '<span title="' . $_aOneEvent[7] . $_aOneEvent[8] . '">' . $_oSc->getName() . '</span>' . $_aOneEvent[5];
                                     } else {
                                         log::add('gCalendar', 'error', '[' . $this->getId() . '|' . $cmdGCal->getId() . '] toHtml().sc=' . $_aOneEvent[3] . ' ' . __("l'id du scénario n'existe pas, merci de vérifier.", __FILE__));
                                     }
                                 } else {
                                     $_sEventTxt = str_replace('{ERR}', "<span title='" . __('Erreur dans le format de la trame', __FILE__) . "'>{ERR}</span>", $_aOneEvent[3]);
                                 }
                             } else {
                                 // titre //
                                 if ($_aOneEvent[4] == 'S') {
                                     $_sEventTxt = 'sc=' . $_aOneEvent[3] . ';' . $_aOneEvent[5] . ';' . $_aOneEvent[6] . ';' . $_aOneEvent[7] . ';' . $_aOneEvent[8];
                                 }
                             }
                             if ($_version == 'mobile') {
                                 if ($_aOneEvent[2] == 'P') {
                                     $_aEvents[$i] = '';
                                     $nbEvent--;
                                 } else {
                                     $_aEvents[$i] = "<div class='gCalendar_itemActif'>" . $_sEventHours . $_sEventState . " " . $_sEventTxt . "</div>";
                                 }
                             } else {
                                 if ($i < count($_aEvents) - 1) {
                                     $_sBorder = 'border-bottom:1px solid #DDDDDD;';
                                 } else {
                                     $_sBorder = '';
                                 }
                                 if ($_aOneEvent[2] == 'P') {
                                     $_aEvents[$i] = "<div class='gCalendar_itemInactif' style='font-style:italic;color:#BBBBBB;" . $_sBorder . "'>" . $_sEventHours . $_sEventState . " " . $_sEventTxt . "</div>";
                                 } else {
                                     $_aEvents[$i] = "<div class='gCalendar_itemActif' style='" . $_sBorder . "'>" . $_sEventHours . $_sEventState . " " . $_sEventTxt . "</div>";
                                 }
                             }
                         }
                         $_sEvents = implode('', $_aEvents);
                     } else {
                         if ($_version == 'mobile') {
                             $_sEvents = "<div class='gCalendar_itemInactif'>" . $_sEvents . "</div>";
                         } else {
                             $_sEvents = "<span class='gCalendar_itemInactif'>" . $_sEvents . "</span>";
                         }
                     }
                 } else {
                     $nbEvent = $cmdGCal->getConfiguration('defaultValue', GCALENDAR_TXT_DV) != $_sEvents ? count(explode(' - ', $_sEvents)) : 0;
                     if ($_version == 'mobile') {
                         $_sEvents = "<div class='gCalendar_itemActif'>" . $_sEvents . "</div>";
                     } else {
                         $_sEvents = "<div class='gCalendar_itemActif'>" . $_sEvents . "</div>";
                     }
                 }
                 $_sEvents = str_replace('"', '\\"', $_sEvents);
                 $replace['#gCalArray#'] .= ',["' . str_replace('"', '\\"', $cmdGCal->getName()) . '", "' . $cmdGCal->getConfiguration('viewStyle') . '", "' . $cmdGCal->getCollectDate() . '", "' . $_sEvents . '", "' . str_replace('"', '\\"', $cmdGCal->getConfiguration('_sGCalTitle')) . '", "' . str_replace('"', '\\"', $cmdGCal->getConfiguration('_sGCalUrlCalendar')) . '", "' . $nbEvent . '"]';
                 $nbCalRefresh++;
             }
         }
     }
     $parameters = $this->getDisplay('parameters');
     if (is_array($parameters)) {
         foreach ($parameters as $key => $value) {
             $replace['#' . $key . '#'] = $value;
         }
     }
     log::add('gCalendar', 'debug', '[' . $this->getId() . '] toHtml().replace=' . print_r($replace, true));
     $html = template_replace($replace, getTemplate('core', $_version, 'gCalendar', 'gCalendar'));
     cache::set('gcalendarWidget' . $_version . $this->getId(), $html, 0);
     log::add('gCalendar', 'info', '[' . $this->getId() . '] toHtml(' . $_version . ') Refresh Widget (' . $nbCalRefresh . ' cal.): OK');
     return $html;
 }