Ignore:
Timestamp:
Sep 13, 2010, 8:40:44 PM (14 years ago)
Author:
grum
Message:

Implement metadata search, release 0.5.1
bug:1846, bug:1691

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/AMetaData/amd_ajax.php

    r6729 r6891  
    8383           $_REQUEST['ajaxfct']=='admin.userDefined.setTag' or
    8484           $_REQUEST['ajaxfct']=='admin.userDefined.deleteTag' or
     85           $_REQUEST['ajaxfct']=='admin.tag.getValues' or
    8586
    8687           $_REQUEST['ajaxfct']=='public.makeStats.doPictureAnalyze')) $_REQUEST['ajaxfct']='';
     
    309310
    310311        /*
     312         * check admin.tag.getValues values
     313         */
     314        if($_REQUEST['ajaxfct']=="admin.tag.getValues" and !isset($_REQUEST['id']))
     315        {
     316          $_REQUEST['ajaxfct']='';
     317        }
     318
     319
     320        /*
    311321         * check public.makeStats.doPictureAnalyze values
    312322         */
     
    387397          $result=$this->ajax_amd_admin_userDefinedDeleteTag($_REQUEST['id']);
    388398          break;
     399        case 'admin.tag.getValues':
     400          $result=$this->ajax_amd_admin_tagGetValues($_REQUEST['id']);
     401          break;
    389402
    390403
     
    406419      {
    407420        // get a randomly picture...
    408         $sql="SELECT pai.imageId, pi.path
     421        $sql="SELECT pai.imageId, pi.path, pi.has_high
    409422              FROM ".$this->tables['images']." pai
    410423                LEFT JOIN ".IMAGES_TABLE." pi ON pai.imageId=pi.id
     
    426439        {
    427440          $imageId=$row['imageId'];
    428           $filename=$path."/".$row['path'];
     441          if($row['has_high']===true and $this->config['amd_UseMetaFromHD']=='y')
     442          {
     443            $filename=$path."/".dirname($row['path'])."/pwg_high/".basename($row['path']);
     444          }
     445          else
     446          {
     447            $filename=$path."/".$row['path'];
     448          }
    429449        }
    430450
     
    546566        $path=dirname(dirname(dirname(__FILE__)));
    547567
    548         $sql="SELECT id, path FROM ".IMAGES_TABLE." WHERE id IN (".implode(", ", $list).")";
     568        $sql="SELECT id, path, has_high FROM ".IMAGES_TABLE." WHERE id IN (".implode(", ", $list).")";
    549569        $result=pwg_query($sql);
    550570        if($result)
     
    564584            //$mem1=memory_get_usage();
    565585            //echo "memory before analyze:".$mem1."\n";
    566             $returned.=$this->analyzeImageFile($path."/".$row['path'], $row['id']);
     586            if($row['has_high']===true and $this->config['amd_UseMetaFromHD']=='y')
     587            {
     588              $returned.=$this->analyzeImageFile($path."/".dirname($row['path'])."/pwg_high/".basename($row['path']), $row['id']);
     589            }
     590            else
     591            {
     592              $returned.=$this->analyzeImageFile($path."/".$row['path'], $row['id']);
     593            }
    567594            //echo $returned."\n";
    568595            //$mem2=memory_get_usage();
     
    722749        {
    723750          $datas[]=array(
    724             "value" => $this->prepareValueForDisplay($row['value'], ($row['translatable']=='y'), ", "),
     751            "value" => AMD_root::prepareValueForDisplay($row['value'], ($row['translatable']=='y'), ", "),
    725752            "nb"    => $row['Nb'],
    726753            "pct"   => ($row['numOfImg']!=0)?sprintf("%.2f", 100*$row['Nb']/$row['numOfImg']):"-"
     
    13421369      foreach($properties['rules'] as $rule)
    13431370      {
     1371        print_r($rule['value']);
    13441372        $inserts[]="('$id', '".$rule['defId']."', '".$rule['parentId']."', '".$rule['order']."', '".$rule['type']."', '".$rule['value']."', '".$rule['conditionType']."', '".$rule['conditionValue']."')";
    13451373      }
     
    14011429    }
    14021430
     1431
     1432    /**
     1433     * return the known values for a given tag id
     1434     *
     1435     * @param String $id : a tag numId
     1436     * @return String : an HTML list ready to use
     1437     */
     1438    private function ajax_amd_admin_tagGetValues($numId)
     1439    {
     1440      $returned="";
     1441
     1442      $sql="SELECT DISTINCT pait.value, COUNT(pait.imageId) AS nbImg, paut.translatable
     1443            FROM ".$this->tables['images_tags']." pait
     1444              LEFT JOIN ".$this->tables['used_tags']." paut
     1445                ON pait.numId=paut.numId
     1446            WHERE pait.numId = '$numId'
     1447            GROUP BY pait.value
     1448            ORDER BY pait.value";
     1449      $result=pwg_query($sql);
     1450      if($result)
     1451      {
     1452        while($row=pwg_db_fetch_assoc($result))
     1453        {
     1454          $value=htmlspecialchars(AMD_root::prepareValueForDisplay($row['value'], ($row['translatable']=='y'), ", "), ENT_QUOTES);
     1455          $returned.="<option displayvalue='$value' rawvalue='".$row['value']."'>$value (".$row['nbImg']." ".l10n('images').")</option>";
     1456        }
     1457      }
     1458      return($returned);
     1459    }
     1460
     1461
    14031462    /**
    14041463     * set value(s) for option(s)
Note: See TracChangeset for help on using the changeset viewer.