Fixed image handle in data view

This commit is contained in:
fbsanchez 2018-02-08 14:17:08 +01:00
parent 4aab64be3d
commit 571ed36276
2 changed files with 14 additions and 27 deletions

View File

@ -283,6 +283,14 @@ if ($get_module_detail) {
if ($attr[1] != "modules_format_data") { if ($attr[1] != "modules_format_data") {
$data[] = date('d F Y h:i:s A', $row['utimestamp']); $data[] = date('d F Y h:i:s A', $row['utimestamp']);
} }
elseif(is_snapshot_data($row[$attr[0]])){
if($config['command_snapshot']){
$data[] = "<a target='_blank' href='".io_safe_input($row[$attr[0]])."'><img style='width:300px' src='".io_safe_input($row[$attr[0]])."'></a>";
}
else{
$data[] = "<span>".wordwrap(io_safe_input($row[$attr[0]]),60,"<br>\n",true)."</span>";
}
}
elseif (($config['command_snapshot'] == '0') && (preg_match ("/[\n]+/i", $row[$attr[0]]))) { elseif (($config['command_snapshot'] == '0') && (preg_match ("/[\n]+/i", $row[$attr[0]]))) {
// Its a single-data, multiline data (data snapshot) ? // Its a single-data, multiline data (data snapshot) ?
@ -342,21 +350,11 @@ if ($get_module_detail) {
$data[] = 'No data'; $data[] = 'No data';
} }
else { else {
if(is_snapshot_data($row[$attr[0]])){ $data_macro = modules_get_unit_macro($row[$attr[0]],$unit);
if($config['command_snapshot']){ if($data_macro){
$data[] = "<a target='_blank' href='".io_safe_input($row[$attr[0]])."'><img style='width:300px' src='".io_safe_input($row[$attr[0]])."'></a>"; $data[] = $data_macro;
} } else {
else{ $data[] = $row[$attr[0]];
$data[] = "<span>".wordwrap(io_safe_input($row[$attr[0]]),60,"<br>\n",true)."</span>";
}
}
else{
$data_macro = modules_get_unit_macro($row[$attr[0]],$unit);
if($data_macro){
$data[] = $data_macro;
} else {
$data[] = $row[$attr[0]];
}
} }
} }
} }

View File

@ -2143,18 +2143,7 @@ function is_image_data ($data) {
* Looks for two or more carriage returns. * Looks for two or more carriage returns.
*/ */
function is_snapshot_data ($data) { function is_snapshot_data ($data) {
return is_image_data($data);
// TODO IDEA: In the future, we can set a variable in setup
// to define how many \n must have a snapshot to define it's
// a snapshot. I think two or three is a good value anyway.
$temp = array();
$count = preg_match_all ("/\n/", $data, $temp);
if ( ($count > 2) || (is_image_data($data)) )
return 1;
else
return 0;
} }
/** /**