Changeset 12879 for trunk/admin
- Timestamp:
- Jan 12, 2012, 10:37:28 PM (12 years ago)
- Location:
- trunk/admin
- Files:
-
- 2 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/batch_manager_global.php
r12831 r12879 34 34 35 35 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 36 include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');37 38 $upload_form_config = get_upload_form_config();39 foreach ($upload_form_config as $param_shortname => $param)40 {41 $param_name = 'upload_form_'.$param_shortname;42 $form_values[$param_shortname] = $conf[$param_name];43 }44 36 45 37 // +-----------------------------------------------------------------------+ … … 464 456 'selection' => $collection, 465 457 'all_elements' => $page['cat_elements_id'], 466 'upload_form_settings' => $form_values,467 458 'U_DISPLAY'=>$base_url.get_query_string_diff(array('display')), 468 459 'F_ACTION'=>$base_url.get_query_string_diff(array('cat')), -
trunk/admin/configuration.php
r12872 r12879 28 28 29 29 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 30 include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php'); 30 31 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); 31 32 … … 54 55 'allow_user_customization', 55 56 ); 57 58 $sizes_checkboxes = array( 59 'original_resize', 60 ); 56 61 57 62 $history_checkboxes = array( … … 183 188 break; 184 189 } 190 case 'sizes' : 191 { 192 $fields = array( 193 'original_resize', 194 'original_resize_maxwidth', 195 'original_resize_maxheight', 196 'original_resize_quality', 197 ); 198 199 $updates = array(); 200 201 foreach ($fields as $field) 202 { 203 $value = !empty($_POST[$field]) ? $_POST[$field] : null; 204 $form_values[$field] = $value; 205 $updates[$field] = $value; 206 } 207 208 save_upload_form_config($updates, $page['errors']); 209 210 if (count($page['errors']) == 0) 211 { 212 array_push( 213 $page['infos'], 214 l10n('Your configuration settings are saved') 215 ); 216 } 217 218 break; 219 } 185 220 case 'history' : 186 221 { … … 229 264 230 265 // updating configuration if no error found 231 if ( count($page['errors']) == 0)266 if ('sizes' != $page['section'] and count($page['errors']) == 0) 232 267 { 233 268 //echo '<pre>'; print_r($_POST); echo '</pre>'; … … 269 304 // TabSheet initialization 270 305 $tabsheet->add('main', l10n('Main'), $conf_link.'main'); 306 $tabsheet->add('sizes', l10n('Photo Sizes'), $conf_link.'sizes'); 271 307 $tabsheet->add('display', l10n('Display'), $conf_link.'display'); 272 308 $tabsheet->add('history', l10n('History'), $conf_link.'history'); … … 440 476 break; 441 477 } 478 case 'sizes' : 479 { 480 $template->assign( 481 'sizes', 482 array( 483 'original_resize_maxwidth' => $conf['original_resize_maxwidth'], 484 'original_resize_maxheight' => $conf['original_resize_maxheight'], 485 'original_resize_quality' => $conf['original_resize_quality'], 486 ) 487 ); 488 489 foreach ($sizes_checkboxes as $checkbox) 490 { 491 $template->append( 492 'sizes', 493 array( 494 $checkbox => $conf[$checkbox] 495 ), 496 true 497 ); 498 } 499 500 break; 501 } 442 502 } 443 503 -
trunk/admin/include/functions_upload.inc.php
r12831 r12879 33 33 // default configuration for upload 34 34 $upload_form_config = array( 35 'websize_resize' => array( 36 'default' => true, 37 'can_be_null' => false, 38 ), 39 40 'websize_maxwidth' => array( 41 'default' => 800, 42 'min' => 100, 43 'max' => 1600, 44 'pattern' => '/^\d+$/', 45 'can_be_null' => true, 46 'error_message' => l10n('The websize maximum width must be a number between %d and %d'), 47 ), 48 49 'websize_maxheight' => array( 50 'default' => 600, 51 'min' => 100, 52 'max' => 1200, 53 'pattern' => '/^\d+$/', 54 'can_be_null' => true, 55 'error_message' => l10n('The websize maximum height must be a number between %d and %d'), 56 ), 57 58 'websize_quality' => array( 59 'default' => 95, 60 'min' => 50, 61 'max' => 100, 62 'pattern' => '/^\d+$/', 63 'can_be_null' => false, 64 'error_message' => l10n('The websize image quality must be a number between %d and %d'), 65 ), 66 67 'thumb_maxwidth' => array( 68 'default' => 128, 69 'min' => 50, 70 'max' => 300, 71 'pattern' => '/^\d+$/', 72 'can_be_null' => false, 73 'error_message' => l10n('The thumbnail maximum width must be a number between %d and %d'), 74 ), 75 76 'thumb_maxheight' => array( 77 'default' => 96, 78 'min' => 50, 79 'max' => 300, 80 'pattern' => '/^\d+$/', 81 'can_be_null' => false, 82 'error_message' => l10n('The thumbnail maximum height must be a number between %d and %d'), 83 ), 84 85 'thumb_quality' => array( 86 'default' => 95, 87 'min' => 50, 88 'max' => 100, 89 'pattern' => '/^\d+$/', 90 'can_be_null' => false, 91 'error_message' => l10n('The thumbnail image quality must be a number between %d and %d'), 92 ), 93 94 'thumb_crop' => array( 35 'original_resize' => array( 95 36 'default' => false, 96 37 'can_be_null' => false, 97 38 ), 98 99 'thumb_follow_orientation' => array( 100 'default' => true, 101 'can_be_null' => false, 102 ), 103 104 'hd_keep' => array( 105 'default' => true, 106 'can_be_null' => false, 107 ), 108 109 'hd_resize' => array( 110 'default' => false, 111 'can_be_null' => false, 112 ), 113 114 'hd_maxwidth' => array( 39 40 'original_resize_maxwidth' => array( 115 41 'default' => 2000, 116 42 'min' => 500, … … 118 44 'pattern' => '/^\d+$/', 119 45 'can_be_null' => false, 120 'error_message' => l10n('The high definitionmaximum width must be a number between %d and %d'),46 'error_message' => l10n('The original maximum width must be a number between %d and %d'), 121 47 ), 122 48 123 ' hd_maxheight' => array(49 'original_resize_maxheight' => array( 124 50 'default' => 2000, 125 'min' => 500,51 'min' => 300, 126 52 'max' => 20000, 127 53 'pattern' => '/^\d+$/', 128 54 'can_be_null' => false, 129 'error_message' => l10n('The high definitionmaximum height must be a number between %d and %d'),55 'error_message' => l10n('The original maximum height must be a number between %d and %d'), 130 56 ), 131 57 132 ' hd_quality' => array(58 'original_resize_quality' => array( 133 59 'default' => 95, 134 60 'min' => 50, 135 'max' => 100,61 'max' => 98, 136 62 'pattern' => '/^\d+$/', 137 63 'can_be_null' => false, 138 'error_message' => l10n('The high definitionimage quality must be a number between %d and %d'),64 'error_message' => l10n('The original image quality must be a number between %d and %d'), 139 65 ), 140 66 ); … … 171 97 172 98 $updates[] = array( 173 'param' => 'upload_form_'.$field,99 'param' => $field, 174 100 'value' => boolean_to_string($value) 175 101 ); … … 178 104 { 179 105 $updates[] = array( 180 'param' => 'upload_form_'.$field,106 'param' => $field, 181 107 'value' => 'false' 182 108 ); … … 191 117 { 192 118 $updates[] = array( 193 'param' => 'upload_form_'.$field,119 'param' => $field, 194 120 'value' => $value 195 121 ); … … 227 153 function add_uploaded_file($source_filepath, $original_filename=null, $categories=null, $level=null, $image_id=null) 228 154 { 229 // Here is the plan230 //231 155 // 1) move uploaded file to upload/2010/01/22/20100122003814-449ada00.jpg 232 156 // 233 // 2) if taller than max_height or wider than max_width, move to pwg_high 234 // + web sized creation 157 // 2) keep/resize original 235 158 // 236 // 3) thumbnail creation from web sized 237 // 238 // 4) register in database 159 // 3) register in database 239 160 240 161 // TODO … … 248 169 if (isset($image_id)) 249 170 { 250 // we are performing an update171 // this photo already exists, we update it 251 172 $query = ' 252 173 SELECT … … 317 238 } 318 239 319 if ($conf['upload_form_websize_resize'] 320 and need_resize($file_path, $conf['upload_form_websize_maxwidth'], $conf['upload_form_websize_maxheight'])) 321 { 322 $high_path = file_path_for_type($file_path, 'high'); 323 $high_dir = dirname($high_path); 324 prepare_directory($high_dir); 325 326 rename($file_path, $high_path); 327 $high_infos = pwg_image_infos($high_path); 328 329 $img = new pwg_image($high_path); 330 331 $img->pwg_resize( 332 $file_path, 333 $conf['upload_form_websize_maxwidth'], 334 $conf['upload_form_websize_maxheight'], 335 $conf['upload_form_websize_quality'], 336 $conf['upload_form_automatic_rotation'], 337 false 338 ); 339 340 if ($img->library != 'gd') 341 { 342 if ($conf['upload_form_hd_keep']) 240 if (pwg_image::get_library() != 'gd') 241 { 242 if ($conf['original_resize']) 243 { 244 $need_resize = need_resize($file_path, $conf['original_resize_maxwidth'], $conf['original_resize_maxheight']); 245 246 if ($need_resize) 343 247 { 344 if ($conf['upload_form_hd_resize']) 345 { 346 $need_resize = need_resize($high_path, $conf['upload_form_hd_maxwidth'], $conf['upload_form_hd_maxheight']); 248 $img = new pwg_image($file_path); 249 250 $img->pwg_resize( 251 $file_path, 252 $conf['original_resize_maxwidth'], 253 $conf['original_resize_maxheight'], 254 $conf['original_resize_quality'], 255 $conf['upload_form_automatic_rotation'], 256 false 257 ); 347 258 348 if ($need_resize) 349 { 350 $img->pwg_resize( 351 $high_path, 352 $conf['upload_form_hd_maxwidth'], 353 $conf['upload_form_hd_maxheight'], 354 $conf['upload_form_hd_quality'], 355 $conf['upload_form_automatic_rotation'], 356 false 357 ); 358 $high_infos = pwg_image_infos($high_path); 359 } 360 } 259 $img->destroy(); 361 260 } 362 else 363 { 364 unlink($high_path); 365 $high_infos = null; 366 } 367 } 368 $img->destroy(); 261 } 369 262 } 370 263 371 264 $file_infos = pwg_image_infos($file_path); 372 265 373 $thumb_path = file_path_for_type($file_path, 'thumb');374 $thumb_dir = dirname($thumb_path);375 prepare_directory($thumb_dir);376 377 $img = new pwg_image($file_path);378 $img->pwg_resize(379 $thumb_path,380 $conf['upload_form_thumb_maxwidth'],381 $conf['upload_form_thumb_maxheight'],382 $conf['upload_form_thumb_quality'],383 false,384 true,385 $conf['upload_form_thumb_crop'],386 $conf['upload_form_thumb_follow_orientation']387 );388 $img->destroy();389 390 $thumb_infos = pwg_image_infos($thumb_path);391 392 266 if (isset($image_id)) 393 267 { 394 268 $update = array( 395 'id' => $image_id,396 269 'file' => pwg_db_real_escape_string(isset($original_filename) ? $original_filename : basename($file_path)), 397 270 'filesize' => $file_infos['filesize'], … … 402 275 ); 403 276 404 if (isset($high_infos))405 {406 $update['has_high'] = 'true';407 $update['high_filesize'] = $high_infos['filesize'];408 $update['high_width'] = $high_infos['width'];409 $update['high_height'] = $high_infos['height'];410 }411 else412 {413 $update['has_high'] = 'false';414 $update['high_filesize'] = null;415 $update['high_width'] = null;416 $update['high_height'] = null;417 }418 419 277 if (isset($level)) 420 278 { … … 422 280 } 423 281 424 mass_updates(282 single_update( 425 283 IMAGES_TABLE, 426 array( 427 'primary' => array('id'), 428 'update' => array_keys($update) 429 ), 430 array($update) 284 $update, 285 array('id' => $image_id) 431 286 ); 432 287 } … … 458 313 $insert['level'] = $level; 459 314 } 460 461 mass_inserts( 462 IMAGES_TABLE, 463 array_keys($insert), 464 array($insert) 465 ); 315 316 single_insert(IMAGES_TABLE, $insert); 466 317 467 318 $image_id = pwg_db_insert_id(IMAGES_TABLE); -
trunk/admin/include/photos_add_direct_process.inc.php
r11975 r12879 203 203 $thumbnail['file'] = $image_infos['file']; 204 204 205 $thumbnail['src'] = get_thumbnail_location( 206 array( 207 'path' => $image_infos['path'], 208 'tn_ext' => $image_infos['tn_ext'], 209 ) 210 ); 205 $thumbnail['src'] = DerivativeImage::thumb_url($image_infos); 211 206 212 207 // TODO: when implementing this plugin in Piwigo core, we should have -
trunk/admin/include/uploadify/uploadify.php
r11963 r12879 73 73 $image_infos = pwg_db_fetch_assoc(pwg_query($query)); 74 74 75 $thumbnail_url = preg_replace('#^'.PHPWG_ROOT_PATH.'#', './', get_thumbnail_url($image_infos));75 $thumbnail_url = preg_replace('#^'.PHPWG_ROOT_PATH.'#', './', DerivativeImage::thumb_url($image_infos)); 76 76 77 77 $return = array( -
trunk/admin/photos_add.php
r10653 r12879 55 55 'code' => 'direct', 56 56 'label' => l10n('Upload Photos'), 57 ),58 array(59 'code' => 'settings',60 'label' => l10n('Settings'),61 57 ), 62 58 array( -
trunk/admin/themes/default/template/configuration.tpl
r12878 r12879 248 248 </div> <!-- configContent --> 249 249 250 {if isset($sizes)} 251 252 {footer_script}{literal} 253 jQuery(document).ready(function(){ 254 function toggleResizeFields(prefix) { 255 var checkbox = jQuery("#"+prefix+"_resize"); 256 var needToggle = jQuery("input[name^="+prefix+"_]").not(checkbox).parents('tr'); 257 258 if (jQuery(checkbox).is(':checked')) { 259 needToggle.show(); 260 } 261 else { 262 needToggle.hide(); 263 } 264 } 265 266 toggleResizeFields("original"); 267 jQuery("#original_resize").click(function () {toggleResizeFields("original")}); 268 }); 269 {/literal}{/footer_script} 270 271 <fieldset id="sizesConf"> 272 <legend>{'Original Size'|@translate}</legend> 273 274 <table> 275 <tr> 276 <th><label for="original_resize">{'Resize after upload'|@translate}</label></th> 277 <td><input type="checkbox" name="original_resize" id="original_resize" {if ($sizes.original_resize)}checked="checked"{/if}></td> 278 </tr> 279 <tr> 280 <th>{'Maximum Width'|@translate}</th> 281 <td><input type="text" name="original_resize_maxwidth" value="{$sizes.original_resize_maxwidth}" size="4" maxlength="4"> {'pixels'|@translate}</td> 282 </tr> 283 <tr> 284 <th>{'Maximum Height'|@translate}</th> 285 <td><input type="text" name="original_resize_maxheight" value="{$sizes.original_resize_maxheight}" size="4" maxlength="4"> {'pixels'|@translate}</td> 286 </tr> 287 <tr> 288 <th>{'Image Quality'|@translate}</th> 289 <td><input type="text" name="original_resize_quality" value="{$sizes.original_resize_quality}" size="3" maxlength="3"> %</td> 290 </tr> 291 </table> 292 293 </fieldset> 294 {/if} 295 250 296 {if isset($default)} 251 297 {$PROFILE_CONTENT} … … 446 492 {if !isset($default)} 447 493 <p> 448 <input class="submit" type="submit" name="submit" value="{'S ubmit'|@translate}">494 <input class="submit" type="submit" name="submit" value="{'Save Settings'|@translate}"> 449 495 <input class="submit" type="reset" name="reset" value="{'Reset'|@translate}"> 450 496 </p>
Note: See TracChangeset
for help on using the changeset viewer.