2011-02-28 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* 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 "<img=.." html tag to print_image function. * include/ajax/skins.ajax.php: Added to repository. New php callback for skins support inside javascript code. * ajax.php: Load of relative_path variable in ajax user session. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4028 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
98645e4f69
commit
f9e506892b
|
@ -1,3 +1,20 @@
|
|||
2011-02-28 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
|
||||
|
||||
* 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 "<img=.." html tag to print_image function.
|
||||
* include/ajax/skins.ajax.php: Added to repository. New php callback for
|
||||
skins support inside javascript code.
|
||||
* ajax.php: Load of relative_path variable in ajax user session.
|
||||
|
||||
2011-02-28 Miguel de Dios <miguel.dedios@artica.es>
|
||||
* include/functions_db.php: cleaned source code, and erased the deprecated
|
||||
function "dame_id_grupo".
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 = $('<tr></tr>');
|
||||
img = $("<img></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 = $("<img></img>").attr ("src", data).addClass ("clickable");
|
||||
}
|
||||
});
|
||||
a = $("<a></a>").append (img)
|
||||
.attr ("id", "add-"+this["id"])
|
||||
.attr ("href", "#condition")
|
||||
|
|
|
@ -127,7 +127,21 @@ function icon_changed () {
|
|||
$('#icon_preview').fadeOut ('normal', function () {
|
||||
$('#icon_preview').empty ();
|
||||
if (data != "") {
|
||||
$('#icon_preview').append ($('<img />').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 ($('<img />').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 ($('<img />').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 ($('<img />').attr ('src', result));
|
||||
}
|
||||
});
|
||||
}
|
||||
$('#parent_preview').fadeIn ();
|
||||
});
|
||||
|
|
|
@ -479,7 +479,20 @@ function chooseSQLquery() {
|
|||
$("#sql_example").html('');
|
||||
}
|
||||
else {
|
||||
$("#sql_example").html('<img src="images/spinner.gif" />');
|
||||
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");
|
||||
|
|
|
@ -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 = $('<div id="' + id_data + '" class="item static_graph" style="left: 0px; top: 0px; color: ' + values['label_color'] + '; text-align: center; position: absolute; ' + sizeStyle + ' margin-top: ' + values['top'] + 'px; margin-left: ' + values['left'] + 'px;">' +
|
||||
'<img id="image_' + id_data + '" class="image" src="' + getImageElement(id_data) + '" ' + imageSize + ' /><br />' +
|
||||
'<img id="image_' + id_data + '" class="image" src="' + img_src + '" ' + imageSize + ' /><br />' +
|
||||
'<span id="text_' + id_data + '" class="text">' + values['label'] + '</span>' +
|
||||
'</div><input id="hidden-status_' + id_data + '" type="hidden" value="' + element_status + '" name="status_' + id_data + '">'
|
||||
);
|
||||
|
@ -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 = $('<div id="' + id_data + '" class="item icon" style="left: 0px; top: 0px; color: ' + values['label_color'] + '; text-align: center; position: absolute; ' + sizeStyle + ' margin-top: ' + values['top'] + 'px; margin-left: ' + values['left'] + 'px;">' +
|
||||
'<img id="image_' + id_data + '" class="image" src="' + getImageElement(id_data) + '" ' + imageSize + ' /><br />' +
|
||||
'<img id="image_' + id_data + '" class="image" src="' + img_src + '" ' + imageSize + ' /><br />' +
|
||||
'</div>'
|
||||
);
|
||||
break;
|
||||
|
@ -1225,10 +1309,26 @@ function showPreviewStaticGraph(staticGraph) {
|
|||
|
||||
if (staticGraph != '') {
|
||||
imgBase = "images/console/icons/" + staticGraph;
|
||||
$("#preview").append("<img src='" + imgBase + "_bad.png' />");
|
||||
$("#preview").append("<img src='" + imgBase + "_ok.png' />");
|
||||
$("#preview").append("<img src='" + imgBase + "_warning.png' />");
|
||||
$("#preview").append("<img src='" + imgBase + ".png' />");
|
||||
|
||||
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("<img src='" + imgBase + ".png' />");
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -74,6 +74,20 @@ function get_list_os_icons_dir() {
|
|||
<script type="text/javascript">
|
||||
|
||||
function show_icon_OS() {
|
||||
$("#icon_image").html('<img src="images/os_icons/' + $("#icon").val() + '" />');
|
||||
|
||||
var params = [];
|
||||
params.push("get_image_path=1");
|
||||
params.push('img_src=images/os_icons/' + $("#icon").val());
|
||||
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) {
|
||||
$("#icon_image").html(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Login check
|
||||
global $config;
|
||||
|
||||
check_login ();
|
||||
|
||||
if (! give_acl ($config['id_user'], 0, "IR")) {
|
||||
pandora_audit("ACL Violation",
|
||||
"Trying to access report builder");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$get_image_path = get_parameter('get_image_path', 0);
|
||||
|
||||
/* skins image checks */
|
||||
if ($get_image_path){
|
||||
$img_src = get_parameter("img_src");
|
||||
$only_src = get_parameter("only_src", 0);
|
||||
|
||||
return print_image($img_src, false, '', $only_src);
|
||||
}
|
||||
|
||||
?>
|
|
@ -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);
|
||||
}
|
||||
|
||||
?>
|
|
@ -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,
|
||||
'<div class="cloudContent' + featureData.id + '" style="text-align: center;"><img src="images/spinner.gif" /></div>',
|
||||
'<div class="cloudContent' + featureData.id + '" style="text-align: center;">' + img_src + '</div>',
|
||||
null,
|
||||
true,
|
||||
function () { popup.destroy(); });
|
||||
|
|
|
@ -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 ('<img src="..." alt="...">').
|
||||
*
|
||||
* @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 = '<img src="'.safe_input ($src).'" '; //safe input necessary to strip out html entities correctly
|
||||
$style = '';
|
||||
|
||||
|
|
Loading…
Reference in New Issue