Changeset 6729 for extensions/AMetaData/amd_ajax.php
- Timestamp:
- Jul 29, 2010, 10:12:25 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/AMetaData/amd_ajax.php
r6723 r6729 66 66 $_REQUEST['ajaxfct']=='admin.makeStats.doAnalyze' or 67 67 $_REQUEST['ajaxfct']=='admin.makeStats.consolidate' or 68 $_REQUEST['ajaxfct']=='admin.makeStats.getStatus' or69 68 $_REQUEST['ajaxfct']=='admin.showStats.getListTags' or 70 69 $_REQUEST['ajaxfct']=='admin.showStats.getListImages' or 71 70 $_REQUEST['ajaxfct']=='admin.updateTag.select' or 71 $_REQUEST['ajaxfct']=='admin.config.setOption' or 72 72 $_REQUEST['ajaxfct']=='admin.group.getList' or 73 73 $_REQUEST['ajaxfct']=='admin.group.delete' or … … 100 100 $_REQUEST['selectMode']=="caddieAdd" or 101 101 $_REQUEST['selectMode']=="caddieReplace" or 102 $_REQUEST['selectMode']=="analyzed" or 102 103 $_REQUEST['selectMode']=="all")) $_REQUEST['selectMode']="caddieAdd"; 103 104 104 105 if(!isset($_REQUEST['numOfItems'])) $_REQUEST['numOfItems']=25; 106 107 if(!isset($_REQUEST['ignoreOptions'])) $_REQUEST['ignoreOptions']=array(); 105 108 } 106 109 … … 135 138 136 139 if(!($_REQUEST['filterType']=="" or 137 $_REQUEST['filterType']=="magic"or140 ($_REQUEST['filterType']=="magic" and !in_array('magic', $this->config['amd_FillDataBaseExcludeFilters'])) or 138 141 $_REQUEST['filterType']=="userDefined" or 139 $_REQUEST['filterType']=="exif" or 140 $_REQUEST['filterType']=="exif.Canon" or 141 $_REQUEST['filterType']=="exif.Nikon" or 142 $_REQUEST['filterType']=="exif.Pentax" or 143 $_REQUEST['filterType']=="xmp" or 144 $_REQUEST['filterType']=="iptc")) $_REQUEST['filterType']=""; 142 ($_REQUEST['filterType']=="exif" and !in_array('exif', $this->config['amd_FillDataBaseExcludeFilters'])) or 143 ($_REQUEST['filterType']=="exif.maker.Canon" and !in_array('maker', $this->config['amd_FillDataBaseExcludeFilters'])) or 144 ($_REQUEST['filterType']=="exif.maker.Nikon" and !in_array('maker', $this->config['amd_FillDataBaseExcludeFilters'])) or 145 ($_REQUEST['filterType']=="exif.maker.Pentax" and !in_array('maker', $this->config['amd_FillDataBaseExcludeFilters'])) or 146 ($_REQUEST['filterType']=="xmp" and !in_array('xmp', $this->config['amd_FillDataBaseExcludeFilters'])) or 147 ($_REQUEST['filterType']=="iptc" and !in_array('iptc', $this->config['amd_FillDataBaseExcludeFilters'])) 148 )) $_REQUEST['filterType']=""; 145 149 146 150 if(!isset($_REQUEST['excludeUnusedTag'])) $_REQUEST['excludeUnusedTag']="n"; … … 176 180 177 181 if(!isset($_REQUEST['tagSelected'])) $_REQUEST['tagSelected']=""; 182 } 183 184 /* 185 * check admin.config.setOption values 186 */ 187 if($_REQUEST['ajaxfct']=="admin.config.setOption") 188 { 189 if(!isset($_REQUEST['id'])) $_REQUEST['ajaxfct']=''; 190 if(!isset($_REQUEST['value'])) $_REQUEST['ajaxfct']=''; 178 191 } 179 192 … … 315 328 { 316 329 case 'admin.makeStats.getList': 317 $result=$this->ajax_amd_admin_makeStatsGetList($_REQUEST['selectMode'], $_REQUEST['numOfItems'] );330 $result=$this->ajax_amd_admin_makeStatsGetList($_REQUEST['selectMode'], $_REQUEST['numOfItems'], $_REQUEST['ignoreOptions']); 318 331 break; 319 332 case 'admin.makeStats.doAnalyze': … … 323 336 $result=$this->ajax_amd_admin_makeStatsConsolidate(); 324 337 break; 325 case 'admin.makeStats.getStatus':326 $result=$this->ajax_amd_admin_makeStatsGetStatus();327 break;328 338 case 'admin.showStats.getListTags': 329 339 $result=$this->ajax_amd_admin_showStatsGetListTags($_REQUEST['orderType'], $_REQUEST['filterType'], $_REQUEST['excludeUnusedTag'], $_REQUEST['selectedTagOnly']); … … 334 344 case 'admin.updateTag.select': 335 345 $result=$this->ajax_amd_admin_updateTagSelect($_REQUEST['numId'], $_REQUEST['tagSelected']); 346 break; 347 case 'admin.config.setOption': 348 $result=$this->ajax_amd_admin_configSetOption($_REQUEST['id'], $_REQUEST['value']); 336 349 break; 337 350 case 'admin.group.getList': … … 452 465 * "23 78 4523 5670" 453 466 */ 454 private function ajax_amd_admin_makeStatsGetList($mode, $nbOfItems )467 private function ajax_amd_admin_makeStatsGetList($mode, $nbOfItems, $ignoreSchemas) 455 468 { 456 469 global $user; 457 470 458 471 $returned=""; 472 $this->config['amd_FillDataBaseIgnoreSchemas']=$ignoreSchemas; 459 473 $this->config['amd_NumberOfItemsPerRequest']=$nbOfItems; 460 474 $this->saveConfig(); 461 475 462 476 $sql="SELECT ait.imageId FROM ".$this->tables['images']." ait"; 463 if($mode== "notAnalyzed")477 if($mode=='notAnalyzed') 464 478 { 465 479 $sql.=" WHERE ait.analyzed='n'"; 466 480 } 467 elseif($mode=="caddieAdd" or $mode=="caddieReplace") 468 { 469 481 elseif($mode=='caddieAdd' or $mode=='caddieReplace') 482 { 470 483 $sql.=" LEFT JOIN ".CADDIE_TABLE." ct ON ait.imageId = ct.element_id 471 484 WHERE ct.user_id = ".$user['id']." "; 472 485 473 if($mode=="caddieAdd") $sql.=" AND ait.analyzed='n'"; 474 } 475 476 if($mode=="all" or $mode=="caddieReplace") 486 if($mode=='caddieAdd') $sql.=" AND ait.analyzed='n'"; 487 } 488 elseif($mode=='analyzed') 489 { 490 $sql.=" WHERE ait.analyzed='y'"; 491 492 pwg_query("UPDATE ".$this->tables['images']." SET nbTags=0 WHERE analyzed='y';"); 493 pwg_query("UPDATE ".$this->tables['used_tags']." SET numOfImg=0"); 494 pwg_query("DELETE FROM ".$this->tables['images_tags']); 495 } 496 497 if($mode=='all' or $mode=='caddieReplace') 477 498 { 478 499 pwg_query("UPDATE ".$this->tables['images']." SET analyzed='n', nbTags=0"); … … 563 584 564 585 /** 565 * returns a list of formated string, separated with a semi-colon :566 * - number of current analyzed pictures + number of current analyzed tags567 * for the analyzed pictures568 * - number of pictures not analyzed569 * - number of pictures without tag570 *571 * @return String572 */573 private function ajax_amd_admin_makeStatsGetStatus()574 {575 $numOfMetaData=0;576 $numOfPictures=0;577 $numOfPicturesNotAnalyzed=0;578 579 $sql="SELECT COUNT(imageId), SUM(nbTags) FROM ".$this->tables['images']."580 WHERE analyzed='y';";581 $result=pwg_query($sql);582 if($result)583 {584 while($row=pwg_db_fetch_row($result))585 {586 $numOfPictures=$row[0];587 $numOfMetaData=$row[1];588 }589 }590 591 592 $sql="SELECT COUNT(imageId) FROM ".$this->tables['images']."593 WHERE analyzed='n';";594 $result=pwg_query($sql);595 if($result)596 {597 while($row=pwg_db_fetch_row($result))598 {599 $numOfPicturesNotAnalyzed=$row[0];600 }601 }602 603 $sql="SELECT COUNT(imageId) FROM ".$this->tables['images']."604 WHERE nbTags=0;";605 $result=pwg_query($sql);606 if($result)607 {608 while($row=pwg_db_fetch_row($result))609 {610 $numOfPicturesWithoutTags=$row[0];611 }612 }613 614 return(sprintf(l10n("g003_numberOfAnalyzedPictures"), $numOfPictures, $numOfMetaData).";".615 sprintf(l10n("g003_numberOfNotAnalyzedPictures"), $numOfPicturesNotAnalyzed).";".616 sprintf(l10n("g003_numberOfPicturesWithoutTags"), $numOfPicturesWithoutTags));617 }618 619 620 /**621 586 * return a formatted <table> (using the template "amd_stat_show_iListTags") 622 587 * of used tag with, for each tag, the number and the percentage of pictures … … 1385 1350 $nbImg=$this->buildUserDefinedTags($id); 1386 1351 1387 $sql="UPDATE ".$this->tables['used_tags']." 1388 SET numOfImg='$nbImg';"; 1389 $result=pwg_query($sql); 1352 $this->makeStatsConsolidation(); 1390 1353 1391 1354 return($id.','.$nbImg); … … 1438 1401 } 1439 1402 1440 1441 } 1403 /** 1404 * set value(s) for option(s) 1405 * 1406 * @param Array or String $ids : a string or an array of string (id) 1407 * @param Array or String $values : a string or an array of string 1408 * @return String : ok or ko 1409 */ 1410 private function ajax_amd_admin_configSetOption($ids, $values) 1411 { 1412 if(is_array($ids) and is_array($values) and count($ids)==count($values)) 1413 { 1414 foreach($ids as $key=>$id) 1415 { 1416 if(isset($id, $this->config)) 1417 { 1418 $this->config[$id]=$values[$key]; 1419 } 1420 } 1421 $this->saveConfig(); 1422 return('ok'); 1423 } 1424 elseif(is_string($ids) and is_string($values)) 1425 { 1426 if(isset($ids, $this->config)) 1427 { 1428 $this->config[$ids]=$values; 1429 } 1430 $this->saveConfig(); 1431 return('ok'); 1432 } 1433 1434 return('ko'); 1435 } 1436 1437 1438 1439 } //class 1442 1440 1443 1441
Note: See TracChangeset
for help on using the changeset viewer.