From 23af6b04ffdd8aceabb1a1716aac18f3ab89c57a Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 16 Feb 2010 15:28:07 +0000 Subject: [PATCH] 2010-02-15 Miguel de Dios * include/functions_gis.php: add the function "getMapConnection" get the row of connection for id connection, "updateMap" function update the all data in the DB, "validateMapData" function validate the map data previous update or save in the database and if it's invalid, write the css code for set colors and other styles, "getMapData" return all data about map for id map, "addConectionMapsInForm" tranlate the map connection array to html code and javascript for to write in the form when edit, "addLayerList" translate the layer array to html code and javascript for write in the form when edit. * operation/gis_maps/render_view.php: fix the link to edit map. * godmode/gis_maps/configure_gis_map.php: change many parts of the source code for add the method the edit in the form and add more usability to form. * godmode/gis_maps/index.php: fix the links to edit and view map. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2370 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 20 + .../godmode/gis_maps/configure_gis_map.php | 368 ++++++++++++++---- pandora_console/godmode/gis_maps/index.php | 2 +- pandora_console/include/functions_gis.php | 262 +++++++++++++ .../operation/gis_maps/render_view.php | 2 +- 5 files changed, 568 insertions(+), 86 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 26d5f4df2d..f3c5d3dae1 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,22 @@ +2010-02-15 Miguel de Dios + + * include/functions_gis.php: add the function "getMapConnection" get the row + of connection for id connection, "updateMap" function update the all data in + the DB, "validateMapData" function validate the map data previous update or + save in the database and if it's invalid, write the css code for set colors + and other styles, "getMapData" return all data about map for id map, + "addConectionMapsInForm" tranlate the map connection array to html code and + javascript for to write in the form when edit, "addLayerList" translate the + layer array to html code and javascript for write in the form when edit. + + * operation/gis_maps/render_view.php: fix the link to edit map. + + * godmode/gis_maps/configure_gis_map.php: change many parts of the source + code for add the method the edit in the form and add more usability + to form. + + * godmode/gis_maps/index.php: fix the links to edit and view map. + 2010-02-15 Pablo de la ConcepciĆ³n * extras/pandoradb_migrate_v3.0_to_v3.1.sql: Added cusstom colums ( @@ -6,6 +25,7 @@ parameters that were missing. Reordering a bit. And fixed a missplaced ';' 2010-02-15 Eric Ross + First batch of changes to implement the new log4x data type. Modified files to show the new data type: diff --git a/pandora_console/godmode/gis_maps/configure_gis_map.php b/pandora_console/godmode/gis_maps/configure_gis_map.php index 283e93f161..8ddd2fbadb 100644 --- a/pandora_console/godmode/gis_maps/configure_gis_map.php +++ b/pandora_console/godmode/gis_maps/configure_gis_map.php @@ -20,12 +20,66 @@ check_login (); require_once ('include/functions_gis.php'); require_javascript_file('openlayers.pandora'); +//Global vars for javascript and scripts. +?> + + $value) { + $cleanValue = trim($value); + if ($cleanValue == '') { + unset($map_connection_list_temp[$index]); + } + } $layer_list = explode(",",get_parameter('layer_list')); + foreach ($layer_list as $index => $value) { + $cleanValue = trim($value); + if ($cleanValue == '') { + unset($layer_list[$index]); + } + } $map_connection_default = get_parameter('map_connection_default'); $map_connection_list = array(); foreach ($map_connection_list_temp as $idMapConnection) { - $default = false; + $default = 0; if ($map_connection_default == $idMapConnection) - $default = true; + $default = 1; $map_connection_list[] = array('id_conection' => $idMapConnection, 'default' => $default); } $arrayLayers = array(); - foreach ($layer_list as $layerID) { $arrayLayers[] = JSON_decode($_POST['layer_values_' . $layerID], true); } - saveMap($map_name, $map_initial_longitude, $map_initial_latitude, - $map_initial_altitude, $map_zoom_level, $map_background, + $invalidFields = validateMapData($map_name, $map_zoom_level, + $map_initial_longitude, $map_initial_latitude, $map_initial_altitude, $map_default_longitude, $map_default_latitude, $map_default_altitude, - $map_group_id, $map_connection_list, $arrayLayers); + $map_connection_list); + + if (empty($invalidFields)) { + saveMap($map_name, $map_initial_longitude, $map_initial_latitude, + $map_initial_altitude, $map_zoom_level, $map_background, + $map_default_longitude, $map_default_latitude, $map_default_altitude, + $map_group_id, $map_connection_list, $arrayLayers); + $mapCreatedOk = true; + } + else { + print_input_hidden('action', 'save_new'); + $mapCreatedOk = false; + } + $layer_list = $arrayLayers; + + print_result_message ($mapCreatedOk, __('Successfully created'), + __('Could not be created')); break; case 'new_map': print_input_hidden('action', 'save_new'); @@ -84,6 +165,114 @@ switch ($action) { $map_default_latitude = ''; $map_default_altitude = ''; $map_group_id = ''; + $map_connection_list = Array(); + $layer_list = Array(); + break; + case 'edit_map': + $idMap = get_parameter('map_id'); + + print_input_hidden('action', 'update_saved'); + print_input_hidden('map_id', $idMap); + + $mapData = getMapData($idMap); + + $map_name = $mapData['map']['map_name']; + $map_group_id = $mapData['map']['group_id']; + $map_zoom_level = $mapData['map']['zoom_level']; + $map_background = $mapData['map']['map_background']; + $map_initial_longitude = $mapData['map']['initial_longitude']; + $map_initial_latitude = $mapData['map']['initial_latitude']; + $map_initial_altitude = $mapData['map']['initial_altitude']; + $map_default_longitude = $mapData['map']['default_longitude']; + $map_default_latitude = $mapData['map']['default_latitude']; + $map_default_altitude = $mapData['map']['default_altitude']; + + $map_connection_list = $mapData['connections']; + + $layer_list = array(); + foreach ($mapData['layers'] as $layer) { + $layerAgentList = array(); + foreach($layer['layer_agent_list'] as $layerAgent) { + $layerAgentList[] = $layerAgent['nombre']; + } + $layer_list[] = array( + 'layer_name' => $layer['layer_name'], + 'layer_group' => $layer['layer_group'], + 'layer_visible' => $layer['layer_visible'], + 'layer_agent_list' => $layerAgentList + ); + } + break; + case 'update_saved': + $idMap = get_parameter('map_id'); + + $map_name = get_parameter('map_name'); + $map_initial_longitude = get_parameter('map_initial_longitude'); + $map_initial_latitude = get_parameter('map_initial_latitude'); + $map_initial_altitude = get_parameter('map_initial_altitude'); + $map_zoom_level = get_parameter('map_zoom_level'); + $map_background = ''; //TODO + $map_default_longitude = get_parameter('map_default_longitude'); + $map_default_latitude = get_parameter('map_default_latitude'); + $map_default_altitude = get_parameter('map_default_altitude'); + $map_group_id = get_parameter('map_group_id'); + + $map_connection_list_temp = explode(",",get_parameter('map_connection_list')); + foreach ($map_connection_list_temp as $index => $value) { + $cleanValue = trim($value); + if ($cleanValue == '') { + unset($map_connection_list_temp[$index]); + } + } + $layer_list = explode(",",get_parameter('layer_list')); + foreach ($layer_list as $index => $value) { + $cleanValue = trim($value); + if ($cleanValue == '') { + unset($layer_list[$index]); + } + } + + $map_connection_default = get_parameter('map_connection_default'); + + $map_connection_list = array(); + foreach ($map_connection_list_temp as $idMapConnection) { + $default = 0; + if ($map_connection_default == $idMapConnection) + $default = 1; + + $map_connection_list[] = array('id_conection' => $idMapConnection, 'default' => $default); + } + + $arrayLayers = array(); + foreach ($layer_list as $layerID) { + $arrayLayers[] = JSON_decode($_POST['layer_values_' . $layerID], true); + } + + $invalidFields = validateMapData($map_name, $map_zoom_level, + $map_initial_longitude, $map_initial_latitude, $map_initial_altitude, + $map_default_longitude, $map_default_latitude, $map_default_altitude, + $map_connection_list); + + if (empty($invalidFields)) { + //TODO + updateMap($idMap, $map_name, $map_initial_longitude, $map_initial_latitude, + $map_initial_altitude, $map_zoom_level, $map_background, + $map_default_longitude, $map_default_latitude, $map_default_altitude, + $map_group_id, $map_connection_list, $arrayLayers); + $mapCreatedOk = true; + } + else { + + print_input_hidden('action', 'update_saved'); + $mapCreatedOk = false; + } + $layer_list = $arrayLayers; + + print_result_message ($mapCreatedOk, __('Successfully update'), + __('Could not be update')); + + print_input_hidden('action', 'update_saved'); + print_input_hidden('map_id', $idMap); break; } @@ -93,6 +282,14 @@ $table->data = array (); $table->data[0][0] = __('Name') . ':'; $table->data[0][1] = print_input_text ('map_name', $map_name, '', 30, 60, true); $table->rowspan[0][2] = 9; + +$iconError = ''; +if (isset($invalidFields['map_connection_list'])) { + if ($invalidFields['map_connection_list']) { + $iconError = ''; + } +} + $table->data[0][2] = " @@ -101,7 +298,7 @@ $table->data[0][2] = "
- + @@ -110,7 +307,7 @@ $table->data[0][2] = "
" . __("Refresh map view") . "
" . __("Add Map connection") . ":" . __("Add Map connection") . ": " . $iconError . " " . print_select_from_sql('SELECT id_tmap_connection, conection_name FROM tgis_map_connection', 'map_connection', '', '', '', '0', true) ."
- + " . addConectionMapsInForm($map_connection_list) . "
"; $table->data[1][0] = __('Group') . ':'; @@ -119,13 +316,13 @@ $table->data[1][1] = print_select_from_sql('SELECT id_grupo, nombre FROM tgrupo' $table->data[2][0] = __('Zoom level') . ':'; $table->data[2][1] = print_input_text ('map_zoom_level', $map_zoom_level, '', 2, 4, true); -$table->data[3][0] = __('Initial Longitude') . ':'; +$table->data[3][0] = __('Center Longitude') . ':'; $table->data[3][1] = print_input_text ('map_initial_longitude', $map_initial_longitude, '', 4, 8, true); -$table->data[4][0] = __('Initial Latitude') . ':'; +$table->data[4][0] = __('Center Latitude') . ':'; $table->data[4][1] = print_input_text ('map_initial_latitude', $map_initial_latitude, '', 4, 8, true); -$table->data[5][0] = __('Initial Altitude') . ':'; +$table->data[5][0] = __('Center Altitude') . ':'; $table->data[5][1] = print_input_text ('map_initial_altitude', $map_initial_altitude, '', 4, 8, true); $table->data[6][0] = __('Default Longitude') . ':'; @@ -146,10 +343,13 @@ $table->data = array (); $table->valign[0] = 'top'; $table->valign[1] = 'top'; -$table->data[0][0] = print_button(__('New layer'), 'new_layer', false, 'newLayer();', 'class="sub new"', true); -$table->data[0][1] = "

List of layers

"; +$table->data[0][0] = "

List of layers

"; +$table->data[0][1] = '
' . print_button(__('New layer'), 'new_layer', false, 'newLayer();', 'class="sub new"', true) . '
'; -$table->data[1][0] = '
+$table->data[1][0] = '' . + addLayerList($layer_list) . + '
'; +$table->data[1][1] = '
@@ -158,9 +358,12 @@ $table->data[1][0] = '
- + + + +
'; -$table->data[1][1] = ' -
'; print_table($table); echo '
'; -print_submit_button(_('Save map'), 'save_button', false, 'class="sub save"'); +switch ($action) { + case 'save_new': + case 'edit_map': + case 'update_saved': + if (!empty($invalidFields)) { + print_submit_button(_('Save map'), 'save_button', false, 'class="sub save"'); + } + else { + print_submit_button(_('Update map'), 'update_button', false, 'class="sub update"'); + } + break; + case 'new_map': + print_submit_button(_('Save map'), 'save_button', false, 'class="sub save"'); + break; +} echo '
'; echo ""; @@ -226,10 +441,13 @@ echo ""; - + + @@ -247,13 +465,6 @@ require_jquery_file ('autocomplete'); require_jquery_file ('json'); ?> + '; + } + + return $returnVar; +} + +/** + * This function use in form the "pandora_console/godmode/gis_maps/configure_gis_map.php" + * in the case of edit a map or when there are any error in save new map. Because this function + * return a html code that it has the rows of layers of map. + * + * @param Array $layer_list The list of layers for convert a html. + * + * @return String The html source code. + */ +function addLayerList($layer_list) { + $returnVar = ''; + + $count = 0; + foreach ($layer_list as $layer) { + //Create the layer temp form as it was in the form + $layerTempForm = array(); + $layerTempForm['layer_name'] = $layer['layer_name']; + $layerTempForm['layer_group'] = $layer['layer_group']; + $layerTempForm['layer_visible'] = $layer['layer_visible']; + if (array_key_exists('layer_agent_list', $layer)) { + foreach($layer['layer_agent_list'] as $agent) { + $layerTempForm['layer_agent_list'][] = $agent; + } + } + + $layerDataJSON = json_encode($layerTempForm); + + $returnVar .= ' + + + + + + + + + + '; + + $count ++; + } + + return $returnVar; +} ?> diff --git a/pandora_console/operation/gis_maps/render_view.php b/pandora_console/operation/gis_maps/render_view.php index 770bba6a78..174ae495f0 100644 --- a/pandora_console/operation/gis_maps/render_view.php +++ b/pandora_console/operation/gis_maps/render_view.php @@ -64,7 +64,7 @@ if ($config["pure"] == 0) { echo " "; if (give_acl ($config["id_user"], $map['group_id'], "AW")) - echo ''.print_image ("images/setup.png", true, array ("title" => __('Setup'))).''; + echo ''.print_image ("images/setup.png", true, array ("title" => __('Setup'))).''; echo ""; printMap('map', $map['zoom_level'], $numZoomLevels, $map['initial_latitude'],
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + +
' . $layer['layer_name'] . ' + + + + +