Changeset 7482 for extensions/GMaps


Ignore:
Timestamp:
Oct 29, 2010, 4:16:18 PM (13 years ago)
Author:
grum
Message:

Maps are not displayed if user navigate with tag
bug:1967

Location:
extensions/GMaps
Files:
2 edited

Legend:

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

    r7479 r7482  
    103103    global $page, $prefixeTable, $template, $user, $conf;
    104104
    105     if($page['section']=='categories')
     105    if($page['section']=='categories' or $page['section']=='tags')
    106106    {
    107107      if(isset($page['category']))
     
    109109        $this->category['id']=$page['category']['id'];
    110110        $this->buildMapList($page['category']['id'], 'C');
    111         $sqlCatRestrict="AND FIND_IN_SET(".$page['category']['id'].", pct.uppercats)!=0";
    112       }
    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();
    123111
    124112        // check if there is picture with gps tag in the selected category
     
    132120               AND (paut.tagId = 'magic.GPS.LatitudeNum' OR paut.tagId = 'magic.GPS.LongitudeNum')
    133121               AND pic.image_id IS NOT NULL
    134                $sqlCatRestrict
     122               AND FIND_IN_SET(".$page['category']['id'].", pct.uppercats)!=0
    135123               GROUP BY paut.tagId";
     124      }
     125      elseif(isset($page['items']))
     126      {
     127        if(count($page['items'])==0) return(false);
     128        // 'tags'
     129        $sql="SELECT paut.tagId, MAX(CAST(pait.value AS DECIMAL(20,17))) AS maxValue, MIN(CAST(pait.value AS DECIMAL(20,17))) AS minValue
     130              FROM ".$prefixeTable."amd_images_tags pait
     131                    LEFT JOIN ".$prefixeTable."amd_used_tags paut ON pait.numId = paut.numId
     132              WHERE (paut.tagId = 'magic.GPS.LatitudeNum' OR paut.tagId = 'magic.GPS.LongitudeNum')
     133               AND pait.imageId IN (".implode(',', $page['items']).")
     134               GROUP BY paut.tagId";
     135        $this->category['id']=0;
     136        $this->buildMapList(0, 'C');
     137      }
     138      else
     139      {
     140        // 'home'
     141        $this->category['id']=0;
     142        $this->buildMapList(0, 'C');
     143        // check if there is picture with gps tag in the selected category
     144        $sql="SELECT paut.tagId, MAX(CAST(pait.value AS DECIMAL(20,17))) AS maxValue, MIN(CAST(pait.value AS DECIMAL(20,17))) AS minValue
     145              FROM (((".USER_CACHE_CATEGORIES_TABLE." pucc
     146                LEFT JOIN ".CATEGORIES_TABLE." pct ON pucc.cat_id = pct.id)
     147                LEFT JOIN ".IMAGE_CATEGORY_TABLE." pic ON pic.category_id = pucc.cat_id)
     148                LEFT JOIN ".$prefixeTable."amd_images_tags pait ON pait.imageId = pic.image_id)
     149                LEFT JOIN ".$prefixeTable."amd_used_tags paut ON pait.numId = paut.numId
     150              WHERE pucc.user_id = '".$user['id']."'
     151               AND (paut.tagId = 'magic.GPS.LatitudeNum' OR paut.tagId = 'magic.GPS.LongitudeNum')
     152               AND pic.image_id IS NOT NULL
     153               GROUP BY paut.tagId";
     154      }
     155
     156      if(count($this->maps)>0)
     157      {
     158        $scripts=array();
    136159
    137160        $result=pwg_query($sql);
     
    256279
    257280    if($this->picture['geolocated']==false and $this->picture['forceDisplay']==false) return(false);
    258 
    259281    if(isset($this->picture['content']['MP']) and count($this->picture['content']['MP'])>0)
    260282    {
     
    340362  public function preparePictureMaps($jpegMD)
    341363  {
    342     global $template, $page;
     364    global $template, $page, $user;
    343365
    344366    $isGeolocated=true;
    345367
    346368    if(is_null($jpegMD->getTag('magic.GPS.LatitudeNum')) or
    347        is_null($jpegMD->getTag('magic.GPS.LongitudeNum')) or
    348        $page['section']!='categories') $isGeolocated=false;
     369       is_null($jpegMD->getTag('magic.GPS.LongitudeNum'))) $isGeolocated=false;
    349370
    350371
     
    355376    else
    356377    {
    357       $this->buildMapList(0, 'P');
     378      $sql="SELECT GROUP_CONCAT(pict.category_id)
     379            FROM ".IMAGE_CATEGORY_TABLE." pict
     380            WHERE pict.image_id=".$page['image_id'];
     381      if($user['forbidden_categories']!='') $sql.=" AND pict.category_id NOT IN (".$user['forbidden_categories'].")";
     382
     383      $result=pwg_query($sql);
     384      if($result)
     385      {
     386        while($row=pwg_db_fetch_row($result))
     387        {
     388          $cats=explode(',', $row[0]);
     389        }
     390      }
     391
     392      $cats[]=0;
     393      $i=0;
     394      while(count($this->maps)==0 and $i<count($cats))
     395      {
     396        $this->buildMapList($cats[$i], 'P');
     397        $i++;
     398      }
    358399    }
    359400
  • extensions/GMaps/main.inc.php

    r7479 r7482  
    5555|         |            |   . Display map if a kml file is associated
    5656|         |            |
    57 |         |            |
    58 |         |            |
     57|         |            | * mantis bug:1967
     58|         |            |   . Maps are not displayed if user navigate with tag
    5959|         |            |
    6060|         |            |
Note: See TracChangeset for help on using the changeset viewer.