Changeset 7139 for extensions/GMaps


Ignore:
Timestamp:
Oct 9, 2010, 9:55:26 PM (14 years ago)
Author:
grum
Message:

add marker style management + minor bugs fixed

Location:
extensions/GMaps
Files:
58 added
10 edited

Legend:

Unmodified
Added
Removed
  • extensions/GMaps/admin/gmaps_category_maps.tpl

    r7132 r7139  
    2828            autoOpen:false,
    2929            width:800,
    30             height:450,
     30            height:465,
    3131            modal: true,
    3232            dialogClass: 'gcBgTabSheet gcBorder',
     
    5050      $('#iBDAssocMapId').bind('change', changeMapDisplayType);
    5151      $('[name=fBDAssocKmlFile]').bind('change', changeKmlFileSource);
     52      $('#iBDAssocIcon').bind('change', changeIcon);
     53      $('#iBDAssocMarker').bind('change', changeMarker);
    5254
    5355      loadList();
     56    }
     57
     58    /**
     59     * called when the icon is changed
     60     */
     61    var changeIcon = function ()
     62    {
     63      $('#iBDAssocIcon').attr('style', $('#iBDAssocIcon option:selected').attr('style')).blur();
     64    }
     65
     66    /**
     67     * called when the marker is changed
     68     */
     69    var changeMarker = function ()
     70    {
     71      $('#iBDAssocMarker').attr('style', $('#iBDAssocMarker option:selected').attr('style')).blur();
    5472    }
    5573
     
    225243        $('#iBDAssocKmlFileUrl').val('');
    226244        $('#iBDAssocIcon').val($('#iBDAssocIcon option:first').val());
     245        $('#iBDAssocMarker').val($('#iBDAssocMarker option:first').val());
    227246        $('#iBDAssocTitle').val('');
    228247      }
     
    249268        $('#iBDAssocKmlFileUrl').val(tmp.kmlFileUrl);
    250269        $('#iBDAssocIcon').val(tmp.icon);
     270        $('#iBDAssocMarker').val(tmp.marker);
    251271        $('#iBDAssocTitle').val(tmp.title);
    252272      }
     
    254274      changeMapDisplayType();
    255275      changeKmlFileSource();
     276      changeIcon();
     277      changeMarker();
    256278    }
    257279
     
    313335        kmlFileUrl:($('#iBDAssocKmlSelect').attr('checked'))?'':$('#iBDAssocKmlFileUrl').val(),
    314336        icon:$('#iBDAssocIcon').val(),
     337        marker:$('#iBDAssocMarker').val(),
    315338        title:$('#iBDAssocTitle').val(),
    316339      }
     
    430453              <select id='iBDAssocCatId'>
    431454                  {foreach from=$datas.cats item=cat}
    432                     <option value='{$cat.id}'>{$cat.name}</option>
     455                    <option value='{$cat.id}' style='padding-left:{$cat.level*12}px;font-size:{$cat.level*-4+130}%;'>{$cat.name}</option>
    433456                  {/foreach}
    434457              </select>
     
    465488              <select id='iBDAssocIcon'>
    466489                  {foreach from=$datas.icons item=icon}
    467                     <option class='{$icon.type}' value='{$icon.file}'>{$icon.file}</option>
     490                    <option style='background-image:url(plugins/GMaps/img/{$icon.file});' value='{$icon.file}'></option>
    468491                  {/foreach}
    469492              </select>
    470             </td>
    471           </tr>
     493              <p id='iBDKmlIconWarning' class='helps' style="width:520px;padding-right:20px;">{'gmaps_icon_info'|@translate}</p>
     494            </td>
     495          </tr>
     496
     497
     498          <tr>
     499            <td>{'gmaps_map_marker'|@translate}</td>
     500            <td>
     501              <select id='iBDAssocMarker'>
     502                  {foreach from=$datas.markers item=marker}
     503                    <option style='background-image:url(plugins/GMaps/img/{$marker.file});' value='{$marker.file}'></option>
     504                  {/foreach}
     505              </select>
     506            </td>
     507          </tr>
     508
    472509
    473510          <tr>
  • extensions/GMaps/gmaps.css

    r7132 r7139  
    5656}
    5757
    58 #iBDAssocCatId, #iBDAssocMapId {
    59   font-family:monospace;
    60   font-size:125%;
    61 }
    62 
    6358#iDialogGMapNfo {
    6459  height:18px;
     
    7873  filter:alpha(opacity:55);
    7974}
     75#iBDAssocIcon, #iBDAssocIcon option {
     76  height:34px;
     77  background-repeat:no-repeat;
     78  background-position:2px 2px;
     79}
     80#iBDAssocIcon {
     81  width:75px;
     82  padding-left:50px;
     83}
     84#iBDAssocIcon option {
     85  width:75px;
     86}
     87
     88#iBDAssocMarker, #iBDAssocMarker option {
     89  background-position:2px 2px;
     90  background-repeat:no-repeat;
     91  height:40px;
     92}
     93#iBDAssocMarker {
     94  width:60px;
     95  padding-left:40px;
     96}
     97#iBDAssocMarker option {
     98  width:40px;
     99}
  • extensions/GMaps/gmaps_aip.class.inc.php

    r7132 r7139  
    2727  {
    2828    parent::__construct($prefixeTable, $filelocation);
     29
    2930    $this->loadConfig();
    3031    $this->configForTemplate();
     
    3637
    3738    $this->tabsheet = new tabsheet();
    38 
    3939
    4040    if($this->amdState!='advanced')
     
    231231    $datas=Array(
    232232      'urlRequest' => $this->getAdminLink('ajax'),
    233       'cats' => $this->makeCategoriesTree(),
     233      'cats' => $this->makeCategoryList(),
    234234      'maps' => $this->makeMapsList(),
    235235      'icons' => $this->makeIconsList(),
     236      'markers' => $this->makeMarkersList(),
    236237      'kmlFiles'  => $this->makeKmlFilesList()
    237238    );
     
    322323
    323324
    324   /**
    325    * build the categories tree
    326    * @return Array : an array, ready to use in the template
    327    */
    328   private function makeCategoriesTree()
     325
     326  /**
     327   * build an ordered category list
     328   * returns an array, each item is an array like :
     329   *  'id'     => the category Id
     330   *  'name'   => the category name
     331   *  'rank'   => the category rank (global)
     332   *  'level'  => the category level
     333   *
     334   * @return Array : the list
     335   */
     336  protected function makeCategoryList()
    329337  {
    330338    $returned=array(
    331339      array(
    332         'id' => 0,
    333         'name' => '-- '.l10n('gmaps_applyForAllTheGallery').' --'
     340        'id'     => 0,
     341        'name'   => l10n('gmaps_applyForAllTheGallery'),
     342        'rank'   => '0000',
     343        'level'  => 0,
     344        'status' => 'public',
     345        'childs'  => false
    334346      )
    335347    );
    336348
    337     $sql="SELECT id, name, global_rank
    338           FROM ".CATEGORIES_TABLE."
    339           ORDER BY global_rank";
    340     $result = pwg_query($sql);
     349    $sql="SELECT DISTINCT pct.id, pct.name, pct.global_rank AS rank
     350          FROM ".CATEGORIES_TABLE." pct
     351            JOIN (
     352              SELECT DISTINCT pgat.cat_id AS catId FROM ".GROUP_ACCESS_TABLE." pgat
     353              UNION DISTINCT
     354              SELECT DISTINCT puat.cat_id AS catId FROM ".USER_ACCESS_TABLE." puat
     355                 ) pat
     356            ON (pat.catId = pct.id AND pct.status = 'private') OR (pct.status = 'public')
     357          ORDER BY global_rank;";
     358    $result=pwg_query($sql);
    341359    if($result)
    342360    {
    343       while ($row = pwg_db_fetch_assoc($result))
     361      while($row=pwg_db_fetch_assoc($result))
    344362      {
    345         $returned[]=array(
    346           'id' => $row['id'],
    347           'name' => str_repeat('&nbsp;&nbsp;', substr_count($row['global_rank'], '.')).$row['name']
    348         );
     363        $row['level']=1+substr_count($row['rank'], '.');
     364
     365        /* rank is in formated without leading zero, giving bad order
     366         *  1
     367         *  1.10
     368         *  1.11
     369         *  1.2
     370         *  1.3
     371         *  ....
     372         *
     373         *  this loop cp,vert all sub rank in four 0 format, allowing to order
     374         *  categories easily
     375         *  0001
     376         *  0001.0010
     377         *  0001.0011
     378         *  0001.0002
     379         *  0001.0003
     380         */
     381        $row['rank']=explode('.', $row['rank']);
     382        foreach($row['rank'] as $key=>$rank)
     383        {
     384          $row['rank'][$key]=str_pad($rank, 4, '0', STR_PAD_LEFT);
     385        }
     386        $row['rank']=implode('.', $row['rank']);
     387
     388        $returned[]=$row;
    349389      }
    350390    }
    351391
     392    usort($returned, array(&$this, 'compareCat'));
     393
    352394    return($returned);
    353   } //makeCategoriesTree
     395  }
     396
     397  /**
     398   * used for sort comparison
     399   * defined as public, but don't use it directly
     400   *
     401   * this function compare two categorie with their rank value
     402   */
     403  public function compareCat($catA, $catB)
     404  {
     405    if($catA['rank'] == $catB['rank'])
     406    {
     407      return(0);
     408    }
     409    return( ($catA['rank'] < $catB['rank'])?-1:1 );
     410  }
    354411
    355412
     
    400457      {
    401458        $returned[]=array(
    402           'type' => (strtolower(substr($file,0,1))=='i')?'img':'other',
    403459          'file' => $file
    404460        );
     
    409465  } //makeIconsList
    410466
     467
     468  /**
     469   * build the markers list
     470   * @return Array : an array, ready to use in the template
     471   */
     472  private function makeMarkersList()
     473  {
     474    $returned=array();
     475
     476    $directory=scandir(GMAPS_PATH.'img/');
     477    foreach($directory as $file)
     478    {
     479      $ext=(pathinfo($file, PATHINFO_EXTENSION));
     480      if(preg_match('/^mS(\d\d)_(\d\d)\.png$/i', $file))
     481      {
     482        $returned[]=array(
     483          'file' => $file
     484        );
     485      }
     486    }
     487
     488    return($returned);
     489  } //makeIconsList
    411490
    412491  /**
  • extensions/GMaps/gmaps_ajax.php

    r7132 r7139  
    206206                 isset($_REQUEST['datas']['kmlFileUrl']) &&
    207207                 isset($_REQUEST['datas']['icon']) &&
     208                 isset($_REQUEST['datas']['marker']) &&
    208209                 isset($_REQUEST['datas']['title']) ))
    209210            {
     
    664665                $properties['kmlFileUrl']."', '".
    665666                $properties['icon']."', '".
     667                $properties['marker']."', '".
    666668                mysql_escape_string($properties['title'])."');";
    667669        $result=pwg_query($sql);
     
    677679                $properties['kmlFileUrl']."', kmlFileId='".
    678680                $properties['kmlFileId']."', icon='".
    679                 $properties['icon']."', title='".
     681                $properties['icon']."', marker='".
     682                $properties['marker']."', title='".
    680683                mysql_escape_string($properties['title'])."'
    681684              WHERE id='$id';";
     
    705708        'kmlFileUrl' => '',
    706709        'icon' => '',
     710        'marker' => '',
    707711        'title' => ''
    708712      );
    709713
    710714      $sql="SELECT id, categoryId, mapId, applySubCat, kmlFileId, kmlFileUrl,
    711                    icon, title
     715                   icon, marker, title
    712716            FROM ".$this->tables['category_maps']."
    713717            WHERE id='$id';";
  • extensions/GMaps/gmaps_install.class.inc.php

    r7132 r7139  
    7272  `kmlFileUrl` varchar(255) NOT NULL,
    7373  `icon` varchar(255) NOT NULL,
     74  `marker` varchar(255) NOT NULL,
    7475  `title` varchar(200) NOT NULL,
    7576  PRIMARY KEY  (`id`),
  • extensions/GMaps/gmaps_pip.class.inc.php

    r7128 r7139  
    167167                id:'iGMapsIcon',
    168168                zoomLevel:".$map['zoomLevel'].",
    169                 marker:true,
     169                markerImg:'".$map['marker']."',
    170170                mapType:'".$map['mapType']."',
    171171                mapTypeControl:'".$map['mapTypeControl']."',
     
    369369        id:'iGMaps".(($map['displayType']=='IP')?'Icon':$map['id'])."',
    370370        zoomLevel:".$map['zoomLevel'].",
    371         marker:true,
     371        markerImg:'".$map['marker']."',
    372372        mapType:'".$map['mapType']."',
    373373        mapTypeControl:'".$map['mapTypeControl']."',
  • extensions/GMaps/gmaps_root.class.inc.php

    r7132 r7139  
    204204      $sql="SELECT DISTINCT pgcm.id, pgcm.categoryId,
    205205              pgcm.imgSort, pgcm.applySubCat, pgcm.kmlFileUrl, pgcm.kmlFileId, pgkf.file AS kmlFileUrlId,
    206               pgcm.icon, pgcm.title,
     206              pgcm.icon, pgcm.title, pgcm.marker,
    207207              pgmm.displayType, pgmm.sizeMode,
    208208              pgmm.width, pgmm.height, pgmm.zoomLevel,
  • extensions/GMaps/js/gmapsCategory.js

    r7128 r7139  
    11
    22var currentMapLoad;
     3var markerImgProp = [
     4  null,
     5  { w:32, h:32, x:15, y:31 }, // s01
     6  { w:32, h:32, x:15, y:31 }, // s02
     7  { w:32, h:32, x:10, y:31 }, // s03
     8  { w:30, h:40, x:4, y:39 }, // s04
     9];
     10
     11
    312
    413/**
     
    3948  {
    4049    kmlFile=null;
     50  }
     51
     52  re=/^mS(\d\d)_.*/i;
     53  iM=re.exec(properties.markerImg);
     54  if(iM!=null) iM=new Number(iM[1]);
     55
     56  if(iM!=null)
     57  {
     58    map.markerImg = new google.maps.MarkerImage('plugins/GMaps/img/'+properties.markerImg,
     59        new google.maps.Size(markerImgProp[iM].w, markerImgProp[iM].h),
     60        new google.maps.Point(0,0),
     61        new google.maps.Point(markerImgProp[iM].x, markerImgProp[iM].y));
     62  }
     63  else
     64  {
     65    map.markerImg = null;
    4166  }
    4267
     
    149174    );
    150175
     176    if(map.markerImg!=null) marker.setIcon(map.markerImg);
     177
    151178    marker.info=markers[i];
    152179    marker.info.displayed=0;
  • extensions/GMaps/js/gmapsPicture.js

    r7125 r7139  
    44  meta:false
    55};
     6var markerImgProp = [
     7  null,
     8  { w:32, h:32, x:15, y:31 }, // s01
     9  { w:32, h:32, x:15, y:31 }, // s02
     10  { w:32, h:32, x:10, y:31 }, // s03
     11  { w:30, h:40, x:4, y:39 }, // s04
     12];
     13
    614
    715function applyMap(properties)
     
    2634  );
    2735
    28   if(properties.marker)
    29   {
    30     var marker = new google.maps.Marker(
    31       {
    32         position:latlng,
    33         map: map,
    34         title:properties.markerTitle
    35       }
    36     );
    37   }
     36
     37  var marker = new google.maps.Marker(
     38    {
     39      position:latlng,
     40      map: map,
     41      title:properties.markerTitle
     42    }
     43  );
     44
     45
     46  re=/^mS(\d\d)_.*/i;
     47  iM=re.exec(properties.markerImg);
     48  if(iM!=null) iM=new Number(iM[1]);
     49
     50  if(iM!=null)
     51  {
     52    var markerImg = new google.maps.MarkerImage('plugins/GMaps/img/'+properties.markerImg,
     53        new google.maps.Size(markerImgProp[iM].w, markerImgProp[iM].h),
     54        new google.maps.Point(0,0),
     55        new google.maps.Point(markerImgProp[iM].x, markerImgProp[iM].y));
     56    marker.setIcon(markerImg);
     57  }
     58
     59
     60
     61
    3862
    3963  if(properties.kmlFileUrl!='')
  • extensions/GMaps/language/fr_FR/plugin.lang.php

    r7132 r7139  
    156156$lang['gmaps_kml_file_none']="Aucun";
    157157
    158 $lang['gmaps_kml_file_access']="Les fichiers KML/KMZ doivent, pour pouvoir être affichés sur une carte, être accessibles par les serveurs de Google";
     158$lang['gmaps_kml_file_access']="Les fichiers KML/KMZ doivent, pour pouvoir être affichés sur une carte, être accessibles par les serveurs de Google.";
     159$lang['gmaps_icon_info']="Si le thème dispose d'une icône aux mêmes dimensions que celle sélectionnée, elle sera appliquée en priorité.";
    159160
     161$lang['gmaps_map_marker']="Aspect du marqueur";
    160162
    161163?>
Note: See TracChangeset for help on using the changeset viewer.