source: trunk/admin/photos_add.php @ 6664

Last change on this file since 6664 was 6365, checked in by plg, 15 years ago

merge r6361 from branch 2.1 to trunk

feature 1697: ability to deactivate the synchronization method to add photos.

File size: 6.2 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
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' => l10n('Upload Photos'),
146    ),
147  array(
148    'code' => 'settings',
149    'label' => l10n('Settings'),
150    ),
151  array(
152    'code' => 'ploader',
153    'label' => l10n('Piwigo Uploader'),
154    ),
155  );
156
157if ($conf['enable_synchronization'])
158{
159  array_push(
160    $tabs,
161    array(
162      'code' => 'ftp',
163      'label' => l10n('FTP + Synchronization'),
164      )
165    );
166}
167
168$tab_codes = array_map(
169  create_function('$a', 'return $a["code"];'),
170  $tabs
171  );
172
173if (isset($_GET['section']) and in_array($_GET['section'], $tab_codes))
174{
175  $page['tab'] = $_GET['section'];
176}
177else
178{
179  $page['tab'] = $tabs[0]['code'];
180}
181
182$tabsheet = new tabsheet();
183foreach ($tabs as $tab)
184{
185  $tabsheet->add(
186    $tab['code'],
187    $tab['label'],
188    PHOTOS_ADD_BASE_URL.'&amp;section='.$tab['code']
189    );
190}
191$tabsheet->select($page['tab']);
192$tabsheet->assign();
193
194// +-----------------------------------------------------------------------+
195// |                             template init                             |
196// +-----------------------------------------------------------------------+
197
198$template->set_filenames(
199  array(
200    'photos_add' => 'photos_add_'.$page['tab'].'.tpl'
201    )
202  );
203
204// $template->append(
205//   'head_elements',
206//   '<link rel="stylesheet" type="text/css" href="'.UPLOAD_FORM_PATH.'upload.css">'."\n"
207//   );
208
209// +-----------------------------------------------------------------------+
210// |                             Load the tab                              |
211// +-----------------------------------------------------------------------+
212
213include(PHPWG_ROOT_PATH.'admin/photos_add_'.$page['tab'].'.php');
214?>
Note: See TracBrowser for help on using the repository browser.