Skip to content

Commit

Permalink
Merge pull request #2727 from Mips2648/clone-eqlogic
Browse files Browse the repository at this point in the history
copy eqLogic backGraph::info
  • Loading branch information
zoic21 authored Jul 3, 2024
2 parents 43adfe3 + 1aabbf8 commit d89aae2
Showing 1 changed file with 29 additions and 23 deletions.
52 changes: 29 additions & 23 deletions core/class/eqLogic.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public static function byCategorie($_category) {
return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__));
}

public static function byTypeAndSearchConfiguration($_eqType_name, $_configuration, $_onlyEnable=false, $_onlyVisible=false) {
public static function byTypeAndSearchConfiguration($_eqType_name, $_configuration, $_onlyEnable = false, $_onlyVisible = false) {
if (is_array($_configuration)) {
$values = array(
'eqType_name' => $_eqType_name,
Expand All @@ -238,9 +238,9 @@ public static function byTypeAndSearchConfiguration($_eqType_name, $_configurati
if ($_onlyEnable) {
$sql .= ' AND isEnable=1';
}
if ($_onlyVisible) {
if ($_onlyVisible) {
$sql .= ' AND isVisible=1';
}
}
$sql .= ' AND JSON_CONTAINS(configuration,:configuration)
ORDER BY name';
if ($_eqType_name != null && class_exists($_eqType_name)) {
Expand All @@ -255,13 +255,13 @@ public static function byTypeAndSearchConfiguration($_eqType_name, $_configurati
$sql = 'SELECT ' . DB::buildField(__CLASS__) . '
FROM eqLogic
WHERE eqType_name=:eqType_name';
if ($_onlyEnable) {
$sql .= ' AND isEnable=1';
if ($_onlyEnable) {
$sql .= ' AND isEnable=1';
}
if ($_onlyVisible) {
$sql .= ' AND isVisible=1';
}
$sql .= '
if ($_onlyVisible) {
$sql .= ' AND isVisible=1';
}
$sql .= '
AND configuration LIKE :configuration
ORDER BY name';
if ($_eqType_name != null && class_exists($_eqType_name)) {
Expand All @@ -270,7 +270,7 @@ public static function byTypeAndSearchConfiguration($_eqType_name, $_configurati
return self::cast(DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL, PDO::FETCH_CLASS, __CLASS__));
}

public static function byTypeAndSearhConfiguration($_eqType_name, $_configuration, $_onlyEnable=false, $_onlyVisible=false) {
public static function byTypeAndSearhConfiguration($_eqType_name, $_configuration, $_onlyEnable = false, $_onlyVisible = false) {
trigger_error('eqLogic::byTypeAndSearhConfiguration() is deprecated since Core v4.4, eqLogic::byTypeAndSearchConfiguration() has been introduced since Core v4.1', E_USER_DEPRECATED);
return self::byTypeAndSearchConfiguration($_eqType_name, $_configuration, $_onlyEnable, $_onlyVisible);
}
Expand Down Expand Up @@ -494,7 +494,7 @@ public static function toHumanReadable($_input) {
}

public static function fromHumanReadable($_input) {
if(empty($_input)){
if (empty($_input)) {
return $_input;
}
$isJson = false;
Expand Down Expand Up @@ -528,7 +528,7 @@ public static function fromHumanReadable($_input) {
return $_input;
}
$text = $_input;
preg_match_all( "/#\[(.*?)\]\[(.*?)\]#/", $text, $matches);
preg_match_all("/#\[(.*?)\]\[(.*?)\]#/", $text, $matches);
if (count($matches) == 3) {
$countMatches = count($matches[0]);
for ($i = 0; $i < $countMatches; $i++) {
Expand Down Expand Up @@ -577,19 +577,19 @@ public static function generateHtmlTable($_nbLine, $_nbColumn, $_options = array
$styletd = (isset($_options['style::td::' . $i . '::' . $j]) && $_options['style::td::' . $i . '::' . $j] != '') ? $_options['style::td::' . $i . '::' . $j] : '';
$attrs = '';
$style = '';
if(trim($styletd) != ''){
foreach (explode(';',$styletd) as $value) {
if($value == '') continue;
if(strpos($value, '=') !== false){
if (trim($styletd) != '') {
foreach (explode(';', $styletd) as $value) {
if ($value == '') continue;
if (strpos($value, '=') !== false) {
$attrs .= $value;
}else{
$style .= $value.';';
} else {
$style .= $value . ';';
}
}
}
$style = $_options['styletd'] . $style;
$classTd = ($style != '') ? 'tableCmdcss' : '';
$return['html'] .= '<td class="' . $classTd . (($_options['center'] == 1) ? ' tableCenter' : '') . '" style="' . $style . '" '.$attrs.' data-line="' . $i . '" data-column="' . $j . '">';
$return['html'] .= '<td class="' . $classTd . (($_options['center'] == 1) ? ' tableCenter' : '') . '" style="' . $style . '" ' . $attrs . ' data-line="' . $i . '" data-column="' . $j . '">';
if (isset($_options['text::td::' . $i . '::' . $j])) {
$return['html'] .= $_options['text::td::' . $i . '::' . $j];
}
Expand Down Expand Up @@ -642,8 +642,8 @@ public function batteryWidget($_version = 'dashboard') {
if ($_version == 'mobile') {
$html .= '<div class="widget-name"><span class="name">' . $eqName . '</span><span class="object">' . $object_name . '</span></div>';
} else {
$html .= '<div class="#battery widget-name"><a href="' . $this->getLinkToConfiguration() . '">' . $eqName . '</a><br><span>' . $object_name . '</span></div>';
}
$html .= '<div class="#battery widget-name"><a href="' . $this->getLinkToConfiguration() . '">' . $eqName . '</a><br><span>' . $object_name . '</span></div>';
}
$html .= '<div class="jeedom-batterie">';
$html .= '<i class="icon jeedom-batterie' . $niveau . '"></i>';
$html .= '<span>' . $this->getStatus('battery', -2) . '%</span>';
Expand Down Expand Up @@ -707,7 +707,7 @@ public function checkAndUpdateCmd($_logicalId, $_value, $_updateTime = null) {
public function copy($_name, $_logicalId = null) {
$eqLogicCopy = clone $this;
$eqLogicCopy->setName($_name);
if($_logicalId){
if ($_logicalId) {
$eqLogicCopy->setLogicalId($_logicalId);
}
$eqLogicCopy->setId('');
Expand All @@ -732,6 +732,13 @@ public function copy($_name, $_logicalId = null) {
$cmd_link[$cmd->getId()]->save();
}
}

$backGraphCmd = $this->getDisplay('backGraph::info', 0);
if ($backGraphCmd != 0 && isset($cmd_link[$backGraphCmd])) {
$eqLogicCopy->setDisplay('backGraph::info', $cmd_link[$backGraphCmd]->getId());
$eqLogicCopy->save(true);
}

return $eqLogicCopy;
}

Expand Down Expand Up @@ -933,7 +940,6 @@ public function postToHtml($_version, $_html) {
}

public function emptyCacheWidget() {

}

public function getAlert() {
Expand Down

0 comments on commit d89aae2

Please sign in to comment.