Ignore:
Timestamp:
May 30, 2012, 7:57:34 AM (12 years ago)
Author:
psli
Message:

Pre-Version 2.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Psli_BingMaps/include/guest.inc.php

    r14891 r15432  
    33Plugin Name: Psli-BingMaps
    44Author: psli
    5 Description: Admin function for plugin "Psli-BingMaps"
    65*/
    76
     
    1817$row = pwg_db_fetch_assoc($result);
    1918$conf[PSLI_CONF_KEY] = $row['value'];
    20 $query = '
    21         SELECT value
    22                 FROM '.CONFIG_TABLE.'
    23                 WHERE param = "'.PSLI_CONF_LAT.'";';
    24 $result = pwg_query($query);
    25 $row = pwg_db_fetch_assoc($result);
    26 $conf[PSLI_CONF_LAT] = $row['value'];
    27 $query = '
    28         SELECT value
    29                 FROM '.CONFIG_TABLE.'
    30                 WHERE param = "'.PSLI_CONF_LON.'";';
    31 $result = pwg_query($query);
    32 $row = pwg_db_fetch_assoc($result);
    33 $conf[PSLI_CONF_LON] = $row['value'];
    34 $query = '
    35         SELECT value
    36                 FROM '.CONFIG_TABLE.'
    37                 WHERE param = "'.PSLI_CONF_ZOOM.'";';
    38 $result = pwg_query($query);
    39 $row = pwg_db_fetch_assoc($result);
    40 $conf[PSLI_CONF_ZOOM] = $row['value'];
    41 $query = '
    42         SELECT value
    43                 FROM '.CONFIG_TABLE.'
    44                 WHERE param = "'.PSLI_CONF_CATEGORY.'";';
    45 $result = pwg_query($query);
    46 $row = pwg_db_fetch_assoc($result);
    47 $conf[PSLI_CONF_CATEGORY] = $row['value'];
    4819
    4920$conf['psli_already_done'] = false;
     
    6233        if (! (strpos($_SERVER['HTTP_USER_AGENT'],"MSIE 6.0") === FALSE))
    6334                return $desc;
     35       
     36        if (isset($page['category']['id']))
     37        {
     38                $query = '
     39                        SELECT id, lat, lon, zoom
     40                                FROM '.PSLI_MAPS_TABLE.'
     41                                WHERE id_category = '.$page['category']['id'].';';
     42                $result = pwg_query($query);
     43        }
    6444               
    6545        // First test album to control availabilty of the map
    66         if ((isset($page['category']['id'])) and  ($page['category']['id'] == $conf[PSLI_CONF_CATEGORY]) and ($conf['psli_already_done'] == false))
     46        if ((isset($page['category']['id'])) and  (pwg_db_num_rows($result) > 0) and ($conf['psli_already_done'] == false))
    6747        {       
    68        
     48                // Set data for this map
     49                $row = pwg_db_fetch_assoc($result);
     50                $lon_initiale = $row['lon'];
     51                $zoom_initiale = $row['zoom'];
     52                $lat_initiale = $row['lat'];
     53                $id_initiale = $row['id'];
     54               
    6955                // Language data
    7056                load_language('plugin.lang', PSLI_BINGMAPS_TEMPLATE_PATH);
     
    8268<script>
    8369psli_g_BingKey = "'.$conf[PSLI_CONF_KEY].'";
    84 psli_g_zoomInitial = '.$conf[PSLI_CONF_ZOOM].';
    85 psli_g_MapCenter = new Microsoft.Maps.Location('.$conf[PSLI_CONF_LAT].', '.$conf[PSLI_CONF_LON].')'."\n";
     70psli_g_zoomInitial = '.$zoom_initiale.';
     71psli_g_MapCenter = new Microsoft.Maps.Location('.$lat_initiale.', '.$lon_initiale.')'."\n";
    8672
    8773       
    8874                $query_entities = '
    89                         SELECT id, lat, lon, zoomMin, zoomMax, action, title, id_category
    90                           FROM '.PSLI_ENTITIES_TABLE.';';
     75                        SELECT e.id id, lat, lon, zoomMin, zoomMax, action, id_action, title, type
     76                          FROM '.PSLI_ENTITIES_TABLE.' e left join '.PSLI_ENTITIES_MAPS_TABLE.' j ON e.id = j.id_entity
     77                          WHERE j.id_map = '.$id_initiale.';';
    9178                $result_entities = pwg_query($query_entities);
    9279               
     
    10087                        // For each sub category
    10188                        while ($entity = pwg_db_fetch_assoc($result_entities))
    102                         {                                       
    103                                 $query_datapoint = '
    104                                         SELECT lat, lon
    105                                                 FROM '.PSLI_DATAPOINT_TABLE.'
    106                                                 WHERE id_entity = '.$entity['id'].' ORDER BY id;';
    107                                 $result_datapoint = pwg_query($query_datapoint);
    108                                 if (pwg_db_num_rows($result_datapoint) > 0)
    109                                 {
    110                                         $desc_data .= 'var psli_t_Vertices'.$entity['id'].' = new Array();'."\n";
    111                                         while ($row = pwg_db_fetch_assoc($result_datapoint))
     89                        {       
     90                                if ($entity['id_action'] != 0)
     91                                {       
     92                                        if ($entity['type'] == 2)
    11293                                        {
    113                                                 $desc_data .= 'psli_t_Vertices'.$entity['id'].'.push(new Microsoft.Maps.Location('.$row['lat'].','.$row['lon'].'));'."\n";
     94                                                $query_datapoint = '
     95                                                        SELECT lat, lon
     96                                                                FROM '.PSLI_DATAPOINT_TABLE.'
     97                                                                WHERE id_entity = '.$entity['id'].' ORDER BY id;';
     98                                                $result_datapoint = pwg_query($query_datapoint);
     99                                                if (pwg_db_num_rows($result_datapoint) > 0)
     100                                                {
     101                                                        $desc_data .= 'var psli_t_Vertices'.$entity['id'].' = new Array();'."\n";
     102                                                        while ($row = pwg_db_fetch_assoc($result_datapoint))
     103                                                        {
     104                                                                $desc_data .= 'psli_t_Vertices'.$entity['id'].'.push(new Microsoft.Maps.Location('.$row['lat'].','.$row['lon'].'));'."\n";
     105                                                        }
     106                                                        $desc_data .= '
     107var psli_t_Child'.$entity['id'].' = new Microsoft.Maps.Polygon(psli_t_Vertices'.$entity['id'].',{fillColor: psli_g_PolygonColor, strokeColor: psli_g_PolygonColor});'."\n";
     108
     109                                                        $desc_function_mouse_over .= '
     110function psli_MapsMouseOver_'.$entity['id'].' (e) {
     111  document.getElementById("Coordonates").innerHTML = "'.l10n('Click to zoom on')." ".$entity['title'].'";
     112}'."\n";
     113                                                }
    114114                                        }
     115                                        else
     116                                        {
     117                                                $desc_data .= '
     118var psli_t_Child'.$entity['id'].' = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location('.$entity['lat'].','.$entity['lon'].'));'."\n";
     119
     120                                                $desc_function_mouse_over .= '
     121function psli_MapsMouseOver_'.$entity['id'].' (e) {
     122  document.getElementById("Coordonates").innerHTML = "'.l10n('Click to show pictures of')." ".$entity['title'].'";
     123}'."\n";
     124                                        }
     125                                       
    115126                                        $desc_data .= '
    116         var psli_t_Child'.$entity['id'].' = new Microsoft.Maps.Polygon(psli_t_Vertices'.$entity['id'].',{fillColor: psli_g_PolygonColor, strokeColor: psli_g_PolygonColor});'."\n";
    117 
    118                                         $desc_function_mouse_over .= '
    119         function psli_MapsMouseOver_'.$entity['id'].' (e) {
    120           document.getElementById("Coordonates").innerHTML = "'.l10n('Cliquez pour zoomer sur').$entity['title'].'";
    121         }'."\n";
    122                                 }
    123                                 else
    124                                 {
    125                                         $desc_data .= '
    126         var psli_t_Child'.$entity['id'].' = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location('.$entity['lat'].','.$entity['lon'].'));'."\n";
    127 
    128                                         $desc_function_mouse_over .= '
    129         function psli_MapsMouseOver_'.$entity['id'].' (e) {
    130           document.getElementById("Coordonates").innerHTML = "'.l10n('Cliquez pour acceder aux photos').$entity['title'].'";
    131         }'."\n";
    132                                 }
     127Microsoft.Maps.Events.addHandler(psli_t_Child'.$entity['id'].', "mouseover", psli_MapsMouseOver_'.$entity['id'].');
     128Microsoft.Maps.Events.addHandler(psli_t_Child'.$entity['id'].', "mouseout", psli_MapsMouseOut);
     129Microsoft.Maps.Events.addHandler(psli_t_Child'.$entity['id'].', "click", psli_MapsClick_'.$entity['id'].');'."\n";
     130               
     131                                        switch ($entity['action'])
     132                                        {
     133                                                case 1:
     134                                                        $desc_function_click .= '
     135function psli_MapsClick_'.$entity['id'].' (e) {
     136        psli_g_Map.setView({zoom:'.$entity['id_action'].', center: new Microsoft.Maps.Location('.$entity['lat'].', '.$entity['lon'].')});
     137}'."\n";
     138                                                        break;
     139                                                case 2:
     140                                                        $desc_function_click .= '
     141function psli_MapsClick_'.$entity['id'].' (e) {
     142        document.location.href=\'index.php?/category/'.$entity['id_action'].'\';
     143}'."\n";
     144                                                        break;
     145                                                case 3:
     146                                                        $desc_function_click .= '
     147function psli_MapsClick_'.$entity['id'].' (e) {
     148  document.location.href=\'picture.php?/'.$entity['id_action'].'\';
     149}'."\n";
     150                                                        break;                         
     151                                        }
    133152                               
    134                                 $desc_data .= '
    135         Microsoft.Maps.Events.addHandler(psli_t_Child'.$entity['id'].', "mouseover", psli_MapsMouseOver_'.$entity['id'].');
    136         Microsoft.Maps.Events.addHandler(psli_t_Child'.$entity['id'].', "mouseout", psli_MapsMouseOut);
    137         Microsoft.Maps.Events.addHandler(psli_t_Child'.$entity['id'].', "click", psli_MapsClick_'.$entity['id'].');'."\n";
    138        
    139                                 if ($entity['action'] == 0)
    140                                 {
    141                                         $desc_function_click .= '
    142 function psli_MapsClick_'.$entity['id'].' (e) {
    143   document.location.href=\'index.php?/category/'.$entity['id_category'].'\';
    144 }'."\n";
    145                                 }
    146                                 else   
    147                                 {
    148                                         $desc_function_click .= '
    149 function psli_MapsClick_'.$entity['id'].' (e) {
    150   psli_g_Map.setView({zoom:'.$entity['action'].', center: new Microsoft.Maps.Location('.$entity['lat'].', '.$entity['lon'].')});
    151 }'."\n";
    152                                 }
    153                        
    154                                 for ($i = $entity['zoomMin']; $i <= $entity['zoomMax']; $i++)
    155                                 {
    156                                         $desc_data .= 'psli_g_ZoomEntity['.($i - 1).'].push(psli_t_Child'.$entity['id'].');'."\n";
     153                                        for ($i = $entity['zoomMin']; $i <= $entity['zoomMax']; $i++)
     154                                        {
     155                                                $desc_data .= 'psli_g_ZoomEntity['.($i - 1).'].push(psli_t_Child'.$entity['id'].');'."\n";
     156                                        }
    157157                                }
    158158                        }
Note: See TracChangeset for help on using the changeset viewer.