Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy eqLogic backGraph::info #2727

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading