source: branches/gettext/admin/photos_add.php @ 21517

Last change on this file since 21517 was 5089, checked in by plg, 15 years ago

feature 1489: integrate UploadForm into Piwigo core. The integration is not
100% done, I just "made it work" on trunk.

pclzip library was updated to version 2.8.2 for memory usage improvement.

File size: 6.0 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' => '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' => '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' => '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' => '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' => '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' => 'The thumbnail image quality must be a number between %d and %d',
105    ),
106  );
107
108$inserts = array();
109
110foreach ($upload_form_config as $param_shortname => $param)
111{
112  $param_name = 'upload_form_'.$param_shortname;
113 
114  if (!isset($conf[$param_name]))
115  {
116    $param_value = boolean_to_string($param['default']);
117   
118    array_push(
119      $inserts,
120      array(
121        'param' => $param_name,
122        'value' => $param_value,
123        )
124      );
125    $conf[$param_name] = $param_value;
126  }
127}
128
129if (count($inserts) > 0)
130{
131  mass_inserts(
132    CONFIG_TABLE,
133    array_keys($inserts[0]),
134    $inserts
135    );
136}
137
138// +-----------------------------------------------------------------------+
139// |                                 Tabs                                  |
140// +-----------------------------------------------------------------------+
141
142$tabs = array(
143  array(
144    'code' => 'direct',
145    'label' => 'Upload Photos',
146    ),
147  array(
148    'code' => 'settings',
149    'label' => 'Settings',
150    )
151  );
152
153$tab_codes = array_map(
154  create_function('$a', 'return $a["code"];'),
155  $tabs
156  );
157
158if (isset($_GET['section']) and in_array($_GET['section'], $tab_codes))
159{
160  $page['tab'] = $_GET['section'];
161}
162else
163{
164  $page['tab'] = $tabs[0]['code'];
165}
166
167$tabsheet = new tabsheet();
168foreach ($tabs as $tab)
169{
170  $tabsheet->add(
171    $tab['code'],
172    l10n($tab['label']),
173    PHOTOS_ADD_BASE_URL.'&amp;section='.$tab['code']
174    );
175}
176$tabsheet->select($page['tab']);
177$tabsheet->assign();
178
179// +-----------------------------------------------------------------------+
180// |                             template init                             |
181// +-----------------------------------------------------------------------+
182
183$template->set_filenames(
184  array(
185    'plugin_admin_content' => 'photos_add_'.$page['tab'].'.tpl'
186    )
187  );
188
189// $template->append(
190//   'head_elements',
191//   '<link rel="stylesheet" type="text/css" href="'.UPLOAD_FORM_PATH.'upload.css">'."\n"
192//   );
193
194// +-----------------------------------------------------------------------+
195// |                             Load the tab                              |
196// +-----------------------------------------------------------------------+
197
198include(PHPWG_ROOT_PATH.'admin/photos_add_'.$page['tab'].'.php');
199?>
Note: See TracBrowser for help on using the repository browser.