Changeset 7125


Ignore:
Timestamp:
Oct 7, 2010, 8:04:43 PM (13 years ago)
Author:
grum
Message:

Admin interface + Gallery integration finished

Location:
extensions/GMaps
Files:
25 added
1 deleted
11 edited

Legend:

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

    r7054 r7125  
    11{known_script id="jquery.ui" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.core.packed.js"}
    2 {known_script id="jquery.ui.sortable" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.sortable.packed.js"}
    32{known_script id="jquery.ui.dialog" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.dialog.packed.js"}
    43{known_script id="jquery.ui.slider" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.slider.packed.js"}
     
    5756        );
    5857
    59       $('#iBDMapId').bind('keyup focusout', function (event)
    60         {
    61           if(!checkIdValidity($(this).val()))
    62           {
    63             $(this).addClass('error');
    64           }
    65           else
    66           {
    67             $(this).removeClass('error');
     58      $('#iBDDisplayTypeIC, #iBDDisplayTypeIP, #iBDDisplayTypeMP').bind('change',
     59        function ()
     60        {
     61          switch($(this).val())
     62          {
     63            case 'IC':
     64              $('#iBDZoomLevelRow').hide();
     65              $('[name=fBDSizeMode]').attr('disabled', false);
     66              break;
     67            case 'IP':
     68              $('#iBDZoomLevelRow').show();
     69              $('[name=fBDSizeMode]').attr('disabled', false);
     70              break;
     71            case 'MP':
     72              $('#iBDZoomLevelRow').show();
     73              $('#iBDSizeModeF').attr('checked', true).change();
     74              $('[name=fBDSizeMode]').attr('disabled', true);
     75              break;
    6876          }
    6977        }
    7078      );
    7179
     80      $('#iBDSizeModeA, #iBDSizeModeF').bind('change',
     81        function ()
     82        {
     83          switch($(this).val())
     84          {
     85            case 'A':
     86              $('#iBDMapWidthSliderRow, #iBDMapHeightSliderRow').hide();
     87              break;
     88            case 'F':
     89              $('#iBDMapWidthSliderRow, #iBDMapHeightSliderRow').show();
     90              break;
     91          }
     92        }
     93      );
    7294
    7395      $("#iBDMapWidthSlider").slider(
     
    326348     * @param String tabsheet : id of the tabsheet to display
    327349     */
    328     this.displayProp = function (tabsheet)
     350    this.displayTab = function (tabsheet)
    329351    {
    330352      switch(tabsheet)
     
    368390      properties.id=id;
    369391      updateDialog('');
    370       this.displayProp('general');
     392      this.displayTab('general');
     393      // >> because li items don't have id... :-(
     394      $('#itab2 li').removeClass('selected_tab').addClass('normal_tab');
     395      $('#itab2 li:first').addClass('selected_tab');
     396      // <<
    371397
    372398      $('#iDialogEdit')
     
    458484      if(items=='')
    459485      {
    460         $('#iBDMapId').val('');
     486        tmp={
     487          sizeMode:'A',
     488          displayTYpe:'IC'
     489        }
    461490        $('#iBDName').val('');
     491        $('#iBDDisplayTypeIC').attr('checked', true);
     492        $('#iBDSizeModeA').attr('checked', true);
    462493        $('#iBDMapWidthSliderValue').val('470');
    463494        $('#iBDMapHeightSliderValue').val('210');
     
    486517
    487518        $('#iBDNumId').val(tmp.id);
    488         $('#iBDMapId').val(tmp.mapId);
    489519        $('#iBDName').val(tmp.name);
     520        $('#iBDDisplayType'+tmp.displayType).attr('checked', true);
     521        $('#iBDSizeMode'+tmp.sizeMode).attr('checked', true);
    490522        $('#iBDMapWidthSliderValue').val(tmp.width);
    491523        $('#iBDMapHeightSliderValue').val(tmp.height);
     
    507539      }
    508540
     541      $('#iBDDisplayType'+tmp.displayType+', #iBDSizeMode'+tmp.sizeMode).change();
    509542      changeSize($('#iBDMapWidthSliderValue').val(), 'iBDMapWidthSlider');
    510543      changeSize($('#iBDMapHeightSliderValue').val(), 'iBDMapHeightSlider');
     
    558591      ok=true;
    559592
    560       if(checkIdValidity($('#iBDMapId').val())==false)
    561       {
    562         $('#iBDMapId').addClass('error');
    563         alert('{/literal}{"gmaps_invalidId"|@translate}{literal}');
    564         ok=false;
    565       }
    566 
    567593      return(ok);
    568594    }
     
    578604      // build datas
    579605      datas = {
    580         mapId:$('#iBDMapId').val(),
    581606        name:$('#iBDName').val(),
     607        displayType:$('[name=fBDDisplayType]:checked').val(),
     608        sizeMode:$('[name=fBDSizeMode]:checked').val(),
    582609        width:$('#iBDMapWidthSliderValue').val(),
    583610        height:$('#iBDMapHeightSliderValue').val(),
     
    652679<table id='iHeaderListMaps' class="littlefont">
    653680  <tr>
    654     <th style="width:150px;">{'gmaps_id'|@translate}</th>
    655681    <th>{'gmaps_name'|@translate}</th>
     682    <th style="width:150px;">{'gmaps_displayType'|@translate}</th>
    656683    <th style="width:90px;">{'gmaps_dimensions'|@translate}</th>
    657684    <th style="width:90px;">{'gmaps_zoomLevel'|@translate}</th>
     
    685712        <table class='formtable'>
    686713          <tr>
    687             <td>{'gmaps_id'|@translate}</td>
    688             <td>
    689               <input type='text' id='iBDMapId' maxlength=12 size=12 value=''>
     714            <td>{'gmaps_name'|@translate}</td>
     715            <td>
     716              <input type='text' id='iBDName' maxlength=80 size=60 value=''>
    690717            </td>
    691718          </tr>
    692719
    693720          <tr>
    694             <td>{'gmaps_name'|@translate}</td>
    695             <td>
    696               <input type='text' id='iBDName' maxlength=80 size=60 value=''>
    697             </td>
    698           </tr>
     721            <td>{'gmaps_displayType'|@translate}</td>
     722            <td>
     723              <label><input type='radio' id='iBDDisplayTypeIC' name='fBDDisplayType' value='IC'>&nbsp;{'gmaps_displayTypeIC'|@translate}</label><br>
     724              <label><input type='radio' id='iBDDisplayTypeIP' name='fBDDisplayType' value='IP'>&nbsp;{'gmaps_displayTypeIP'|@translate}</label><br>
     725              <label><input type='radio' id='iBDDisplayTypeMP' name='fBDDisplayType' value='MP'>&nbsp;{'gmaps_displayTypeMP'|@translate}</label>
     726            </td>
     727          </tr>
     728
    699729        </table>
    700730      </div>
    701731
    702732      <div id='iTabDimensions' style='display:none;'>
     733
    703734        <table class="formtable">
    704735          <tr>
    705             <td>{'gmaps_width'|@translate}</td>
     736            <td>{'gmaps_map_dimensions_are'|@translate}</td>
     737            <td colspan="3">
     738              <label><input type="radio" id="iBDSizeModeA" name="fBDSizeMode" value="A">&nbsp;{'gmaps_interface_dimensions_a'|@translate}</label><br>
     739              <label><input type="radio" id="iBDSizeModeF" name="fBDSizeMode" value="F">&nbsp;{'gmaps_interface_dimensions_f'|@translate}</label>
     740            </td>
     741          </tr>
     742
     743          <tr id='iBDMapWidthSliderRow'>
     744            <td>&nbsp;</td>
     745            <td style='padding-left:30px;'>{'gmaps_width'|@translate}</td>
    706746            <td>
    707747              <input type="hidden" id="iBDMapWidthSliderValue" value="">
     
    712752            </td>
    713753          </tr>
    714           <tr>
    715             <td>{'gmaps_height'|@translate}</td>
     754          <tr id='iBDMapHeightSliderRow'>
     755            <td>&nbsp;</td>
     756            <td style='padding-left:30px;'>{'gmaps_height'|@translate}</td>
    716757            <td>
    717758              <input type="hidden" id="iBDMapHeightSliderValue" value="">
     
    775816      <div id='iTabZoomLevel' style='display:none;'>
    776817        <table class='formtable'>
    777           <tr>
     818          <tr id='iBDZoomLevelRow'>
    778819            <td>{'gmaps_zoomLevel'|@translate}</td>
    779820            <td>
  • extensions/GMaps/admin/gmaps_maps_iListMaps.tpl

    r7054 r7125  
    22  {foreach from=$datas item=data}
    33  <tr>
    4     <td style="width:150px;">{$data.mapId}</td>
    54    <td>{$data.name}</td>
     5    <th style="width:150px;">{$data.displayType}</th>
    66    <th style="width:90px;">{$data.dimensions}</th>
    77    <th style="width:90px;">{$data.zoomLevel}</th>
  • extensions/GMaps/gmaps.css

    r7054 r7125  
    11#iHeaderListMaps { width:100%; border:1px solid; border-collapse: collapse; margin-top:3px; }
    2 #iListMaps { width:100%; border:1px solid; height:280px; border-top:0px; overflow:auto; position:relative; left:-1px;}
    3 #iListMapsNb { width:99%; text-align:right; margin-bottom:8px; padding:2px; font-size:80%; }
    4 #iListMaps table, table.listMaps { width:100%; text-align:left; border-collapse: collapse; }
    5 #iListMaps.roma table tr:hover { cursor:pointer; background:#303030; }
    6 #iListMaps.clear table tr:hover { cursor:pointer; color: #D54E21; background:#dbe8f3; }
     2#iListMaps, #iListAssoc { width:100%; border:1px solid; height:280px; border-top:0px; overflow:auto; position:relative; left:-1px;}
     3#iListMapsNb, #iListAssocNb { width:99%; text-align:right; margin-bottom:8px; padding:2px; font-size:80%; }
     4#iListMaps table, table.listMaps, #iListAssoc table { width:100%; text-align:left; border-collapse: collapse; }
     5#iListMaps.roma table tr:hover, #iListAssoc.roma table tr:hover { cursor:pointer; background:#303030; }
     6#iListMaps.clear table tr:hover, #iListAssoc.clear table tr:hover { cursor:pointer; color: #D54E21; background:#dbe8f3; }
    77div.addMap { text-align:left; }
    88
     
    4141
    4242#itab2 {
    43   margin:20px -6px 0 -10px;
     43  border-top:1px solid;
     44  margin:25px -6px 0 -10px;
     45  padding-top:3px;
    4446}
     47
     48#iBDAssocCatId, #iBDAssocMapId {
     49  font-family:monospace;
     50  font-size:125%;
     51}
     52
     53
  • extensions/GMaps/gmaps_aip.class.inc.php

    r7054 r7125  
    2222{
    2323  protected $tabsheet;
     24  protected $amdState;
    2425
    2526  public function __construct($prefixeTable, $filelocation)
     
    2829    $this->loadConfig();
    2930    $this->configForTemplate();
     31
     32    $this->amdState=GMaps_root::checkAMDActivated();
     33
     34    $this->initRequest();
    3035    $this->initEvents();
    3136
    3237    $this->tabsheet = new tabsheet();
     38
     39
     40    if($this->amdState!='advanced')
     41    {
     42      $this->tabsheet->add('amd_warning',
     43                            l10n('gmaps_warning'),
     44                            $this->getAdminLink()."&amp;fGMaps_tabsheet=amd_warning");
     45    }
    3346    $this->tabsheet->add('maps',
    3447                          l10n('gmaps_maps'),
     
    3750                          l10n('gmaps_associate_category_maps'),
    3851                          $this->getAdminLink()."&amp;fGMaps_tabsheet=category_maps");
     52/*
     53    $this->tabsheet->add('kml_files',
     54                          l10n('gmaps_kml_files_management'),
     55                          $this->getAdminLink()."&amp;fGMaps_tabsheet=kml_files");
     56    $this->tabsheet->add('search',
     57                          l10n('gmaps_search'),
     58                          $this->getAdminLink()."&amp;fGMaps_tabsheet=search");
    3959    $this->tabsheet->add('help',
    4060                          l10n('gmaps_help'),
    4161                          $this->getAdminLink()."&amp;fGMaps_tabsheet=help");
     62*/
    4263  }
    4364
     
    7293    switch($_REQUEST['fGMaps_tabsheet'])
    7394    {
     95      case 'amd_warning':
     96        $this->displayAmdWarning();
     97        break;
    7498      case 'maps':
    7599        $this->displayMaps();
     
    77101      case 'category_maps':
    78102        $this->displayCategoryMaps();
     103        break;
     104      case 'kml_files':
     105        $this->displayKmlFiles();
     106        break;
     107      case 'search':
     108        $this->displaySearch();
    79109        break;
    80110      case 'help':
     
    116146
    117147    if(!($_REQUEST['fGMaps_tabsheet']!="maps" or
    118          $_REQUEST['fGMaps_tabsheet']!="category_maps")) $_REQUEST['fGMaps_tabsheet']="maps";
     148         $_REQUEST['fGMaps_tabsheet']!="category_maps" or
     149         $_REQUEST['fGMaps_tabsheet']!="amd_warning"
     150         //$_REQUEST['fGMaps_tabsheet']!="kml_files" or
     151         //$_REQUEST['fGMaps_tabsheet']!="search" or
     152         //$_REQUEST['fGMaps_tabsheet']!="help"
     153         )) $_REQUEST['fGMaps_tabsheet']="maps";
     154
     155    if($_REQUEST['fGMaps_tabsheet']=="amd_warning" and $this->amdState=='advanced') $_REQUEST['fGMaps_tabsheet']="maps";
    119156  }
    120157
     
    137174    $mapTabsheet->add('general',
    138175                          l10n('gmaps_properties_general'),
    139                           '', true, "udm.displayProp('general');");
     176                          '', true, "udm.displayTab('general');");
    140177    $mapTabsheet->add('dimensions',
    141178                          l10n('gmaps_dimensions'),
    142                           '', false, "udm.displayProp('dimensions');");
     179                          '', false, "udm.displayTab('dimensions');");
    143180    $mapTabsheet->add('mapType',
    144181                          l10n('gmaps_properties_mapType'),
    145                           '', false, "udm.displayProp('mapType');");
     182                          '', false, "udm.displayTab('mapType');");
    146183    $mapTabsheet->add('zoomLevel',
    147184                          l10n('gmaps_properties_zoomLevel'),
    148                           '', false, "udm.displayProp('zoomLevel');");
     185                          '', false, "udm.displayTab('zoomLevel');");
    149186    $mapTabsheet->assign();
    150187
     
    167204    global $template;
    168205
     206    $template->set_filename('body_page',
     207                dirname($this->getFileLocation()).'/admin/gmaps_category_maps.tpl');
     208
     209    $mapTabsheet = new GPCTabSheet('mapTabsheet', $this->tabsheet->get_titlename(), 'tabsheet2 gcBorder', 'itab2');
     210    $mapTabsheet->add('assoc',
     211                          l10n('gmaps_map_assoc'),
     212                          '', false, "am.displayTab('assoc');");
     213    $mapTabsheet->add('integration',
     214                          l10n('gmaps_map_integration'),
     215                          '', true, "am.displayTab('integration');");
     216    $mapTabsheet->assign();
     217
     218
     219    $datas=Array(
     220      'urlRequest' => $this->getAdminLink('ajax'),
     221      'cats' => $this->makeCategoriesTree(),
     222      'maps' => $this->makeMapsList(),
     223      'icons' => $this->makeIconsList(),
     224    );
     225    $template->assign('datas', $datas);
     226
     227    $template->assign_var_from_handle('GMAPS_BODY_PAGE', 'body_page');
     228  }
     229
     230
     231  /**
     232   * display the kml file management page
     233   *
     234   */
     235  protected function displayKmlFiles()
     236  {
     237    global $template;
     238
    169239    /*$template->set_filename('body_page',
    170240                dirname($this->getFileLocation()).'/admin/plugin_admin_maps.tpl');
     
    174244  }
    175245
    176   /**
    177    * display the help page
    178    *
    179    */
    180   protected function displayHelp()
     246
     247
     248  /**
     249   * display the search page
     250   *
     251   */
     252  protected function displaySearch()
    181253  {
    182254    global $template;
     
    189261  }
    190262
     263
     264  /**
     265   * display the help page
     266   *
     267   */
     268  protected function displayHelp()
     269  {
     270    global $template;
     271
     272    /*$template->set_filename('body_page',
     273                dirname($this->getFileLocation()).'/admin/plugin_admin_maps.tpl');
     274
     275
     276    $template->assign_var_from_handle('GMAPS_BODY_PAGE', 'body_page');*/
     277  }
     278
     279
     280
     281  /**
     282   * display a warning page if AMD is not installed
     283   *
     284   */
     285  protected function displayAmdWarning()
     286  {
     287    global $template;
     288
     289    $template->set_filename('body_page',
     290                dirname($this->getFileLocation()).'/admin/gmaps_amd_warning.tpl');
     291
     292    switch(GMaps_root::checkAMDActivated())
     293    {
     294      case 'none':
     295      case 'inactive':
     296        $template->assign('gmaps_amd_warning_inactive', sprintf(l10n('gmaps_amd_warning_inactive'), GMAPS_AMD_NEEDED));
     297        break;
     298      case 'basic':
     299        $template->assign('gmaps_amd_warning_basic', l10n('gmaps_amd_warning_basic'));
     300        break;
     301    }
     302    $template->assign_var_from_handle('GMAPS_BODY_PAGE', 'body_page');
     303  }
     304
     305
     306  /**
     307   * build the categories tree
     308   * @return Array : an array, ready to use in the template
     309   */
     310  private function makeCategoriesTree()
     311  {
     312    $returned=array(
     313      array(
     314        'id' => 0,
     315        'name' => '-- '.l10n('gmaps_applyForAllTheGallery').' --'
     316      )
     317    );
     318
     319    $sql="SELECT id, name, global_rank
     320          FROM ".CATEGORIES_TABLE."
     321          ORDER BY global_rank";
     322    $result = pwg_query($sql);
     323    if($result)
     324    {
     325      while ($row = pwg_db_fetch_assoc($result))
     326      {
     327        $returned[]=array(
     328          'id' => $row['id'],
     329          'name' => str_repeat('&nbsp;&nbsp;', substr_count($row['global_rank'], '.')).$row['name']
     330        );
     331      }
     332    }
     333
     334    return($returned);
     335  } //makeCategoriesTree
     336
     337
     338  /**
     339   * build a maps list
     340   * @return Array : an array, ready to use in the template
     341   */
     342  private function makeMapsList()
     343  {
     344    $returned=array(
     345      'IC' => array(),
     346      'IP' => array(),
     347      'MP' => array()
     348    );
     349
     350    $sql="SELECT id, name, displayType
     351          FROM ".$this->tables['maps']."
     352          ORDER BY displayType, name";
     353    $result = pwg_query($sql);
     354    if($result)
     355    {
     356      while($row = pwg_db_fetch_assoc($result))
     357      {
     358        $returned[$row['displayType']][]=array(
     359          'id' => $row['id'],
     360          'name' => $row['name']
     361        );
     362      }
     363    }
     364
     365    return($returned);
     366  } //makeCategoriesTree
     367
     368
     369  /**
     370   * build THE ICON LIST
     371   * @return Array : an array, ready to use in the template
     372   */
     373  private function makeIconsList()
     374  {
     375    $returned=array();
     376
     377    $directory=scandir(GMAPS_PATH.'img/');
     378    foreach($directory as $file)
     379    {
     380      $ext=(pathinfo($file, PATHINFO_EXTENSION));
     381      if(preg_match('/^i.*(?:jpg|jpeg|png|gif)$/i', $file))
     382      {
     383        $returned[]=array(
     384          'type' => (strtolower(substr($file,0,1))=='i')?'img':'other',
     385          'file' => $file
     386        );
     387      }
     388    }
     389
     390    return($returned);
     391  } //makeCategoriesTree
     392
     393
    191394} //class
    192395
  • extensions/GMaps/gmaps_ajax.php

    r7054 r7125  
    6565           $_REQUEST['ajaxfct']=='admin.maps.setMap' or
    6666           $_REQUEST['ajaxfct']=='admin.maps.getMap' or
    67            $_REQUEST['ajaxfct']=='admin.maps.deleteMap'
     67           $_REQUEST['ajaxfct']=='admin.maps.deleteMap' or
     68           $_REQUEST['ajaxfct']=='admin.assoc.getList' or
     69           $_REQUEST['ajaxfct']=='admin.assoc.setAssoc' or
     70           $_REQUEST['ajaxfct']=='admin.assoc.getAssoc' or
     71           $_REQUEST['ajaxfct']=='admin.assoc.deleteAssoc' or
     72
     73           $_REQUEST['ajaxfct']=='public.maps.init' or
     74           $_REQUEST['ajaxfct']=='public.maps.getMarkers' or
     75           $_REQUEST['ajaxfct']=='public.maps.getMarkerInfos'
    6876           )) $_REQUEST['ajaxfct']='';
    6977
     
    7482      {
    7583        /*
    76          * check admin.maps.getList values
    77          */
    78         if($_REQUEST['ajaxfct']=="admin.maps.getList")
    79         {
    80         }
     84         * no check for admin.maps.getList & admin.assoc.getList requests
     85         */
     86
    8187
    8288        /*
    83          * check admin.maps.getMap values
    84          */
    85         if($_REQUEST['ajaxfct']=="admin.maps.getMap")
     89         * check admin.maps.getMap & admin.assoc.getAssoc values
     90         */
     91        if($_REQUEST['ajaxfct']=="admin.maps.getMap" or
     92           $_REQUEST['ajaxfct']=="admin.assoc.getAssoc")
    8693        {
    8794          if(!isset($_REQUEST['id']) or
     
    93100         * check admin.maps.deleteMap values
    94101         */
    95         if($_REQUEST['ajaxfct']=="admin.maps.deleteMap")
     102        if($_REQUEST['ajaxfct']=="admin.maps.deleteMap" or
     103           $_REQUEST['ajaxfct']=="admin.maps.deleteAssoc")
    96104        {
    97105          if(!isset($_REQUEST['id']) or
     
    101109
    102110        /*
    103          * check admin.maps.gsetMap values
     111         * check admin.maps.setMap values
    104112         */
    105113        if($_REQUEST['ajaxfct']=="admin.maps.setMap")
     
    112120          else
    113121          {
    114             if(!(isset($_REQUEST['datas']['mapId']) &&
     122            if(!(isset($_REQUEST['datas']['displayType']) &&
     123                 isset($_REQUEST['datas']['sizeMode']) &&
    115124                 isset($_REQUEST['datas']['name']) &&
    116125                 isset($_REQUEST['datas']['width']) &&
     
    127136            else
    128137            {
     138              if(!($_REQUEST['datas']['displayType']=='IC' or
     139                  $_REQUEST['datas']['displayType']=='IP' or
     140                  $_REQUEST['datas']['displayType']=='MP')) $_REQUEST['ajaxfct']='';
     141
     142              if(!($_REQUEST['datas']['sizeMode']=='A' or
     143                  $_REQUEST['datas']['sizeMode']=='F')) $_REQUEST['ajaxfct']='';
     144
    129145              if(!is_numeric($_REQUEST['datas']['width']) or
    130146                  $_REQUEST['datas']['width']<100 or
     
    158174        }
    159175
     176
     177        /*
     178         * check admin.maps.setAssoc values
     179         */
     180        if($_REQUEST['ajaxfct']=="admin.assoc.setAssoc")
     181        {
     182          if(!isset($_REQUEST['id']) or
     183             !isset($_REQUEST['datas']) or !is_array($_REQUEST['datas']))
     184          {
     185            $_REQUEST['ajaxfct']='';
     186          }
     187          else
     188          {
     189            if(!(isset($_REQUEST['datas']['categoryId']) &&
     190                 isset($_REQUEST['datas']['mapId']) &&
     191                 isset($_REQUEST['datas']['applySubCat']) &&
     192                 isset($_REQUEST['datas']['kmlFileUrl']) &&
     193                 isset($_REQUEST['datas']['icon']) &&
     194                 isset($_REQUEST['datas']['title']) ))
     195            {
     196              $_REQUEST['ajaxfct']='';
     197            }
     198            else
     199            {
     200              if($_REQUEST['datas']['categoryId']=='' or
     201                 $_REQUEST['datas']['categoryId']<0) $_REQUEST['ajaxfct']='';
     202
     203              if($_REQUEST['datas']['mapId']=='') $_REQUEST['ajaxfct']='';
     204
     205              if(!($_REQUEST['datas']['applySubCat']=='y' or
     206                   $_REQUEST['datas']['applySubCat']=='n')) $_REQUEST['datas']['applySubCat']='y';
     207            }
     208          }
     209        }
     210
     211
     212        /*
     213         * check public.maps.getMarkers values
     214         */
     215        if($_REQUEST['ajaxfct']=="public.maps.getMarkers")
     216        {
     217          if(!isset($_REQUEST['datas']) or
     218             !is_array($_REQUEST['datas']))
     219          {
     220            $_REQUEST['ajaxfct']='';
     221          }
     222          else
     223          {
     224            if(!(isset($_REQUEST['datas']['requestId']) &&
     225                 isset($_REQUEST['datas']['bounds']) &&
     226                 isset($_REQUEST['datas']['width']) &&
     227                 isset($_REQUEST['datas']['height']) &&
     228                 isset($_REQUEST['datas']['distanceTreshold']) &&
     229                 isset($_REQUEST['datas']['bounds']['north']) &&
     230                 isset($_REQUEST['datas']['bounds']['south']) &&
     231                 isset($_REQUEST['datas']['bounds']['east']) &&
     232                 isset($_REQUEST['datas']['bounds']['west']) ))
     233            {
     234              $_REQUEST['ajaxfct']='';
     235            }
     236          }
     237        }
     238
     239        /*
     240         * check public.maps.getMarkerInfos values
     241         */
     242        if($_REQUEST['ajaxfct']=="public.maps.init")
     243        {
     244          if(!isset($_REQUEST['category']))
     245          {
     246            $_REQUEST['ajaxfct']='';
     247          }
     248        }
    160249
    161250      }
     
    183272          $result=$this->ajax_gmaps_admin_mapsDeleteMap($_REQUEST['id']);
    184273          break;
     274        case 'admin.assoc.getList':
     275          $result=$this->ajax_gmaps_admin_assocGetList();
     276          break;
     277        case 'admin.assoc.getAssoc':
     278          $result=$this->ajax_gmaps_admin_assocGetAssoc($_REQUEST['id']);
     279          break;
     280        case 'admin.assoc.setAssoc':
     281          $result=$this->ajax_gmaps_admin_assocSetAssoc($_REQUEST['id'], $_REQUEST['datas']);
     282          break;
     283        case 'admin.assoc.deleteAssoc':
     284          $result=$this->ajax_gmaps_admin_assocDeleteAssoc($_REQUEST['id']);
     285          break;
     286
     287        case 'public.maps.init':
     288          $result=$this->ajax_gmaps_public_mapsInit($_REQUEST['category']);
     289          break;
     290        case 'public.maps.getMarkers':
     291          $result=$this->ajax_gmaps_public_mapsGetMarkers($_REQUEST['datas']);
     292          break;
    185293      }
    186294      GPCAjax::returnResult($result);
     
    208316      $datas=Array();
    209317
    210       $sql="SELECT id, mapId, name, width, height, zoomLevel, mapType, mapTypeControl, navigationControl, scaleControl
     318      $sql="SELECT id, name, displayType, sizeMode, width, height, zoomLevel, mapType, mapTypeControl, navigationControl, scaleControl
    211319            FROM ".$this->tables['maps']."
    212             ORDER BY id";
     320            ORDER BY displayType ASC, name ASC";
    213321      $result=pwg_query($sql);
    214322      if($result)
     
    216324        while($row=pwg_db_fetch_assoc($result))
    217325        {
    218           $row['dimensions']=$row['width'].'x'.$row['height'];
     326          if($row['displayType']=='IC')
     327          {
     328            $row['zoomLevel']=l10n('gmaps_auto');
     329          }
     330
     331          $row['displayType']=l10n('gmaps_displayTypeShort'.$row['displayType']);
     332
     333          if($row['sizeMode']=='A')
     334          {
     335            $row['dimensions']=l10n('gmaps_auto');
     336          }
     337          else
     338          {
     339            $row['dimensions']=$row['width'].'x'.$row['height'];
     340          }
    219341
    220342          $row['mapType']=l10n('gmaps_googleMapType_'.$row['mapType']);
     
    244366      global $template;
    245367
    246       // if create a new map, check if map id is unique
    247       $sql="SELECT id, mapId FROM ".$this->tables['maps']."
    248             WHERE mapId='".$properties['mapId']."';";
    249       $result=pwg_query($sql);
    250       if($result)
    251       {
    252         while($row=pwg_db_fetch_assoc($result))
    253         {
    254           if($row['id']!=$id)
    255           {
    256             return('iBDMapId!'.l10n('gmaps_mapIdAlreadyExist'));
    257           }
    258         }
    259       }
    260 
    261368      if($id=='')
    262369      {
    263370        $sql="INSERT INTO ".$this->tables['maps']."
    264               VALUES ('', '".mysql_escape_string($properties['mapId'])."', '".
    265                 mysql_escape_string($properties['name'])."', '".
     371              VALUES ('', '".mysql_escape_string($properties['name'])."', '".
     372                $properties['displayType']."', '".
     373                $properties['sizeMode']."', '".
    266374                $properties['width']."', '".
    267375                $properties['height']."', '".
     
    278386      {
    279387        $sql="UPDATE ".$this->tables['maps']."
    280               SET name='".mysql_escape_string($properties['name'])."', mapId='".
     388              SET name='".mysql_escape_string($properties['name'])."', displayType='".
     389                $properties['displayType']."', sizeMode='".
     390                $properties['sizeMode']."', width='".
    281391                $properties['mapId']."', width='".
    282392                $properties['width']."', height='".
     
    307417        'id' => '',
    308418        'name' => '',
    309         'mapId' => '',
     419        'displayType' => '',
     420        'sizeMode' => '',
    310421        'width' => 470,
    311422        'height' => 210,
     
    317428      );
    318429
    319       $sql="SELECT id, mapId, name, width, height, zoomLevel, mapType, mapTypeControl, navigationControl, scaleControl
     430      $sql="SELECT id, displayType, sizeMode, name, width, height, zoomLevel, mapType, mapTypeControl, navigationControl, scaleControl
    320431            FROM ".$this->tables['maps']."
    321432            WHERE id='$id';";
     
    330441
    331442      return(json_encode($returned));
    332     }
     443    } //ajax_gmaps_admin_mapsGetMap
    333444
    334445
     
    354465
    355466      return('ko!unknown error');
     467    } //ajax_gmaps_admin_mapsDeleteMap
     468
     469
     470
     471
     472
     473    /**
     474     * return a HTML list of defined associations
     475     *
     476     * @return String
     477     */
     478    private function ajax_gmaps_admin_assocGetList()
     479    {
     480      global $template;
     481
     482      $template->set_filename('list_page',
     483                    dirname($this->getFileLocation()).'/admin/gmaps_category_maps_iListMaps.tpl');
     484
     485      $datas=Array();
     486
     487      $sql="SELECT pgcm.id, pgcm.categoryId, pct.name AS catName,
     488                   pgmm.name AS mapName, pgmm.displayType,
     489                   pgcm.kmlFileUrl, pgcm.imgSort, pgcm.applySubCat, pgcm.icon,
     490                   pgcm.title
     491            FROM (".$this->tables['category_maps']." pgcm
     492                  LEFT JOIN ".CATEGORIES_TABLE." pct ON pct.id=pgcm.categoryId)
     493                  LEFT JOIN ".$this->tables['maps']." pgmm ON pgcm.mapId = pgmm.id
     494            ORDER BY pct.name, pgmm.displayType, pgcm.imgSort";
     495      $result=pwg_query($sql);
     496      if($result)
     497      {
     498        $keys=array(
     499          'prev' => '',
     500          'curr' => ''
     501        );
     502        while($row=pwg_db_fetch_assoc($result))
     503        {
     504          $keys['prev']=$keys['curr'];
     505
     506          $tmp=array(
     507            'id' => $row['id'],
     508            'catName' => ($row['categoryId']==0)?l10n('gmaps_applyForAllTheGallery'):$row['catName'],
     509            'applySubCat' => l10n('gmaps_'.$row['applySubCat']),
     510            'mapName' => $row['mapName'],
     511            'mapKmlFile' => l10n('gmaps_'.(($row['kmlFileUrl']=='')?'n':'y')),
     512            'icon' => $row['icon'],
     513            'displayType' => l10n('gmaps_displayTypeShort'.$row['displayType']),
     514            'title' => $row['title']
     515          );
     516
     517          $keys['curr']=$row['categoryId'].$row['displayType'];
     518
     519          if($keys['curr']==$keys['prev'])
     520          {
     521            $tmp['catName']='';
     522            $tmp['displayType']='';
     523            $tmp['applySubCat']='';
     524          }
     525
     526          $datas[]=$tmp;
     527        }
     528      }
     529
     530      $template->assign('datas', $datas);
     531      return($template->parse('list_page', true));
     532    } //ajax_gmaps_admin_assocGetList
     533
     534
     535
     536
     537    /**
     538     * set properties for a given association id ; if no association id is given
     539     * create a new association
     540     *
     541     * @param String id : the association Id
     542     * @param Array datas : properties of the association (assuming array index
     543     *                      were checked by the checkRequest function)
     544     * @return String : the num id, or an error message
     545     */
     546    private function ajax_gmaps_admin_assocSetAssoc($id, $properties)
     547    {
     548      global $template;
     549
     550      // if create a new assoc, get the last imgSort
     551      $db=array(
     552        'nbId' => 0,
     553        'displayType' => '',
     554        'maxImgSort' => 0
     555      );
     556
     557      $sql="SELECT MAX(imgSort) AS maxImgSort, pgmm.displayType, COUNT(pgcm.id) AS nbId
     558            FROM (".$this->tables['category_maps']." pgcm
     559              LEFT JOIN ".$this->tables['maps']." pgmm ON pgmm.id = pgcm.mapId)
     560              LEFT JOIN ".$this->tables['maps']." pgmm2 ON pgmm2.displayType=pgmm.displayType
     561
     562            WHERE categoryId='".$properties['categoryId']."'
     563              AND pgmm2.id='".$properties['mapId']."'
     564            GROUP BY pgmm.displayType;";
     565      $result=pwg_query($sql);
     566      if($result)
     567      {
     568        while($row=pwg_db_fetch_assoc($result))
     569        {
     570          $db=$row;
     571        }
     572      }
     573
     574      if($id=='' and
     575          ($db['displayType']=='IC' or $db['displayType']=='IP') and
     576          $db['nbId']>0
     577        )
     578      {
     579        return('!'.l10n('gmaps_only_one_map_is_allowed_for_this_mode'));
     580      }
     581
     582
     583      if($id=='')
     584      {
     585        $sql="INSERT INTO ".$this->tables['category_maps']."
     586              VALUES ('', '".
     587                $properties['categoryId']."', '".
     588                $properties['mapId']."', '".
     589                ($db['maxImgSort']+1)."', '".
     590                $properties['applySubCat']."', '".
     591                $properties['kmlFileUrl']."', '".
     592                $properties['icon']."', '".
     593                mysql_escape_string($properties['title'])."');";
     594        $result=pwg_query($sql);
     595        $id=pwg_db_insert_id();
     596      }
     597      else
     598      {
     599        $sql="UPDATE ".$this->tables['category_maps']."
     600              SET categoryId='".
     601                $properties['categoryId']."', mapId='".
     602                $properties['mapId']."', applySubCat='".
     603                $properties['applySubCat']."', kmlFileUrl='".
     604                $properties['kmlFileUrl']."', icon='".
     605                $properties['icon']."', title='".
     606                mysql_escape_string($properties['title'])."'
     607              WHERE id='$id';";
     608        $result=pwg_query($sql);
     609      }
     610
     611      return($id);
     612    } //ajax_gmaps_admin_assocSetAssoc
     613
     614
     615
     616
     617    /**
     618     * get properties for a given association id
     619     *
     620     * @param String id : the association Id
     621     * @return String : data formatted in a JSON string
     622     */
     623    private function ajax_gmaps_admin_assocGetAssoc($id)
     624    {
     625      $returned=array(
     626        'id' => '',
     627        'categoryId' => 0,
     628        'mapId' => '',
     629        'applySubCat'=> 'y',
     630        'kmlFileUrl' => '',
     631        'icon' => '',
     632        'title' => ''
     633      );
     634
     635      $sql="SELECT id, categoryId, mapId, applySubCat, kmlFileUrl,
     636                   icon, title
     637            FROM ".$this->tables['category_maps']."
     638            WHERE id='$id';";
     639      $result=pwg_query($sql);
     640      if($result)
     641      {
     642        while($row=pwg_db_fetch_assoc($result))
     643        {
     644          $returned=$row;
     645        }
     646      }
     647
     648      return(json_encode($returned));
     649    } //ajax_gmaps_admin_assocGetAssoc
     650
     651
     652
     653
     654    /**
     655     * delete an association
     656     *
     657     * @param String id : if of the association to delete
     658     * @return String : ok or ko
     659     */
     660    private function ajax_gmaps_admin_assocDeleteAssoc($id)
     661    {
     662      $sql="DELETE FROM ".$this->tables['category_maps']."
     663            WHERE id='$id';";
     664      $result=pwg_query($sql);
     665      if($result) return('ok');
     666
     667      return('ko!unknown error');
     668    } //ajax_gmaps_admin_assocDeleteAssoc
     669
     670
     671    /**
     672     * prepare the cache for the user / category
     673     *
     674     *
     675     * @param Integer $category : the category Id, 0 if want to init map for all
     676     *                            the gallery
     677     * @return String : the requestId
     678     */
     679    private function ajax_gmaps_public_mapsInit($category)
     680    {
     681      global $prefixeTable, $template, $user, $conf;
     682
     683      $returned='';
     684
     685      $this->buildMapList($category, 'C');
     686      if($category>0)
     687      {
     688        $sqlCatRestrict="AND FIND_IN_SET($category, pct.uppercats)!=0";
     689      }
     690      else
     691      {
     692        $sqlCatRestrict="";
     693      }
     694
     695      if(count($this->maps)>0)
     696      {
     697        $scripts=array();
     698        $bounds=array(
     699          'N' => -90,
     700          'S' => 90,
     701          'E' => -180,
     702          'W' => 180
     703        );
     704
     705        // there is some maps to display
     706        $requestId=date('Y-m-d h:i:s');
     707
     708        // delete cache (for user and data having more than 24h)
     709        $sql="DELETE FROM ".$this->tables['cache']."
     710              WHERE userId='".$user['id']."'
     711                 OR requestId<'".date('Y-m-d h:i:s', time()-86400)."';";
     712        pwg_query($sql);
     713
     714        // prepare the cache (same request in the 'GMaps_pip->displayCategoryPageMap' function)
     715        $sql="SELECT DISTINCT pic.image_id, GROUP_CONCAT(DISTINCT pait.value ORDER BY pait.numID ASC SEPARATOR ';') AS coords,
     716                GROUP_CONCAT(DISTINCT pic.category_id ORDER BY pic.category_id SEPARATOR ';') AS imageCatsId,
     717                GROUP_CONCAT(DISTINCT pct.name ORDER BY pct.id SEPARATOR ';') AS imageCatsNames,
     718                GROUP_CONCAT(DISTINCT IF(pct.permalink IS NULL, CONCAT('*', pct.id), pct.permalink) ORDER BY pct.id SEPARATOR ';') AS imageCatsPLink,
     719                pit.name AS imageName, pit.path, pit.tn_ext
     720              FROM ((((".USER_CACHE_CATEGORIES_TABLE." pucc
     721                LEFT JOIN ".CATEGORIES_TABLE." pct ON pucc.cat_id = pct.id)
     722                LEFT JOIN ".IMAGE_CATEGORY_TABLE." pic ON pic.category_id = pucc.cat_id)
     723                LEFT JOIN ".$prefixeTable."amd_images_tags pait ON pait.imageId = pic.image_id)
     724                LEFT JOIN ".$prefixeTable."amd_used_tags paut ON pait.numId = paut.numId)
     725                LEFT JOIN ".IMAGES_TABLE." pit ON pit.id = pic.image_id
     726              WHERE pucc.user_id = '".$user['id']."'
     727               AND (paut.tagId = 'magic.GPS.LatitudeNum' OR paut.tagId = 'magic.GPS.LongitudeNum')
     728               AND pic.image_id IS NOT NULL
     729               $sqlCatRestrict
     730               GROUP BY pic.image_id";
     731/*
     732 * get_sql_condition_FandF(
     733                array
     734                  (
     735                    'forbidden_categories' => 'pic.category_id',
     736                    'visible_categories' => 'pic.category_id',
     737                    'visible_images' => 'pic.image_id'
     738                  ),
     739                'AND'
     740              );
     741*/
     742        $result=pwg_query($sql);
     743        if($result)
     744        {
     745          $massInsert=array();
     746
     747          while($row=pwg_db_fetch_assoc($result))
     748          {
     749            $coords=explode(';', $row['coords']);
     750            $this->updateBounds($bounds, array(
     751                'lat' => $coords[0],
     752                'lng' => $coords[1]
     753              )
     754            );
     755
     756            $massInsert[]=array(
     757              'userId' => $user['id'],
     758              'requestId' => $requestId,
     759              'imageId' => $row['image_id'],
     760              'latitude' => $coords[0],
     761              'longitude' => $coords[1],
     762              'imageName' => mysql_escape_string($row['imageName']),
     763              'imageTnFile' => dirname($row['path']).'/'.$conf['dir_thumbnail'].'/'.$conf['prefix_thumbnail'].get_filename_wo_extension(basename($row['path'])).'.'.$row['tn_ext'],
     764              'imageCatsId' => $row['imageCatsId'],
     765              'imageCatsNames' => mysql_escape_string($row['imageCatsNames']),
     766              'imageCatsPLink' => $row['imageCatsPLink']
     767            );
     768          }
     769
     770          mass_inserts($this->tables['cache'], array('userId', 'requestId', 'imageId', 'latitude', 'longitude', 'imageName', 'imageTnFile', 'imageCatsId', 'imageCatsNames', 'imageCatsPLink'), $massInsert);
     771
     772          $returned=$requestId;
     773        }
     774      }
     775
     776      return($requestId);
    356777    }
    357778
     779
     780    /**
     781     * returns a list of markers
     782     *
     783     *
     784     * @param Array $datas : 'requestId' id of the request
     785     *                       'bounds'  (north, east, west, south) : only markers
     786     *                          inside the given bounds are returned
     787     *                       'width' : width of maps in pixels
     788     *                       'height' : height of maps in pixels
     789     * @return Array|String : a JSON string of an array of points (nbPictures, lat, lng)
     790     */
     791    private function ajax_gmaps_public_mapsGetMarkers($datas)
     792    {
     793      global $user, $page;
     794
     795      $returned=array();
     796
     797      /*
     798       * the 'make_picture_url' function use the 'get_root_url' function which
     799       * use the $page['root_path'] value
     800       *
     801       * here, this $page index doesn't exist, so we need to initialize it
     802       */
     803      $page['root_path']='';
     804
     805      if($datas['bounds']['east']<$datas['bounds']['west'])
     806      {
     807        /*  E = -xxx    W = +xxx
     808         *  a(lng E:+x)
     809         *  b(lng W:-x)
     810         *
     811         *  E         +180/-180     W
     812         * (+)                     (-)
     813         *  +-------------+---------+
     814         *  |             :         |
     815         *  |             :    b    |
     816         *  |     a       :         |
     817         *  |             :         |
     818         *  +-------------+---------+
     819         *
     820         */
     821        $lngClause="
     822              longitude <= ".$datas['bounds']['east']."
     823              OR longitude >= ".$datas['bounds']['west']." ";
     824      }
     825      else
     826      {
     827        /*  E = -xxx    W = +xxx
     828         *  a(lng W:-x)
     829         *  b(lng E:+x)
     830         *
     831         *  W             0         E
     832         * (-)                     (+)
     833         *  +-------------+---------+
     834         *  |             :         |
     835         *  |             :    b    |
     836         *  |      a      :         |
     837         *  |             :         |
     838         *  +-------------+---------+
     839         *
     840         */
     841        $lngClause="
     842              longitude >= ".$datas['bounds']['west']."
     843              AND longitude <= ".$datas['bounds']['east']." ";
     844      }
     845
     846      $sql="SELECT latitude, longitude, imageId, imageCatsId, imageCatsNames, imageTnFile, imageName, imageCatsPLink
     847            FROM ".$this->tables['cache']."
     848            WHERE userId='".$user['id']."'
     849              AND requestId='".$datas['requestId']."'
     850              AND ($lngClause)
     851              AND latitude >= ".$datas['bounds']['south']."
     852              AND latitude <= ".$datas['bounds']['north']."
     853            ORDER BY latitude, longitude;";
     854
     855      $result=pwg_query($sql);
     856      if($result)
     857      {
     858        // compute ratio map size / bound size
     859        $ratioW=($datas['bounds']['east']-$datas['bounds']['west'])/$datas['width'];
     860        $ratioH=($datas['bounds']['north']-$datas['bounds']['south'])/$datas['height'];
     861        // works with the highest ratio
     862        $ratio=max($ratioW, $ratioH);
     863
     864
     865        $points=array();
     866        $groups=array();
     867
     868        while($row=pwg_db_fetch_assoc($result))
     869        {
     870          $points[]=$row;
     871        }
     872
     873        /*
     874         *  build groups
     875         */
     876        while(count($points)>0)
     877        {
     878          $currentGroup=array();
     879          $currentGroup[]=array_shift($points);
     880
     881          $i=0;
     882          while($i<count($points))
     883          {
     884            $dist=sqrt(pow($points[$i]['latitude']-$currentGroup[0]['latitude'],2) + pow($points[$i]['longitude']-$currentGroup[0]['longitude'],2))/$ratio;
     885
     886            if($dist <= $datas['distanceTreshold'])
     887            {
     888              $tmp=array_splice($points, $i, 1);
     889              $currentGroup[]=$tmp[0];
     890              $points=array_values($points); // reset array index...
     891            }
     892            else
     893            {
     894              $i++;
     895            }
     896          }
     897
     898          $groups[]=$currentGroup;
     899          unset($currentGroup);
     900        }
     901
     902        /*
     903         * for each group, calculate coordinates for a unique representative
     904         * point
     905         */
     906        foreach($groups as $keyGroup => $group)
     907        {
     908          $coords=array(
     909            'nbImagesTxt' => '',
     910            'nbImages' => 0,
     911            'latitude' => 0,
     912            'longitude' => 0,
     913            'imagesTnFile' => array(),
     914            'imagesCatsNames' => array(),
     915            'imagesName' => array(),
     916            'imagesCatsUrl' => array(),
     917          );
     918
     919          foreach($group as $point)
     920          {
     921            $tmpCatsUrl=array();
     922            $tmpCatsId=explode(';', $point['imageCatsId']);
     923            $tmpCatsNames=explode(';', $point['imageCatsNames']);
     924            $tmpCatsPLinks=explode(';', $point['imageCatsPLink']);
     925
     926            foreach($tmpCatsId as $key => $id)
     927            {
     928              $tmpCatsUrl[]=make_picture_url(
     929                array(
     930                  'image_id' => $point['imageId'],
     931                  'category' => array(
     932                    'id' => $id,
     933                    'name' => $tmpCatsNames[$key],
     934                    'permalink' => (substr($tmpCatsPLinks[$key],0,1)=='*')?'':$tmpCatsPLinks[$key],
     935                  )
     936                )
     937              );
     938            }
     939
     940            $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']);
     951
     952          if($coords['nbImages']==1)
     953          {
     954            $coords['nbImagesTxt']=l10n('gmaps_1_picture');
     955          }
     956          else
     957          {
     958            $coords['nbImagesTxt']=sprintf(l10n('gmaps_nb_pictures'), $coords['nbImages']);
     959          }
     960
     961          $returned[]=$coords;
     962        }
     963      }
     964
     965      return(json_encode($returned));
     966    }
    358967
    359968
  • extensions/GMaps/gmaps_install.class.inc.php

    r7054 r7125  
    4848
    4949      $tables_def=array(
    50 "CREATE TABLE   `".$this->tables['maps']."` (
     50"CREATE TABLE `".$this->tables['maps']."` (
    5151  `id` int(10) unsigned NOT NULL auto_increment,
    52   `mapId` char(12) NOT NULL,
    5352  `name` varchar(80) NOT NULL,
     53  `displayType` char(2) NOT NULL,
     54  `sizeMode` char(1) NOT NULL,
    5455  `width` int(10) unsigned NOT NULL default '470',
    5556  `height` int(10) unsigned NOT NULL default '210',
     
    6061  `scaleControl` char(1) NOT NULL default 'y',
    6162  `style` varchar(512) NOT NULL,
    62   PRIMARY KEY  (`id`),
    63   KEY `byMapId` (`mapId`)
     63  PRIMARY KEY  (`id`)
    6464)",
    65 "CREATE TABLE   `".$this->tables['category_maps']."` (
     65"CREATE TABLE `".$this->tables['category_maps']."` (
    6666  `id` int(10) unsigned NOT NULL auto_increment,
    67   `target` char(1) NOT NULL default 'P',
    68   `category_id` smallint(5) unsigned NOT NULL,
    69   `map_id` int(11) NOT NULL,
    70   `sort` smallint(5) unsigned NOT NULL default '0',
     67  `categoryId` smallint(5) unsigned NOT NULL,
     68  `mapId` int(11) NOT NULL,
     69  `imgSort` smallint(5) unsigned NOT NULL default '0',
    7170  `applySubCat` char(1) NOT NULL default 'y',
    7271  `kmlFileUrl` varchar(255) NOT NULL,
    73   `marker` varchar(1) NOT NULL,
     72  `icon` varchar(255) NOT NULL,
     73  `title` varchar(200) NOT NULL,
    7474  PRIMARY KEY  (`id`),
    75   KEY `byTarget` USING BTREE (`target`,`category_id`,`sort`),
    76   KEY `byCategorie` (`category_id`,`target`)
     75  KEY `byCategorie` (`categoryId`,`mapId`)
     76)",
     77"CREATE TABLE `".$this->tables['cache']."` (
     78  `userId` smallint(5) NOT NULL,
     79  `requestId` timestamp NOT NULL default '0000-00-00 00:00:00',
     80  `imageId` mediumint(8) NOT NULL,
     81  `latitude` decimal(20,17) NOT NULL default '0.00000000000000000',
     82  `longitude` decimal(20,17) NOT NULL default '0.00000000000000000',
     83  `imageName` varchar(255) NOT NULL,
     84  `imageTnFile` varchar(255) NOT NULL,
     85  `imageCatsId` varchar(255) NOT NULL,
     86  `imageCatsNames` varchar(255) NOT NULL,
     87  `imageCatsPLink` varchar(255) NOT NULL,
     88  PRIMARY KEY  USING BTREE (`userId`,`requestId`,`imageId`)
    7789)"
    7890      );
  • extensions/GMaps/gmaps_pip.class.inc.php

    r7054 r7125  
    1818class GMaps_PIP extends GMaps_root
    1919{
    20   protected $coords = array();
    21   protected $maps = array();
    22   protected $content = '';
    23   protected $pictureGeolocated;
     20  protected $maps = array(); //list of maps
     21  protected $category=array(
     22    'id' => 0,
     23    'bounds' => array(
     24      'N' => -90,
     25      'S' => 90,
     26      'E' => -180,
     27      'W' => 180
     28    ),
     29    'icon' => array(
     30      'style' => true,
     31      'file' => '',
     32      'width' => -1,
     33      'height' => -1
     34    )
     35  );
     36  protected $picture=array(
     37    'geolocated' => false,
     38    'coords' => array('lat' => 0, 'lng' => 0),
     39    'content' => array(
     40      'I' => array(), // icon display mode
     41      'M' => array(), // meta display mode
     42    ),
     43    'properties' => array(),
     44    'icon' => array(
     45      'style' => true,
     46      'file' => '',
     47      'width' => -1,
     48      'height' => -1
     49      )
     50  );
     51  protected $css2;
    2452
    2553  public function __construct($prefixeTable, $filelocation)
    2654  {
    2755    parent::__construct($prefixeTable, $filelocation);
     56    $this->css2 = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles()."2.css");
    2857    $this->loadConfig();
    29 
    3058    $this->initEvents();
    3159    $this->load_lang();
    32 
    33     $this->pictureGeolocated=false;
    34     $this->coords['lat']=0;
    35     $this->coords['lng']=0;
    36 
    37     $this->loadMaps();
    3860  }
    3961
    4062  public function __destruct()
    4163  {
    42     unset($section_page);
     64    unset($maps);
     65    unset($picture);
    4366    parent::__destruct();
    4467  }
     
    6184    parent::initEvents();
    6285
    63     //add_event_handler('loc_end_page_header', array(&$this, 'loadJS'));
    64     add_event_handler('amd_jpegMD_loaded', array(&$this, 'prepareMap'));
    65     add_event_handler('loc_begin_picture', array(&$this, 'applyMap'), 55);
     86    add_event_handler('loc_begin_index', array(&$this, 'displayCategoryPageMap'));
     87    add_event_handler('loc_begin_picture', array(&$this, 'displayPicturePageMap'), 55);
     88    add_event_handler('amd_jpegMD_loaded', array(&$this, 'preparePictureMaps'));
     89    add_event_handler('loc_end_page_header', array(&$this->css2, 'applyCSS'));
    6690  }
    6791
     
    7296  ------------------------------------------------------------------------- */
    7397
    74 
    75 
    7698  /**
    77    * build the maps
     99   * this function display the map on the category page
    78100   */
    79   public function prepareMap($jpegMD)
    80   {
    81     global $template;
    82 
    83     if(is_null($jpegMD->getTag('magic.GPS.LatitudeNum')) or
    84        is_null($jpegMD->getTag('magic.GPS.LongitudeNum'))) return(false);
    85 
    86     $this->coords['lat']=$jpegMD->getTag('magic.GPS.LatitudeNum')->getValue();
    87     $this->coords['lng']=$jpegMD->getTag('magic.GPS.LongitudeNum')->getValue();
    88 
    89     $this->pictureGeolocated=true;
    90 
    91     $mapsProperties='';
    92     foreach($this->maps as $val)
    93     {
    94       $this->content.="<div id='iGMaps".$val['id']."' style='width:".$val['width'].";height:".$val['height'].";".$val['style']."'></div>";
    95 
    96       if($mapsProperties!='') $mapsProperties.=',';
    97       $mapsProperties.="
    98       {
    99         id:'iGMaps".$val['id']."',
    100         zoomLevel:".$val['zoomLevel'].",
    101         displayMarker:".(($val['displayMarker']=='Y')?'true':'false').",
    102         mapTypeId:'".$val['mode']."',
     101  public function displayCategoryPageMap()
     102  {
     103    global $page, $prefixeTable, $template, $user, $conf;
     104
     105    if($page['section']=='categories')
     106    {
     107      if(isset($page['category']))
     108      {
     109        $this->category['id']=$page['category']['id'];
     110        $this->buildMapList($page['category']['id'], 'C');
     111        $sqlCatRestrict="AND FIND_IN_SET(".$page['category']['id'].", pct.uppercats)!=0";
    103112      }
    104       ";
    105     }
    106     $this->content="<div id='iGMapContent' style='text-align:center;'>".$this->content."</div>";
    107 
    108     $template->append('head_elements',
     113      else
     114      {
     115        $this->category['id']=0;
     116        $this->buildMapList(0, 'C');
     117        $sqlCatRestrict="";
     118      }
     119
     120      if(count($this->maps)>0)
     121      {
     122        $scripts=array();
     123
     124        // check if there is picture with gps tag in the selected category
     125        $sql="SELECT paut.tagId, MAX(CAST(pait.value AS DECIMAL(20,17))) AS maxValue, MIN(CAST(pait.value AS DECIMAL(20,17))) AS minValue
     126              FROM (((".USER_CACHE_CATEGORIES_TABLE." pucc
     127                LEFT JOIN ".CATEGORIES_TABLE." pct ON pucc.cat_id = pct.id)
     128                LEFT JOIN ".IMAGE_CATEGORY_TABLE." pic ON pic.category_id = pucc.cat_id)
     129                LEFT JOIN ".$prefixeTable."amd_images_tags pait ON pait.imageId = pic.image_id)
     130                LEFT JOIN ".$prefixeTable."amd_used_tags paut ON pait.numId = paut.numId
     131              WHERE pucc.user_id = '".$user['id']."'
     132               AND (paut.tagId = 'magic.GPS.LatitudeNum' OR paut.tagId = 'magic.GPS.LongitudeNum')
     133               AND pic.image_id IS NOT NULL
     134               $sqlCatRestrict
     135               GROUP BY paut.tagId";
     136
     137        $result=pwg_query($sql);
     138        if($result)
     139        {
     140          $nb=0;
     141          while($row=pwg_db_fetch_assoc($result))
     142          {
     143            switch($row['tagId'])
     144            {
     145              case 'magic.GPS.LatitudeNum':
     146                $this->category['bounds']['N']=$row['maxValue'];
     147                $this->category['bounds']['S']=$row['minValue'];
     148                break;
     149              case 'magic.GPS.LongitudeNum':
     150                $this->category['bounds']['E']=$row['maxValue'];
     151                $this->category['bounds']['W']=$row['minValue'];
     152                break;
     153            }
     154            $nb++;
     155          }
     156
     157          if($nb>0)
     158          {
     159            /*
     160             * prepare js script for each map
     161             */
     162
     163            foreach($this->maps as $keyMap => $map)
     164            {
     165              $scripts[]="
     166              {
     167                id:'iGMapsIcon',
     168                zoomLevel:".$map['zoomLevel'].",
     169                marker:true,
     170                mapType:'".$map['mapType']."',
     171                mapTypeControl:'".$map['mapTypeControl']."',
     172                navigationControl:'".$map['navigationControl']."',
     173                scaleControl:'".$map['scaleControl']."',
     174                kmlFileUrl:'".$map['kmlFileUrl']."',
     175                displayType:'".$map['displayType']."',
     176                sizeMode:'".$map['sizeMode']."',
     177                title:'".addslashes( ($map['title']=='')?l10n('gmaps_geolocation'):$map['title']  )."',
     178                markers:[],
     179                fitToBounds:true
     180              }";
     181
     182              preg_match('/^i(\d+)x(\d+).*/i', basename($map['icon']), $result);
     183              $this->category['icon']['iconStyle']=$map['iconStyle'];
     184              $this->category['icon']['file']=$map['icon'];
     185              $this->category['icon']['width']=isset($result[1])?$result[1]:-1;
     186              $this->category['icon']['height']=isset($result[2])?$result[2]:-1;
     187            }
     188
     189
     190            $template->assign('maps', $this->maps);
     191            $template->set_filename('gmapsCatMap',
     192                        dirname($this->getFileLocation()).'/templates/gmaps_category.tpl');
     193            $template->append('footer_elements', $template->parse('gmapsCatMap', true), false);
     194
     195            if(is_array($this->category['icon']))
     196            {
     197              $template->assign('mapIcon', $this->category['icon']);
     198              $template->set_filename('gmapsIconButton',
     199                          dirname($this->getFileLocation()).'/templates/gmaps_category_iconbutton.tpl');
     200              $template->concat('PLUGIN_INDEX_ACTIONS', $template->parse('gmapsIconButton', true), false);
     201              $template->assign('mapIcon');
     202            }
     203
     204
     205            $template->append('head_elements',
     206  "<script type=\"text/javascript\">
     207  gmaps =
     208    {
     209      lang:{
     210        boundmap:'".l10n('gmaps_i_boundmap')."',
     211        boundkml:'".l10n('gmaps_i_boundkml')."'
     212      },
     213      requestId:'',
     214      categoryId:".$this->category['id'].",
     215      bounds:
     216        {
     217          north:".$this->category['bounds']['N'].",
     218          south:".$this->category['bounds']['S'].",
     219          east:".$this->category['bounds']['E'].",
     220          west:".$this->category['bounds']['W']."
     221        },
     222      maps:
     223      [".implode(',', $scripts)."],
     224    }
     225  </script>", false);
     226
     227          }
     228        }
     229      }
     230    }
     231  }
     232
     233
     234
     235  /**
     236   * this function display the map on the picture page
     237   *
     238   * the 'amd_jpegMD_loaded' event is triggered before the 'loc_begin_picture'
     239   * event so, when this function is called the $this->picture var was already
     240   * initialized
     241   */
     242  public function displayPicturePageMap()
     243  {
     244    global $page, $template;
     245
     246    if($this->picture['geolocated']==false) return(false);
     247
     248    if(count($this->picture['content']['MP'])>0)
     249    {
     250      // there is maps in meta display mode
     251      $template->set_filename('gmapsMeta',
     252                  dirname($this->getFileLocation()).'/templates/gmaps_picture_meta.tpl');
     253      $template->assign('maps', $this->picture['content']['MP']);
     254
     255      $metadata=array
     256        (
     257          'TITLE' => l10n('gmaps_geolocation'),
     258          'lines' =>
     259            array(
     260              /* <!--rawContent-->  is a trick to display raw data in tabs
     261               * for the gally template
     262               *
     263               * on the default template, the displayed content is done
     264               * normally
     265               */
     266              '<!--rawContent-->' => $template->parse('gmapsMeta', true)
     267            )
     268        );
     269      $template->append('metadata', $metadata, false);
     270    }
     271
     272    if(count($this->picture['content']['IP'])>0)
     273    {
     274      // there is maps in icon display mode
     275      $template->assign('map', $this->picture['content']['IP'][0]);
     276      $template->assign('mapIcon', $this->picture['icon']);
     277
     278      $template->set_filename('gmapsIconMap',
     279                  dirname($this->getFileLocation()).'/templates/gmaps_picture_icon.tpl');
     280      $template->append('footer_elements', $template->parse('gmapsIconMap', true), false);
     281
     282      $template->set_filename('gmapsIconButton',
     283                  dirname($this->getFileLocation()).'/templates/gmaps_picture_iconbutton.tpl');
     284      $template->concat('PLUGIN_PICTURE_ACTIONS',  $template->parse('gmapsIconButton', true), false);
     285    }
     286
     287    if(count($this->picture['properties'])>0)
     288    {
     289      $template->append('head_elements',
    109290"<script type=\"text/javascript\">
    110291  gmaps =
    111292    {
     293      lang:{
     294        centermap:'".l10n('gmaps_i_centermap')."',
     295        boundkml:'".l10n('gmaps_i_boundkml')."'
     296      },
    112297      coords:
    113298      {
    114         latitude:'".$this->coords['lat']."',
    115         longitude:'".$this->coords['lng']."',
     299        latitude:'".$this->picture['coords']['lat']."',
     300        longitude:'".$this->picture['coords']['lng']."',
    116301      },
    117302      maps:
    118       [$mapsProperties],
    119     }
    120 </script>");
    121 
    122 
    123     if(!isset($template->known_scripts)) $template->known_scripts=Array();
    124 
    125     if(!array_key_exists('jquery', $template->known_scripts))
    126     {
    127       $template->known_scripts['jquery']='themes/default/js/jquery.packed.js';
    128       $template->block_html_head(null, '<script type="text/javascript" src="themes/default/js/jquery.packed.js"></script>', $template->smarty, $false);
    129     }
    130 
    131     $template->known_scripts['maps.google.com/api']='http://maps.google.com/maps/api/js?sensor=false';
    132     $template->block_html_head(null, '<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>', $template->smarty, $false);
    133 
    134     $template->known_scripts['gmaps.gmaps']='plugins/'.basename(dirname(__FILE__)).'/js/gmaps.js';
    135     $template->block_html_head(null, '<script type="text/javascript" src="plugins/'.basename(dirname(__FILE__)).'/js/gmaps.js"></script>', $template->smarty, $false);
    136 
    137 
    138     //$template->append('head_elements', '<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>');
    139     //$template->append('head_elements', '<script type="text/javascript" src="plugins/'.basename(dirname(__FILE__)).'/js/gmaps.js"></script>');
    140   }
     303      [".implode(',', $this->picture['properties'])."],
     304    }
     305</script>", false);
     306    }
     307  }
     308
     309
    141310
    142311
    143312  /**
    144    * add the maps container to the page
     313   * prepare the maps for the picture page
     314   *
     315   * this function is called when the plugin AdvancedMetadata has finished to
     316   * read the metadata ; if picture is not geolocated, there is no map to display
     317   *
     318   * @param JpegMetadata $jpegMD : a JpegMetadata object
    145319   */
    146   public function applyMap()
    147   {
    148     global $template;
    149 
    150     if(!$this->pictureGeolocated) return(false);
    151 
    152     $metadata=$template->get_template_vars('metadata');
    153 
    154     $metadata[]=array
    155       (
    156         'TITLE' => l10n('gmaps_geolocation'),
    157         'lines' =>
    158           array(
    159             '<!--rawContent-->' => $this->content
    160           )
     320  public function preparePictureMaps($jpegMD)
     321  {
     322    global $template, $page;
     323
     324    if(is_null($jpegMD->getTag('magic.GPS.LatitudeNum')) or
     325       is_null($jpegMD->getTag('magic.GPS.LongitudeNum')) or
     326       $page['section']!='categories') return(false);
     327
     328
     329    $this->picture['geolocated']=true;
     330    $this->picture['coords']['lat']=$jpegMD->getTag('magic.GPS.LatitudeNum')->getValue();
     331    $this->picture['coords']['lng']=$jpegMD->getTag('magic.GPS.LongitudeNum')->getValue();
     332
     333
     334    if(isset($page['category']))
     335    {
     336      $this->buildMapList($page['category']['id'], 'P');
     337    }
     338    else
     339    {
     340      $this->buildMapList(0, 'P');
     341    }
     342
     343
     344    foreach($this->maps as $map)
     345    {
     346      if($map['displayType']=='IP')
     347      {
     348        preg_match('/^i(\d+)x(\d+).*/i', basename($map['icon']), $result);
     349        $this->picture['icon']=array(
     350          'iconStyle' => $map['iconStyle'],
     351          'file' => $map['icon'],
     352          'width' => isset($result[1])?$result[1]:-1,
     353          'height' => isset($result[2])?$result[2]:-1
     354        );
     355      }
     356
     357
     358      $this->picture['content'][$map['displayType']][]=array(
     359        'id' => $map['id'],
     360        'width' => $map['width'],
     361        'height' => $map['height'],
     362        'style' => $map['style'],
     363        'mode' => $map['displayType']
    161364      );
    162     $template->assign('metadata', $metadata);
    163   }
    164 
    165 
    166   /**
    167    * loads the maps list
    168    */
    169   private function loadMaps()
    170   {
    171     $sql="SELECT id, width, height, zoomLevel, displayMarker, mode, style
    172           FROM ".$this->tables['maps']."
    173           ORDER BY id";
    174     $result=pwg_query($sql);
    175     if($result)
    176     {
    177       while($row=pwg_db_fetch_assoc($result))
    178       {
    179         $this->maps[]=$row;
    180       }
    181     }
    182   }
     365
     366      $this->picture['properties'][]="
     367      {
     368        id:'iGMaps".(($map['displayType']=='IP')?'Icon':$map['id'])."',
     369        zoomLevel:".$map['zoomLevel'].",
     370        marker:true,
     371        mapType:'".$map['mapType']."',
     372        mapTypeControl:'".$map['mapTypeControl']."',
     373        navigationControl:'".$map['navigationControl']."',
     374        scaleControl:'".$map['scaleControl']."',
     375        kmlFileUrl:'".$map['kmlFileUrl']."',
     376        displayType:'".$map['displayType']."',
     377        sizeMode:'".$map['sizeMode']."',
     378        title:'".addslashes( ($map['title']=='')?l10n('gmaps_geolocation'):$map['title']  )."'
     379      }";
     380    }
     381  }
     382
     383
    183384
    184385
  • extensions/GMaps/gmaps_root.class.inc.php

    r7054 r7125  
    1919    protected $css;
    2020
     21    /**
     22     * check the available AMD release
     23     */
     24    static public function checkAMDRelease()
     25    {
     26      if(!defined('AMD_VERSION')) return(false);
     27
     28      $currentAMDRelease = explode(".", GPC_VERSION);
     29
     30      $neededAMDRelease=explode('.', GMAPS_AMD_NEEDED);
     31      $major=$neededAMDRelease[0];
     32      $minor=$neededAMDRelease[1];
     33      $minor2=$neededAMDRelease[2];
     34
     35      if(($currentAMDRelease[0]>$major) ||
     36         ($currentAMDRelease[0]==$major)&&($currentAMDRelease[1]>$minor) ||
     37         ($currentAMDRelease[0]==$major)&&($currentAMDRelease[1]==$minor)&&($currentAMDRelease[2]>=$minor2))
     38      {
     39        return(true);
     40      }
     41      return(false);
     42    }
     43
     44    /**
     45     * check if AMD plugin is activated and mode
     46     *
     47     * @return String : 'none' if plugin is not installed
     48     *                  'inactive' if plugin is not active
     49     *                  'basic' if plugin active in basic mode
     50     *                  'advanced' if plugin active in advanced mode
     51     */
     52    static public function checkAMDActivated()
     53    {
     54      if(!self::checkAMDRelease()) return('none');
     55
     56      $sql="SELECT state FROM ".PLUGINS_TABLE." WHERE id='AMetaData';";
     57      $result=pwg_query($sql);
     58      if($result)
     59      {
     60        $row=pwg_db_fetch_assoc($result);
     61        if(!(isset($row['state']) and $row['state']='active')) return('inactive');
     62
     63        $amdConfig=array();
     64        GPCCore::loadConfig('amd', $amdConfig);
     65
     66        return($amdConfig['amd_InterfaceMode']);
     67      }
     68    }
     69
     70
    2171    public function __construct($prefixeTable, $filelocation)
    2272    {
     
    2676      $this->section_name=$this->getPluginNameFiles();
    2777
    28       $this->setTablesList(array('maps', 'category_maps'));
     78      $this->setTablesList(array('maps', 'category_maps', 'cache'));
    2979      $this->css = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().".css");
    3080    }
     
    3787    public function initEvents()
    3888    {
    39       add_event_handler('blockmanager_register_blocks', array(&$this, 'register_blocks') );
    4089    }
    4190
     
    111160
    112161    /* ---------------------------------------------------------------------------
    113       ajax functions
     162
    114163    --------------------------------------------------------------------------- */
    115164
     165    /**
     166     * update the given bound with the given coords
     167     *
     168     * @param &Array $bounds : the bounds (N,S,E,W)
     169     * @param Array $coords  : coords (0=>lat, 1=>lng)
     170     */
     171    protected function updateBounds(&$bounds, $coords)
     172    {
     173      if($bounds['E']<$coords['lng']) $bounds['E']=$coords['lng'];
     174      if($bounds['N']<$coords['lat']) $bounds['N']=$coords['lat'];
     175      if($bounds['W']>$coords['lng']) $bounds['W']=$coords['lng'];
     176      if($bounds['S']>$coords['lat']) $bounds['S']=$coords['lat'];
     177    }
     178
     179    /**
     180     * build the list of maps (initialize the $this->maps var)
     181     *
     182     * used by GMaps_ajax & GMaps_pip classes
     183     *
     184     * @param Array $categories : array of categories id (cat + parent list)
     185     * @param String $page : 'P' for picture page, 'C' for category page
     186     */
     187    protected function buildMapList($category, $page)
     188    {
     189      global $template ;
     190
     191      if($page=='C')
     192      {
     193        $where=" displayType='IC' ";
     194      }
     195      else
     196      {
     197        $where=" (displayType='IP' or displayType='MP') ";
     198      }
     199
     200      /*
     201       * sql request select all possible association, sorted from the highest to
     202       * the lowest priority
     203       */
     204      $sql="SELECT DISTINCT pgcm.id, pgcm.categoryId,
     205              pgcm.imgSort, pgcm.applySubCat, pgcm.kmlFileUrl,
     206              pgcm.icon, pgcm.title,
     207              pgmm.displayType, pgmm.sizeMode,
     208              pgmm.width, pgmm.height, pgmm.zoomLevel,
     209              pgmm.mapType, pgmm.mapTypeControl, pgmm.scaleControl,
     210              pgmm.navigationControl, pgmm.style,
     211              IF(pgcm.categoryId=0, 0, pct.global_rank) AS priorityRank
     212            FROM (".$this->tables['category_maps']." pgcm
     213              LEFT JOIN ".$this->tables['maps']." pgmm ON pgcm.mapId = pgmm.id)
     214              LEFT JOIN ".CATEGORIES_TABLE." pct ON (FIND_IN_SET(pgcm.categoryId, pct.uppercats)!=0 OR pgcm.categoryId=0)
     215            WHERE $where ";
     216      if($category!=0)
     217      {
     218        $sql.=" AND pct.id = '$category' ";
     219      }
     220      else
     221      {
     222        $sql.=" AND pgcm.categoryId = 0 ";
     223      }
     224      $sql.=" AND pgcm.applySubCat='y'
     225            ORDER BY priorityRank DESC, pgmm.displayType ASC, pgcm.categoryId ASC, pgcm.imgSort ASC;";
     226      $result=pwg_query($sql);
     227
     228      if($result)
     229      {
     230        // for each found row, choose the highest only
     231        $pcat='';
     232        $displayType=array(
     233         'IC' => true,
     234         'IP' => true,
     235         'MP' => true,
     236        );
     237        while($row=pwg_db_fetch_assoc($result))
     238        {
     239          if($row['displayType']!='MP')
     240          {
     241            $themeConf=$template->get_template_vars('themeconf');
     242            $fileName=preg_replace('/^([i|c]\d+x\d+)(?:_\d+){0,1}(\..*)/i', '$1$2', $row['icon']);
     243
     244            if(file_exists(PHPWG_ROOT_PATH.$themeConf['icon_dir'].'/gmaps/'.$fileName))
     245            {
     246              $row['icon']=$themeConf['icon_dir'].'/gmaps/'.$fileName;
     247              $row['iconStyle']=false;
     248            }
     249            else
     250            {
     251              $row['icon']='plugins/GMaps/img/'.$row['icon'];
     252              $row['iconStyle']=true;
     253            }
     254          }
     255
     256          if($displayType[$row['displayType']])
     257          {
     258            if($row['displayType']=='MP')
     259            {
     260              if($displayType['MP'] and ($row['categoryId']==$pcat or $pcat=='')) $this->maps[]=$row;
     261              if($displayType['MP'] and $row['categoryId']!=$pcat and $pcat!='') $displayType['MP']=false;
     262              $pcat=$row['categoryId'];
     263            }
     264            else
     265            {
     266              $this->maps[]=$row;
     267              $displayType[$row['displayType']]=false;
     268            }
     269          }
     270        }
     271      }
     272    }
     273
     274
    116275
    117276  } //class
  • extensions/GMaps/gmaps_version.inc.php

    r7054 r7125  
    1818  define('GMAPS_VERSION2', '00.02.00');
    1919  define('GMAPS_GPC_NEEDED', '3.2.0');
     20  define('GMAPS_AMD_NEEDED', '0.5.2'); //advanced metadata plugin is needed
    2021?>
  • extensions/GMaps/language/fr_FR/plugin.lang.php

    r7054 r7125  
    11<?php
     2
     3$lang['To install this plugin, you need to install Grum Plugin Classes %s before']="Pour installer ce plugin, vous devez au préalable installer le plugin Grum Plugin Classes %s";
     4$lang['To install this plugin, you need to install Advanced Metadata %s before']="Pour installer ce plugin, vous devez au préalable installer le plugin Advanced Metadata %s";
     5$lang['gmaps_amd_warning_inactive']="Attention ! <br><br>Le plugin Advanced Metadata %s ne semble pas être installé/activé : les cartes ne pourront être affichées tant qu'il ne sera pas activé.";
     6$lang['gmaps_amd_warning_basic']="Attention ! <br><br>Le plugin Advanced Metadata fonctionne en mode 'basique' : les cartes associées aux catégories ne pourront pas être affichées.";
     7$lang['gmaps_warning']='Avertissement';
    28
    39$lang['gmaps_release']='v';
     
    511$lang['gmaps_geolocation'] = 'Géolocalisation';
    612$lang['gmaps_maps'] = 'Cartes';
     13$lang['gmaps_map'] = 'Carte';
    714$lang['gmaps_associate_category_maps'] = 'Association des cartes';
     15$lang['gmaps_search'] = 'Rechercher';
     16$lang['gmaps_kml_files_management'] = 'Gestion des fichiers KML';
    817$lang['gmaps_help'] = 'Aide';
    918
    1019$lang['gmaps_maps_management']='Gestion des cartes';
    1120
     21$lang['gmaps_y'] = "Oui";
     22$lang['gmaps_n'] = "Non";
    1223$lang['gmaps_ok'] = "Ok";
    1324$lang['gmaps_cancel'] = "Annuler";
     
    1627$lang['gmaps_loading'] = "Chargement...";
    1728
    18 $lang['gmaps_config_map']="Paramétrage d\'une carte";
     29$lang['gmaps_config_map']="Paramétrage d\\'une carte";
    1930$lang['gmaps_pleaseConfirmMetadataDelete_1']="La carte ainsi que toutes les associations qui en dépendent seront supprimées.";
    2031$lang['gmaps_pleaseConfirmMetadataDelete_2']="Merci de confirmer la suppression.";
     32$lang['gmaps_pleaseConfirmAssoc']="Merci de confirmer la suppression.";
    2133$lang['gmaps_deleteMap']="Suppression de la carte";
    22 $lang['gmaps_invalidId']="Identifiant invalide !";
    23 $lang['gmaps_mapIdAlreadyExist']="Une carte avec cet identifiant existe déjà !";
    2434$lang['gmaps_add_a_new_map']="Ajouter une carte";
    2535
    26 $lang['gmaps_id']="Identifiant de la carte";
    2736$lang['gmaps_name']="Nom";
    2837$lang['gmaps_dimensions']="Dimensions";
     
    3140$lang['gmaps_width']="Largeur";
    3241$lang['gmaps_height']="Hauteur";
     42$lang['gmaps_auto']="Automatique";
     43$lang['gmaps_displayType']="Méthode d'affichage";
    3344
    34 $lang['gmaps_fullScreen']="Plein écran";
    35 $lang['gmaps_zoomAuto']="Automatique";
     45$lang['gmaps_displayTypeShortIC']="Catégorie (lightbox)";
     46$lang['gmaps_displayTypeShortIP']="Photo (lightbox)";
     47$lang['gmaps_displayTypeShortMP']="Photo (métadonnée)";
     48$lang['gmaps_displayTypeIC']="A afficher sur la page d'une catégorie (lightbox)";
     49$lang['gmaps_displayTypeIP']="A afficher sur la page d'une photo (lightbox)";
     50$lang['gmaps_displayTypeMP']="A afficher sur la page d'une photo (en tant que métadonnée)";
     51
     52$lang['gmaps_map_dimensions_are']="Les dimensions de la carte sont :";
     53$lang['gmaps_interface_dimensions_f']="Fixées";
     54$lang['gmaps_interface_dimensions_a']="Adaptées à la taille de la fenêtre";
     55
     56
    3657$lang['gmaps_googleMapType_hybrid']="Mixte";
    3758$lang['gmaps_googleMapType_terrain']="Relief";
     
    6586$lang['gmaps_googleMapControlPos_BR']="En bas à droite";
    6687
    67 
    6888$lang['gmaps_properties_general']="Propriétés";
    6989$lang['gmaps_properties_mapType']="Gestion de l'affichage";
    7090$lang['gmaps_properties_zoomLevel']="Gestion du zoom";
    7191
     92$lang['gmaps_add_a_new_association']="Ajouter une nouvelle association";
     93$lang['gmaps_category']="Catégorie";
     94$lang['gmaps_picture']="Photo";
     95$lang['gmaps_nb_pictures']="%s photos";
     96$lang['gmaps_1_picture']="1 photo";
     97$lang['gmaps_apply_subcat']="Appliquer aux sous-catégories";
     98$lang['gmaps_map_id']="Carte";
     99$lang['gmaps_map_kmlfile']="Présence fichier KML";
     100$lang['gmaps_map_icon']="Icone";
     101$lang['gmaps_map_kmlfile']="Associer un fichier KML";
     102$lang['gmaps_map_associate_kmlfile']="Associer un fichier KML (saisir l'URL)";
     103
     104$lang['gmaps_map_integration']="Intégration dans la galerie";
     105$lang['gmaps_map_assoc']="Caractéristiques";
     106
     107$lang['gmaps_manage_assoc']="Gestion d\\'une association";
     108$lang['gmaps_deleteAssoc']="Suppression d\\'une association";
     109
     110
     111$lang['gmaps_applyForAllTheGallery']="Toute la galerie";
     112$lang['gmaps_only_one_map_is_allowed_for_this_mode']="Un paramétrage existe déjà pour cette association";
     113$lang['gmaps_view_map']="Localiser la photo sur une carte";
     114$lang['gmaps_map_title']="Titre";
     115
     116
     117
     118$lang['gmaps_i_boundmap']="Adapter la taille de la carte pour voir tous les éléments";
     119$lang['gmaps_i_boundkml']="Adapter la taille de la carte pour voir l\\'intégralité du tracé";
     120$lang['gmaps_i_centermap']="Centrer la carte";
     121$lang['gmaps_i_show_this_picture_in']="Voir cette photo dans la catégorie :";
     122
    72123?>
  • extensions/GMaps/maintain.inc.php

    r7054 r7125  
    4040}
    4141
    42 function gpcMsgError(&$errors)
     42function gpcMsgError(&$errors, $errorMessage)
    4343{
    44   global $gpcNeeded;
    45   $msg=sprintf(l10n('To install this plugin, you need to install Grum Plugin Classes %s before'), GMAPS_GPC_NEEDED);
     44  switch($errorMessage)
     45  {
     46    case 'gpc':
     47      $msg=sprintf(l10n('To install this plugin, you need to install Grum Plugin Classes %s before'), GMAPS_GPC_NEEDED);
     48      break;
     49    case 'amd':
     50      $msg=sprintf(l10n('To install this plugin, you need to install Advanced Metadata %s before'), GMAPS_AMD_NEEDED);
     51      break;
     52  }
     53
    4654  if(is_array($errors))
    4755  {
     
    6472{
    6573  global $prefixeTable, $gpcInstalled;
    66   if($gpcInstalled)
     74  if(!$gpcInstalled)
    6775  {
    68     $gmaps=new GMaps_Install($prefixeTable, __FILE__);
    69     $result=$gmaps->install();
     76    gpcMsgError($errors, 'gpc');
     77    return(false);
    7078  }
    71   else
     79  if(GMaps_root::checkAMDActivated()=='none')
    7280  {
    73     gpcMsgError($errors);
     81    amdMsgError($errors, 'amd');
     82    return(false);
    7483  }
     84
     85  $gmaps=new GMaps_Install($prefixeTable, __FILE__);
     86  $result=$gmaps->install();
    7587}
    7688
     
    107119  else
    108120  {
    109     gpcMsgError($errors);
     121    gpcMsgError($errors, 'gpc');
    110122  }
    111123}
Note: See TracChangeset for help on using the changeset viewer.