Ignore:
Timestamp:
Oct 8, 2010, 3:02:29 AM (14 years ago)
Author:
grum
Message:

Connect the plugin to the RBuilder component + fixe some small bugs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/GMaps/gmaps_ajax.php

    r7125 r7128  
    7272
    7373           $_REQUEST['ajaxfct']=='public.maps.init' or
    74            $_REQUEST['ajaxfct']=='public.maps.getMarkers' or
    75            $_REQUEST['ajaxfct']=='public.maps.getMarkerInfos'
     74           $_REQUEST['ajaxfct']=='public.maps.getMarkers' //or
     75           //$_REQUEST['ajaxfct']=='public.maps.getMarkerInfos'
    7676           )) $_REQUEST['ajaxfct']='';
    7777
     
    234234              $_REQUEST['ajaxfct']='';
    235235            }
     236            else
     237            {
     238              if(!isset($_REQUEST['datas']['levelInfo'])) $_REQUEST['datas']['levelInfo']=1;
     239
     240              if(!($_REQUEST['datas']['levelInfo']==0 or
     241                   $_REQUEST['datas']['levelInfo']==1)) $_REQUEST['datas']['levelInfo']=1;
     242            }
    236243          }
    237244        }
     
    246253            $_REQUEST['ajaxfct']='';
    247254          }
     255
     256
    248257        }
    249258
     
    787796     *                       'width' : width of maps in pixels
    788797     *                       'height' : height of maps in pixels
     798     *                       'levelInfo' : 0 = don't return pictures info (name, url, ...)
     799     *                                     1 = return pictures informations
    789800     * @return Array|String : a JSON string of an array of points (nbPictures, lat, lng)
    790801     */
     
    793804      global $user, $page;
    794805
    795       $returned=array();
     806      $returned=array(
     807        'markers' => array(),
     808        'datas' => array(
     809          'nbPhotos' => 0
     810        )
     811      );
    796812
    797813      /*
     
    907923        {
    908924          $coords=array(
    909             'nbImagesTxt' => '',
     925            'nbImgTxt' => '',
    910926            'nbImages' => 0,
    911             'latitude' => 0,
    912             'longitude' => 0,
    913             'imagesTnFile' => array(),
    914             'imagesCatsNames' => array(),
    915             'imagesName' => array(),
    916             'imagesCatsUrl' => array(),
     927            'lat' => 0,                   // 'lat' rather than 'latitude'
     928            'lng' => 0,                   // 'lng' rather than 'longitude'
     929            'imgTn' => array(),
     930            'imgCatsNames' => array(),
     931            'imgName' => array(),
     932            'imgCatsUrl' => array(),
    917933          );
    918934
     
    938954            }
    939955
     956            if(count($tmpCatsId)<=1) $tmpCatsNames='';
     957
    940958            $coords['nbImages']++;
    941             $coords['latitude']+=$point['latitude'];
    942             $coords['longitude']+=$point['longitude'];
    943             $coords['imagesTnFile'][]=$point['imageTnFile'];
    944             $coords['imagesCatsNames'][]=$tmpCatsNames;
    945             $coords['imagesName'][]=$point['imageName'];
    946             $coords['imagesCatsUrl'][]=$tmpCatsUrl;
    947           }
    948           $coords['latitude']=$coords['latitude']/count($group);
    949           $coords['longitude']=$coords['longitude']/count($group);
    950           $coords['uniqueId']=md5($coords['latitude'].$coords['latitude']);
     959
     960            $coords['lat']+=$point['latitude'];
     961            $coords['lng']+=$point['longitude'];
     962
     963            if($datas['levelInfo']==1)
     964            {
     965              $coords['imgTn'][]=substr($point['imageTnFile'],12);
     966              $coords['imgCatsNames'][]=$tmpCatsNames;
     967              $coords['imgName'][]=$point['imageName'];
     968              $coords['imgCatsUrl'][]=$tmpCatsUrl;
     969            }
     970          }
     971          $coords['lat']=$coords['lat']/count($group);
     972          $coords['lng']=$coords['lng']/count($group);
     973          $coords['uniqueId']=md5($coords['lat'].$coords['lng']);
    951974
    952975          if($coords['nbImages']==1)
    953976          {
    954             $coords['nbImagesTxt']=l10n('gmaps_1_picture');
     977            $coords['nbImgTxt']=l10n('gmaps_1_picture');
    955978          }
    956979          else
    957980          {
    958             $coords['nbImagesTxt']=sprintf(l10n('gmaps_nb_pictures'), $coords['nbImages']);
    959           }
    960 
    961           $returned[]=$coords;
    962         }
     981            $coords['nbImgTxt']=sprintf(l10n('gmaps_nb_pictures'), $coords['nbImages']);
     982          }
     983
     984
     985
     986          $returned['markers'][]=$coords;
     987          $returned['datas']['nbPhotos']+=$coords['nbImages'];
     988        }
     989      }
     990
     991      if($returned['datas']['nbPhotos']>1)
     992      {
     993        $returned['datas']['nbPhotos']=sprintf(l10n('gmaps_nb_pictures'), $returned['datas']['nbPhotos']);
     994      }
     995      else
     996      {
     997        $returned['datas']['nbPhotos']=l10n('gmaps_1_picture');
    963998      }
    964999
Note: See TracChangeset for help on using the changeset viewer.