From e38858753e5cd415ad90a33253240e09776264c5 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Wed, 27 Jan 2010 15:46:20 +0000 Subject: [PATCH] 2010-01-27 Miguel de Dios * include/functions_gis.php: add the prototipe of function "saveMap2" at the moment for to develop in next hours or days. * include/javascript/jquery.json.js: add json plugin for jquery. * godmode/gis_maps/configure_gis_map.php: rewrite all source code, change the form and adapt to new gis tables. * godmode/gis_maps/index.php: few changes for more correct source code. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2312 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 8 + .../godmode/gis_maps/configure_gis_map.php | 781 +++++++++++------- pandora_console/godmode/gis_maps/index.php | 15 +- pandora_console/include/functions_gis.php | 7 + .../include/javascript/jquery.json.js | 31 + 5 files changed, 549 insertions(+), 293 deletions(-) create mode 100644 pandora_console/include/javascript/jquery.json.js diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index a83170c7d0..d50027c644 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,11 @@ +2010-01-27 Miguel de Dios + * include/functions_gis.php: add the prototipe of function "saveMap2" at + the moment for to develop in next hours or days. + * include/javascript/jquery.json.js: add json plugin for jquery. + * godmode/gis_maps/configure_gis_map.php: rewrite all source code, change + the form and adapt to new gis tables. + * godmode/gis_maps/index.php: few changes for more correct source code. + 2010-01-27 Pablo de la ConcepciĆ³n * include/functions_gis.php: Added more Openlayers Controls to the case diff --git a/pandora_console/godmode/gis_maps/configure_gis_map.php b/pandora_console/godmode/gis_maps/configure_gis_map.php index fdcf3a742e..aa5f9056f5 100644 --- a/pandora_console/godmode/gis_maps/configure_gis_map.php +++ b/pandora_console/godmode/gis_maps/configure_gis_map.php @@ -26,369 +26,576 @@ if (! give_acl ($config['id_user'], 0, "IW")) { } //debugPrint($_POST); -$action = get_parameter('action'); +$action = get_parameter('action', 'new_map'); + +echo '
'; switch ($action) { case 'save_new': - $conf['name'] = get_parameter('name'); - $conf['group'] = get_parameter('group'); - $conf['numLevelsZoom'] = get_parameter('num_levels_zoom'); - $conf['initial_zoom'] = get_parameter('initial_zoom'); + $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'); - $baselayersID = get_parameter('order_baselayer'); - $baselayersID = explode(',', $baselayersID); + $map_connection_list = explode(",",get_parameter('map_connection_list')); + $layer_list = explode(",",get_parameter('layer_list')); - $defaultMap = get_parameter('default_map'); - $baselayers = array(); - foreach ($baselayersID as $id) { - if (strlen($id) == 0) - continue; - $temp = array(); - - $temp['type'] = $_POST['type_' . $id]; - - if ($defaultMap == $id) - $temp['default'] = true; - else - $temp['default'] = false; - - switch ($temp['type']) { - case 'osm': - $temp['url'] = $_POST['url_' . $temp['type'] . '_' . $id]; - break; - } - $baselayers[] = $temp; + foreach ($map_connection_list as $mapConnection) { + //TODO extract the default } - $layersID = get_parameter('order_layer'); - $layersID = explode(',', $layersID); - $layers = array(); - foreach ($layersID as $index => $id) { - if (strlen($id) == 0) - continue; - - $temp = array(); - $temp['group'] = $_POST['layer_group_id_' . $id]; - $temp['name'] = $_POST['layer_name_' . $id]; - $temp['visible'] = $_POST['layer_visible_' . $id]; - - $layers[$index] = $temp; + //debugPrint($map_connection_list); + + $arrayLayers = array(); + + foreach ($layer_list as $layerID) { + $arrayLayers[] = JSON_decode($_POST['layer_values_' . $layerID], true); } - saveMap($conf, $baselayers, $layers); + saveMap2($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); - return; + //debugPrint($arrayLayers); + break; + case 'new_map': + print_input_hidden('action', 'save_new'); + + echo "

" . __('GIS Maps') . " » " . __('Builder') . "

"; + $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 = ''; break; } -echo "

" . __('GIS Maps') . " » " . __('Builder') . "

"; - -$map_config = array(); -$map_config["name"] = ''; -$map_config["group"] = ''; -$map_config["type"] = ''; -$map_config["url"] = ''; -$map_config["num_levels_zoom"] = ''; -$map_config["initial_zoom"] = ''; - $table->width = '90%'; $table->data = array (); -echo ''; -print_input_hidden('action', 'save_new'); -echo "

" . __('Basic configuration') . "

"; +$table->data[0][0] = __('Name') . ':'; +$table->data[0][1] = print_input_text ('map_name', $map_name, '', 30, 60, true); +$table->rowspan[0][2] = 9; +$table->data[0][2] = " + + + + + + + + + + + +
" . __("Refresh map view") . "
" . __("Add Map connection") . ": + " . print_select_from_sql('SELECT id_tmap_connection, conection_name FROM tgis_map_connection', 'map_connection', '', '', '', '0', true) ." + + " . print_image ("images/add.png", true) . " + + +
"; -$table->data = array(); -$table->data[0][0] = __('Name') . ":"; -$table->data[0][1] = print_input_text ('name', $map_config["name"], '', 30, 60, true); +$table->data[1][0] = __('Group') . ':'; +$table->data[1][1] = print_select_from_sql('SELECT id_grupo, nombre FROM tgrupo', 'map_group_id', $map_group_id, '', '', '0', true); -$table->data[1][0] = __("Group") . ":"; -$table->data[1][1] = print_select_from_sql('SELECT id_grupo, nombre FROM tgrupo', 'group', $map_config["group"], '', '', '0', true); -$table->data[2][0] = __('Num levels zoom') . ":"; -$table->data[2][1] = print_input_text ('num_levels_zoom', $map_config["num_levels_zoom"], '', 2, 10, true); -$table->data[3][0] = __('Initial zoom level') . ":"; -$table->data[3][1] = print_input_text ('initial_zoom', $map_config["initial_zoom"], '', 2, 10, true); +$table->data[2][0] = __('Zoom level') . ':'; +$table->data[2][1] = print_input_text ('map_zoom_level', $map_zoom_level, '', 2, 4, true); -print_table ($table); +$table->data[3][0] = __('Initial Longitude') . ':'; +$table->data[3][1] = print_input_text ('map_initial_longitude', $map_initial_longitude, '', 4, 8, true); -$table->width = '80%'; -echo "

" . __('Maps') . "

"; -$table->data = array(); -$table->id = "maps"; -$types["OSM"] = __('Open Street Maps'); -$table->data[0][0] = __('Type') . ":"; -$table->data[0][1] = print_select ($types, 'sel_type', $map_config["type"], '', '', __('Select your type map'), true); -$table->data[0][2] = '' . print_image ("images/add.png", true) . ''; +$table->data[4][0] = __('Initial Latitude') . ':'; +$table->data[4][1] = print_input_text ('map_initial_latitude', $map_initial_latitude, '', 4, 8, true); -print_table ($table); +$table->data[5][0] = __('Initial Altitude') . ':'; +$table->data[5][1] = print_input_text ('map_initial_altitude', $map_initial_altitude, '', 4, 8, true); -echo ""; +$table->data[6][0] = __('Default Longitude') . ':'; +$table->data[6][1] = print_input_text ('map_default_longitude', $map_default_longitude, '', 4, 8, true); + +$table->data[7][0] = __('Default Latitude') . ':'; +$table->data[7][1] = print_input_text ('map_default_latitude', $map_default_latitude, '', 4, 8, true); + +$table->data[8][0] = __('Default Altitude') . ':'; +$table->data[8][1] = print_input_text ('map_default_altitude', $map_default_altitude, '', 4, 8, true); -echo "

" . __('Layers') . "

"; -$table->width = '50%'; -$table->data = array(); -$table->id = "layers"; -$table->data[0][0] = _('Group') . ':'; -$table->data[0][1] = print_select_from_sql('SELECT id_grupo, nombre FROM tgrupo', 'group', $map_config["group"], '', '', '0', true); -$table->data[0][2] = '' . print_image ("images/add.png", true) . ''; print_table($table); -echo ""; +echo "

" . __('Layers') . "

"; -echo "

" . __('Center') . "

"; -echo "

" . __('Please create a map before selecting the center.') . "TODO

"; +$table->width = '90%'; +$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[1][0] = '
+ + + + + + + + + + + + + + + + + + + + + + +
'; +$table->data[1][1] = ' +
'; + +print_table($table); echo '
'; -print_submit_button (__('Create'), 'create_button', false, 'class="sub upd"'); +print_submit_button(_('Save map'), 'save_button', false, 'class="sub save"'); echo '
'; -echo '
'; -//Chunks of table maps for when add maps to form -//-------------------------INI OSM--------------------------------------- -$table->width = '80%'; -$table->data = array(); -$table->rowclass[0] = 'OSM'; -$table->rowclass[1] = 'OSM'; -$table->rowclass[2] = 'OSM'; -$table->rowclass[3] = 'OSM'; -$table->rowstyle[0] = 'visibility: hidden;'; -$table->rowstyle[1] = 'visibility: hidden;'; -$table->rowstyle[2] = 'visibility: hidden;'; -$table->rowstyle[3] = 'visibility: hidden;'; -$table->colspan[0][0] = 3; -$table->data[0][0] = '
'; -$table->data[1][0] = "" . __('OSM') . ""; -$table->data[1][1] = ''; -$table->data[1][2] = '' . print_image ("images/cross.png", true) . ''; -$table->data[2][0] = __('URL_OSM') . ":"; -$table->data[2][1] = print_input_text ('url_osm', $map_config["url"], '', 50, 100, true); -$table->data[2][2] = ''; -$table->data[3][0] = __('Default') . ':'; -$table->data[3][1] = print_radio_button ('default_map', '2', '', true, true); -$table->data[3][2] = ''; +echo ""; -print_table($table); -unset($table->rowclass); -unset($table->rowstyle); -unset($table->colspan); -//-------------------------INI OSM--------------------------------------- -//Chunks of table layer for when add layers to form -//-------------------------INI LAYERS--------------------------------------- +//-------------------------INI CHUNKS--------------------------------------- ?> - - + + - - - - - - - - - - + + - - - - -
Group: - - -
Name:
Visible:
+ + + + + + + +
XXXX + + +
+ + + + + + + + + +
XXXXXXXXXXXXXXXXXX + + +
\ No newline at end of file diff --git a/pandora_console/godmode/gis_maps/index.php b/pandora_console/godmode/gis_maps/index.php index 2422a4fb7d..3a20693b48 100644 --- a/pandora_console/godmode/gis_maps/index.php +++ b/pandora_console/godmode/gis_maps/index.php @@ -40,18 +40,21 @@ $table->align[3] = 'center'; $maps = get_db_all_rows_in_table ('tgis_map','map_name'); $table->data = array(); -foreach ($maps as $map) { - $table->data[] = array('' . $map['map_name'] . '', - print_group_icon ($map['group_id'], true), - '' . print_image ("images/eye.png", true).'', - '' . print_image ("images/cross.png", true).''); + +if ($maps !== false) { + foreach ($maps as $map) { + $table->data[] = array('' . $map['map_name'] . '', + print_group_icon ($map['group_id'], true), + '' . print_image ("images/eye.png", true).'', + '' . print_image ("images/cross.png", true).''); + } } print_table($table); echo '
'; echo '
'; -print_input_hidden ('action','create_map'); +print_input_hidden ('action','new_map'); print_submit_button (__('Create'), '', false, 'class="sub next"'); echo '
'; echo '
'; diff --git a/pandora_console/include/functions_gis.php b/pandora_console/include/functions_gis.php index aea2019728..76871796bc 100644 --- a/pandora_console/include/functions_gis.php +++ b/pandora_console/include/functions_gis.php @@ -536,6 +536,13 @@ function saveMap($conf, $baselayers, $layers) { return $return; } +function saveMap2($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) { +} +?> + /** * Get the configuration parameters of a map connection * diff --git a/pandora_console/include/javascript/jquery.json.js b/pandora_console/include/javascript/jquery.json.js new file mode 100644 index 0000000000..bad4a0afa0 --- /dev/null +++ b/pandora_console/include/javascript/jquery.json.js @@ -0,0 +1,31 @@ + +(function($){$.toJSON=function(o) +{if(typeof(JSON)=='object'&&JSON.stringify) +return JSON.stringify(o);var type=typeof(o);if(o===null) +return"null";if(type=="undefined") +return undefined;if(type=="number"||type=="boolean") +return o+"";if(type=="string") +return $.quoteString(o);if(type=='object') +{if(typeof o.toJSON=="function") +return $.toJSON(o.toJSON());if(o.constructor===Date) +{var month=o.getUTCMonth()+1;if(month<10)month='0'+month;var day=o.getUTCDate();if(day<10)day='0'+day;var year=o.getUTCFullYear();var hours=o.getUTCHours();if(hours<10)hours='0'+hours;var minutes=o.getUTCMinutes();if(minutes<10)minutes='0'+minutes;var seconds=o.getUTCSeconds();if(seconds<10)seconds='0'+seconds;var milli=o.getUTCMilliseconds();if(milli<100)milli='0'+milli;if(milli<10)milli='0'+milli;return'"'+year+'-'+month+'-'+day+'T'+ +hours+':'+minutes+':'+seconds+'.'+milli+'Z"';} +if(o.constructor===Array) +{var ret=[];for(var i=0;i