本文整理汇总了PHP中jeedom::versionAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP jeedom::versionAlias方法的具体用法?PHP jeedom::versionAlias怎么用?PHP jeedom::versionAlias使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jeedom
的用法示例。
在下文中一共展示了jeedom::versionAlias方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toHtml
public function toHtml($_version = 'dashboard')
{
$lien_dossier = realpath(dirname(__FILE__) . '/../../flux_rss');
$li = null;
//$array_dossier = scandir($lien_dossier);
$lienfor = $lien_dossier . '/fluxrss_' . $this->getId() . '.json';
if (file_exists($lienfor)) {
$fluxRSS = fopen($lienfor, 'r');
$fluxRSSread = fread($fluxRSS, filesize($lienfor));
fclose($fluxRSS);
$fluxRSS = json_decode($fluxRSSread);
foreach ($fluxRSS as $key => $value) {
$lien_file_dash_rss = $lien_dossier . '/' . $value . '.json';
$file_dash_rss = fopen($lien_file_dash_rss, 'r');
$read_file_dash_rss = fread($file_dash_rss, filesize($lien_file_dash_rss));
fclose($file_dash_rss);
$file_dash_rss = null;
$recuperateur = json_decode($read_file_dash_rss, true);
$read_file_dash_rss = null;
$configuration = $this->getconfiguration();
$theme_voulu = $configuration['theme'];
if ($theme_voulu == 1) {
$theme = 'barre';
} else {
$theme = 'standard';
}
if ($theme == 'standard') {
$width = '300px';
$mini_height = "160px";
$mini_widht = "280px";
$li .= '<a href="#" class="list-group-item disabled"><img src="http://www.google.com/s2/favicons?domain=' . $recuperateur['lien_rss'] . '" /> ' . $recuperateur['name_rss'] . '</a>';
foreach ($recuperateur['contenu'] as $recup) {
if (isset($recup['title'])) {
$li .= '<a onclick="open_rss' . $this->getId() . '(\'' . $recup['link'] . '\')" class="list-group-item" style="background-color:transparent;cursor:pointer;font-size : 0.9em;">' . htmlentities($recup['title']) . '</a>';
} else {
foreach ($recup as $recupencore) {
if (isset($recupencore['title'])) {
$li .= '<a onclick="open_rss' . $this->getId() . '(\'' . $recupencore['link'] . '\')" class="list-group-item" style="background-color:transparent;cursor:pointer;font-size : 0.9em;">' . $recupencore['title'] . '</a>';
}
}
}
}
} elseif ($theme == 'barre') {
$width = '586px';
$mini_height = "80px";
$mini_widht = "500px";
$li .= '<div class="btn-group" style="width:100%;">';
$li .= '<button type="button" style="float:left;width:20%;" class="btn btn-danger" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><img src="http://www.google.com/s2/favicons?domain=' . $recuperateur['lien_rss'] . '" /> ' . $recuperateur['name_rss'] . '</button>';
//$li .= '<div style="float:left;padding: 6px 12px;" > TEST </div>';
$li .= '<button type="button" style="float:left;width:75%;height:32px;" class="btn btn btn-info" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><marquee>';
foreach ($recuperateur['contenu'] as $recup) {
if (isset($recup['title'])) {
$li .= htmlentities($recup['title']) . ' // ';
} else {
foreach ($recup as $recupencore) {
if (isset($recupencore['title'])) {
$li .= $recupencore['title'] . ' // ';
}
}
}
}
$li .= '</marquee></button>';
$li .= '<button type="button" style="float:right;width:5%;" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">';
$li .= '<span class="caret"></span>';
$li .= '<span class="sr-only">Toggle Dropdown</span>';
$li .= '</button>';
$li .= '<ul class="dropdown-menu" style="width:100%;">';
foreach ($recuperateur['contenu'] as $recup) {
if (isset($recup['title'])) {
$li .= '<li><a onclick="open_rss' . $this->getId() . '(\'' . $recup['link'] . '\')" class="list-group-item" style="background-color:transparent;cursor:pointer;font-size : 0.9em;">' . htmlentities($recup['title']) . '</a></li>';
} else {
foreach ($recup as $recupencore) {
if (isset($recupencore['title'])) {
$li .= '<li><a onclick="open_rss' . $this->getId() . '(\'' . $recupencore['link'] . '\')" class="list-group-item" style="background-color:transparent;cursor:pointer;font-size : 0.9em;">' . $recupencore['title'] . '</a></li>';
}
}
}
}
$li .= '</ul>';
$li .= '</div>';
$li .= '<br />';
}
}
}
$_version = jeedom::versionAlias($_version);
$replace = array('#id#' => $this->getId(), '#name#' => $this->getIsVisible() ? $this->getName() : '<del>' . $this->getName() . '</del>', '#eqLink#' => $this->getLinkToConfiguration(), '#li#' => $li, '#height#' => $this->getDisplay('height', 'auto'), '#width#' => $this->getDisplay('width', $width), '#miniheight#' => $mini_height, '#miniwidth#' => $mini_widht);
return template_replace($replace, getTemplate('core', $_version, 'eqLogic', 'rss'));
}
示例2: toHtml
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;
}
示例3: toHtml
public function toHtml($_version = 'dashboard')
{
if ($this->getIsEnable() != 1) {
return '';
}
if (!$this->hasRight('r')) {
return '';
}
$version = jeedom::versionAlias($_version);
if ($this->getDisplay('hideOn' . $version) == 1) {
return '';
}
$mc = cache::byKey('porkfolioWidget' . jeedom::versionAlias($_version) . $this->getId());
if ($mc->getValue() != '') {
return preg_replace("/" . preg_quote(self::UIDDELIMITER) . "(.*?)" . preg_quote(self::UIDDELIMITER) . "/", self::UIDDELIMITER . mt_rand() . self::UIDDELIMITER, $mc->getValue());
}
$background = $this->getBackgroundColor($_version);
if ($this->getCmd(null, 'derniervers')->execCmd() < 0) {
$humeur = 'triste';
} else {
$humeur = 'content';
}
if ($this->getCmd(null, 'somme')->execCmd() >= $this->getCmd(null, 'objectif')->execCmd()) {
$humeur = 'jeedom';
$background = '#34a729';
}
if ($this->getCmd(null, 'somme')->execCmd() == 0) {
$background = '#e54016';
$humeur = 'very_triste';
}
$replace = array('#name#' => $this->getName(), '#id#' => $this->getId(), '#background_color#' => $background, '#uid#' => 'porkfolio' . $this->getId() . self::UIDDELIMITER . mt_rand() . self::UIDDELIMITER, '#eqLink#' => $this->getLinkToConfiguration(), '#porky_humeur#' => $humeur);
foreach ($this->getCmd('info') as $cmd) {
$replace['#' . $cmd->getLogicalId() . '_history#'] = '';
if ($cmd->getIsVisible() == 1) {
$replace['#' . $cmd->getLogicalId() . '_id#'] = $cmd->getId();
if ($cmd->getName() == 'Date dépot' || $cmd->getName() == 'Date retournement' || $cmd->getName() == 'Date mouvement') {
$replace['#' . $cmd->getLogicalId() . '#'] = date("d/m/y H:i:s", $cmd->execCmd());
} else {
$replace['#' . $cmd->getLogicalId() . '#'] = $cmd->execCmd();
}
$replace['#' . $cmd->getLogicalId() . '_collect#'] = $cmd->getCollectDate();
if ($cmd->getIsHistorized() == 1) {
$replace['#' . $cmd->getLogicalId() . '_history#'] = 'history cursor';
}
} else {
$replace['#' . $cmd->getLogicalId() . '#'] = '';
}
}
$refresh = $this->getCmd(null, 'refresh');
$replace['#refresh_id#'] = $refresh->getId();
$parameters = $this->getDisplay('parameters');
if (is_array($parameters)) {
foreach ($parameters as $key => $value) {
$replace['#' . $key . '#'] = $value;
}
}
$html = template_replace($replace, getTemplate('core', $_version, 'porkfolio', 'porkfolio'));
cache::set('porkfolioWidget' . $_version . $this->getId(), $html, 0);
return $html;
}
示例4: toHtml
public function toHtml($_version = 'dashboard')
{
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 '';
}
$hasOnlyEventOnly = $this->hasOnlyEventOnlyCmd();
if ($hasOnlyEventOnly) {
$sql = 'SELECT `value` FROM cache
WHERE `key`="widgetHtml' . $_version . $this->getId() . '"';
$result = DB::Prepare($sql, array(), DB::FETCH_TYPE_ROW);
if ($result['value'] != '') {
return preg_replace("/" . preg_quote(self::UIDDELIMITER) . "(.*?)" . preg_quote(self::UIDDELIMITER) . "/", self::UIDDELIMITER . mt_rand() . self::UIDDELIMITER, $result['value']);
}
}
$parameters = $this->getDisplay('parameters');
$cmd_html = '';
$vcolor = 'cmdColor';
if ($version == 'mobile') {
$vcolor = 'mcmdColor';
}
$cmdColor = $this->getPrimaryCategory() == '' ? '' : jeedom::getConfiguration('eqLogic:category:' . $this->getPrimaryCategory() . ':' . $vcolor);
if (is_array($parameters) && isset($parameters['background_cmd_color'])) {
$cmdColor = $parameters['background_cmd_color'];
}
if ($this->getIsEnable()) {
foreach ($this->getCmd(null, null, true) as $cmd) {
if ($cmd->getDisplay('hideOn' . $version) == 1) {
continue;
}
if ($cmd->getDisplay('forceReturnLineBefore', 0) == 1) {
$cmd_html .= '<br/>';
}
$cmd_html .= $cmd->toHtml($_version, '', $cmdColor);
if ($cmd->getDisplay('forceReturnLineAfter', 0) == 1) {
$cmd_html .= '<br/>';
}
}
}
$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#' => '', '#max_width#' => '650px', '#logicalId#' => $this->getLogicalId(), '#battery#' => $this->getConfiguration('batteryStatus', -2), '#batteryDatetime#' => $this->getConfiguration('batteryStatusDatetime', __('inconnue', __FILE__)), '#batteryType#' => $this->getConfiguration('battery_type', ''), '#object_name#' => '', '#height#' => $this->getDisplay('height', 'auto'), '#width#' => $this->getDisplay('width', 'auto'), '#uid#' => 'eqLogic' . $this->getId() . self::UIDDELIMITER . mt_rand() . self::UIDDELIMITER);
if (($_version == 'dview' || $_version == 'mview') && $this->getDisplay('doNotShowObjectNameOnView', 0) == 0) {
$object = $this->getObject();
$replace['#object_name#'] = is_object($object) ? '(' . $object->getName() . ')' : '';
}
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;
}
if (is_array($parameters)) {
foreach ($parameters as $key => $value) {
$replace['#' . $key . '#'] = $value;
}
}
if (!isset(self::$_templateArray[$version])) {
self::$_templateArray[$version] = getTemplate('core', $version, 'eqLogic');
}
$html = template_replace($replace, self::$_templateArray[$version]);
if ($hasOnlyEventOnly) {
cache::set('widgetHtml' . $_version . $this->getId(), $html, 0);
}
return $html;
}
示例5: toHtml
public function toHtml($_version = 'dashboard')
{
$replace = $this->preToHtml($_version);
if (!is_array($replace)) {
return $replace;
}
$version = jeedom::versionAlias($_version);
foreach ($this->getCmd('action') as $cmd) {
if ($cmd->getIsVisible() == 1 && $cmd->getDisplay('showOn' . $_version, 1) == 1) {
$replace['#' . $cmd->getLogicalId() . '_id#'] = $cmd->getId();
} else {
$replace['#' . $cmd->getLogicalId() . '_id#'] = '';
}
}
return $this->postToHtml($_version, template_replace($replace, getTemplate('core', $version, 'nabaztag', 'nabaztag')));
}
示例6: toHtml
public function toHtml($_version = 'dashboard')
{
if ($this->getIsEnable() != 1) {
return '';
}
if (!$this->hasRight('r')) {
return '';
}
$_version = jeedom::versionAlias($_version);
if ($this->getDisplay('hideOn' . $_version) == 1) {
return '';
}
$mc = cache::byKey('weatherWidget' . $_version . $this->getId());
if ($mc->getValue() != '') {
return preg_replace("/" . preg_quote(self::UIDDELIMITER) . "(.*?)" . preg_quote(self::UIDDELIMITER) . "/", self::UIDDELIMITER . mt_rand() . self::UIDDELIMITER, $mc->getValue());
}
$html_forecast = '';
if ($_version != 'mobile' || $this->getConfiguration('fullMobileDisplay', 0) == 1) {
$forcast_template = getTemplate('core', $_version, 'forecast', 'weather');
for ($i = 0; $i < 5; $i++) {
$replace = array();
$replace['#day#'] = date_fr(date('l', strtotime('+' . $i . ' days')));
if ($i == 0) {
$temperature_min = $this->getCmd(null, 'temperature_min');
} else {
$temperature_min = $this->getCmd(null, 'temperature_' . $i . '_min');
}
$replace['#low_temperature#'] = is_object($temperature_min) ? $temperature_min->execCmd() : '';
if ($i == 0) {
$temperature_max = $this->getCmd(null, 'temperature_max');
} else {
$temperature_max = $this->getCmd(null, 'temperature_' . $i . '_max');
}
$replace['#hight_temperature#'] = is_object($temperature_max) ? $temperature_max->execCmd() : '';
$replace['#tempid#'] = is_object($temperature_max) ? $temperature_max->getId() : '';
if ($i == 0) {
$condition = $this->getCmd(null, 'condition');
} else {
$condition = $this->getCmd(null, 'condition_' . $i);
}
$replace['#icone#'] = is_object($condition) ? self::getIconFromCondition($condition->execCmd()) : '';
$replace['#conditionid#'] = is_object($condition) ? $condition->getId() : '';
$html_forecast .= template_replace($replace, $forcast_template);
}
}
$replace = array('#id#' => $this->getId(), '#city#' => $this->getConfiguration('city_name'), '#collectDate#' => '', '#background_color#' => $this->getBackgroundColor($_version), '#eqLink#' => $this->hasRight('w') ? $this->getLinkToConfiguration() : '#', '#forecast#' => $html_forecast, '#uid#' => 'weather' . $this->getId() . self::UIDDELIMITER . mt_rand() . self::UIDDELIMITER);
$temperature = $this->getCmd(null, 'temperature');
$replace['#temperature#'] = is_object($temperature) ? $temperature->execCmd() : '';
$replace['#tempid#'] = is_object($temperature) ? $temperature->getId() : '';
$humidity = $this->getCmd(null, 'humidity');
$replace['#humidity#'] = is_object($humidity) ? $humidity->execCmd() : '';
$pressure = $this->getCmd(null, 'pressure');
$replace['#pressure#'] = is_object($pressure) ? $pressure->execCmd() : '';
$replace['#pressureid#'] = is_object($pressure) ? $pressure->getId() : '';
$wind_speed = $this->getCmd(null, 'wind_speed');
$replace['#windspeed#'] = is_object($wind_speed) ? $wind_speed->execCmd() : '';
$replace['#windid#'] = is_object($wind_speed) ? $wind_speed->getId() : '';
$sunrise = $this->getCmd(null, 'sunrise');
$replace['#sunrise#'] = is_object($sunrise) ? $sunrise->execCmd() : '';
$replace['#sunid#'] = is_object($sunrise) ? $sunrise->getId() : '';
if (strlen($replace['#sunrise#']) == 3) {
$replace['#sunrise#'] = substr($replace['#sunrise#'], 0, 1) . ':' . substr($replace['#sunrise#'], 1, 2);
} else {
if (strlen($replace['#sunrise#']) == 4) {
$replace['#sunrise#'] = substr($replace['#sunrise#'], 0, 2) . ':' . substr($replace['#sunrise#'], 2, 2);
}
}
$sunset = $this->getCmd(null, 'sunset');
$replace['#sunset#'] = is_object($sunset) ? $sunset->execCmd() : '';
if (strlen($replace['#sunset#']) == 3) {
$replace['#sunset#'] = substr($replace['#sunset#'], 0, 1) . ':' . substr($replace['#sunset#'], 1, 2);
} else {
if (strlen($replace['#sunset#']) == 4) {
$replace['#sunset#'] = substr($replace['#sunset#'], 0, 2) . ':' . substr($replace['#sunset#'], 2, 2);
}
}
$wind_direction = $this->getCmd(null, 'wind_direction');
$replace['#wind_direction#'] = is_object($wind_direction) ? $wind_direction->execCmd() : 0;
$refresh = $this->getCmd(null, 'refresh');
$replace['#refresh_id#'] = is_object($refresh) ? $refresh->getId() : '';
$condition = $this->getCmd(null, 'condition_now');
$sunset_time = is_object($sunset) ? $sunset->execCmd() : null;
$sunrise_time = is_object($sunrise) ? $sunrise->execCmd() : null;
if (is_object($condition)) {
$replace['#icone#'] = self::getIconFromCondition($condition->execCmd(), $sunrise_time, $sunset_time);
$replace['#condition#'] = $condition->execCmd();
$replace['#conditionid#'] = $condition->getId();
$replace['#collectDate#'] = $condition->getCollectDate();
} else {
$replace['#icone#'] = '';
$replace['#condition#'] = '';
$replace['#collectDate#'] = '';
}
$parameters = $this->getDisplay('parameters');
if (is_array($parameters)) {
foreach ($parameters as $key => $value) {
$replace['#' . $key . '#'] = $value;
}
}
$html = template_replace($replace, getTemplate('core', $_version, 'current', 'weather'));
//.........这里部分代码省略.........
示例7: toHtml
public function toHtml($_version = 'dashboard')
{
if ($this->getIsEnable() != 1) {
return '';
}
if (!$this->hasRight('r')) {
return '';
}
$_version = jeedom::versionAlias($_version);
$replace = array('#id#' => $this->getId(), '#info#' => isset($info) ? $info : '', '#name#' => $this->getIsEnable() ? $this->getName() : '<del>' . $this->getName() . '</del>', '#eqLink#' => $this->getLinkToConfiguration(), '#action#' => isset($action) ? $action : '', '#height#' => $this->getDisplay('height', 'auto'), '#width#' => $this->getDisplay('width', '330px'), '#background_color#' => $this->getBackgroundColor($_version));
// Charger les template de groupe
$groups_template = array();
$group_names = $this->getGroups();
foreach ($group_names as $group) {
$groups_template[$group] = getTemplate('core', $_version, $group, 'dlControl');
$replace['#group_' . $group . '#'] = '';
}
// Afficher les commandes dans les bonnes templates
// html_groups: permet de gérer le #cmd# dans la template.
$html_groups = array();
if ($this->getIsEnable()) {
foreach ($this->getCmd() as $cmd) {
$cmd_html = ' ';
$group = $cmd->getConfiguration('group');
if (substr($cmd->getName(), 0, 5) == 'Pause') {
$mode = 'Pause';
} else {
$mode = 'Play';
}
if ($cmd->getIsVisible()) {
if ($cmd->getType() == 'info') {
log::add('dlControl', 'debug', 'cmd = info');
$cmd_html = $cmd->toHtml();
} else {
$cmd_template = getTemplate('core', $_version, $group . '_cmd', 'dlControl');
$cmd_replace = array('#id#' => $cmd->getId(), '#name#' => $cmd->getDisplay('icon') != '' ? $cmd->getDisplay('icon') : $cmd->getName(), '#oriname#' => $cmd->getName(), '#mode#' => $mode, '#theme#' => $this->getConfiguration('theme'));
// Construction du HTML pour #cmd#
$cmd_html = template_replace($cmd_replace, $cmd_template);
}
if (isset($html_groups[$group])) {
$html_groups[$group]++;
$html_groups[$group] .= $cmd_html;
} else {
$html_groups[$group] = $cmd_html;
}
}
$cmd_replace = array('#' . strtolower($cmd->getName()) . '#' => $cmd_html);
$groups_template[$group] = template_replace($cmd_replace, $groups_template[$group]);
}
}
// Remplacer #group_xxx de la template globale
$replace['#cmd'] = "";
$keys = array_keys($html_groups);
foreach ($html_groups as $group => $html_cmd) {
$group_template = $groups_template[$group];
$group_replace = array('#cmd#' => $html_cmd);
$replace['#group_' . $group . '#'] .= template_replace($group_replace, $group_template);
}
$parameters = $this->getDisplay('parameters');
if (is_array($parameters)) {
foreach ($parameters as $key => $value) {
$replace['#' . $key . '#'] = $value;
}
}
return template_replace($replace, getTemplate('core', $_version, 'eqLogic', 'dlControl'));
}
示例8: toHtml
public function toHtml($_version = 'dashboard')
{
if ($this->getIsEnable() != 1) {
return '';
}
if (!$this->hasRight('r')) {
return '';
}
$_version = jeedom::versionAlias($_version);
$background = $this->getBackgroundColor($_version);
$replace = array('#name#' => $this->getName(), '#id#' => $this->getId(), '#background_color#' => $background, '#eqLink#' => $this->getLinkToConfiguration(), '#height#' => $this->getDisplay('height', 'auto'), '#width#' => $this->getDisplay('width', '200px'), '#temperature_airneufexterieur#' => jeedom::evaluateExpression($this->getConfiguration('temperature_airneufexterieur')), '#temperature_airneufinsuflé#' => jeedom::evaluateExpression($this->getConfiguration('temperature_airneufinsuflé')), '#temperature_airvicie#' => jeedom::evaluateExpression($this->getConfiguration('temperature_airvicie')), '#temperature_airvicierejete#' => jeedom::evaluateExpression($this->getConfiguration('temperature_airvicierejete')));
$parameters = $this->getDisplay('parameters');
if (is_array($parameters)) {
foreach ($parameters as $key => $value) {
$replace['#' . $key . '#'] = $value;
}
}
$html = template_replace($replace, getTemplate('core', $_version, 'eqLogic', 'vmc'));
return $html;
}
示例9: toHtml
public function toHtml($_version = 'dashboard')
{
if ($this->getIsEnable() != 1) {
return '';
}
if (!$this->hasRight('r')) {
return '';
}
$_version = jeedom::versionAlias($_version);
if ($this->getDisplay('hideOn' . $_version) == 1) {
return '';
}
$mc = cache::byKey('networksWidget' . $_version . $this->getId());
if ($mc->getValue() != '') {
return preg_replace("/" . preg_quote(self::UIDDELIMITER) . "(.*?)" . preg_quote(self::UIDDELIMITER) . "/", self::UIDDELIMITER . mt_rand() . self::UIDDELIMITER, $mc->getValue());
}
$replace = array('#name#' => $this->getName(), '#id#' => $this->getId(), '#background_color#' => '#bdc3c7', '#eqLink#' => $this->hasRight('w') ? $this->getLinkToConfiguration() : '#', '#uid#' => 'networks' . $this->getId() . self::UIDDELIMITER . mt_rand() . self::UIDDELIMITER);
foreach ($this->getCmd('info') as $cmd) {
$replace['#' . $cmd->getLogicalId() . '_history#'] = '';
$replace['#' . $cmd->getLogicalId() . '_id#'] = $cmd->getId();
$replace['#' . $cmd->getLogicalId() . '#'] = $cmd->execCmd(null, 2);
if ($cmd->getSubType() == 'numeric' && $replace['#' . $cmd->getLogicalId() . '#'] === '') {
$replace['#' . $cmd->getLogicalId() . '#'] = 0;
}
$replace['#' . $cmd->getLogicalId() . '_collect#'] = $cmd->getCollectDate();
if ($cmd->getIsHistorized() == 1) {
$replace['#' . $cmd->getLogicalId() . '_history#'] = 'history cursor';
}
}
$replace['#action#'] = '';
foreach ($this->getCmd('action') as $cmd) {
if ($cmd->getLogicalId() == 'refresh') {
continue;
}
$replace['#action#'] .= $cmd->toHtml($_version, '', '#7f8c8d');
}
$refresh = $this->getCmd(null, 'refresh');
if (is_object($refresh)) {
$replace['#refresh_id#'] = $refresh->getId();
}
$parameters = $this->getDisplay('parameters');
if (is_array($parameters)) {
foreach ($parameters as $key => $value) {
$replace['#' . $key . '#'] = $value;
}
}
if ($replace['#action#'] == '') {
$html = template_replace($replace, getTemplate('core', $_version, 'networks', 'networks'));
} else {
$html = template_replace($replace, getTemplate('core', $_version, 'networks2', 'networks'));
}
cache::set('networksWidget' . $_version . $this->getId(), $html, 0);
return $html;
}
示例10: toHtml
/**
* 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];
//.........这里部分代码省略.........
示例11: toHtml
public function toHtml($_version = 'dashboard')
{
if ($this->getIsEnable() != 1) {
return '';
}
if (!$this->hasRight('r')) {
return '';
}
$version = jeedom::versionAlias($_version);
if ($this->getDisplay('hideOn' . $version) == 1) {
return '';
}
$mc = cache::byKey('sonosWidget' . $_version . $this->getId());
if ($mc->getValue() != '') {
return preg_replace("/" . preg_quote(self::UIDDELIMITER) . "(.*?)" . preg_quote(self::UIDDELIMITER) . "/", self::UIDDELIMITER . mt_rand() . self::UIDDELIMITER, $mc->getValue());
}
$replace = array('#id#' => $this->getId(), '#info#' => isset($info) ? $info : '', '#name#' => $this->getName(), '#eqLink#' => $this->hasRight('w') ? $this->getLinkToConfiguration() : '#', '#text_color#' => $this->getConfiguration('text_color'), '#background_color#' => '#5d9cec', '#hideThumbnail#' => 0, '#object_name#' => '', '#version#' => $_version, '#style#' => '', '#uid#' => 'sonos' . $this->getId() . self::UIDDELIMITER . mt_rand() . self::UIDDELIMITER);
if ($_version == 'dview' || $_version == 'mview') {
$object = $this->getObject();
$replace['#name#'] = is_object($object) ? $object->getName() . ' - ' . $replace['#name#'] : $replace['#name#'];
}
if (($_version == 'dview' || $_version == 'mview') && $this->getDisplay('doNotShowNameOnView') == 1) {
$replace['#name#'] = '';
}
if (($_version == 'mobile' || $_version == 'dashboard') && $this->getDisplay('doNotShowNameOnDashboard') == 1) {
$replace['#name#'] = '';
}
$cmd_state = $this->getCmd(null, 'state');
if (is_object($cmd_state)) {
$replace['#state#'] = $cmd_state->execCmd(null, 2);
if ($replace['#state#'] == __('Lecture', __FILE__)) {
$replace['#state_nb#'] = 1;
} else {
$replace['#state_nb#'] = 0;
}
}
foreach ($this->getCmd('action') as $cmd) {
$replace['#' . $cmd->getLogicalId() . '_id#'] = $cmd->getId();
if ($_version != 'mobile' && $_version != 'mview' && $cmd->getLogicalId() == 'play_playlist') {
$replace['#playlist#'] = $cmd->getDisplay('title_possibility_list');
}
if ($_version != 'mobile' && $_version != 'mview' && $cmd->getLogicalId() == 'play_radio') {
$replace['#radio#'] = $cmd->getDisplay('title_possibility_list');
}
}
foreach ($this->getCmd('info') as $cmd) {
$replace['#' . $cmd->getLogicalId() . '_id#'] = $cmd->getId();
$replace['#' . $cmd->getLogicalId() . '#'] = $cmd->execCmd(null, 2);
}
if ($replace['#mute_state#'] == 1) {
$replace['#mute_id#'] = $replace['#unmute_id#'];
}
$cmd_track_artist = $this->getCmd(null, 'track_artist');
if (is_object($cmd_track_artist)) {
$replace['#title#'] = $cmd_track_artist->execCmd(null, 2);
}
$cmd_track_album = $this->getCmd(null, 'track_album');
if (is_object($cmd_track_album)) {
$replace['#title#'] .= ' - ' . $cmd_track_album->execCmd(null, 2);
}
$replace['#title#'] = trim(trim(trim($replace['#title#']), ' - ' . __('Aucun', __FILE__)));
$cmd_track_title = $this->getCmd(null, 'track_title');
if (is_object($cmd_track_title)) {
$replace['#title#'] .= ' - ' . $cmd_track_title->execCmd(null, 2);
}
$replace['#title#'] = trim(trim(trim($replace['#title#']), '-'));
if (strlen($replace['#title#']) > 12) {
$replace['#title#'] = '<marquee behavior="scroll" direction="left" scrollamount="2">' . $replace['#title#'] . '</marquee>';
}
if ($_version != 'mobile' && $_version != 'mview') {
$replace['#queue#'] = str_replace("'", "\\'", $this->getConfiguration('queue'));
$replace['#speakers#'] = str_replace("'", "\\'", $this->getConfiguration('speakers'));
}
$cmd_track_image = $this->getCmd(null, 'track_image');
if (is_object($cmd_track_image)) {
$img = dirname(__FILE__) . '/../../../../plugins/sonos3/sonos_' . $this->getId() . '.jpg';
if (file_exists($img) && filesize($img) > 500) {
$replace['#thumbnail#'] = 'plugins/sonos3/sonos_' . $this->getId() . '.jpg?' . md5($cmd_track_image->execCmd(null, 2));
} else {
$replace['#thumbnail#'] = 'plugins/sonos3/doc/images/sonos3_alt_icon.png';
}
}
$parameters = $this->getDisplay('parameters');
if (is_array($parameters)) {
foreach ($parameters as $key => $value) {
$replace['#' . $key . '#'] = $value;
}
}
$_version = jeedom::versionAlias($_version);
$html = template_replace($replace, getTemplate('core', $_version, 'eqLogic', 'sonos3'));
cache::set('sonosWidget' . $_version . $this->getId(), $html, 0);
return $html;
}
示例12: toHtml
public function toHtml($_version = 'dashboard')
{
if ($this->getIsEnable() != 1) {
return '';
}
if (!$this->hasRight('r')) {
return '';
}
$_version = jeedom::versionAlias($_version);
$background = $this->getBackgroundColor($_version);
$hide1 = $this->getConfiguration('hide1');
$hide2 = $this->getConfiguration('hide2');
$hide3 = $this->getConfiguration('hide3');
$replace = array('#name#' => $this->getName(), '#id#' => $this->getId(), '#background_color#' => $background, '#eqLink#' => $this->getLinkToConfiguration(), '#height#' => $this->getDisplay('height', 'auto'), '#width#' => $this->getDisplay('width', '330px'), '#hide1#' => $hide1, '#hide2#' => $hide2, '#hide3#' => $hide3);
foreach ($this->getCmd('info') as $cmd) {
$replace['#' . $cmd->getLogicalId() . '_history#'] = '';
$replace['#' . $cmd->getLogicalId() . '_id#'] = $cmd->getId();
$replace['#' . $cmd->getLogicalId() . '#'] = $cmd->execCmd();
$replace['#' . $cmd->getLogicalId() . '_collect#'] = $cmd->getCollectDate();
if ($cmd->getIsHistorized() == 1) {
$replace['#' . $cmd->getLogicalId() . '_history#'] = 'history cursor';
}
}
$refresh = $this->getCmd(null, 'refresh');
$replace['#refresh_id#'] = $refresh->getId();
$parameters = $this->getDisplay('parameters');
if (is_array($parameters)) {
foreach ($parameters as $key => $value) {
$replace['#' . $key . '#'] = $value;
}
}
$html = template_replace($replace, getTemplate('core', $_version, 'eqlogic', 'wazeintime'));
return $html;
}
示例13: toHtml
public function toHtml($_version = 'dashboard')
{
$replace = $this->preToHtml($_version);
if (!is_array($replace)) {
return $replace;
}
$version = jeedom::versionAlias($_version);
$replace['#select_effect#'] = '<option disabled selected>' . __('Effet...', __FILE__) . '</option>';
$color = $this->getCmd(null, 'color');
if (is_object($color)) {
$replace['#color_state#'] = $color->toHtml($_version, '', $replace['#cmd-background-color#']);
} else {
$replace['#color#'] = '';
}
$clear = $this->getCmd(null, 'clear');
if (is_object($clear)) {
$replace['#clear#'] = $clear->toHtml($_version, '', $replace['#cmd-background-color#']);
} else {
$replace['#clear#'] = '';
}
foreach ($this->getCmd('action') as $cmd) {
if ($cmd->getIsVisible() == 1 && $cmd->getDisplay('showOn' . $_version, 1) == 1 && $cmd->getLogicalId() != 'color' && $cmd->getLogicalId() != 'clear') {
$replace['#select_effect#'] .= '<option value="' . $cmd->getId() . '">' . $cmd->getName() . '</option>';
}
}
$html = template_replace($replace, getTemplate('core', $version, 'hyperion', 'hyperion2'));
return $html;
}
示例14: toHtml
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;
}
//.........这里部分代码省略.........
示例15: toHtml
public function toHtml($_version = 'dashboard')
{
$replace = $this->preToHtml($_version);
if (!is_array($replace)) {
return $replace;
}
$version = jeedom::versionAlias($_version);
foreach ($this->getCmd('info') as $cmd) {
$replace['#' . $cmd->getLogicalId() . '#'] = $cmd->execCmd();
$replace['#' . $cmd->getLogicalId() . '_id#'] = $cmd->getId();
if ($cmd->getIsHistorized() == 1) {
$replace['#' . $cmd->getLogicalId() . '_history#'] = 'history cursor';
}
}
if ($replace['#sleep#'] == 0) {
$replace['#state#'] = 'awake';
$replace['#actionstate#'] = __('Endormir le Karotz', __FILE__);
} else {
$replace['#state#'] = 'sleep';
$replace['#actionstate#'] = __('Réveiller le Karotz', __FILE__);
}
$replace['#enablesqueezebox#'] = $this->getConfiguration('enablesqueezebox', 0);
$replace['#enablemoods#'] = $this->getConfiguration('enablemoods', 0);
$replace['#enableclock#'] = $this->getConfiguration('enableclock', 0);
foreach ($this->getCmd('info') as $cmd) {
$replace['#' . $cmd->getLogicalId() . '_history#'] = '';
$replace['#' . $cmd->getLogicalId() . '_id#'] = $cmd->getId();
$replace['#' . $cmd->getLogicalId() . '#'] = $cmd->execCmd();
$replace['#' . $cmd->getLogicalId() . '_collect#'] = $cmd->getCollectDate();
if ($cmd->getIsHistorized() == 1) {
$replace['#' . $cmd->getLogicalId() . '_history#'] = 'history cursor';
}
}
foreach ($this->getCmd('action') as $cmd) {
$replace['#' . $cmd->getLogicalId() . '_id#'] = $cmd->getId();
}
return $this->postToHtml($_version, template_replace($replace, getTemplate('core', $version, 'karotz', 'karotz')));
}