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_root.class.inc.php

    r6734 r6891  
    2323include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php');
    2424include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCCss.class.inc.php');
     25include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCRequestBuilder.class.inc.php');
    2526
    2627include_once('amd_jpegmetadata.class.inc.php');
     
    4849      'groups',
    4950      'user_tags_label',
    50       'user_tags_def');
     51      'user_tags_def',
     52      'tags_values');
    5153    $this->setTablesList($tableList);
    5254
     
    6668    //parent::__destruct();
    6769  }
    68 
    6970
    7071  /* ---------------------------------------------------------------------------
     
    8586      'amd_FillDataBaseContinuously' => "y",
    8687      'amd_FillDataBaseIgnoreSchemas' => array(),
     88      'amd_UseMetaFromHD' => "y",
    8789
    8890      // theses options can be set manually
     
    178180  public function doRandomAnalyze()
    179181  {
    180     $sql="SELECT tai.imageId, ti.path FROM ".$this->tables['images']." tai
     182    $sql="SELECT tai.imageId, ti.path, ti.has_high FROM ".$this->tables['images']." tai
    181183            LEFT JOIN ".IMAGES_TABLE." ti ON tai.imageId = ti.id
    182184          WHERE tai.analyzed = 'n'
     
    190192      while($row=pwg_db_fetch_assoc($result))
    191193      {
    192         $this->analyzeImageFile($path."/".$row['path'], $row['imageId']);
     194        if($row['has_high']===true and $this->config['amd_UseMetaFromHD']=='y')
     195        {
     196          $this->analyzeImageFile($path."/".dirname($row['path'])."/pwg_high/".basename($row['path']), $row['imageId']);
     197        }
     198        else
     199        {
     200          $this->analyzeImageFile($path."/".$row['path'], $row['imageId']);
     201        }
    193202      }
    194203
     
    234243    }
    235244
    236     $sqlInsert="";
     245    //$sqlInsert="";
    237246    $massInsert=array();
    238247    $nbTags=0;
     
    272281        {
    273282          $nbTags++;
    274           if($sqlInsert!="") $sqlInsert.=", ";
    275           $sqlInsert.="($imageId, '$numId', '".addslashes($value)."')";
     283          //if($sqlInsert!="") $sqlInsert.=", ";
     284          //$sqlInsert.="($imageId, '$numId', '".addslashes($value)."')";
    276285          $massInsert[]="('$imageId', '$numId', '".addslashes($value)."') ";
    277286        }
     
    291300    pwg_query($sql);
    292301
     302    unset($massInsert);
    293303
    294304    return("$imageId=$nbTags;");
     
    398408            if(!is_null($buildValue['value']))
    399409            {
     410              $buildValue['value']=addslashes($buildValue['value']);
    400411              $inserts[]=$buildValue;
    401412              $num++;
     
    483494              if(isset($values[$rule['value']]) and
    484495                 !preg_match('/'.$rule['conditionValue'].'/i', $values[$rule['value']])) $ok=true;
     496              break;
     497            case '^%':
     498              if(isset($values[$rule['value']]) and
     499                 preg_match('/^'.$rule['conditionValue'].'/i', $values[$rule['value']])) $ok=true;
     500              break;
     501            case '!^%':
     502              if(isset($values[$rule['value']]) and
     503                 !preg_match('/^'.$rule['conditionValue'].'/i', $values[$rule['value']])) $ok=true;
     504              break;
     505            case '$%':
     506              if(isset($values[$rule['value']]) and
     507                 preg_match('/'.$rule['conditionValue'].'$/i', $values[$rule['value']])) $ok=true;
     508              break;
     509            case '!$%':
     510              if(isset($values[$rule['value']]) and
     511                 !preg_match('/'.$rule['conditionValue'].'$/i', $values[$rule['value']])) $ok=true;
    485512              break;
    486513          }
     
    557584  }
    558585
    559 
    560586  /**
    561587   * This function :
     
    569595   * @return String               : the value prepared
    570596   */
    571   protected function prepareValueForDisplay($value, $translatable=true, $separator=", ")
     597  static public function prepareValueForDisplay($value, $translatable=true, $separator=", ")
    572598  {
    573599    global $user;
     
    720746  }
    721747
     748
    722749} // amd_root  class
    723750
    724751
    725752
     753Class AMD_functions {
     754  /**
     755   *  return all HTML&JS code necessary to display a dialogbox to choose
     756   *  a metadata
     757   */
     758  static public function dialogBoxMetadata()
     759  {
     760    global $template, $prefixeTable;
     761
     762    $tables=array(
     763        'used_tags' => $prefixeTable.'amd_used_tags',
     764        'selected_tags' => $prefixeTable.'amd_selected_tags',
     765    );
     766
     767    $template->set_filename('metadata_choose',
     768                  dirname(__FILE__).'/templates/amd_dialog_metadata_choose.tpl');
     769
     770    $datas=array(
     771      'urlRequest' => 'plugins/'.basename(dirname(__FILE__)).'/amd_ajax.php',
     772      'tagList' => array(),
     773    );
     774
     775    /*
     776     * build tagList
     777     */
     778    $sql="SELECT ut.name, ut.numId, ut.tagId
     779          FROM ".$tables['used_tags']." ut
     780            JOIN ".$tables['selected_tags']." st ON st.tagId = ut.tagId
     781          ORDER BY tagId";
     782    $result=pwg_query($sql);
     783    if($result)
     784    {
     785      while($row=pwg_db_fetch_assoc($result))
     786      {
     787        $datas['tagList'][]=Array(
     788          'tagId' => $row['tagId'],
     789          'name'  => L10n::get($row['name']),
     790          'numId' => $row['numId']
     791        );
     792      }
     793    }
     794
     795    $template->assign('datas', $datas);
     796    unset($data);
     797
     798    return($template->parse('metadata_choose', true));
     799  }
     800}
     801
     802
     803
    726804?>
Note: See TracChangeset for help on using the changeset viewer.