[5089] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 3 | // | Piwigo - a PHP based photo gallery | |
---|
[5089] | 4 | // +-----------------------------------------------------------------------+ |
---|
| 5 | // | Copyright(C) 2010 Pierrick LE GALL http://piwigo.org | |
---|
| 6 | // +-----------------------------------------------------------------------+ |
---|
| 7 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 8 | // | it under the terms of the GNU General Public License as published by | |
---|
| 9 | // | the Free Software Foundation | |
---|
| 10 | // | | |
---|
| 11 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 12 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 13 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 14 | // | General Public License for more details. | |
---|
| 15 | // | | |
---|
| 16 | // | You should have received a copy of the GNU General Public License | |
---|
| 17 | // | along with this program; if not, write to the Free Software | |
---|
| 18 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 19 | // | USA. | |
---|
| 20 | // +-----------------------------------------------------------------------+ |
---|
| 21 | |
---|
| 22 | if (!defined('PHOTOS_ADD_BASE_URL')) |
---|
| 23 | { |
---|
| 24 | die ("Hacking attempt!"); |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | // by default, the form values are the current configuration |
---|
| 28 | // we may overwrite them with the current form values |
---|
| 29 | $form_values = array(); |
---|
| 30 | |
---|
| 31 | foreach ($upload_form_config as $param_shortname => $param) |
---|
| 32 | { |
---|
| 33 | $param_name = 'upload_form_'.$param_shortname; |
---|
| 34 | $form_values[$param_shortname] = $conf[$param_name]; |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | // +-----------------------------------------------------------------------+ |
---|
| 38 | // | process form | |
---|
| 39 | // +-----------------------------------------------------------------------+ |
---|
| 40 | |
---|
| 41 | if (isset($_POST['submit'])) |
---|
| 42 | { |
---|
| 43 | $updates = array(); |
---|
| 44 | |
---|
| 45 | // let's care about the specific checkbox that disable/enable other |
---|
| 46 | // settings |
---|
| 47 | $field = 'websize_resize'; |
---|
[8227] | 48 | $fields[] = $field; |
---|
[5089] | 49 | |
---|
[8227] | 50 | if (!empty($_POST[$field])) |
---|
[5089] | 51 | { |
---|
| 52 | $fields[] = 'websize_maxwidth'; |
---|
| 53 | $fields[] = 'websize_maxheight'; |
---|
| 54 | $fields[] = 'websize_quality'; |
---|
[8227] | 55 | } |
---|
[5089] | 56 | |
---|
[8227] | 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 | } |
---|
[5089] | 72 | } |
---|
| 73 | |
---|
| 74 | // and now other fields, processed in a generic way |
---|
| 75 | $fields[] = 'thumb_maxwidth'; |
---|
| 76 | $fields[] = 'thumb_maxheight'; |
---|
| 77 | $fields[] = 'thumb_quality'; |
---|
[10552] | 78 | $fields[] = 'thumb_crop'; |
---|
| 79 | $fields[] = 'thumb_follow_orientation'; |
---|
| 80 | |
---|
[5089] | 81 | foreach ($fields as $field) |
---|
| 82 | { |
---|
[10589] | 83 | $value = !empty($_POST[$field]) ? $_POST[$field] : null; |
---|
[8227] | 84 | $form_values[$field] = $value; |
---|
[10589] | 85 | $updates[$field] = $value; |
---|
[5089] | 86 | } |
---|
| 87 | |
---|
[10589] | 88 | save_upload_form_config($updates, $page['errors']); |
---|
| 89 | |
---|
[5089] | 90 | if (count($page['errors']) == 0) |
---|
| 91 | { |
---|
| 92 | array_push( |
---|
| 93 | $page['infos'], |
---|
| 94 | l10n('Your configuration settings are saved') |
---|
| 95 | ); |
---|
| 96 | } |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | // +-----------------------------------------------------------------------+ |
---|
| 100 | // | template init | |
---|
| 101 | // +-----------------------------------------------------------------------+ |
---|
| 102 | |
---|
[8227] | 103 | foreach (array_keys($upload_form_config) as $field) |
---|
| 104 | { |
---|
| 105 | if (is_bool($upload_form_config[$field]['default'])) |
---|
| 106 | { |
---|
| 107 | $form_values[$field] = $form_values[$field] ? 'checked="checked"' : ''; |
---|
| 108 | } |
---|
| 109 | } |
---|
[5089] | 110 | |
---|
| 111 | $template->assign( |
---|
| 112 | array( |
---|
| 113 | 'F_ADD_ACTION'=> PHOTOS_ADD_BASE_URL, |
---|
[10684] | 114 | 'MANAGE_HD' => pwg_image::get_library() != 'gd', |
---|
[5089] | 115 | 'values' => $form_values |
---|
| 116 | ) |
---|
| 117 | ); |
---|
| 118 | |
---|
| 119 | |
---|
| 120 | // +-----------------------------------------------------------------------+ |
---|
| 121 | // | sending html code | |
---|
| 122 | // +-----------------------------------------------------------------------+ |
---|
| 123 | |
---|
[5960] | 124 | $template->assign_var_from_handle('ADMIN_CONTENT', 'photos_add'); |
---|
[5089] | 125 | ?> |
---|