Changeset 19069 for trunk/admin/batch_manager.php
- Timestamp:
- Nov 19, 2012, 7:26:37 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/batch_manager.php
r18988 r19069 371 371 if (isset($_SESSION['bulk_manager_filter']['dimension']['max_ratio'])) 372 372 { 373 $where_clause[] = 'width/height <= '. $_SESSION['bulk_manager_filter']['dimension']['max_ratio'];373 $where_clause[] = 'width/height <= '.sprintf('%.2f99', $_SESSION['bulk_manager_filter']['dimension']['max_ratio']); 374 374 } 375 375 … … 442 442 // | dimensions | 443 443 // +-----------------------------------------------------------------------+ 444 445 $widths = array(); 446 $heights = array(); 447 $ratios = array(); 448 444 449 $query = ' 445 450 SELECT 446 MIN(width) as min_width, 447 MAX(width) as max_width, 448 MIN(height) as min_height, 449 MAX(height) as max_height, 450 MIN(width/height) as min_ratio, 451 MAX(width/height) as max_ratio 452 FROM '.IMAGES_TABLE.' 453 ;'; 451 DISTINCT width, height 452 FROM '.IMAGES_TABLE.' 453 WHERE width IS NOT NULL 454 AND height IS NOT NULL 455 ;'; 456 $result = pwg_query($query); 457 while ($row = pwg_db_fetch_assoc($result)) 458 { 459 $widths[] = $row['width']; 460 $heights[] = $row['height']; 461 $ratios[] = floor($row['width'] * 100 / $row['height']) / 100; 462 } 463 464 $widths = array_unique($widths); 465 sort($widths); 466 467 $heights = array_unique($heights); 468 sort($heights); 469 470 $ratios = array_unique($ratios); 471 sort($ratios); 472 473 $dimensions['widths'] = implode(',', $widths); 474 $dimensions['heights'] = implode(',', $heights); 475 $dimensions['ratios'] = implode(',', $ratios); 476 454 477 $dimensions['bounds'] = pwg_db_fetch_assoc(pwg_query($query)); 455 $dimensions['bounds']['min_ratio'] = floor($dimensions['bounds']['min_ratio']*100)/100; 456 $dimensions['bounds']['max_ratio'] = ceil($dimensions['bounds']['max_ratio']*100)/100; 478 479 $dimensions['bounds'] = array( 480 'min_width' => $widths[0], 481 'max_width' => $widths[count($widths)-1], 482 'min_height' => $heights[0], 483 'max_height' => $heights[count($heights)-1], 484 'min_ratio' => $ratios[0], 485 'max_ratio' => $ratios[count($ratios)-1], 486 ); 487 488 $ratio_categories = array( 489 'portrait' => array(), 490 'square' => array(), 491 'landscape' => array(), 492 'panorama' => array(), 493 ); 494 495 foreach ($ratios as $ratio) 496 { 497 if ($ratio < 0.95) 498 { 499 $ratio_categories['portrait'][] = $ratio; 500 } 501 502 if ($ratio >= 0.95 and $ratio < 1.05) 503 { 504 $ratio_categories['square'][] = $ratio; 505 } 506 507 if ($ratio > 1.05 and $ratio <= 2.5) 508 { 509 $ratio_categories['landscape'][] = $ratio; 510 } 511 512 if ($ratio > 2.5) 513 { 514 $ratio_categories['panorama'][] = $ratio; 515 } 516 } 517 518 foreach (array_keys($ratio_categories) as $ratio_category) 519 { 520 if (count($ratio_categories[$ratio_category]) > 0) 521 { 522 $dimensions['ratio_'.$ratio_category] = array( 523 'min' => $ratio_categories[$ratio_category][0], 524 'max' => $ratio_categories[$ratio_category][count($ratio_categories[$ratio_category]) - 1] 525 ); 526 } 527 } 457 528 458 529 foreach (array_keys($dimensions['bounds']) as $type) 459 530 { 460 $dimensions['selected'][$type] = isset($_SESSION['bulk_manager_filter']['dimension'][$type]) ? $_SESSION['bulk_manager_filter']['dimension'][$type] : $dimensions['bounds'][$type]; 461 } 531 $dimensions['selected'][$type] = isset($_SESSION['bulk_manager_filter']['dimension'][$type]) 532 ? $_SESSION['bulk_manager_filter']['dimension'][$type] 533 : $dimensions['bounds'][$type] 534 ; 535 } 536 462 537 $template->assign('dimensions', $dimensions); 463 538
Note: See TracChangeset
for help on using the changeset viewer.