Changeset 5080 for extensions/AMetaData/amd_aip.class.inc.php
- Timestamp:
- Mar 7, 2010, 10:24:29 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/AMetaData/amd_aip.class.inc.php
r5040 r5080 53 53 l10n('g003_metadata'), 54 54 $this->page_link.'&fAMD_tabsheet=metadata'); 55 $this->tabsheet->add(' database',56 l10n('g003_ database'),57 $this->page_link.'&fAMD_tabsheet= database');55 $this->tabsheet->add('help', 56 l10n('g003_help'), 57 $this->page_link.'&fAMD_tabsheet=help'); 58 58 $this->ajax = new Ajax(); 59 59 $this->jpegMD=new JpegMetaData(); … … 99 99 $template->assign('plugin', $template_plugin); 100 100 101 if($_REQUEST['fAMD_tabsheet']==' database')102 { 103 $this->displayDatabase();101 if($_REQUEST['fAMD_tabsheet']=='help') 102 { 103 //$this->displayHelp(); 104 104 } 105 105 elseif($_REQUEST['fAMD_tabsheet']=='metadata') … … 213 213 else 214 214 { 215 $defautTabsheet=" metadata";215 $defautTabsheet="select"; 216 216 } 217 217 … … 222 222 223 223 if($_REQUEST['fAMD_tabsheet']!="metadata" and 224 $_REQUEST['fAMD_tabsheet']!=" database")225 { 226 $_REQUEST['fAMD_tabsheet']= $defautTabsheet;224 $_REQUEST['fAMD_tabsheet']!="help") 225 { 226 $_REQUEST['fAMD_tabsheet']="metadata"; 227 227 } 228 228 229 229 if($_REQUEST['fAMD_tabsheet']=="metadata" and !isset($_REQUEST['fAMD_page'])) 230 230 { 231 $_REQUEST['fAMD_page']= "select";231 $_REQUEST['fAMD_page']=$defautTabsheet; 232 232 } 233 233 234 234 if($_REQUEST['fAMD_tabsheet']=="metadata" and 235 235 !($_REQUEST['fAMD_page']=="select" or 236 $_REQUEST['fAMD_page']=="database" or 236 237 $_REQUEST['fAMD_page']=="display")) 237 238 { 238 $_REQUEST['fAMD_page']= "select";239 $_REQUEST['fAMD_page']=$defautTabsheet; 239 240 } 240 241 … … 249 250 if($_REQUEST['ajaxfct']=="makeStatsGetList" and !isset($_REQUEST['selectMode'])) 250 251 { 251 $_REQUEST['selectMode']=" notAnalyzed";252 $_REQUEST['selectMode']="caddieAdd"; 252 253 } 253 254 254 255 if($_REQUEST['ajaxfct']=="makeStatsGetList" and 255 256 !($_REQUEST['selectMode']=="notAnalyzed" or 257 $_REQUEST['selectMode']=="caddieAdd" or 258 $_REQUEST['selectMode']=="caddieReplace" or 256 259 $_REQUEST['selectMode']=="all")) 257 260 { 258 $_REQUEST['selectMode']=" notAnalyzed";261 $_REQUEST['selectMode']="caddieAdd"; 259 262 } 260 263 … … 477 480 478 481 /** 479 * display and manage the database page480 *481 * the function automatically update the AMD tables :482 * - add new pictures in the AMD image table (assuming image is not analyzed483 * yet)484 * - remove deleted pictures in the AMD image & image_tags table485 *486 * @return String : the content of the page487 */488 private function displayDatabase()489 {490 global $template, $page;491 492 /*493 * insert new image (from piwigo images table) in the AMD images table, with494 * statut 'not analyzed'495 */496 $sql="INSERT INTO ".$this->tables['images']."497 SELECT id, 'n', 0498 FROM ".IMAGES_TABLE."499 WHERE id NOT IN (SELECT imageId FROM ".$this->tables['images'].")";500 pwg_query($sql);501 502 503 /*504 * delete image who are in the AMD images table and not in the piwigo image505 * table506 */507 $sql="DELETE FROM ".$this->tables['images']."508 WHERE imageId NOT IN (SELECT id FROM ".IMAGES_TABLE.")";509 pwg_query($sql);510 511 512 /*513 * delete metdata for images that are not in the AMD image table514 */515 $sql="DELETE FROM ".$this->tables['images_tags']."516 WHERE imageId NOT IN (SELECT imageId FROM ".$this->tables['images'].")";517 pwg_query($sql);518 519 520 $template->set_filename('body_page', dirname(__FILE__).'/admin/amd_database.tpl');521 522 $datas=array(523 'urlRequest' => $this->page_link,524 'NumberOfItemsPerRequest' => $this->my_config['amd_NumberOfItemsPerRequest'],525 );526 527 $template->assign("datas", $datas);528 529 $template->assign_var_from_handle('AMD_BODY_PAGE', 'body_page');530 } // displayDatabase531 532 533 534 /**535 482 * display and manage the metadata page 536 483 * the page have two tabsheet : … … 547 494 $statTabsheet = new tabsheet('statTabsheet', $this->tabsheet->get_titlename()); 548 495 $statTabsheet->select($tab); 496 $statTabsheet->add('database', 497 l10n('g003_database'), 498 $this->page_link.'&fAMD_tabsheet=metadata&fAMD_page=database'); 549 499 $statTabsheet->add('select', 550 500 l10n('g003_select'), … … 561 511 $template->assign('sheetContent', $this->displayMetaDataSelect()); 562 512 } 513 elseif($tab=="display") 514 { 515 $template->assign('sheetContent', $this->displayMetaDataDisplay()); 516 } 563 517 else 564 518 { 565 $template->assign('sheetContent', $this->display MetaDataDisplay());519 $template->assign('sheetContent', $this->displayDatabase()); 566 520 } 567 521 … … 670 624 671 625 626 /** 627 * display and manage the database page 628 * 629 * the function automatically update the AMD tables : 630 * - add new pictures in the AMD image table (assuming image is not analyzed 631 * yet) 632 * - remove deleted pictures in the AMD image & image_tags table 633 * 634 * @return String : the content of the page 635 */ 636 private function displayDatabase() 637 { 638 global $template, $page; 639 640 /* 641 * insert new image (from piwigo images table) in the AMD images table, with 642 * statut 'not analyzed' 643 */ 644 $sql="INSERT INTO ".$this->tables['images']." 645 SELECT id, 'n', 0 646 FROM ".IMAGES_TABLE." 647 WHERE id NOT IN (SELECT imageId FROM ".$this->tables['images'].")"; 648 pwg_query($sql); 649 650 651 /* 652 * delete image who are in the AMD images table and not in the piwigo image 653 * table 654 */ 655 $sql="DELETE FROM ".$this->tables['images']." 656 WHERE imageId NOT IN (SELECT id FROM ".IMAGES_TABLE.")"; 657 pwg_query($sql); 658 659 660 /* 661 * delete metdata for images that are not in the AMD image table 662 */ 663 $sql="DELETE FROM ".$this->tables['images_tags']." 664 WHERE imageId NOT IN (SELECT imageId FROM ".$this->tables['images'].")"; 665 pwg_query($sql); 666 667 668 $template->set_filename('sheet_page', dirname(__FILE__).'/admin/amd_metadata_database.tpl'); 669 670 $datas=array( 671 'urlRequest' => $this->page_link, 672 'NumberOfItemsPerRequest' => $this->my_config['amd_NumberOfItemsPerRequest'], 673 ); 674 675 $template->assign("datas", $datas); 676 677 return($template->parse('sheet_page', true)); 678 } // displayDatabase 679 680 681 672 682 673 683 /** … … 729 739 if($sqlInsert!="") $sqlInsert.=", "; 730 740 $sqlInsert.="($imageId, '$numId', '".addslashes($value)."')"; 731 $massInsert[]=array( 732 'imageId' => $imageId, 733 'numId' => $numId, 734 'value' => addslashes($value) 735 ); 741 $massInsert[]="('$imageId', '$numId', '".addslashes($value)."') "; 736 742 } 737 743 } 738 744 } 739 745 740 /*if($sqlInsert!="") 741 { 742 $sqlInsert="INSERT INTO ".$this->tables['images_tags']." VALUES ".$sqlInsert; 743 pwg_query($sqlInsert); 744 }*/ 745 mass_inserts($this->tables['images_tags'], array('imageId', 'numId', 'value'), $massInsert); 746 $sql="REPLACE INTO ".$this->tables['images_tags']." (imageId, numId, value) 747 VALUES ".implode(", ", $massInsert); 748 //mass_inserts($this->tables['images_tags'], array('imageId', 'numId', 'value'), $massInsert); 746 749 747 750 $sql="UPDATE ".$this->tables['images']." … … 803 806 private function ajax_amd_makeStatsGetList($mode, $nbOfItems) 804 807 { 808 global $user; 809 805 810 $returned=""; 806 811 $this->my_config['amd_NumberOfItemsPerRequest']=$nbOfItems; 807 812 $this->save_config(); 808 813 809 $sql="SELECT imageId FROM ".$this->tables['images'];814 $sql="SELECT ait.imageId FROM ".$this->tables['images']." ait"; 810 815 if($mode=="notAnalyzed") 811 816 { 812 $sql.=" WHERE analyzed='n'"; 813 } 814 else 817 $sql.=" WHERE ait.analyzed='n'"; 818 } 819 elseif($mode=="caddieAdd" or $mode=="caddieReplace") 820 { 821 822 $sql.=" LEFT JOIN ".CADDIE_TABLE." ct ON ait.imageId = ct.element_id 823 WHERE ct.user_id = ".$user['id'].";"; 824 } 825 826 if($mode=="all" or $mode=="caddieReplace") 815 827 { 816 828 pwg_query("UPDATE ".$this->tables['images']." SET analyzed='n', nbTags=0");
Note: See TracChangeset
for help on using the changeset viewer.