From f9e506892bde3cc933acdd9172d1423306d9580d Mon Sep 17 00:00:00 2001 From: juanmanuelr Date: Mon, 28 Feb 2011 16:53:09 +0000 Subject: [PATCH] 2011-02-28 Juan Manuel Ramon * include/functions_html.php: new parameter in function print_image in order to return only src field of image. * include/ajax/visual_console_builder.ajax.php include/functions_gis.php godmode/groups/configure_group.php godmode/alerts/configure_alert_compound.php godmode/setup/os.builder.php godmode/reporting/visual_console_builder.editor.js godmode/reporting/visual_console_builder.editor.php godmode/reporting/reporting_builder.item_editor.php: Changed the way of create images from " + + * include/functions_html.php: new parameter in function print_image in + order to return only src field of image. + * include/ajax/visual_console_builder.ajax.php + include/functions_gis.php + godmode/groups/configure_group.php + godmode/alerts/configure_alert_compound.php + godmode/setup/os.builder.php + godmode/reporting/visual_console_builder.editor.js + godmode/reporting/visual_console_builder.editor.php + godmode/reporting/reporting_builder.item_editor.php: Changed the way of create + images from " * include/functions_db.php: cleaned source code, and erased the deprecated function "dame_id_grupo". diff --git a/pandora_console/ajax.php b/pandora_console/ajax.php index c14d0605ee..db5e51b8a7 100644 --- a/pandora_console/ajax.php +++ b/pandora_console/ajax.php @@ -37,6 +37,9 @@ $page = (string) get_parameter ('page'); $page = safe_url_extraclean ($page); $page .= '.php'; $config["id_user"] = $_SESSION["id_usuario"]; +$isFunctionSkins = enterprise_include_once ('include/functions_skins.php'); +if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) + $config["relative_path"] = enterprise_hook('set_image_skin_path',array($config['id_user'])); session_write_close (); if (file_exists ($page)) { require_once ($page); diff --git a/pandora_console/godmode/alerts/configure_alert_compound.php b/pandora_console/godmode/alerts/configure_alert_compound.php index 234876f457..d1e11b5016 100644 --- a/pandora_console/godmode/alerts/configure_alert_compound.php +++ b/pandora_console/godmode/alerts/configure_alert_compound.php @@ -666,7 +666,21 @@ function add_alert () { .clone () .append (td); - $("img", tr).attr ("src", "images/delete.png"); + var params = []; + params.push("get_image_path=1"); + params.push("img_src=images/delete.png"); + params.push("page=include/ajax/skins.ajax"); + params.push("only_src=1"); + jQuery.ajax ({ + data: params.join ("&"), + type: 'POST', + url: action="ajax.php", + async: false, + timeout: 10000, + success: function (data) { + $("img", tr).attr ("src", data); + } + }); $("a", tr).attr("id", "remove-"+id) .click (remove_alert); @@ -740,8 +754,22 @@ $(document).ready (function () { alerts = Array (); jQuery.each (data, function () { tr = $(''); - img = $("").attr ("src", "images/add.png") - .addClass ("clickable"); + + var params = []; + params.push("get_image_path=1"); + params.push("img_src=images/add.png"); + params.push("page=include/ajax/skins.ajax"); + params.push("only_src=1"); + jQuery.ajax ({ + data: params.join ("&"), + type: 'POST', + url: action="ajax.php", + async: false, + timeout: 10000, + success: function (data) { + img = $("").attr ("src", data).addClass ("clickable"); + } + }); a = $("").append (img) .attr ("id", "add-"+this["id"]) .attr ("href", "#condition") diff --git a/pandora_console/godmode/groups/configure_group.php b/pandora_console/godmode/groups/configure_group.php index 4f9a694f5c..32a91b7973 100644 --- a/pandora_console/godmode/groups/configure_group.php +++ b/pandora_console/godmode/groups/configure_group.php @@ -127,7 +127,21 @@ function icon_changed () { $('#icon_preview').fadeOut ('normal', function () { $('#icon_preview').empty (); if (data != "") { - $('#icon_preview').append ($('').attr ('src', 'images/groups_small/'+data)); + var params = []; + params.push("get_image_path=1"); + params.push("img_src=images/groups_small/" + data); + params.push("page=include/ajax/skins.ajax"); + params.push("only_src=1"); + jQuery.ajax ({ + data: params.join ("&"), + type: 'POST', + url: action="ajax.php", + async: false, + timeout: 10000, + success: function (result) { + $('#icon_preview').append ($('').attr ('src', result)); + } + }); } $('#icon_preview').fadeIn (); }); @@ -149,7 +163,21 @@ function parent_changed () { $('#parent_preview').fadeOut ('normal', function () { $('#parent_preview').empty (); if (data_ != null) { - $('#parent_preview').append ($('').attr ('src', 'images/groups_small/'+data['icon']+'.png')); + var params = []; + params.push("get_image_path=1"); + params.push("img_src=images/groups_small/" + data['icon'] + ".png"); + params.push("page=include/ajax/skins.ajax"); + params.push("only_src=1"); + jQuery.ajax ({ + data: params.join ("&"), + type: 'POST', + url: action="ajax.php", + async: false, + timeout: 10000, + success: function (result) { + $('#parent_preview').append ($('').attr ('src', result)); + } + }); } $('#parent_preview').fadeIn (); }); diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 8c948f0864..bbb59b6c1c 100644 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -479,7 +479,20 @@ function chooseSQLquery() { $("#sql_example").html(''); } else { - $("#sql_example").html(''); + var params1 = []; + params1.push("get_image_path=1"); + params1.push("img_src=" + "images/spinner.gif"); + params1.push("page=include/ajax/skins.ajax"); + jQuery.ajax ({ + data: params1.join ("&"), + type: 'POST', + url: action="ajax.php", + async: false, + timeout: 10000, + success: function (data) { + $("#sql_example").html(data); + } + }); var params = []; params.push("get_custom_sql=1"); diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js index a35e621a19..60d417595d 100644 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.js +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -126,7 +126,23 @@ function updateAction() { $("#background").css('height', values['height']); //$("#background").css('background', 'url(images/console/background/' + values['background'] + ')'); - $("#background_img").attr('src', 'images/console/background/' + values['background']); + + var params = []; + params.push("get_image_path=1"); + params.push("img_src=images/console/background/" + values['background']); + params.push("page=include/ajax/skins.ajax"); + params.push("only_src=1"); + jQuery.ajax ({ + data: params.join ("&"), + type: 'POST', + url: action="ajax.php", + async: false, + timeout: 10000, + success: function (data) { + $("#background_img").attr('src', data); + } + }); + var idElement = 0; break; case 'static_graph': @@ -158,7 +174,22 @@ function updateAction() { // Default is Grey (Other) } - $("#image_" + idItem).attr('src', 'images/console/icons/' + values['image'] + suffix); + var params = []; + params.push("get_image_path=1"); + params.push("img_src=images/console/icons/" + values['image'] + suffix); + params.push("page=include/ajax/skins.ajax"); + params.push("only_src=1"); + jQuery.ajax ({ + data: params.join ("&"), + type: 'POST', + url: action="ajax.php", + async: false, + timeout: 10000, + success: function (data) { + $("#image_" + idItem).attr('src', data); + } + }); + if ((values['width'] != 0) && (values['height'] != 0)) { $("#image_" + idItem).attr('width', values['width']); $("#image_" + idItem).attr('height', values['height']); @@ -189,7 +220,23 @@ function updateAction() { $("#text_" + idItem).html(values['label']); break; case 'icon': - $("#image_" + idItem).attr('src', getImageElement(idItem)); + + var params = []; + params.push("get_image_path=1"); + params.push("img_src=" + getImageElement(idItem)); + params.push("page=include/ajax/skins.ajax"); + params.push("only_src=1"); + jQuery.ajax ({ + data: params.join ("&"), + type: 'POST', + url: action="ajax.php", + async: false, + timeout: 10000, + success: function (data) { + $("#image_" + idItem).attr('src', data); + } + }); + if ((values['width'] != 0) && (values['height'] != 0)) { $("#image_" + idItem).attr('width', values['width']); $("#image_" + idItem).attr('height', values['height']); @@ -672,7 +719,7 @@ function createItem(type, values, id_data) { var sizeStyle = 'width: ' + values['width'] + 'px; height: ' + values['height'] + 'px;'; var imageSize = 'width="' + values['width'] + '" height="' + values['height'] + '"'; } - + var element_status= null; var parameter = Array(); parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"}); @@ -689,9 +736,27 @@ function createItem(type, values, id_data) { element_status = data; } }); + + var img_src= null; + var parameter = Array(); + parameter.push ({name: "page", value: "include/ajax/skins.ajax"}); + parameter.push ({name: "get_image_path", value: "1"}); + parameter.push ({name: "img_src", value: getImageElement(id_data)}); + parameter.push ({name: "only_src", value: "1"}); + jQuery.ajax ({ + type: 'POST', + url: action="ajax.php", + data: parameter, + async: false, + timeout: 10000, + success: function (data) { + img_src = data; + } + }); + var item = $('
' + - '
' + + '
' + '' + values['label'] + '' + '
' ); @@ -741,8 +806,27 @@ function createItem(type, values, id_data) { var sizeStyle = 'width: ' + values['width'] + 'px; height: ' + values['height'] + 'px;'; var imageSize = 'width="' + values['width'] + '" height="' + values['height'] + '"'; } + + var img_src= null; + var parameter = Array(); + parameter.push ({name: "page", value: "include/ajax/skins.ajax"}); + parameter.push ({name: "get_image_path", value: "1"}); + parameter.push ({name: "img_src", value: getImageElement(id_data)}); + parameter.push ({name: "only_src", value: "1"}); + + jQuery.ajax ({ + type: 'POST', + url: action="ajax.php", + data: parameter, + async: false, + timeout: 10000, + success: function (data) { + img_src = data; + } + }); + var item = $('
' + - '
' + + '
' + '
' ); break; @@ -1225,10 +1309,26 @@ function showPreviewStaticGraph(staticGraph) { if (staticGraph != '') { imgBase = "images/console/icons/" + staticGraph; - $("#preview").append(""); - $("#preview").append(""); - $("#preview").append(""); - $("#preview").append(""); + + var img_src= null; + var parameter = Array(); + parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"}); + parameter.push ({name: "get_image_path_status", value: "1"}); + parameter.push ({name: "img_src", value: imgBase }); + + jQuery.ajax ({ + type: 'POST', + url: action="ajax.php", + data: parameter, + async: false, + dataType: 'json', + timeout: 10000, + success: function (data) { + jQuery.each(data, function(i, line) { + $("#preview").append(line); + }); + } + }); } } @@ -1238,6 +1338,20 @@ function showPreviewIcon(icon) { if (icon != '') { imgBase = "images/console/icons/" + icon; - $("#preview").append(""); + + var params = []; + params.push("get_image_path=1"); + params.push("img_src=" + imgBase + ".png"); + params.push("page=include/ajax/skins.ajax"); + jQuery.ajax ({ + data: params.join ("&"), + type: 'POST', + url: action="ajax.php", + async: false, + timeout: 10000, + success: function (data) { + $("#preview").append(data); + } + }); } } diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.php b/pandora_console/godmode/reporting/visual_console_builder.editor.php index 985463e988..a38633c9bd 100644 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.php +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.php @@ -32,7 +32,11 @@ if (is_ajax ()) { if ($get_original_size_background) { $background = get_parameter('background', ''); - $size = getimagesize($background); + $replace = strlen($config["homeurl"] . '/'); + if (substr($background, 0, $replace) == $config["homeurl"] . '/') + $size = getimagesize(substr($background, $replace)); + else + $size = getimagesize($background); echo json_encode($size); return; } diff --git a/pandora_console/godmode/setup/os.builder.php b/pandora_console/godmode/setup/os.builder.php index 90909fb4e1..c289581de1 100644 --- a/pandora_console/godmode/setup/os.builder.php +++ b/pandora_console/godmode/setup/os.builder.php @@ -74,6 +74,20 @@ function get_list_os_icons_dir() { \ No newline at end of file diff --git a/pandora_console/include/ajax/skins.ajax.php b/pandora_console/include/ajax/skins.ajax.php new file mode 100644 index 0000000000..f74abbf130 --- /dev/null +++ b/pandora_console/include/ajax/skins.ajax.php @@ -0,0 +1,37 @@ + diff --git a/pandora_console/include/ajax/visual_console_builder.ajax.php b/pandora_console/include/ajax/visual_console_builder.ajax.php index 51c61d7b26..3d46a6216d 100644 --- a/pandora_console/include/ajax/visual_console_builder.ajax.php +++ b/pandora_console/include/ajax/visual_console_builder.ajax.php @@ -53,6 +53,7 @@ $height_module_graph = get_parameter('height_module_graph', null); $width_module_graph = get_parameter('width_module_graph', null); $get_element_status = get_parameter('get_element_status', 0); +$get_image_path_status = get_parameter('get_image_path_status', 0); switch ($action) { case 'get_layout_data': @@ -297,4 +298,19 @@ if ($get_element_status){ return; } +if ($get_image_path_status){ + $img_src = get_parameter("img_src"); + $only_src = get_parameter("only_src", 0); + + $result = array(); + + $result['bad'] = print_image($img_src . '_bad.png', true, '', $only_src); + $result['ok'] = print_image($img_src . '_ok.png', true, '', $only_src); + $result['warning'] = print_image($img_src . '_warning.png', true, '', $only_src); + $result['ok'] = print_image($img_src . '_ok.png', true, '', $only_src); + $result['normal'] = print_image($img_src . '.png', true, '', $only_src); + + echo json_encode($result); +} + ?> \ No newline at end of file diff --git a/pandora_console/include/functions_gis.php b/pandora_console/include/functions_gis.php index d42c564f82..a99b98356a 100644 --- a/pandora_console/include/functions_gis.php +++ b/pandora_console/include/functions_gis.php @@ -165,10 +165,27 @@ function makeLayer($name, $visible = true, $dot = null, $idLayer = null) { var long_lat = featureData.long_lat; var popup; + var img_src= null; + var parameter = Array(); + parameter.push ({name: "page", value: "include/ajax/skins.ajax"}); + parameter.push ({name: "get_image_path", value: "1"}); + parameter.push ({name: "img_src", value: "images/spinner.gif"}); + + jQuery.ajax ({ + type: 'POST', + url: action="ajax.php", + data: parameter, + async: false, + timeout: 10000, + success: function (data) { + img_src = data; + } + }); + popup = new OpenLayers.Popup.FramedCloud('cloud00', long_lat, null, - '
', + '
' + img_src + '
', null, true, function () { popup.destroy(); }); diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index a00f1a8cc5..bb24401b15 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -1094,10 +1094,11 @@ function print_checkbox ($name, $value, $checked = false, $return = false, $disa * @param bool $return Whether to return or print * @param array $options Array with optional HTML options to set. At this moment, the * following options are supported: alt, style, title, width, height, class, pos_tree. + * @param bool $return_src Whether to return src field of image ('images/*.*') or complete html img tag ('...'). * * @return string HTML code if return parameter is true. */ -function print_image ($src, $return = false, $options = false) { +function print_image ($src, $return = false, $options = false, $return_src = false) { global $config; /* Checks if user's skin is available */ @@ -1112,6 +1113,15 @@ function print_image ($src, $return = false, $options = false) { // path to image $src = $config["homeurl"] . '/' . $src; + // Only return src field of image + if ($return_src){ + if (!$return){ + echo safe_input($src); + return; + } + return safe_input($src); + } + $output = '