Changeset 26298 for extensions/header_manager/include/functions.inc.php
- Timestamp:
- Dec 28, 2013, 6:08:42 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/header_manager/include/functions.inc.php
r22857 r26298 8 8 function list_banners($delete_orphans=false) 9 9 { 10 if (!file_exists(HEADER_MANAGER_DIR)) return array(); 10 if (!file_exists(HEADER_MANAGER_DIR)) 11 { 12 return array(); 13 } 14 11 15 $dir = scandir(HEADER_MANAGER_DIR); 12 16 $banners = array(); … … 14 18 foreach ($dir as $file) 15 19 { 16 if ( in_array($file, array('.','..','index.php','.svn'))) continue;17 if ( !in_array(strtolower(get_extension($file)), array('jpg','jpeg','png','gif'))) continue;18 if ( strpos($file, '-thumbnail')!==false) continue;20 if (in_array($file, array('.','..','index.php','.svn'))) continue; 21 if (!in_array(strtolower(get_extension($file)), array('jpg','jpeg','png','gif'))) continue; 22 if (strpos($file, '-thumbnail')!==false) continue; 19 23 20 24 $banner = get_banner($file); 21 25 22 if ( $delete_orphans and !file_exists($banner['THUMB']))26 if ($delete_orphans and !file_exists($banner['THUMB'])) 23 27 { 24 28 @unlink($banner['PATH']); … … 43 47 return array( 44 48 'NAME' => $file, 45 'PATH' => get_root_url() .HEADER_MANAGER_DIR . $file,46 'THUMB' => get_root_url() .HEADER_MANAGER_DIR . get_filename_wo_extension($file) . '-thumbnail.'. get_extension($file),49 'PATH' => get_root_url() . HEADER_MANAGER_DIR . $file, 50 'THUMB' => get_root_url() . HEADER_MANAGER_DIR . get_filename_wo_extension($file) . '-thumbnail.' . get_extension($file), 47 51 'SIZE' => getimagesize(HEADER_MANAGER_DIR . $file), 48 52 ); … … 85 89 $crop['coi']['y'] = ($picture['coi']['b']+$picture['coi']['t'])/2; 86 90 87 // define default crop frame 88 if ($picture['width'] > $conf['header_manager']['width']) 91 $crop['desired_width'] = $conf['header_manager']['width']; 92 $crop['desired_height'] = $conf['header_manager']['height']; 93 94 if ($picture['width'] > $crop['desired_width']) 89 95 { 90 $crop['display_width'] = $conf['header_manager']['width']; 91 $crop['display_height'] = round($picture['height']*$crop['display_width']/$picture['width']); 92 93 $crop['coi']['x'] = round($crop['coi']['x']*$crop['display_width']/$picture['width']); 94 $crop['coi']['y'] = round($crop['coi']['y']*$crop['display_height']/$picture['height']); 95 96 $crop['l'] = 0; 97 $crop['r'] = $conf['header_manager']['width']; 98 $crop['t'] = max(0, $crop['coi']['y']-$conf['header_manager']['height']/2); 99 $crop['b'] = min($crop['display_height'], $crop['t']+$conf['header_manager']['height']); 96 $crop['box_width'] = $crop['desired_width']; 97 $crop['box_height'] = round($picture['height']*$crop['box_width']/$picture['width']); 100 98 } 101 99 else 102 100 { 103 $crop['display_width'] = $picture['width']; 104 $crop['display_height'] = $picture['height']; 105 106 $adapted_crop_height = round($conf['header_manager']['height']*$picture['width']/$conf['header_manager']['width']); 107 108 $crop['l'] = 0; 109 $crop['r'] = $picture['width']; 110 $crop['t'] = max(0, $crop['coi']['y']-$adapted_crop_height/2); 111 $crop['b'] = min($crop['display_height'], $crop['t']+$adapted_crop_height); 101 $crop['box_width'] = $picture['width']; 102 $crop['box_height'] = $picture['height']; 112 103 } 104 105 $crop['real_width'] = $picture['width']; 106 $crop['real_height'] = round($crop['desired_height']*$crop['real_width']/$crop['desired_width']); 107 108 $crop['l'] = 0; 109 $crop['r'] = $crop['real_width']; 110 $crop['t'] = max(0, $crop['coi']['y']-$crop['real_height']/2); 111 $crop['b'] = min($picture['height'], $crop['t']+$crop['real_height']); 113 112 114 113 return $crop; 115 114 } 116 117 /**118 * clean table when categroies are delete119 */120 function header_manager_delete_categories($ids)121 {122 $query = '123 DELETE FROM '.HEADER_MANAGER_TABLE.'124 WHERE category_id IN('.implode(',', $ids).')125 ;';126 pwg_query($query);127 }128 129 ?>
Note: See TracChangeset
for help on using the changeset viewer.