Ignore:
Timestamp:
Oct 29, 2010, 3:01:40 PM (13 years ago)
Author:
grum
Message:

implement feature:1950

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/GMaps/gmaps_pip.class.inc.php

    r7308 r7479  
    1818class GMaps_PIP extends GMaps_root
    1919{
    20   protected $maps = array(); //list of maps
    2120  protected $category=array(
    2221    'id' => 0,
     
    3635  protected $picture=array(
    3736    'geolocated' => false,
     37    'forceDisplay' => false,
    3838    'coords' => array('lat' => 0, 'lng' => 0),
    3939    'content' => array(
     
    155155          }
    156156
    157           if($nb>0)
     157          if($nb>0 or $this->forceDisplay>0)
    158158          {
    159159            /*
     
    163163            foreach($this->maps as $keyMap => $map)
    164164            {
    165               $scripts[]="
     165              if($nb>0 or
     166                 $map['forceDisplay']=='y' and ($map['kmlFileUrl']!='' or $map['kmlFileId']!=0)
     167                )
    166168              {
    167                 id:'iGMapsIcon',
    168                 zoomLevel:".$map['zoomLevel'].",
    169                 markerImg:'".$map['marker']."',
    170                 mapType:'".$map['mapType']."',
    171                 mapTypeControl:'".$map['mapTypeControl']."',
    172                 navigationControl:'".$map['navigationControl']."',
    173                 scaleControl:'".$map['scaleControl']."',
    174                 streetViewControl:'".$map['streetViewControl']."',
    175                 kmlFileUrl:'".$map['kmlFileUrl']."',
    176                 displayType:'".$map['displayType']."',
    177                 sizeMode:'".$map['sizeMode']."',
    178                 title:'".addslashes( ($map['title']=='')?l10n('gmaps_geolocation'):$map['title']  )."',
    179                 markers:[],
    180                 fitToBounds:true,
    181                 zoomLevelMaxActivated:".($map['zoomLevelMaxActivated']=='y'?'true':'false')."
    182               }";
    183 
    184               preg_match('/^i(\d+)x(\d+).*/i', basename($map['icon']), $result);
    185               $this->category['icon']['iconStyle']=$map['iconStyle'];
    186               $this->category['icon']['file']=$map['icon'];
    187               $this->category['icon']['width']=isset($result[1])?$result[1]:-1;
    188               $this->category['icon']['height']=isset($result[2])?$result[2]:-1;
     169                $scripts[]="
     170                {
     171                  id:'iGMapsIcon',
     172                  zoomLevel:".$map['zoomLevel'].",
     173                  markerImg:'".$map['marker']."',
     174                  mapType:'".$map['mapType']."',
     175                  mapTypeControl:'".$map['mapTypeControl']."',
     176                  navigationControl:'".$map['navigationControl']."',
     177                  scaleControl:'".$map['scaleControl']."',
     178                  streetViewControl:'".$map['streetViewControl']."',
     179                  kmlFileUrl:'".$map['kmlFileUrl']."',
     180                  displayType:'".$map['displayType']."',
     181                  sizeMode:'".$map['sizeMode']."',
     182                  title:'".addslashes( ($map['title']=='')?l10n('gmaps_geolocation'):$map['title']  )."',
     183                  markers:[],
     184                  fitToBounds:true,
     185                  zoomLevelMaxActivated:".($map['zoomLevelMaxActivated']=='y'?'true':'false')."
     186                }";
     187
     188                preg_match('/^i(\d+)x(\d+).*/i', basename($map['icon']), $result);
     189                $this->category['icon']['iconStyle']=$map['iconStyle'];
     190                $this->category['icon']['file']=$map['icon'];
     191                $this->category['icon']['width']=isset($result[1])?$result[1]:-1;
     192                $this->category['icon']['height']=isset($result[2])?$result[2]:-1;
     193              }
    189194            }
    190 
    191195
    192196            $template->assign('maps', $this->maps);
     
    209213  gmaps =
    210214    {
     215      geolocated:".($nb>0?'true':'false').",
     216      forceDisplay:".($nb==0?'true':'false').",
    211217      lang:{
    212218        boundmap:'".l10n('gmaps_i_boundmap')."',
     
    249255    global $page, $template;
    250256
    251     if($this->picture['geolocated']==false) return(false);
     257    if($this->picture['geolocated']==false and $this->picture['forceDisplay']==false) return(false);
    252258
    253259    if(isset($this->picture['content']['MP']) and count($this->picture['content']['MP'])>0)
     
    258264      $template->assign('maps', $this->picture['content']['MP']);
    259265
     266      $metaTitle='';
     267      foreach($this->picture['content']['MP'] as $map)
     268      {
     269        if($metaTitle=='') $metaTitle=$map['title'];
     270      }
     271
    260272      $metadata=array
    261273        (
    262           'TITLE' => l10n('gmaps_geolocation'),
     274          'TITLE' => ($metaTitle=='')?l10n('gmaps_geolocation'):$metaTitle,
    263275          'lines' =>
    264276            array(
     
    296308  gmaps =
    297309    {
     310      geolocated:".($this->picture['geolocated']?'true':'false').",
     311      forceDisplay:".($this->picture['forceDisplay']?'true':'false').",
    298312      lang:{
    299313        centermap:'".l10n('gmaps_i_centermap')."',
     
    328342    global $template, $page;
    329343
     344    $isGeolocated=true;
     345
    330346    if(is_null($jpegMD->getTag('magic.GPS.LatitudeNum')) or
    331347       is_null($jpegMD->getTag('magic.GPS.LongitudeNum')) or
    332        $page['section']!='categories') return(false);
    333 
    334 
    335     $this->picture['geolocated']=true;
    336     $this->picture['coords']['lat']=$jpegMD->getTag('magic.GPS.LatitudeNum')->getValue();
    337     $this->picture['coords']['lng']=$jpegMD->getTag('magic.GPS.LongitudeNum')->getValue();
     348       $page['section']!='categories') $isGeolocated=false;
    338349
    339350
     
    347358    }
    348359
     360    if($this->forceDisplay==0 and !$isGeolocated) return(false);
     361
     362    $this->picture['geolocated']=$isGeolocated;
     363    $this->picture['forceDisplay']=!$isGeolocated;
     364    if($isGeolocated)
     365    {
     366      $this->picture['coords']['lat']=$jpegMD->getTag('magic.GPS.LatitudeNum')->getValue();
     367      $this->picture['coords']['lng']=$jpegMD->getTag('magic.GPS.LongitudeNum')->getValue();
     368    }
     369
    349370
    350371    foreach($this->maps as $map)
    351372    {
    352       if($map['displayType']=='IP')
    353       {
    354         preg_match('/^i(\d+)x(\d+).*/i', basename($map['icon']), $result);
    355         $this->picture['icon']=array(
    356           'iconStyle' => $map['iconStyle'],
    357           'file' => $map['icon'],
    358           'width' => isset($result[1])?$result[1]:-1,
    359           'height' => isset($result[2])?$result[2]:-1
     373      if($isGeolocated or
     374         $map['forceDisplay']=='y' and ($map['kmlFileUrl']!='' or $map['kmlFileId']!=0)
     375        )
     376      {
     377        if($map['displayType']=='IP')
     378        {
     379          preg_match('/^i(\d+)x(\d+).*/i', basename($map['icon']), $result);
     380          $this->picture['icon']=array(
     381            'iconStyle' => $map['iconStyle'],
     382            'file' => $map['icon'],
     383            'width' => isset($result[1])?$result[1]:-1,
     384            'height' => isset($result[2])?$result[2]:-1
     385          );
     386        }
     387
     388
     389        $this->picture['content'][$map['displayType']][]=array(
     390          'id' => $map['id'],
     391          'width' => $map['width'],
     392          'height' => $map['height'],
     393          'style' => $map['style'],
     394          'displayType' => $map['displayType'],
     395          'title' => $map['title'],
    360396        );
     397
     398        $this->picture['properties'][]="
     399        {
     400          id:'iGMaps".(($map['displayType']=='IP')?'Icon':$map['id'])."',
     401          zoomLevel:".$map['zoomLevel'].",
     402          markerImg:'".$map['marker']."',
     403          mapType:'".$map['mapType']."',
     404          mapTypeControl:'".$map['mapTypeControl']."',
     405          navigationControl:'".$map['navigationControl']."',
     406          scaleControl:'".$map['scaleControl']."',
     407          streetViewControl:'".$map['streetViewControl']."',
     408          kmlFileUrl:'".$map['kmlFileUrl']."',
     409          displayType:'".$map['displayType']."',
     410          sizeMode:'".$map['sizeMode']."',
     411          title:'".addslashes( ($map['title']=='')?l10n('gmaps_geolocation'):$map['title']  )."'
     412        }";
    361413      }
    362 
    363 
    364       $this->picture['content'][$map['displayType']][]=array(
    365         'id' => $map['id'],
    366         'width' => $map['width'],
    367         'height' => $map['height'],
    368         'style' => $map['style'],
    369         'displayType' => $map['displayType']
    370       );
    371 
    372       $this->picture['properties'][]="
    373       {
    374         id:'iGMaps".(($map['displayType']=='IP')?'Icon':$map['id'])."',
    375         zoomLevel:".$map['zoomLevel'].",
    376         markerImg:'".$map['marker']."',
    377         mapType:'".$map['mapType']."',
    378         mapTypeControl:'".$map['mapTypeControl']."',
    379         navigationControl:'".$map['navigationControl']."',
    380         scaleControl:'".$map['scaleControl']."',
    381         streetViewControl:'".$map['streetViewControl']."',
    382         kmlFileUrl:'".$map['kmlFileUrl']."',
    383         displayType:'".$map['displayType']."',
    384         sizeMode:'".$map['sizeMode']."',
    385         title:'".addslashes( ($map['title']=='')?l10n('gmaps_geolocation'):$map['title']  )."'
    386       }";
    387414    }
    388415  }
Note: See TracChangeset for help on using the changeset viewer.