Changeset 5183 for extensions/AMetaData/amd_aip.class.inc.php
- Timestamp:
- Mar 18, 2010, 11:47:11 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/AMetaData/amd_aip.class.inc.php
r5097 r5183 33 33 protected $tabsheet; 34 34 protected $ajax; 35 protected $jpegMD;36 35 37 36 /** … … 42 41 * @param String $filelocation 43 42 */ 44 function __construct($prefixeTable, $filelocation)43 public function __construct($prefixeTable, $filelocation) 45 44 { 46 45 parent::__construct($prefixeTable, $filelocation); … … 57 56 $this->page_link.'&fAMD_tabsheet=help'); 58 57 $this->ajax = new Ajax(); 59 $this->jpegMD=new JpegMetaData(); 60 } 61 62 function __destruct() 58 } 59 60 public function __destruct() 63 61 { 64 62 unset($this->tabsheet); 65 63 unset($this->ajax); 66 unset($this->jpegMD);64 parent::__destruct(); 67 65 } 68 66 … … 681 679 682 680 683 /**684 * this function analyze tags from a picture, and insert the result into the685 * database686 *687 * NOTE : only implemented tags are analyzed and stored688 *689 * @param String $fileName : filename of picture to analyze690 * @param Integer $imageId : id of image in piwigo's database691 */692 protected function analyzeImageFile($fileName, $imageId)693 {694 /*695 * the JpegMetaData object is instancied in the constructor696 */697 $this->jpegMD->load($fileName, Array(698 'filter' => JpegMetaData::TAGFILTER_IMPLEMENTED,699 'optimizeIptcDateTime' => true)700 );701 702 $sqlInsert="";703 $massInsert=array();704 $nbTags=0;705 foreach($this->jpegMD->getTags() as $key => $val)706 {707 $value=$val->getLabel();708 709 if($val->isTranslatable())710 $translatable="y";711 else712 $translatable="n";713 714 if($value instanceof DateTime)715 {716 $value=$value->format("Y-m-d H:i:s");717 }718 elseif(is_array($value))719 {720 /*721 * array values are stored in a serialized string722 */723 $value=serialize($value);724 }725 726 $sql="SELECT numId FROM ".$this->tables['used_tags']." WHERE tagId = '$key'";727 $result=pwg_query($sql);728 if($result)729 {730 $numId=-1;731 while($row=mysql_fetch_assoc($result))732 {733 $numId=$row['numId'];734 }735 736 if($numId>0)737 {738 $nbTags++;739 if($sqlInsert!="") $sqlInsert.=", ";740 $sqlInsert.="($imageId, '$numId', '".addslashes($value)."')";741 $massInsert[]="('$imageId', '$numId', '".addslashes($value)."') ";742 }743 }744 }745 746 $sql="REPLACE INTO ".$this->tables['images_tags']." (imageId, numId, value)747 VALUES ".implode(", ", $massInsert);748 pwg_query($sql);749 //mass_inserts($this->tables['images_tags'], array('imageId', 'numId', 'value'), $massInsert);750 751 $sql="UPDATE ".$this->tables['images']."752 SET analyzed = 'y', nbTags=".$nbTags."753 WHERE imageId=$imageId;";754 pwg_query($sql);755 756 757 return("$imageId=$nbTags;");758 }759 760 761 /**762 * returns the number of pictures analyzed763 *764 * @return Integer765 */766 protected function getNumOfPictures()767 {768 $numOfPictures=0;769 $sql="SELECT COUNT(imageId) FROM ".$this->tables['images']."770 WHERE analyzed='y';";771 $result=pwg_query($sql);772 if($result)773 {774 while($row=mysql_fetch_row($result))775 {776 $numOfPictures=$row[0];777 }778 }779 return($numOfPictures);780 }781 681 782 682 … … 910 810 private function ajax_amd_makeStatsConsolidation() 911 811 { 912 $sql="UPDATE ".$this->tables['used_tags']." ut, 913 (SELECT COUNT(imageId) AS nb, numId 914 FROM ".$this->tables['images_tags']." 915 GROUP BY numId) nb 916 SET ut.numOfImg = nb.nb 917 WHERE ut.numId = nb.numId;"; 918 pwg_query($sql); 812 $this->makeStatsConsolidation(); 919 813 } 920 814
Note: See TracChangeset
for help on using the changeset viewer.