Changeset 8227 for trunk/admin
- Timestamp:
- Dec 22, 2010, 4:15:35 PM (13 years ago)
- Location:
- trunk/admin
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions_upload.inc.php
r8219 r8227 85 85 false 86 86 ); 87 88 if (is_imagick()) 89 { 90 if ($conf['upload_form_hd_keep']) 91 { 92 $need_resize = need_resize($high_path, $conf['upload_form_hd_maxwidth'], $conf['upload_form_hd_maxheight']); 93 94 if ($conf['upload_form_hd_resize'] and $need_resize) 95 { 96 pwg_image_resize( 97 false, 98 $high_path, 99 $high_path, 100 $conf['upload_form_hd_maxwidth'], 101 $conf['upload_form_hd_maxheight'], 102 $conf['upload_form_hd_quality'], 103 false 104 ); 105 $high_infos = pwg_image_infos($high_path); 106 } 107 } 108 else 109 { 110 unlink($high_path); 111 $high_infos = null; 112 } 113 } 87 114 } 88 115 … … 251 278 } 252 279 253 if ( extension_loaded('imagick'))280 if (is_imagick()) 254 281 { 255 282 return pwg_image_resize_im($source_filepath, $destination_filepath, $max_width, $max_height, $quality, $strip_metadata); … … 521 548 array_push($_SESSION['uploads_error'][$upload_id], $error_message); 522 549 } 550 551 function is_imagick() 552 { 553 if (extension_loaded('imagick')) 554 { 555 return true; 556 } 557 558 return false; 559 } 523 560 ?> -
trunk/admin/photos_add.php
r6365 r8227 104 104 'error_message' => l10n('The thumbnail image quality must be a number between %d and %d'), 105 105 ), 106 107 'hd_keep' => array( 108 'default' => true, 109 'can_be_null' => false, 110 ), 111 112 'hd_resize' => array( 113 'default' => false, 114 'can_be_null' => false, 115 ), 116 117 'hd_maxwidth' => array( 118 'default' => 2000, 119 'min' => 500, 120 'max' => 20000, 121 'pattern' => '/^\d+$/', 122 'can_be_null' => false, 123 'error_message' => l10n('The high definition maximum width must be a number between %d and %d'), 124 ), 125 126 'hd_maxheight' => array( 127 'default' => 2000, 128 'min' => 500, 129 'max' => 20000, 130 'pattern' => '/^\d+$/', 131 'can_be_null' => false, 132 'error_message' => l10n('The high definition maximum height must be a number between %d and %d'), 133 ), 134 135 'hd_quality' => array( 136 'default' => 95, 137 'min' => 50, 138 'max' => 100, 139 'pattern' => '/^\d+$/', 140 'can_be_null' => false, 141 'error_message' => l10n('The high definition image quality must be a number between %d and %d'), 142 ), 106 143 ); 107 144 -
trunk/admin/photos_add_settings.php
r6363 r8227 46 46 // settings 47 47 $field = 'websize_resize'; 48 $fields[] = $field; 48 49 49 if (empty($_POST[$field])) 50 { 51 $value = false; 52 } 53 else 50 if (!empty($_POST[$field])) 54 51 { 55 52 $fields[] = 'websize_maxwidth'; 56 53 $fields[] = 'websize_maxheight'; 57 54 $fields[] = 'websize_quality'; 55 } 58 56 59 $value = true; 57 // hd_keep 58 $field = 'hd_keep'; 59 $fields[] = $field; 60 61 if (!empty($_POST[$field])) 62 { 63 $field = 'hd_resize'; 64 $fields[] = $field; 65 66 if (!empty($_POST[$field])) 67 { 68 $fields[] = 'hd_maxwidth'; 69 $fields[] = 'hd_maxheight'; 70 $fields[] = 'hd_quality'; 71 } 60 72 } 61 73 62 $updates[] = array(63 'param' => 'upload_form_'.$field,64 'value' => boolean_to_string($value),65 );66 $form_values[$field] = $value;;67 68 74 // and now other fields, processed in a generic way 69 75 $fields[] = 'thumb_maxwidth'; … … 78 84 $value = $_POST[$field]; 79 85 } 80 $form_values[$field] = $value;81 86 82 if ($upload_form_config[$field]['can_be_null'] and empty($value)) 87 if (is_bool($upload_form_config[$field]['default'])) 88 { 89 if (isset($value)) 90 { 91 $value = true; 92 } 93 else 94 { 95 $value = false; 96 } 97 98 $updates[] = array( 99 'param' => 'upload_form_'.$field, 100 'value' => boolean_to_string($value) 101 ); 102 } 103 elseif ($upload_form_config[$field]['can_be_null'] and empty($value)) 83 104 { 84 105 $updates[] = array( … … 112 133 } 113 134 } 135 136 $form_values[$field] = $value; 114 137 } 115 138 … … 136 159 // +-----------------------------------------------------------------------+ 137 160 138 // specific case, "websize_resize" is a checkbox 139 $field = 'websize_resize'; 140 $form_values[$field] = $form_values[$field] ? 'checked="checked"' : ''; 161 foreach (array_keys($upload_form_config) as $field) 162 { 163 if (is_bool($upload_form_config[$field]['default'])) 164 { 165 $form_values[$field] = $form_values[$field] ? 'checked="checked"' : ''; 166 } 167 } 141 168 142 169 $template->assign( 143 170 array( 144 171 'F_ADD_ACTION'=> PHOTOS_ADD_BASE_URL, 172 'MANAGE_HD' => is_imagick(), 145 173 'values' => $form_values 146 174 ) -
trunk/admin/themes/default/template/photos_add_settings.tpl
r6363 r8227 2 2 <script type="text/javascript"> 3 3 $(document).ready(function(){ 4 function toggleResizeFields() { 5 var checkbox = $("#websize_resize"); 6 var needToggle = $("input[name^=websize_]").not(checkbox).parents('tr'); 4 function toggleResizeFields(prefix) { 5 var checkbox = $("#"+prefix+"_resize"); 6 var needToggle = $("input[name^="+prefix+"_]").not(checkbox).not($("#hd_keep")).parents('tr'); 7 7 8 8 9 if ($(checkbox).is(':checked')) { 9 10 needToggle.show(); 11 12 if (prefix == "websize") { 13 $("#hd_keep").parents("fieldset").show(); 14 } 15 } 16 else { 17 needToggle.hide(); 18 19 if (prefix == "websize") { 20 $("#hd_keep").parents("fieldset").hide(); 21 } 22 } 23 } 24 25 toggleResizeFields("websize"); 26 $("#websize_resize").click(function () {toggleResizeFields("websize")}); 27 28 toggleResizeFields("hd"); 29 $("#hd_resize").click(function () {toggleResizeFields("hd")}); 30 31 function toggleHdFields() { 32 var checkbox = $("#hd_keep"); 33 var needToggle = $("input[name^=hd_]").not(checkbox).parents('tr'); 34 35 if ($(checkbox).is(':checked')) { 36 needToggle.show(); 37 toggleResizeFields("hd"); 10 38 } 11 39 else { … … 14 42 } 15 43 16 toggle ResizeFields();17 $("# websize_resize").click(function () {toggleResizeFields()});44 toggleHdFields(); 45 $("#hd_keep").click(function () {toggleHdFields()}); 18 46 }); 19 47 </script> … … 70 98 </fieldset> 71 99 100 {if $MANAGE_HD} 101 <fieldset> 102 <legend>{'High definition'|@translate}</legend> 103 104 <table> 105 <tr> 106 <th><label for="hd_keep">{'Keep high definition'|@translate}</label></th> 107 <td><input type="checkbox" name="hd_keep" id="hd_keep" {$values.hd_keep}></td> 108 </tr> 109 <tr> 110 <th><label for="hd_resize">{'Resize'|@translate}</label></th> 111 <td><input type="checkbox" name="hd_resize" id="hd_resize" {$values.hd_resize}></td> 112 </tr> 113 <tr> 114 <th>{'Maximum Width'|@translate}</th> 115 <td><input type="text" name="hd_maxwidth" value="{$values.hd_maxwidth}" size="4" maxlength="4"> {'pixels'|@translate}</td> 116 </tr> 117 <tr> 118 <th>{'Maximum Height'|@translate}</th> 119 <td><input type="text" name="hd_maxheight" value="{$values.hd_maxheight}" size="4" maxlength="4"> {'pixels'|@translate}</td> 120 </tr> 121 <tr> 122 <th>{'Image Quality'|@translate}</th> 123 <td><input type="text" name="hd_quality" value="{$values.hd_quality}" size="3" maxlength="3"> %</td> 124 </tr> 125 </table> 126 </fieldset> 127 {/if} 128 72 129 <p> 73 130 <input class="submit" type="submit" name="submit" value="{'Save Settings'|@translate}"/>
Note: See TracChangeset
for help on using the changeset viewer.