2010-01-19 16:49:34 +01:00
< ? php
// Pandora FMS - http://pandorafms.com
// ==================================================
2010-05-06 17:53:38 +02:00
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
2010-01-19 16:49:34 +01:00
// 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.
2010-03-02 13:00:57 +01:00
/**
* Print javascript to add parent lines between the agents .
*
* @ param inteer $idMap The id of map .
*
* @ return None
*/
function addParentLines () {
2010-03-08 19:42:15 +01:00
makeLayer ( __ ( 'Hierarchy of agents' ));
2010-03-02 13:00:57 +01:00
echo " <script type='text/javascript'> " ;
echo " $ (document).ready (function () {
2010-03-08 19:42:15 +01:00
var layer = map . getLayersByName ( '" . __(' Hierarchy of agents ') . "' );
2010-03-02 13:00:57 +01:00
layer = layer [ 0 ];
map . setLayerIndex ( layer , 0 );
2010-03-08 19:42:15 +01:00
js_refreshParentLines ( '" . __(' Hierarchy of agents ') . "' );
2010-03-02 13:00:57 +01:00
}); " ;
echo " </script> " ;
}
2010-02-18 14:29:36 +01:00
/**
* Return the data of last position of agent from tgis_data_status .
*
* @ param integer $idAgent The id of agent .
* @ param boolean $returnEmptyArrayInFail The set return a empty array when fail and true .
* @ return Array The row of agent in tgis_data_status , and it ' s a associative array .
*/
function getDataLastPositionAgent ( $idAgent , $returnEmptyArrayInFail = false ) {
$returnVar = get_db_row ( 'tgis_data_status' , 'tagente_id_agente' , $idAgent );
if (( $returnVar === false ) && ( $returnEmptyArrayInFail )) {
return array ();
}
return $returnVar ;
}
2010-03-08 18:40:23 +01:00
/**
* Write a javascript vars for to call the js_printMap .
*
* @ param string $idDiv The id of div to paint the map .
* @ param integer $iniZoom The zoom to init the map .
* @ param float $latCenter The latitude center to init the map .
* @ param float $lonCenter The longitude center to init the map .
* @ param array $baselayers The list of baselayer with the connection data .
* @ param array $controls The string list of controls .
*
* @ return None
*/
function printMap ( $idDiv , $iniZoom , $latCenter , $lonCenter , $baselayers , $controls = null ) {
2010-03-02 16:13:04 +01:00
require_javascript_file ( 'OpenLayers/OpenLayers' );
2010-03-03 17:25:39 +01:00
2010-03-08 18:40:23 +01:00
echo " <script type='text/javascript'> " ;
echo " var controlsList = []; " ;
foreach ( $controls as $control ) {
echo " controlsList.push(' " . $control . " '); " ;
}
echo " var idDiv = ' " . $idDiv . " '; " ;
echo " var initialZoom = " . $iniZoom . " ; " ;
echo " var centerLatitude = " . $latCenter . " ; " ;
echo " var centerLongitude = " . $lonCenter . " ; " ;
echo " var baselayerList = []; " ;
echo " var baselayer = null; " ;
foreach ( $baselayers as $baselayer ) {
echo " baselayer = {
bb_bottom : null ,
bb_left : null ,
bb_right : null ,
bb_top : null ,
gmap_type : null ,
image_height : null ,
image_width : null ,
num_zoom_levels : null ,
name : null ,
type : null ,
url : null
}; " ;
echo " baselayer['type'] = ' " . $baselayer [ 'typeBaseLayer' ] . " '; " ;
echo " baselayer['name'] = ' " . $baselayer [ 'name' ] . " '; " ;
echo " baselayer['num_zoom_levels'] = ' " . $baselayer [ 'num_zoom_levels' ] . " '; " ;
switch ( $baselayer [ 'typeBaseLayer' ]) {
case 'OSM' :
echo " baselayer['url'] = ' " . $baselayer [ 'url' ] . " '; " ;
break ;
case 'Static_Image' :
echo " baselayer['bb_left'] = ' " . $baselayer [ 'bb_left' ] . " '; " ;
echo " baselayer['bb_bottom'] = ' " . $baselayer [ 'bb_bottom' ] . " '; " ;
echo " baselayer['bb_right'] = ' " . $baselayer [ 'bb_right' ] . " '; " ;
echo " baselayer['bb_top'] = ' " . $baselayer [ 'bb_top' ] . " '; " ;
echo " baselayer['image_width'] = ' " . $baselayer [ 'image_width' ] . " '; " ;
echo " baselayer['image_height'] = ' " . $baselayer [ 'image_height' ] . " '; " ;
echo " baselayer['url'] = ' " . $baselayer [ 'url' ] . " '; " ;
break ;
case 'Gmap' :
echo " baselayer['gmap_type'] = ' " . $baselayer [ 'gmap_type' ] . " '; " ;
break ;
}
echo " baselayerList.push(baselayer); " ;
}
echo " js_printMap(idDiv, initialZoom, centerLatitude, centerLongitude,
baselayerList , controlsList ) " ;
echo " </script> " ;
2010-01-19 16:49:34 +01:00
}
2010-02-17 18:27:25 +01:00
function makeLayer ( $name , $visible = true , $dot = null , $idLayer = null ) {
2010-01-19 16:49:34 +01:00
if ( $dot == null ) {
$dot [ 'url' ] = 'images/dot_green.png' ;
$dot [ 'width' ] = 20 ; //11;
$dot [ 'height' ] = 20 ; //11;
}
$visible = ( bool ) $visible ;
?>
< script type = " text/javascript " >
$ ( document ) . ready (
function () {
//Creamos el estilo
var style = new OpenLayers . StyleMap (
{ fontColor : " #ff0000 " ,
labelYOffset : -< ? php echo $dot [ 'height' ]; ?> ,
graphicHeight : < ? php echo $dot [ 'height' ]; ?> ,
graphicWidth : < ? php echo $dot [ 'width' ]; ?> ,
externalGraphic : " <?php echo $dot['url'] ; ?> " , label : " ${ nombre } "
}
);
//Creamos la capa de tipo vector
var layer = new OpenLayers . Layer . Vector (
2010-05-06 17:53:38 +02:00
'<?php echo $name; ?>' , { styleMap : style }
);
2010-02-17 18:27:25 +01:00
2010-05-06 17:53:38 +02:00
layer . data = {};
layer . data . id = '<?php echo $idLayer; ?>' ;
2010-01-19 16:49:34 +01:00
2010-05-06 17:53:38 +02:00
layer . setVisibility ( < ? php echo $visible ; ?> );
map . addLayer ( layer );
2010-01-19 16:49:34 +01:00
2010-05-06 17:53:38 +02:00
layer . events . on ({
" featureselected " : function ( e ) {
if ( e . feature . geometry . CLASS_NAME == " OpenLayers.Geometry.Point " ) {
var feature = e . feature ;
var featureData = feature . data ;
var long_lat = featureData . long_lat ;
2010-01-19 16:49:34 +01:00
var popup ;
2010-05-06 17:53:38 +02:00
popup = new OpenLayers . Popup . FramedCloud ( 'cloud00' ,
long_lat ,
2010-01-19 16:49:34 +01:00
null ,
'<div class="cloudContent' + featureData . id + '" style="text-align: center;"><img src="images/spinner.gif" /></div>' ,
null ,
true ,
function () { popup . destroy (); });
2010-05-06 17:53:38 +02:00
feature . popup = popup ;
map . addPopup ( popup );
jQuery . ajax ({
data : " page=operation/gis_maps/ajax&opt= " + featureData . type + " &id= " + featureData . id ,
type : " GET " ,
dataType : 'json' ,
url : " ajax.php " ,
timeout : 10000 ,
success : function ( data ) {
if ( data . correct ) {
$ ( '.cloudContent' + featureData . id ) . css ( 'text-align' , 'left' );
$ ( '.cloudContent' + featureData . id ) . html ( data . content );
popup . updateSize ();
}
}
});
}
}
});
2010-01-19 16:49:34 +01:00
}
);
</ script >
< ? php
}
2010-01-21 18:08:58 +01:00
function activateSelectControl ( $layers = null ) {
?>
< script type = " text/javascript " >
$ ( document ) . ready (
function () {
2010-05-06 17:53:38 +02:00
var layers = map . getLayersByClass ( " OpenLayers.Layer.Vector " );
var select = new OpenLayers . Control . SelectFeature ( layers );
map . addControl ( select );
select . activate ();
2010-01-21 18:08:58 +01:00
}
);
</ script >
< ? php
}
2010-02-04 11:34:30 +01:00
/**
2010-05-06 17:53:38 +02:00
* Activate the feature refresh by ajax .
2010-02-04 11:34:30 +01:00
*
* @ param Array $layers Its a rows of table " tgis_map_layer " or None is all .
* @ param integer $lastTimeOfData The time in unix timestamp of last query of data GIS in DB .
*
* @ return None
*/
function activateAjaxRefresh ( $layers = null , $lastTimeOfData = null ) {
if ( $lastTimeOfData === null ) $lastTimeOfData = time ();
require_jquery_file ( 'json' );
?>
< script type = " text/javascript " >
var last_time_of_data = < ? php echo $lastTimeOfData ; ?> ; //This time use in the ajax query to next recent points.
2010-02-24 12:49:03 +01:00
var refreshAjaxIntervalSeconds = 60000 ;
2010-02-04 11:34:30 +01:00
var idIntervalAjax = null ;
2010-02-24 12:49:03 +01:00
var oldRefreshAjaxIntervalSeconds = 60000 ;
2010-02-04 11:34:30 +01:00
2010-02-23 13:12:41 +01:00
< ? php
if ( $layers === null ) {
echo " var agentView = 1; " ;
}
else {
echo " var agentView = 0; " ;
}
?>
2010-02-04 11:34:30 +01:00
function refreshAjaxLayer ( layer ) {
var featureIdArray = Array ();
for ( featureIndex = 0 ; featureIndex < layer . features . length ; featureIndex ++ ) {
feature = layer . features [ featureIndex ];
if ( feature . data . type != 'point_path_info' ) {
2010-02-23 13:12:41 +01:00
if ( feature . geometry . CLASS_NAME == " OpenLayers.Geometry.Point " ) {
featureIdArray . push ( feature . data . id );
}
2010-02-04 11:34:30 +01:00
}
}
if ( featureIdArray . length > 0 ) {
2010-05-06 17:53:38 +02:00
jQuery . ajax ({
data : " page=operation/gis_maps/ajax&opt=get_new_positions&id_features= " + featureIdArray . toString ()
+ " &last_time_of_data= " + last_time_of_data + " &layer_id= " + layer . data . id + " &agent_view= " + agentView ,
type : " GET " ,
dataType : 'json' ,
url : " ajax.php " ,
timeout : 10000 ,
success : function ( data ) {
if ( data . correct ) {
content = $ . evalJSON ( data . content );
if ( content != null ) {
for ( var idAgent in content ) {
if ( isInt ( idAgent )) {
agentDataGIS = content [ idAgent ];
feature = searchPointAgentById ( idAgent );
layer . removeFeatures ( feature );
delete feature ;
feature = null
status = parseInt ( agentDataGIS [ 'status' ]);
2010-02-19 13:26:54 +01:00
2010-05-06 17:53:38 +02:00
js_addAgentPointExtent ( layer . name , agentDataGIS [ 'name' ],
agentDataGIS [ 'stored_longitude' ], agentDataGIS [ 'stored_latitude' ],
agentDataGIS [ 'icon_path' ], 20 , 20 , idAgent , 'point_agent_info' , status , agentDataGIS [ 'id_parent' ]);
//TODO: Optimize, search a new position to call for all agent in the layer and or optimice code into function.
js_refreshParentLines ();
}
}
}
}
}
});
2010-02-04 11:34:30 +01:00
}
}
2010-02-25 13:46:47 +01:00
function clock_ajax_refresh () {
//console.log(new Date().getHours() + ":" + new Date().getMinutes() + ":" + new Date().getSeconds());
2010-02-04 11:34:30 +01:00
for ( layerIndex = 0 ; layerIndex < map . getNumLayers (); layerIndex ++ ) {
layer = map . layers [ layerIndex ];
< ? php
if ( $layers === null ) {
2010-02-23 13:12:41 +01:00
?>
if ( layer . isVector ) {
refreshAjaxLayer ( layer );
}
< ? php
2010-02-04 11:34:30 +01:00
}
else {
foreach ( $layers as $layer ) {
?>
if ( layer . name == '<?php echo $layer[' layer_name ']; ?>' ) {
refreshAjaxLayer ( layer );
}
< ? php
}
}
?>
}
2010-03-02 13:00:57 +01:00
2010-02-17 18:27:25 +01:00
last_time_of_data = Math . round ( new Date () . getTime () / 1000 ); //Unixtimestamp
2010-02-04 11:34:30 +01:00
2010-02-23 17:36:24 +01:00
//Test if the user change the refresh time.
if ( oldRefreshAjaxIntervalSeconds != refreshAjaxIntervalSeconds ) {
clearInterval ( idIntervalAjax );
idIntervalAjax = setInterval ( " clock_ajax_refresh() " , refreshAjaxIntervalSeconds );
oldRefreshAjaxIntervalSeconds = refreshAjaxIntervalSeconds ;
}
2010-02-04 11:34:30 +01:00
}
$ ( document ) . ready (
function () {
idIntervalAjax = setInterval ( " clock_ajax_refresh() " , refreshAjaxIntervalSeconds );
}
);
</ script >
< ? php
}
2010-02-25 18:27:55 +01:00
function addAgentPoint ( $layerName , $pointName , $lat , $lon , $icon = null , $width = 20 ,
2010-05-06 17:53:38 +02:00
$height = 20 , $point_id = '' , $status = - 1 , $type_string = '' , $idParent = 0 ) {
2010-01-19 16:49:34 +01:00
?>
< script type = " text/javascript " >
$ ( document ) . ready (
function () {
< ? php
2010-02-22 17:13:12 +01:00
if ( $icon != null ) {
2010-02-25 18:27:55 +01:00
//echo "js_addPointExtent('$layerName', '$pointName', $lon, $lat, '$icon', $width, $height, $point_id, '$type_string', $status);";
echo " js_addAgentPointExtent(' $layerName ', ' $pointName ', $lon , $lat , ' $icon ', $width , $height , $point_id , ' $type_string ', $status , $idParent ); " ;
2010-01-19 16:49:34 +01:00
}
2010-02-22 17:13:12 +01:00
else {
2010-02-25 18:27:55 +01:00
//echo "js_addPoint('$layerName', '$pointName', $lon, $lat, $point_id, '$type_string', $status);";
echo " js_addAgentPoint(' $layerName ', ' $pointName ', $lon , $lat , $point_id , ' $type_string ', $status , $idParent ); " ;
2010-01-19 16:49:34 +01:00
}
?>
}
);
</ script >
< ? php
}
2010-02-25 13:46:47 +01:00
/**
* Get the agents in layer but not by group in layer .
*
* @ param integer $idLayer Layer ID .
* @ param array $fields Fields of row tagente to return .
*
* @ return array The array rows of tagente of agents in the layer .
*/
function getAgentsLayer ( $idLayer , $fields = null ) {
if ( $fields === null ) {
$select = '*' ;
}
else {
$select = implode ( ',' , $fields );
}
$agents = get_db_all_rows_sql ( 'SELECT ' . $select . ' FROM tagente WHERE id_agente IN (
SELECT tagente_id_agente FROM tgis_map_layer_has_tagente WHERE tgis_map_layer_id_tmap_layer = ' . $idLayer . ' ); ' );
2010-03-01 12:40:07 +01:00
if ( $agents !== false ) {
foreach ( $agents as $index => $agent ) {
$agents [ $index ] = $agent [ 'nombre' ];
}
}
else {
return array ();
2010-02-25 13:46:47 +01:00
}
return $agents ;
}
2010-01-19 16:49:34 +01:00
function addPointPath ( $layerName , $lat , $lon , $color , $manual = 1 , $id ) {
?>
< script type = " text/javascript " >
$ ( document ) . ready (
function () {
2010-02-04 11:34:30 +01:00
js_addPointPath ( '<?php echo $layerName; ?>' , < ? php echo $lon ; ?> , <?php echo $lat; ?>, '<?php echo $color; ?>', <?php echo $manual; ?>, <?php echo $id; ?>);
2010-01-19 16:49:34 +01:00
}
);
</ script >
< ? php
}
function getMaps () {
return get_db_all_rows_in_table ( 'tgis_map' , 'map_name' );
}
2010-01-27 17:10:14 +01:00
/**
* Gets the configuration of all the base layers of a map
*
* @ param $idMap : Map identifier of the map to get the configuration
*
* @ return An array of arrays of configuration parameters
*/
2010-01-19 16:49:34 +01:00
function getMapConf ( $idMap ) {
2010-01-27 20:52:53 +01:00
$mapConfs = get_db_all_rows_sql ( ' SELECT tconn .* , trel . default_map_connection FROM tgis_map_connection AS tconn , tgis_map_has_tgis_map_connection AS trel
2010-01-27 17:10:14 +01:00
WHERE trel . tgis_map_connection_id_tmap_connection = tconn . id_tmap_connection AND trel . tgis_map_id_tgis_map = ' . $idMap );
return $mapConfs ;
2010-01-19 16:49:34 +01:00
}
2010-02-16 16:28:07 +01:00
function getMapConnection ( $idMapConnection ) {
return get_db_row ( 'tgis_map_connection' , 'id_tmap_connection' , $idMapConnection );
}
2010-01-19 16:49:34 +01:00
function getLayers ( $idMap ) {
$layers = get_db_all_rows_sql ( 'SELECT * FROM tgis_map_layer WHERE tgis_map_id_tgis_map = ' . $idMap );
return $layers ;
}
2010-02-25 18:27:55 +01:00
function get_agent_icon_map ( $idAgent , $state = false , $status = null ) {
2010-01-19 16:49:34 +01:00
$row = get_db_row_sql ( 'SELECT id_grupo, icon_path FROM tagente WHERE id_agente = ' . $idAgent );
2010-02-22 17:13:12 +01:00
if (( $row [ 'icon_path' ] === null ) || ( strlen ( $row [ 'icon_path' ]) == 0 )) {
$icon = " images/groups_small/ " . get_group_icon ( $row [ 'id_grupo' ]);
2010-01-19 16:49:34 +01:00
}
else {
$icon = " images/gis_map/icons/ " . $row [ 'icon_path' ];
2010-02-22 17:13:12 +01:00
}
2010-02-25 18:27:55 +01:00
if ( $state === false ) {
2010-02-22 17:13:12 +01:00
return $icon . " .png " ;
}
else {
2010-02-25 18:27:55 +01:00
if ( $status === null ) {
$status = get_agent_status ( $idAgent );
2010-03-05 12:16:20 +01:00
if ( $status === null ) {
$status = - 1 ;
}
2010-02-25 18:27:55 +01:00
}
switch ( $status ) {
2010-02-22 17:13:12 +01:00
case 1 :
case 4 :
//Critical (BAD or ALERT)
$state = " .bad " ;
break ;
case 0 :
//Normal (OK)
$state = " .ok " ;
break ;
case 2 :
//Warning
$state = " .warning " ;
break ;
default :
// Default is Grey (Other)
$state = '.default' ;
break ;
2010-02-04 11:34:30 +01:00
}
2010-03-05 12:16:20 +01:00
$returnIcon = $icon . $state . " .png " ;
return $returnIcon ;
2010-01-19 16:49:34 +01:00
}
}
2010-02-25 16:51:37 +01:00
/**
* Print the path of agent .
*
* @ param string $layerName String of layer .
* @ param integer $idAgent The id of agent
2010-03-03 11:34:35 +01:00
* @ param integer $history_time Number of seconds in the past to show from where to start the history path .
* @ param array $lastPosition The last position of agent that is not in history table .
2010-02-25 16:51:37 +01:00
*
* @ return None
*/
2010-03-03 11:34:35 +01:00
function addPath ( $layerName , $idAgent , $lastPosition = null , $history_time = null ) {
2010-02-25 16:51:37 +01:00
if ( $history_time === null ) {
$where = '1 = 1' ;
}
else {
2010-02-25 17:32:07 +01:00
$where = 'start_timestamp >= FROM_UNIXTIME(UNIX_TIMESTAMP() - ' . $history_time . ')' ;
2010-02-25 16:51:37 +01:00
}
2010-01-21 18:08:58 +01:00
2010-02-25 16:51:37 +01:00
$listPoints = get_db_all_rows_sql ( ' SELECT *
FROM tgis_data_history
WHERE
tagente_id_agente = ' . $idAgent . ' AND
' . $where . '
ORDER BY end_timestamp ASC ' );
2010-02-18 17:54:24 +01:00
//If the agent is empty the history
if ( $listPoints === false ) {
return ;
}
2010-01-19 16:49:34 +01:00
$avaliableColors = array ( " #ff0000 " , " #00ff00 " , " #0000ff " , " #000000 " );
2010-01-21 18:08:58 +01:00
$randomIndex = array_rand ( $avaliableColors );
$color = $avaliableColors [ $randomIndex ];
2010-01-19 16:49:34 +01:00
?>
< script type = " text/javascript " >
$ ( document ) . ready (
function () {
< ? php
if ( $listPoints != false ) {
$listPoints = ( array ) $listPoints ;
$first = true ;
echo " var points = [ " ;
foreach ( $listPoints as $point ) {
if ( ! $first ) echo " , " ;
$first = false ;
echo " new OpenLayers.Geometry.Point( " . $point [ 'longitude' ] . " , " . $point [ 'latitude' ] . " ) " ;
}
2010-03-03 11:34:35 +01:00
if ( $lastPosition !== null ) {
echo " , new OpenLayers.Geometry.Point( " . $lastPosition [ 'longitude' ] . " , " . $lastPosition [ 'latitude' ] . " ) " ;
}
2010-01-19 16:49:34 +01:00
echo " ]; " ;
}
?>
2010-02-04 11:34:30 +01:00
js_addLineString ( '<?php echo $layerName; ?>' , points , '<?php echo $color; ?>' );
2010-01-19 16:49:34 +01:00
}
);
</ script >
< ? php
if ( $listPoints != false ) {
foreach ( $listPoints as $point ) {
2010-03-03 11:34:35 +01:00
if (( end ( $listPoints ) != $point ) || (( $lastPosition !== null )))
2010-01-27 13:50:28 +01:00
addPointPath ( $layerName , $point [ 'latitude' ], $point [ 'longitude' ], $color , ( int ) $point [ 'manual_placement' ], $point [ 'id_tgis_data' ]);
2010-01-19 16:49:34 +01:00
}
2010-01-26 11:13:44 +01:00
}
}
function deleteMapConnection ( $idConectionMap ) {
process_sql_delete ( 'tgis_map_connection' , array ( 'id_tmap_connection' => $idConectionMap ));
//TODO DELETE IN OTHER TABLES
}
function saveMapConnection ( $mapConnection_name , $mapConnection_group ,
$mapConnection_numLevelsZoom , $mapConnection_defaultZoom ,
$mapConnection_defaultLatitude , $mapConnection_defaultLongitude ,
$mapConnection_defaultAltitude , $mapConnection_centerLatitude ,
$mapConnection_centerLongitude , $mapConnection_centerAltitude ,
$mapConnectionData , $idConnectionMap = null ) {
if ( $idConnectionMap !== null ) {
$returnQuery = process_sql_update ( 'tgis_map_connection' ,
array (
'conection_name' => $mapConnection_name ,
'connection_type' => $mapConnectionData [ 'type' ],
'conection_data' => json_encode ( $mapConnectionData ),
'num_zoom_levels' => $mapConnection_numLevelsZoom ,
'default_zoom_level' => $mapConnection_defaultZoom ,
'default_longitude' => $mapConnection_defaultLongitude ,
'default_latitude' => $mapConnection_defaultLatitude ,
'default_altitude' => $mapConnection_defaultAltitude ,
'initial_longitude' => $mapConnection_centerLongitude ,
'initial_latitude' => $mapConnection_centerLatitude ,
'initial_altitude' => $mapConnection_centerAltitude ,
'group_id' => $mapConnection_group
),
array ( 'id_tmap_connection' => $idConnectionMap )
);
}
else {
$returnQuery = process_sql_insert ( 'tgis_map_connection' ,
array (
'conection_name' => $mapConnection_name ,
'connection_type' => $mapConnectionData [ 'type' ],
'conection_data' => json_encode ( $mapConnectionData ),
'num_zoom_levels' => $mapConnection_numLevelsZoom ,
'default_zoom_level' => $mapConnection_defaultZoom ,
'default_longitude' => $mapConnection_defaultLongitude ,
'default_latitude' => $mapConnection_defaultLatitude ,
'default_altitude' => $mapConnection_defaultAltitude ,
'initial_longitude' => $mapConnection_centerLongitude ,
'initial_latitude' => $mapConnection_centerLatitude ,
'initial_altitude' => $mapConnection_centerAltitude ,
'group_id' => $mapConnection_group
)
);
}
return $returnQuery ;
2010-01-19 16:49:34 +01:00
}
2010-01-21 18:08:58 +01:00
2010-01-28 18:58:30 +01:00
/**
* Delete the map in the all tables are related .
*
* @ param $idMap integer The id of map .
* @ return None
*/
function deleteMap ( $idMap ) {
$listIdLayers = get_db_all_rows_sql ( " SELECT id_tmap_layer FROM tgis_map_layer WHERE tgis_map_id_tgis_map = " . $idMap );
if ( $listIdLayers !== false ) {
foreach ( $listIdLayers as $idLayer ) {
process_sql_delete ( 'tgis_map_layer_has_tagente' , array ( 'tgis_map_layer_id_tmap_layer' => $idLayer ));
}
}
process_sql_delete ( 'tgis_map_layer' , array ( 'tgis_map_id_tgis_map' => $idMap ));
process_sql_delete ( 'tgis_map_has_tgis_map_connection' , array ( 'tgis_map_id_tgis_map' => $idMap ));
process_sql_delete ( 'tgis_map' , array ( 'id_tgis_map' => $idMap ));
2010-02-15 12:00:51 +01:00
$numMaps = get_db_num_rows ( 'SELECT * FROM tgis_map' );
2010-01-28 18:58:30 +01:00
clean_cache ();
}
2010-01-27 18:17:41 +01:00
/**
* Save the map into DB , tgis_map and with id_map save the connetions in
* tgis_map_has_tgis_map_connection , and with id_map save the layers in
* tgis_map_layer and witch each id_layer save the agent in this layer in
* table tgis_map_layer_has_tagente .
*
2010-01-27 20:52:53 +01:00
* @ param $map_name
* @ param $map_initial_longitude
* @ param $map_initial_latitude
* @ param $map_initial_altitude
* @ param $map_zoom_level
* @ param $map_background
* @ param $map_default_longitude
* @ param $map_default_latitude
* @ param $map_default_altitude
* @ param $map_group_id
* @ param $map_connection_list
* @ param $arrayLayers
2010-01-27 18:17:41 +01:00
*/
2010-01-28 15:44:57 +01:00
function saveMap ( $map_name , $map_initial_longitude , $map_initial_latitude ,
2010-01-27 16:46:20 +01:00
$map_initial_altitude , $map_zoom_level , $map_background ,
$map_default_longitude , $map_default_latitude , $map_default_altitude ,
$map_group_id , $map_connection_list , $arrayLayers ) {
2010-01-27 18:17:41 +01:00
$idMap = process_sql_insert ( 'tgis_map' ,
array ( 'map_name' => $map_name ,
'initial_longitude' => $map_initial_longitude ,
'initial_latitude' => $map_initial_latitude ,
'initial_altitude' => $map_initial_altitude ,
'zoom_level' => $map_zoom_level ,
'map_background' => $map_background ,
'default_longitude' => $map_default_longitude ,
'default_latitude' => $map_default_latitude ,
'default_altitude' => $map_default_altitude ,
'group_id' => $map_group_id
)
);
2010-02-15 12:00:51 +01:00
$numMaps = get_db_num_rows ( 'SELECT * FROM tgis_map' );
if ( $numMaps == 1 )
process_sql_update ( 'tgis_map' , array ( 'default_map' => 1 ), array ( 'id_tgis_map' => $idMap ));
2010-01-27 18:17:41 +01:00
foreach ( $map_connection_list as $map_connection ) {
process_sql_insert ( 'tgis_map_has_tgis_map_connection' ,
array (
'tgis_map_id_tgis_map' => $idMap ,
2010-05-06 17:53:38 +02:00
'tgis_map_connection_id_tmap_connection' => $map_connection [ 'id_conection' ],
2010-02-10 19:27:24 +01:00
'default_map_connection' => $map_connection [ 'default' ]
2010-01-27 18:17:41 +01:00
)
);
}
foreach ( $arrayLayers as $index => $layer ) {
$idLayer = process_sql_insert ( 'tgis_map_layer' ,
array (
'layer_name' => $layer [ 'layer_name' ],
'view_layer' => $layer [ 'layer_visible' ],
'layer_stack_order' => $index ,
'tgis_map_id_tgis_map' => $idMap ,
'tgrupo_id_grupo' => $layer [ 'layer_group' ]
)
);
2010-04-28 20:59:11 +02:00
if (( isset ( $layer [ 'layer_agent_list' ])) AND ( count ( $layer [ 'layer_agent_list' ]) > 0 )) {
2010-01-27 18:17:41 +01:00
foreach ( $layer [ 'layer_agent_list' ] as $agent_name ) {
process_sql_insert ( 'tgis_map_layer_has_tagente' ,
array (
'tgis_map_layer_id_tmap_layer' => $idLayer ,
'tagente_id_agente' => get_agent_id ( $agent_name )
)
);
}
}
}
2010-01-27 16:46:20 +01:00
}
2010-02-16 16:28:07 +01:00
function 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 ) {
process_sql_update ( 'tgis_map' ,
array ( 'map_name' => $map_name ,
'initial_longitude' => $map_initial_longitude ,
'initial_latitude' => $map_initial_latitude ,
'initial_altitude' => $map_initial_altitude ,
'zoom_level' => $map_zoom_level ,
'map_background' => $map_background ,
'default_longitude' => $map_default_longitude ,
'default_latitude' => $map_default_latitude ,
'default_altitude' => $map_default_altitude ,
'group_id' => $map_group_id
),
array ( 'id_tgis_map' => $idMap ));
process_sql_delete ( 'tgis_map_has_tgis_map_connection' , array ( 'tgis_map_id_tgis_map' => $idMap ));
foreach ( $map_connection_list as $map_connection ) {
process_sql_insert ( 'tgis_map_has_tgis_map_connection' ,
array (
'tgis_map_id_tgis_map' => $idMap ,
2010-05-06 17:53:38 +02:00
'tgis_map_connection_id_tmap_connection' => $map_connection [ 'id_conection' ],
2010-02-16 16:28:07 +01:00
'default_map_connection' => $map_connection [ 'default' ]
)
);
}
$listOldIdLayers = get_db_all_rows_sql ( 'SELECT id_tmap_layer FROM tgis_map_layer WHERE tgis_map_id_tgis_map = ' . $idMap );
if ( $listOldIdLayers == false )
$listOldIdLayers = array ();
foreach ( $listOldIdLayers as $idLayer ) {
process_sql_delete ( 'tgis_map_layer_has_tagente' , array ( 'tgis_map_layer_id_tmap_layer' => $idLayer [ 'id_tmap_layer' ]));
}
process_sql_delete ( 'tgis_map_layer' , array ( 'tgis_map_id_tgis_map' => $idMap ));
foreach ( $arrayLayers as $index => $layer ) {
$idLayer = process_sql_insert ( 'tgis_map_layer' ,
array (
'layer_name' => $layer [ 'layer_name' ],
'view_layer' => $layer [ 'layer_visible' ],
'layer_stack_order' => $index ,
'tgis_map_id_tgis_map' => $idMap ,
'tgrupo_id_grupo' => $layer [ 'layer_group' ]
)
);
if ( array_key_exists ( 'layer_agent_list' , $layer )) {
if ( count ( $layer [ 'layer_agent_list' ]) > 0 ) {
foreach ( $layer [ 'layer_agent_list' ] as $agent_name ) {
process_sql_insert ( 'tgis_map_layer_has_tagente' ,
array (
'tgis_map_layer_id_tmap_layer' => $idLayer ,
'tagente_id_agente' => get_agent_id ( $agent_name )
)
);
}
}
}
}
}
2010-01-27 13:50:28 +01:00
/**
* Get the configuration parameters of a map connection
*
* @ param idConnection : connection identifier for the map
*
* @ result : An array with all the configuration parameters
*/
2010-05-06 17:53:38 +02:00
function getConectionConf ( $idConnection ) {
$confParameters = get_db_row_sql ( 'SELECT * FROM tgis_map_connection WHERE id_tmap_connection = ' . $idConnection );
2010-01-27 13:50:28 +01:00
return $confParameters ;
}
/**
* Shows the map of an agent in a div with the width and heigth given and the history if asked
*
* @ param $agent_id : id of the agent as in the table tagente ;
* @ param $height : heigth in a string in css format
* @ param $width : width in a string in css format
* @ param $show_history : by default or when this parameter is false in the map the path with the
2010-02-10 14:08:33 +01:00
* @ param $centerInAgent boolean Default is true , set the map center in the icon agent .
2010-01-27 13:50:28 +01:00
* @ param $history_time : Number of seconds in the past to show from where to start the history path .
*
2010-03-01 12:17:27 +01:00
* @ return boolean True ok and false fail .
2010-01-27 13:50:28 +01:00
*/
2010-02-10 14:08:33 +01:00
function getAgentMap ( $agent_id , $heigth , $width , $show_history = false , $centerInAgent = true , $history_time = 86400 ) {
2010-02-10 11:16:51 +01:00
$defaultMap = get_db_all_rows_sql ( "
SELECT t1 .* , t3 . conection_name , t3 . connection_type , t3 . conection_data , t3 . num_zoom_levels
FROM tgis_map AS t1 ,
tgis_map_has_tgis_map_connection AS t2 ,
tgis_map_connection AS t3
WHERE t1 . default_map = 1 AND t2 . tgis_map_id_tgis_map = t1 . id_tgis_map
AND t2 . default_map_connection = 1
AND t3 . id_tmap_connection = t2 . tgis_map_connection_id_tmap_connection " );
2010-03-01 12:17:27 +01:00
if ( $defaultMap === false )
return false ;
2010-02-10 11:16:51 +01:00
$defaultMap = $defaultMap [ 0 ];
2010-01-27 13:50:28 +01:00
2010-02-18 14:29:36 +01:00
$agent_position = getDataLastPositionAgent ( $agent_id );
if ( $agent_position === false ) {
$agentPositionLongitude = $defaultMap [ 'default_longitude' ];
$agentPositionLatitude = $defaultMap [ 'default_latitude' ];
$agentPositionAltitude = $defaultMap [ 'default_altitude' ];
}
else {
$agentPositionLongitude = $agent_position [ 'stored_longitude' ];
$agentPositionLatitude = $agent_position [ 'stored_latitude' ];
$agentPositionAltitude = $agent_position [ 'stored_altitude' ];
}
$agent_name = get_agent_name ( $agent_id );
2010-02-10 11:16:51 +01:00
$baselayers [ 0 ][ 'name' ] = $defaultMap [ 'conection_name' ];
2010-03-04 07:01:13 +01:00
$baselayers [ 0 ][ 'num_zoom_levels' ] = $defaultMap [ 'num_zoom_levels' ];
2010-05-12 10:52:25 +02:00
$conectionData = json_decode ( $defaultMap [ 'conection_data' ], true );
$baselayers [ 0 ][ 'typeBaseLayer' ] = $conectionData [ 'type' ];
2010-03-04 18:29:52 +01:00
$controls = array ( 'PanZoomBar' , 'ScaleLine' , 'Navigation' , 'MousePosition' );
2010-05-12 10:52:25 +02:00
$gmap_layer = false ;
switch ( $conectionData [ 'type' ]) {
case 'OSM' :
$baselayers [ 0 ][ 'url' ] = $conectionData [ 'url' ];
break ;
case 'Gmap' :
$baselayers [ 0 ][ 'gmap_type' ] = $conectionData [ 'gmap_type' ];
$baselayers [ 0 ][ 'gmap_key' ] = $conectionData [ 'gmap_key' ];
$gmap_key = $conectionData [ 'gmap_key' ];
// Onece a Gmap base layer is found we mark it to import the API
$gmap_layer = true ;
break ;
case 'Static_Image' :
$baselayers [ 0 ][ 'url' ] = $conectionData [ 'url' ];
$baselayers [ 0 ][ 'bb_left' ] = $conectionData [ 'bb_left' ];
$baselayers [ 0 ][ 'bb_right' ] = $conectionData [ 'bb_right' ];
$baselayers [ 0 ][ 'bb_bottom' ] = $conectionData [ 'bb_bottom' ];
$baselayers [ 0 ][ 'bb_top' ] = $conectionData [ 'bb_top' ];
$baselayers [ 0 ][ 'image_width' ] = $conectionData [ 'image_width' ];
$baselayers [ 0 ][ 'image_height' ] = $conectionData [ 'image_height' ];
break ;
}
if ( $gmap_layer === true ) {
?>
< script type = " text/javascript " src = " http://maps.google.com/maps?file=api&v=2&sensor=false&key=<?php echo $gmap_key ?> " ></ script >
< ? php
}
2010-02-10 11:16:51 +01:00
printMap ( $agent_name . " _agent_map " , $defaultMap [ 'zoom_level' ],
2010-03-08 18:40:23 +01:00
$defaultMap [ 'initial_latitude' ],
2010-02-10 11:16:51 +01:00
$defaultMap [ 'initial_longitude' ], $baselayers , $controls );
2010-01-27 13:50:28 +01:00
makeLayer ( " layer_for_agent_ " . $agent_name );
2010-02-10 11:16:51 +01:00
2010-02-23 13:12:41 +01:00
$agent_icon = get_agent_icon_map ( $agent_id , true );
2010-02-24 14:42:01 +01:00
$status = get_agent_status ( $agent_id );
2010-03-03 11:34:35 +01:00
2010-02-18 17:54:24 +01:00
/* If show_history is true, show the path of the agent */
2010-01-27 13:50:28 +01:00
if ( $show_history ) {
2010-03-03 11:34:35 +01:00
$lastPosition = array ( 'longitude' => $agentPositionLongitude , 'latitude' => $agentPositionLatitude );
addPath ( " layer_for_agent_ " . $agent_name , $agent_id , $lastPosition , $history_time );
2010-01-27 13:50:28 +01:00
}
2010-02-18 17:54:24 +01:00
2010-02-25 18:27:55 +01:00
addAgentPoint ( " layer_for_agent_ " . $agent_name , $agent_name , $agentPositionLatitude , $agentPositionLongitude , $agent_icon , 20 , 20 , $agent_id , $status , 'point_agent_info' );
2010-02-10 14:08:33 +01:00
if ( $centerInAgent ) {
?>
< script type = " text/javascript " >
$ ( document ) . ready (
function () {
2010-02-18 14:29:36 +01:00
var lonlat = new OpenLayers . LonLat ( < ? php echo $agentPositionLongitude ; ?> , <?php echo $agentPositionLatitude; ?>)
2010-02-10 14:08:33 +01:00
. transform ( map . displayProjection , map . getProjectionObject ());
map . setCenter ( lonlat , < ? php echo $defaultMap [ 'zoom_level' ]; ?> , false, false);
});
</ script >
< ? php
}
2010-03-01 12:17:27 +01:00
return true ;
2010-01-27 13:50:28 +01:00
}
2010-02-04 11:34:30 +01:00
/**
* Return a array of images as icons in the / pandora_console / images / gis_map / icons .
*
* @ param boolean $fullpath Return as image . png or full path .
*
* @ return Array The array is [ N ][ 3 ], where the N index is name base of icon and [ N ][ 'ok' ] ok image , [ N ][ 'bad' ] bad image , [ N ][ 'warning' ] warning image and [ N ][ ' default ] default image
*/
function getArrayListIcons ( $fullpath = true ) {
$return = array ();
$validExtensions = array ( 'jpg' , 'jpeg' , 'gif' , 'png' );
$path = '' ;
if ( $fullpath )
$path = 'images/gis_map/icons/' ;
$dir = scandir ( 'images/gis_map/icons/' );
foreach ( $dir as $index => $item ) {
$chunks = explode ( '.' , $item );
$extension = end ( $chunks );
if ( ! in_array ( $extension , $validExtensions ))
unset ( $dir [ $index ]);
}
foreach ( $dir as $item ) {
$chunks = explode ( '.' , $item );
$extension = end ( $chunks );
$nameWithoutExtension = str_replace ( " . " . $extension , " " , $item );
2010-02-22 17:13:12 +01:00
$nameClean = str_replace ( array ( '.bad' , '.ok' , '.warning' , '.default' ), " " , $nameWithoutExtension );
2010-02-04 11:34:30 +01:00
2010-02-22 17:13:12 +01:00
$return [ $nameClean ][ 'ok' ] = $path . $nameClean . '.ok.png' ;
$return [ $nameClean ][ 'bad' ] = $path . $nameClean . '.bad.png' ;
$return [ $nameClean ][ 'warning' ] = $path . $nameClean . '.warning.png' ;
$return [ $nameClean ][ 'default' ] = $path . $nameClean . '.default.png' ;
2010-02-04 11:34:30 +01:00
}
return $return ;
}
2010-02-16 16:28:07 +01:00
function validateMapData ( $map_name , $map_zoom_level ,
$map_initial_longitude , $map_initial_latitude , $map_initial_altitude ,
$map_default_longitude , $map_default_latitude , $map_default_altitude ,
2010-02-26 12:20:15 +01:00
$map_connection_list , $map_levels_zoom ) {
2010-02-16 16:28:07 +01:00
$invalidFields = array ();
echo " <style type='text/css'> " ;
//validateMap
if ( $map_name == '' ) {
echo " input[name=map_name] { background: #FF5050;} " ;
$invalidFields [ 'map_name' ] = true ;
}
//validate zoom level
2010-02-26 12:20:15 +01:00
if (( $map_zoom_level == '' ) || ( $map_zoom_level > $map_levels_zoom )) {
2010-02-16 16:28:07 +01:00
echo " input[name=map_zoom_level] { background: #FF5050;} " ;
$invalidFields [ 'map_zoom_level' ] = true ;
}
//validate map_initial_longitude
if ( $map_initial_longitude == '' ) {
echo " input[name=map_initial_longitude] { background: #FF5050;} " ;
$invalidFields [ 'map_initial_longitude' ] = true ;
}
//validate map_initial_latitude
if ( $map_initial_latitude == '' ) {
echo " input[name=map_initial_latitude] { background: #FF5050;} " ;
$invalidFields [ 'map_initial_latitude' ] = true ;
}
//validate map_initial_altitude
if ( $map_initial_altitude == '' ) {
echo " input[name=map_initial_altitude] { background: #FF5050;} " ;
$invalidFields [ 'map_initial_altitude' ] = true ;
}
//validate map_default_longitude
if ( $map_default_longitude == '' ) {
echo " input[name=map_default_longitude] { background: #FF5050;} " ;
$invalidFields [ 'map_default_longitude' ] = true ;
}
//validate map_default_latitude
if ( $map_default_latitude == '' ) {
echo " input[name=map_default_latitude] { background: #FF5050;} " ;
$invalidFields [ 'map_default_latitude' ] = true ;
}
//validate map_default_altitude
if ( $map_default_altitude == '' ) {
echo " input[name=map_default_altitude] { background: #FF5050;} " ;
$invalidFields [ 'map_default_altitude' ] = true ;
}
//validate map_default_altitude
if ( $map_connection_list == '' ) {
$invalidFields [ 'map_connection_list' ] = true ;
}
echo " </style> " ;
return $invalidFields ;
}
/**
* Get all data ( connections , layers with agents ) of a map passed as id .
*
* @ param integer $idMap The id of map in database .
*
* @ return Array Return a asociative array whith the items 'map' , 'connections' and 'layers' . And in 'layers' has data and item 'agents' .
*/
function getMapData ( $idMap ) {
$returnVar = array ();
$map = get_db_row ( 'tgis_map' , 'id_tgis_map' , $idMap );
2010-02-26 12:20:15 +01:00
$connections = get_db_all_rows_sql ( ' SELECT t1 . tgis_map_connection_id_tmap_connection AS id_conection ,
t1 . default_map_connection AS `default` ,
( SELECT t2 . num_zoom_levels
FROM tgis_map_connection AS t2 WHERE t2 . id_tmap_connection = t1 . tgis_map_connection_id_tmap_connection ) AS num_zoom_levels
FROM tgis_map_has_tgis_map_connection AS t1 WHERE t1 . tgis_map_id_tgis_map = '. $map[' id_tgis_map ' ]);
2010-02-16 16:28:07 +01:00
$layers = get_db_all_rows_sql ( 'SELECT id_tmap_layer, layer_name, tgrupo_id_grupo AS layer_group, view_layer AS layer_visible FROM tgis_map_layer WHERE tgis_map_id_tgis_map = ' . $map [ 'id_tgis_map' ]);
if ( $layers === false ) $layers = array ();
foreach ( $layers as $index => $layer ) {
$agents = get_db_all_rows_sql ( ' SELECT nombre
FROM tagente
WHERE id_agente IN ( SELECT tagente_id_agente FROM tgis_map_layer_has_tagente WHERE tgis_map_layer_id_tmap_layer = ' . $layer[' id_tmap_layer '] . ' ) ' );
if ( $agents !== false )
$layers [ $index ][ 'layer_agent_list' ] = $agents ;
else
$layers [ $index ][ 'layer_agent_list' ] = array ();
}
$returnVar [ 'map' ] = $map ;
$returnVar [ 'connections' ] = $connections ;
$returnVar [ 'layers' ] = $layers ;
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 connections .
*
* @ param Array $map_connection_list The list of map connections for convert a html .
*
* @ return String The html source code .
*/
function addConectionMapsInForm ( $map_connection_list ) {
$returnVar = '' ;
foreach ( $map_connection_list as $mapConnection ) {
$mapConnectionRowDB = getMapConnection ( $mapConnection [ 'id_conection' ]);
if ( $mapConnection [ 'default' ]) {
$radioButton = print_radio_button_extended ( 'map_connection_default' , $mapConnection [ 'id_conection' ], '' , $mapConnection [ 'id_conection' ], false , 'changeDefaultConection(this.value)' , '' , true );
}
else
$radioButton = print_radio_button_extended ( 'map_connection_default' , $mapConnection [ 'id_conection' ], '' , null , false , 'changeDefaultConection(this.value)' , '' , true );
$returnVar .= '
< tbody id = " map_connection_' . $mapConnection['id_conection'] . ' " >
< tr class = " row_0 " >
< td > ' . print_input_text (' map_connection_name_ ' . $mapConnection[' id_conection '], $mapConnectionRowDB[' conection_name '], ' ', 20, 40, true, true) . ' </ td >
< td > ' . $radioButton . ' </ td >
2011-02-04 14:30:50 +01:00
< td >< a id = " delete_row " href = " javascript: deleteConnectionMap( \ '' . $mapConnection['id_conection'] . ' \ ') " > ' . print_image("images/cross.png", true, array("alt" => "")) . ' </ a ></ td >
2010-02-16 16:28:07 +01:00
</ tr >
</ tbody >
< script type = " text/javascript " >
connectionMaps . push ( ' . $mapConnection[' id_conection '] . ' );
</ script >
' ;
}
return $returnVar ;
}
2010-02-26 12:20:15 +01:00
/**
* From a list of connection maps , extract the num levels zooom
*
* @ param array $map_connection_list The list of connections maps .
*
* @ return integer The num zoom levels .
*/
function getNumZoomLevelsOfConnectionDefault ( $map_connection_list ) {
foreach ( $map_connection_list as $connection ) {
if ( $connection [ 'default' ]) {
return $connection [ 'num_zoom_levels' ];
}
}
}
2010-02-16 16:28:07 +01:00
/**
* 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 .= '
< tbody id = " layer_item_' . $count . ' " >
< tr >
< td class = " col1 " > ' . $layer[' layer_name '] . ' </ td >
2011-02-04 14:30:50 +01:00
< td class = " up_arrow " >< a id = " up_arrow " href = " javascript: upLayer(' . $count . '); " > ' . print_image("images/up.png", true, array("alt" => "")) . ' </ a ></ td >
< td class = " down_arrow " >< a id = " down_arrow " href = " javascript: downLayer(' . $count . '); " > ' . print_image("images/down.png", true, array("alt" => "")) . ' </ a ></ td >
2010-02-16 16:28:07 +01:00
< td class = " col3 " >
2011-02-04 14:30:50 +01:00
< a id = " edit_layer " href = " javascript: editLayer(' . $count . '); " > ' . print_image("images/config.png", true, array("alt" => "")) . ' </ a >
2010-02-16 16:28:07 +01:00
</ td >
< td class = " col4 " >
< input type = " hidden " name = " layer_values_' . $count . ' " value = \ '' . $layerDataJSON . '\' id="layer_values_' . $count . ' " />
2011-02-04 14:30:50 +01:00
< a id = " delete_row " href = " javascript: deleteLayer(' . $count . ') " > ' . print_image("images/cross.png", true, array("alt" => "")) . ' </ a >
2010-02-16 16:28:07 +01:00
</ td >
</ tr >
</ tbody >
< script type = " text/javascript " >
layerList . push ( countLayer );
countLayer ++ ;
updateArrowLayers ();
</ script > ' ;
$count ++ ;
}
return $returnVar ;
}
2010-01-27 13:50:28 +01:00
?>