Changeset 574


Ignore:
Timestamp:
Sep 29, 2013, 2:38:34 PM (11 years ago)
Author:
chronos
Message:
  • Upraveno: Pozice na mapě se nyní uchovávají v databázi v položce typu varchar(255) namísto dvou desetinných míst.
  • Přidáno: Nově lze vybrat při úpravě formuláře polohu přímo v mapě.
  • Upraveno: Akce zobrazení v mapě nyní zobrazuje polohu pomocí google maps.
  • Přidáno: Pro podporu více mapových systémů definována obecná třída MapApi.
Location:
trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Form/Types/String.php

    r548 r574  
    1515  function OnEdit($Item)
    1616  {
    17     $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
     17    $Output = '<input type="text" name="'.$Item['Name'].'" id="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
    1818    return($Output);
    1919  }
  • trunk/Common/Form/Types/Type.php

    r548 r574  
    8686 
    8787    $Type['Name'] = $Name;
     88    $Type['Class'] = $Name;
    8889    if(array_key_exists('Parameters', $Type))
    8990      $Type['Parameters'] = array_merge($Type['Parameters'], $Parameters);
  • trunk/Common/Version.php

    r573 r574  
    11<?php
    22
    3 $Revision = 572; // Subversion revision
    4 $DatabaseRevision = 571; // SQL structure revision
    5 $ReleaseTime = '2013-09-26';
     3$Revision = 574; // Subversion revision
     4$DatabaseRevision = 574; // SQL structure revision
     5$ReleaseTime = '2013-09-29';
  • trunk/Modules/IS/IS.php

    r561 r574  
    2727    if($Action == 'list') $Content = $this->ShowList($Table);
    2828    else if($Action == 'select') $Content = $this->ShowSelect($Table);
     29    else if($Action == 'mapselect') $Content = $this->ShowMapSelect($Table);
    2930    else if($Action == 'edit') $Content = $this->ShowEdit($Table, $ItemId);
    3031    else if($Action == 'add') $Content = $this->ShowAdd($Table);
     
    380381    $this->BasicHTML = true;
    381382    $this->HideMenu = true;
    382     $RowActions = '<a href="javascript:window.close();" onclick="set_return(#RowId,&quot;'.$_GET['r'].'&quot;);"><img alt="Vybrat" title="Vybrat" src="'.
     383    $RowActions = '<a href="javascript:window.close();" onclick="set_return(#RowId,&quot;'.
     384      $_GET['r'].'&quot;);"><img alt="Vybrat" title="Vybrat" src="'.
    383385      $this->System->Link('/images/select.png').'"/></a>';
    384386    $Output = $this->ShowTable($Table, $Filter, $Title, $RowActions);   
     387    return($Output);
     388  }   
     389 
     390  function ShowMapSelect($Table, $Filter = '', $Title = '')
     391  {
     392    $MapApi = new MapApiGoogle($this->System);
     393    $MapApi->Position = array('Lat' => $this->System->Config['Map']['DefaultLatitude'],
     394      'Lng' => $this->System->Config['Map']['DefaultLongitude']);
     395    $MapApi->Zoom = $this->System->Config['Map']['DefaultZoom'];
     396    $MapApi->Key = $this->System->Config['Map']['GoogleMapsApiKey'];
     397    $MapApi->OnClickObject = $_GET['r'];
     398    //$MapApi->ShowMarker = true;
     399    $Output = $MapApi->ShowPage($this);
    385400    return($Output);
    386401  }   
  • trunk/Modules/Map/Map.php

    r566 r574  
    11<?php
    22
    3 include_once(dirname(__FILE__).'/../../Common/Global.php');
     3include_once(dirname(__FILE__).'/MapAPI.php');
    44
    55class PageNetworkMap extends Page
     
    1515    if(count($this->System->PathItems) > 1)
    1616    {
    17       if($this->System->PathItems[1] == 'show-position')
    18       {
    19         $DbResult = $this->Database->select('MapPosition', '*', 'Id='.$_GET['i']);
    20         if($DbResult->num_rows > 0)
    21         {
    22           $DbRow = $DbResult->fetch_assoc();
    23           Header('Location: http://www.mapy.cz/#!x='.$DbRow['Longitude'].'&y='.
    24             $DbRow['Latitude'].'&z=17&t=s&l=15&d=user_'.$DbRow['Longitude'].'%2C'.
    25             $DbRow['Latitude'].'%2C'.$DbRow['Name'].'~%0A_1');
    26           return('Přesměrování na http://www.mapy.cz/');
    27         } else return('Položka nenalezena');
    28         return('');
    29       }
     17      if($this->System->PathItems[1] == 'show-position') return($this->ShowPosition());
    3018      else return(PAGE_NOT_FOUND);
    3119    } else return($this->ShowMain());
    3220  }
    3321 
     22  function ShowPosition()
     23  {
     24    $DbResult = $this->Database->select('MapPosition', '*', 'Id='.$_GET['i']);
     25    if($DbResult->num_rows > 0)
     26    {
     27      $DbRow = $DbResult->fetch_assoc();
     28      $Pos = explode(';', $DbRow['Pos']);
     29      $MapApi = new MapApiGoogle($this->System);
     30      $MapApi->Position = array('Lat' => $Pos[0], 'Lng' => $Pos[1]);
     31      $MapApi->Zoom = 18;
     32      $MapApi->Key = $this->System->Config['Map']['GoogleMapsApiKey'];
     33      $MapApi->ShowMarker = true;
     34      $MapApi->MarkerText = $DbRow['Name'];
     35      $Output = $MapApi->ShowPage($this);
     36      return($Output);
     37    } else return('Položka nenalezena');
     38  }
     39 
    3440  function ShowMain()
    3541  {
    36     $Output = '<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=true&amp;key='.$this->System->Config['Web']['GoogleMapsApiKey'].'"
     42    $Output = '<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=true&amp;key='.
     43    $this->System->Config['Map']['GoogleMapsApiKey'].'"
    3744    type="text/javascript">
    3845  </script>';
     
    6067tinyIcon.shadowSize = new GSize(10, 10);
    6168tinyIcon.iconAnchor = new GPoint(5, 5);
    62 tinyIcon.infoWindowAnchor = new GPoint(5, 1);';
    63    
    64     $Output .= '   
     69tinyIcon.infoWindowAnchor = new GPoint(5, 1);
     70   
     71        toggleLabel(\'NetworkLinks\');
     72        toggleLabel(\'NetworkDevices\');';
     73   
     74            $Output .= '   
    6575       }     
    6676    }
     
    8191    while($Link = $DbResult->fetch_assoc())
    8292    {
    83       $DbResult2 = $this->Database->query('SELECT NetworkDevice.Used, MapPosition.Latitude, MapPosition.Longitude FROM NetworkDevice JOIN MapPosition ON MapPosition.Id = NetworkDevice.MapPosition WHERE NetworkDevice.Id = (SELECT NetworkInterface.Device FROM NetworkInterface WHERE NetworkInterface.Id = '.$Link['Interface1'].')');
    84       $DbResult3 = $this->Database->query('SELECT NetworkDevice.Used, MapPosition.Latitude, MapPosition.Longitude FROM NetworkDevice JOIN MapPosition ON MapPosition.Id = NetworkDevice.MapPosition WHERE NetworkDevice.Id = (SELECT NetworkInterface.Device FROM NetworkInterface WHERE NetworkInterface.Id = '.$Link['Interface2'].')');
     93      $DbResult2 = $this->Database->query('SELECT NetworkDevice.Used, MapPosition.Pos FROM NetworkDevice '.
     94        'JOIN MapPosition ON MapPosition.Id = NetworkDevice.MapPosition '.
     95        'WHERE NetworkDevice.Id = (SELECT NetworkInterface.Device FROM NetworkInterface WHERE NetworkInterface.Id = '.$Link['Interface1'].')');
     96      $DbResult3 = $this->Database->query('SELECT NetworkDevice.Used, MapPosition.Pos FROM NetworkDevice '.
     97        'JOIN MapPosition ON MapPosition.Id = NetworkDevice.MapPosition '.
     98        'WHERE NetworkDevice.Id = (SELECT NetworkInterface.Device FROM NetworkInterface WHERE NetworkInterface.Id = '.$Link['Interface2'].')');
    8599      if(($DbResult2->num_rows > 0) and ($DbResult3->num_rows > 0))
    86100      {
    87101        $Device1 = $DbResult2->fetch_assoc();
     102        $Pos1 = explode(';', $Device1['Pos']);
    88103        $Device2 = $DbResult3->fetch_assoc();
     104        $Pos2 = explode(';', $Device2['Pos']);
    89105        if(($Device1['Used'] == 1) and ($Device2['Used'] == 1))
    90           $Output .= 'new GPolyline([new GLatLng('.$Device1['Latitude'].', '.$Device1['Longitude'].'),new GLatLng('.$Device2['Latitude'].', '.$Device2['Longitude'].')], "#4F4FBF", 3, 0.8), ';
     106          $Output .= 'new GPolyline([new GLatLng('.$Pos1[0].', '.
     107        $Pos1[1].'),new GLatLng('.$Pos2[0].', '.$Pos2[1].')], "#4F4FBF", 3, 0.8), ';
    91108      }
    92109    }
     
    120137
    121138    $DbResult = $this->Database->query('SELECT GROUP_CONCAT(NetworkDevice.Name SEPARATOR ",") AS Name, '.
    122       'MapPosition.Latitude AS Latitude, MapPosition.Longitude AS Longitude, MapPosition.Name AS NodeName '.
     139      'MapPosition.Pos AS Pos, MapPosition.Name AS NodeName '.
    123140      'FROM NetworkDevice LEFT JOIN MapPosition ON MapPosition.Id = NetworkDevice.MapPosition '.
    124141      'WHERE (NetworkDevice.Used=1) AND (NetworkDevice.MapPosition IS NOT NULL) '.
     
    126143    while($Device = $DbResult->fetch_assoc())
    127144    {
    128       $Output .= 'new GMarker(new GLatLng('.$Device['Latitude'].', '.
    129       $Device['Longitude'].'), {title: "'.$Device['NodeName'].': '.$Device['Name'].'", icon:tinyIcon }), ';
     145      $Pos = explode(';', $Device['Pos']);
     146      $Output .= 'new GMarker(new GLatLng('.$Pos[0].', '.
     147      $Pos[1].'), {title: "'.$Device['NodeName'].': '.$Device['Name'].'", icon:tinyIcon }), ';
    130148    }
    131149    $Output .= '];
     
    141159                        NetworkDevices[i] = null;
    142160                }
    143         }
     161        }       
    144162}
    145163
     
    151169    <td style="width: 20%">
    152170    <form>
    153     <input type="checkbox" id="NetworkLinks" onClick="UpdateNetworkLinks();" >
     171    <input type="checkbox" id="NetworkLinks" onClick="UpdateNetworkLinks();">
    154172       <a href="" onClick="toggleLabel(\'NetworkLinks\');return false;">Ukázat spoje</a>
    155173       </input><br />
    156     <input type="checkbox" id="NetworkDevices" onClick="UpdateNetworkDevices();" >
     174    <input type="checkbox" id="NetworkDevices" onClick="UpdateNetworkDevices();">
    157175       <a href="" onClick="toggleLabel(\'NetworkDevices\');return false;">Ukázat zařízení</a>
    158176       </input>
     
    160178                  </tr>
    161179                </table>';
     180    return($Output);
     181  }
     182}
     183
     184class TypeMapPosition extends TypeString
     185{
     186  function OnEdit($Item)
     187  {
     188    $Output = parent::OnEdit($Item);
     189    if($this->FormManager->ShowRelation)
     190      $Output .=  '<img src="'.$this->FormManager->Root.'/images/select.png" alf="Vybrat" language="javascript" '.
     191        'onclick="return popupwindow(&quot;'.$this->FormManager->Root.'/is/?a=mapselect&amp;r='.
     192        $Item['Name'].'&quot;,&quot;test&quot;);" style="cursor:hand;cursor:pointer"/>';
    162193    return($Output);
    163194  }
     
    182213    parent::Start();
    183214    $this->System->Pages['map'] = 'PageNetworkMap';
     215    $this->System->FormManager->Type->RegisterType('MapPosition', 'String', array());
    184216    $this->System->FormManager->RegisterClass('MapPosition', array(
    185217      'Title' => 'Pozice na mapě',
     
    187219      'Items' => array(
    188220        'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
    189         'Latitude' => array('Type' => 'Float', 'Caption' => 'Zeměpisná šířka', 'Default' => '0'),
    190         'Longitude' => array('Type' => 'Float', 'Caption' => 'Zeměpisná výška', 'Default' => '0'),
     221        'Pos' => array('Type' => 'MapPosition', 'Caption' => 'Poloha', 'Default' => '0;0'),
    191222      ),
    192223      'ItemActions' => array(
  • trunk/admin/DefaultConfig.php

    r548 r574  
    2929  array('Name' => 'Web/News/Count', 'Type' => 'Integer', 'Default' => '5', 'Title' => 'Počet zobrazovaných aktualit na skupinu'),
    3030  array('Name' => 'Web/News/DirectoryId', 'Type' => 'Integer', 'Default' => '1', 'Title' => 'Id adresáře souborů příloh aktualit'),
    31   array('Name' => 'Web/GoogleMapsApiKey', 'Type' => 'String', 'Default' => '', 'Title' => 'API google map'),
     31  array('Name' => 'Map/GoogleMapsApiKey', 'Type' => 'String', 'Default' => '', 'Title' => 'API google map'),
     32  array('Name' => 'Map/DefaultLatitude', 'Type' => 'Float', 'Default' => '49.260422', 'Title' => 'Výchozí pozice na mapě'),
     33  array('Name' => 'Map/DefaultLongitude', 'Type' => 'Float', 'Default' => '18.081179', 'Title' => 'Výchozí pozice na mapě'),
     34  array('Name' => 'Map/DefaultZoom', 'Type' => 'Float', 'Default' => '15', 'Title' => 'Výchozí přihlížení mapy'),
    3235  array('Name' => 'Web/ItemsPerPage', 'Type' => 'Integer', 'Default' => '50', 'Title' => 'Položek na stránku'),
    3336  array('Name' => 'Web/VisiblePagingItems', 'Type' => 'Integer', 'Default' => '20', 'Title' => 'Položek stránkování'),
  • trunk/admin/Updates.php

    r572 r574  
    375375}
    376376
     377function UpdateTo574($Manager)
     378{
     379  $Manager->Execute('ALTER TABLE `MapPosition` ADD `Pos` VARCHAR( 255 ) NOT NULL ;');
     380  $Manager->Execute('UPDATE `MapPosition` SET `Pos`=CONCAT(`Latitude`, ";", `Longitude`)');
     381  $Manager->Execute('ALTER TABLE `MapPosition` DROP `Latitude`');
     382  $Manager->Execute('ALTER TABLE `MapPosition` DROP `Longitude`');
     383}
    377384
    378385$Updates = array(
     
    397404  551 => array('Revision' => 565, 'Function' => 'UpdateTo565'),
    398405  565 => array('Revision' => 571, 'Function' => 'UpdateTo571'),
     406  571 => array('Revision' => 574, 'Function' => 'UpdateTo574'),
    399407);
Note: See TracChangeset for help on using the changeset viewer.