source: trunk/admin/photos_add.php @ 8247

Last change on this file since 8247 was 8227, checked in by plg, 13 years ago

feature 2077 added: when ImageMagick is active, ability to remove or resize
the high definition version of the photo.

File size: 7.1 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture 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("PHPWG_ROOT_PATH") )
23{
24  die ("Hacking attempt!");
25}
26
27include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
28include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
29include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
30
31define(
32  'PHOTOS_ADD_BASE_URL',
33  get_root_url().'admin.php?page=photos_add'
34  );
35
36// +-----------------------------------------------------------------------+
37// | Check Access and exit when user status is not ok                      |
38// +-----------------------------------------------------------------------+
39
40check_status(ACCESS_ADMINISTRATOR);
41
42// +-----------------------------------------------------------------------+
43// |                          Load configuration                           |
44// +-----------------------------------------------------------------------+
45
46// automatic fill of configuration parameters
47$upload_form_config = array(
48  'websize_resize' => array(
49    'default' => true,
50    'can_be_null' => false,
51    ),
52 
53  'websize_maxwidth' => array(
54    'default' => 800,
55    'min' => 100,
56    'max' => 1600,
57    'pattern' => '/^\d+$/',
58    'can_be_null' => true,
59    'error_message' => l10n('The websize maximum width must be a number between %d and %d'),
60    ),
61 
62  'websize_maxheight' => array(
63    'default' => 600,
64    'min' => 100,
65    'max' => 1200,
66    'pattern' => '/^\d+$/',
67    'can_be_null' => true,
68    'error_message' => l10n('The websize maximum height must be a number between %d and %d'),
69    ),
70 
71  'websize_quality' => array(
72    'default' => 95,
73    'min' => 50,
74    'max' => 100,
75    'pattern' => '/^\d+$/',
76    'can_be_null' => false,
77    'error_message' => l10n('The websize image quality must be a number between %d and %d'),
78    ),
79 
80  'thumb_maxwidth' => array(
81    'default' => 128,
82    'min' => 50,
83    'max' => 300,
84    'pattern' => '/^\d+$/',
85    'can_be_null' => false,
86    'error_message' => l10n('The thumbnail maximum width must be a number between %d and %d'),
87    ),
88 
89  'thumb_maxheight' => array(
90    'default' => 96,
91    'min' => 50,
92    'max' => 300,
93    'pattern' => '/^\d+$/',
94    'can_be_null' => false,
95    'error_message' => l10n('The thumbnail maximum height must be a number between %d and %d'),
96    ),
97 
98  'thumb_quality' => array(
99    'default' => 95,
100    'min' => 50,
101    'max' => 100,
102    'pattern' => '/^\d+$/',
103    'can_be_null' => false,
104    'error_message' => l10n('The thumbnail image quality must be a number between %d and %d'),
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    ),
143  );
144
145$inserts = array();
146
147foreach ($upload_form_config as $param_shortname => $param)
148{
149  $param_name = 'upload_form_'.$param_shortname;
150 
151  if (!isset($conf[$param_name]))
152  {
153    $param_value = boolean_to_string($param['default']);
154   
155    array_push(
156      $inserts,
157      array(
158        'param' => $param_name,
159        'value' => $param_value,
160        )
161      );
162    $conf[$param_name] = $param_value;
163  }
164}
165
166if (count($inserts) > 0)
167{
168  mass_inserts(
169    CONFIG_TABLE,
170    array_keys($inserts[0]),
171    $inserts
172    );
173}
174
175// +-----------------------------------------------------------------------+
176// |                                 Tabs                                  |
177// +-----------------------------------------------------------------------+
178
179$tabs = array(
180  array(
181    'code' => 'direct',
182    'label' => l10n('Upload Photos'),
183    ),
184  array(
185    'code' => 'settings',
186    'label' => l10n('Settings'),
187    ),
188  array(
189    'code' => 'ploader',
190    'label' => l10n('Piwigo Uploader'),
191    ),
192  );
193
194if ($conf['enable_synchronization'])
195{
196  array_push(
197    $tabs,
198    array(
199      'code' => 'ftp',
200      'label' => l10n('FTP + Synchronization'),
201      )
202    );
203}
204
205$tab_codes = array_map(
206  create_function('$a', 'return $a["code"];'),
207  $tabs
208  );
209
210if (isset($_GET['section']) and in_array($_GET['section'], $tab_codes))
211{
212  $page['tab'] = $_GET['section'];
213}
214else
215{
216  $page['tab'] = $tabs[0]['code'];
217}
218
219$tabsheet = new tabsheet();
220foreach ($tabs as $tab)
221{
222  $tabsheet->add(
223    $tab['code'],
224    $tab['label'],
225    PHOTOS_ADD_BASE_URL.'&amp;section='.$tab['code']
226    );
227}
228$tabsheet->select($page['tab']);
229$tabsheet->assign();
230
231// +-----------------------------------------------------------------------+
232// |                             template init                             |
233// +-----------------------------------------------------------------------+
234
235$template->set_filenames(
236  array(
237    'photos_add' => 'photos_add_'.$page['tab'].'.tpl'
238    )
239  );
240
241// $template->append(
242//   'head_elements',
243//   '<link rel="stylesheet" type="text/css" href="'.UPLOAD_FORM_PATH.'upload.css">'."\n"
244//   );
245
246// +-----------------------------------------------------------------------+
247// |                             Load the tab                              |
248// +-----------------------------------------------------------------------+
249
250include(PHPWG_ROOT_PATH.'admin/photos_add_'.$page['tab'].'.php');
251?>
Note: See TracBrowser for help on using the repository browser.