source: trunk/admin/photos_add_settings.php @ 12259

Last change on this file since 12259 was 10684, checked in by patdenice, 14 years ago

feature:2284
Rename $confimage_library into $confgraphics_library
Display library used in admin intro page.

File size: 4.1 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
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
22if (!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
31foreach ($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
41if (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';
48  $fields[] = $field;
49 
50  if (!empty($_POST[$field]))
51  {
52    $fields[] = 'websize_maxwidth';
53    $fields[] = 'websize_maxheight';
54    $fields[] = 'websize_quality';
55  }
56
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    }
72  }
73 
74  // and now other fields, processed in a generic way
75  $fields[] = 'thumb_maxwidth';
76  $fields[] = 'thumb_maxheight';
77  $fields[] = 'thumb_quality';
78  $fields[] = 'thumb_crop';
79  $fields[] = 'thumb_follow_orientation';
80
81  foreach ($fields as $field)
82  {
83    $value = !empty($_POST[$field]) ? $_POST[$field] : null;
84    $form_values[$field] = $value;
85    $updates[$field] = $value;
86  }
87
88  save_upload_form_config($updates, $page['errors']);
89
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
103foreach (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}
110
111$template->assign(
112    array(
113      'F_ADD_ACTION'=> PHOTOS_ADD_BASE_URL,
114      'MANAGE_HD' => pwg_image::get_library() != 'gd',
115      'values' => $form_values
116    )
117  );
118
119
120// +-----------------------------------------------------------------------+
121// |                           sending html code                           |
122// +-----------------------------------------------------------------------+
123
124$template->assign_var_from_handle('ADMIN_CONTENT', 'photos_add');
125?>
Note: See TracBrowser for help on using the repository browser.