Changeset 10513 for trunk/admin
- Timestamp:
- Apr 20, 2011, 8:08:46 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/element_set_ranks.php
r9868 r10513 209 209 ;'; 210 210 $result = pwg_query($query); 211 212 // template thumbnail initialization 213 $current_rank = 1; 214 $thumbnail_info=array(); 215 $clipping=array(); 216 while ($row = pwg_db_fetch_assoc($result)) 217 { 218 $src = get_thumbnail_url($row); 219 220 $thumbnail_size = getimagesize($src); 221 if ( !empty( $row['name'] ) ) 222 { 223 $thumbnail_name = $row['name']; 224 } 225 else 226 { 227 $file_wo_ext = get_filename_wo_extension($row['file']); 228 $thumbnail_name = str_replace('_', ' ', $file_wo_ext); 229 } 230 $thumbnail_info[] = array( 231 'name' => $thumbnail_name, 232 'width' => $thumbnail_size[0], 233 'height' => $thumbnail_size[1], 234 'id' => $row['id'], 235 'tn_src' => $src, 236 'rank' => $current_rank * 10, 237 ); 238 if ($thumbnail_size[0]<=128 and $thumbnail_size[1]<=128) 211 if (pwg_db_num_rows($result) > 0) 212 { 213 // template thumbnail initialization 214 $current_rank = 1; 215 $thumbnail_info=array(); 216 $clipping=array(); 217 while ($row = pwg_db_fetch_assoc($result)) 239 218 { 240 $clipping[]= min($thumbnail_size[0],$thumbnail_size[1]); 219 $src = get_thumbnail_url($row); 220 221 $thumbnail_size = getimagesize($src); 222 if ( !empty( $row['name'] ) ) 223 { 224 $thumbnail_name = $row['name']; 225 } 226 else 227 { 228 $file_wo_ext = get_filename_wo_extension($row['file']); 229 $thumbnail_name = str_replace('_', ' ', $file_wo_ext); 230 } 231 $thumbnail_info[] = array( 232 'name' => $thumbnail_name, 233 'width' => $thumbnail_size[0], 234 'height' => $thumbnail_size[1], 235 'id' => $row['id'], 236 'tn_src' => $src, 237 'rank' => $current_rank * 10, 238 ); 239 if ($thumbnail_size[0]<=128 and $thumbnail_size[1]<=128) 240 { 241 $clipping[]= min($thumbnail_size[0],$thumbnail_size[1]); 242 } 243 else 244 { 245 $clipping[]= min($thumbnail_size[0]*0.75,$thumbnail_size[1]*0.75); 246 } 247 $current_rank++; 241 248 } 242 else 249 $clipping=array_sum($clipping)/count($clipping); 250 foreach ($thumbnail_info as $thumbnails_info) 243 251 { 244 $clipping[]= min($thumbnail_size[0]*0.75,$thumbnail_size[1]*0.75); 252 $thumbnail_x_center = $thumbnails_info['width']/2; 253 $thumbnail_y_center = $thumbnails_info['height']/2; 254 $template->append( 255 'thumbnails', 256 array( 257 'ID' => $thumbnails_info['id'], 258 'NAME' => $thumbnails_info['name'], 259 'TN_SRC' => $thumbnails_info['tn_src'], 260 'RANK' => $thumbnails_info['rank'], 261 'CLIPING' => round($clipping), 262 'CLIPING_li' => round($clipping+8), 263 'CLIP_TOP' => round($thumbnail_y_center - $clipping/2), 264 'CLIP_RIGHT' => round($thumbnail_x_center + $clipping/2), 265 'CLIP_BOTTOM' => round($thumbnail_y_center + $clipping/2), 266 'CLIP_LEFT' => round($thumbnail_x_center - $clipping/2) 267 ) 268 ); 245 269 } 246 $current_rank++;247 }248 $clipping=array_sum($clipping)/count($clipping);249 foreach ($thumbnail_info as $thumbnails_info)250 {251 $thumbnail_x_center = $thumbnails_info['width']/2;252 $thumbnail_y_center = $thumbnails_info['height']/2;253 $template->append(254 'thumbnails',255 array(256 'ID' => $thumbnails_info['id'],257 'NAME' => $thumbnails_info['name'],258 'TN_SRC' => $thumbnails_info['tn_src'],259 'RANK' => $thumbnails_info['rank'],260 'CLIPING' => round($clipping),261 'CLIPING_li' => round($clipping+8),262 'CLIP_TOP' => round($thumbnail_y_center - $clipping/2),263 'CLIP_RIGHT' => round($thumbnail_x_center + $clipping/2),264 'CLIP_BOTTOM' => round($thumbnail_y_center + $clipping/2),265 'CLIP_LEFT' => round($thumbnail_x_center - $clipping/2)266 )267 );268 270 } 269 271 // image order management
Note: See TracChangeset
for help on using the changeset viewer.