diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 3920033fc9..eb6b0f1f6e 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2009-07-27 Miguel de Dios + + * include/functions_visual_map.php: changes for support maps as widget in + dashboard of Pandora Enterprise. + * include/Image/image_functions.php: script content functions and code + for manage image thumbnails and resize images. + 2009-07-24 Miguel de Dios * index.php: fix mistake, add lost lines between my "dirty installation" and diff --git a/pandora_console/include/Image/image_functions.php b/pandora_console/include/Image/image_functions.php new file mode 100644 index 0000000000..23709315eb --- /dev/null +++ b/pandora_console/include/Image/image_functions.php @@ -0,0 +1,78 @@ + diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index 8ec259b10e..6b4a517e32 100644 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -22,11 +22,34 @@ * @param bool $show_links * @param bool $draw_lines */ -function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines = true) { +function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines = true, $width = null, $height = null) { global $config; $layout = get_db_row ('tlayout', 'id', $id_layout); - echo '
'; + $resizedMap = false; + $proportion = 1; + if (!is_null($width)) { + $resizedMap = true; + if (!is_null($height)) { + $mapWidth = $width; + $mapHeight = $height; + } + else { + $mapWidth = $width; + $proportion = $width / $layout["width"]; + $mapHeight = $proportion * $layout["height"]; + } + $backgroundImage = 'include/Image/image_functions.php?getFile=1&thumb=1&thumb_size=' . $mapWidth . 'x' . $mapHeight . '&file=' . + $config['homeurl'] . '/' . 'images/console/background/'.safe_input ($layout["background"]); + } + else { + $mapWidth = $layout["width"]; + $mapHeight = $layout["height"]; + $backgroundImage = 'images/console/background/'.safe_input ($layout["background"]); + } + + echo '
'; $layout_datas = get_db_all_rows_field_filter ('tlayout_data', 'id_layout', $id_layout); $lines = array (); @@ -71,8 +94,11 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines = else $z_index = 1; // Print BAD over good - // Draw image - echo '
'; + // Draw image + if ($resizedMap) + echo '
'; + else + echo '
'; if (!isset ($id_agent)) $id_agent = 0; @@ -120,6 +146,27 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines = // Default is Grey (Other) } + if (is_file($img)) + $infoImage = getimagesize($img); + + if (!empty ($layout_data["width"])) { + if ($resizedMap) + $img_style["width"] = (integer)($proportion * $layout_data["width"]); + else + $img_style["width"] = $layout_data["width"]; + } + else + $img_style["width"] = (integer)($proportion * $infoImage[0]); + + if (!empty ($layout_data["height"])) { + if ($resizedMap) + $img_style["height"] = (integer)($proportion * $img_style["height"]); + else + $img_style["height"] = $layout_data["height"]; + } + else + $img_style["height"] = (integer)($proportion * $infoImage[1]); + print_image ($img, false, $img_style); echo ""; @@ -135,40 +182,60 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines = // SIMPLE DATA VALUE (type = 2) switch ($layout_data['type']) { case 2: - echo '
'; + if ($resizedMap) + echo '
'; + else + echo '
'; echo ''.$layout_data['label']. ' '; echo get_db_value ('datos', 'tagente_estado', 'id_agente_modulo', $layout_data['id_agente_modulo']); echo '
'; break; case 3: - // Percentile bar (type = 3) - echo '
'; - $valor = get_db_sql ('SELECT datos FROM tagente_estado WHERE id_agente_modulo = '.$layout_data['id_agente_modulo']); - $width = $layout_data['width']; - if ( $layout_data['height'] > 0) - $percentile = $valor / $layout_data['height'] * 100; - else - $percentile = 100; - echo $layout_data['label']; - echo "
"; + + // Percentile bar (type = 3) + if ($resizedMap) + echo '
'; + else + echo '
'; + $valor = get_db_sql ('SELECT datos FROM tagente_estado WHERE id_agente_modulo = '.$layout_data['id_agente_modulo']); + $width = $layout_data['width']; + if ( $layout_data['height'] > 0) + $percentile = $valor / $layout_data['height'] * 100; + else + $percentile = 100; + + echo $layout_data['label']; + echo "
"; - echo ""; - - echo '
'; + if ($resizedMap) + echo ""; + else + echo ""; + + echo '
'; + //} break; case 1; - // SINGLE GRAPH (type = 1) - echo '
'; - if ($show_links) { - if (($layout_data['id_layout_linked'] == "") || ($layout_data['id_layout_linked'] == 0)) { - echo ''; - } else { - echo ''; + // SINGLE GRAPH (type = 1) + if ($resizedMap) + echo '
'; + else + echo '"; + if ($resizedMap) + print_image ("include/fgraph.php?tipo=sparse&id=".$layout_data['id_agente_modulo']."&label=".safe_input ($layout_data['label'])."&height=".((integer)($proportion * $layout_data['height']))."&width=".((integer)($proportion * $layout_data['width']))."&period=".$layout_data['period'], false, array ("title" => $layout_data['label'], "border" => 0)); + else + print_image ("include/fgraph.php?tipo=sparse&id=".$layout_data['id_agente_modulo']."&label=".safe_input ($layout_data['label'])."&height=".$layout_data['height']."&width=".$layout_data['width']."&period=".$layout_data['period'], false, array ("title" => $layout_data['label'], "border" => 0)); + echo ""; + echo "
"; + break; } // Line, not implemented in editor /*