source: extensions/upload_form/base.php @ 17835

Last change on this file since 17835 was 4897, checked in by plg, 15 years ago

feature 1409 added: new tab "Settings".

Note: I would have like to use jQuery UI sliders for resize dimensions and
image quality BUT I can't even find the documentation of the very old version
of jQuery UI we use. I'll implement theses widget when integrating UploadForm
into trunk (with jQuery + jQuery UI updated).

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');
29
30include_once(UPLOAD_FORM_PATH.'include/functions_upload.inc.php');
31load_language('plugin.lang', UPLOAD_FORM_PATH);
32
33define(
34  'UPLOAD_FORM_BASE_URL',
35  get_root_url().'admin.php?page=plugin&amp;section=upload_form%2Fbase.php'
36  );
37
38// +-----------------------------------------------------------------------+
39// | Check Access and exit when user status is not ok                      |
40// +-----------------------------------------------------------------------+
41
42check_status(ACCESS_ADMINISTRATOR);
43
44// +-----------------------------------------------------------------------+
45// |                          Load configuration                           |
46// +-----------------------------------------------------------------------+
47
48// automatic fill of configuration parameters
49$upload_form_config = array(
50  'websize_resize' => array(
51    'default' => true,
52    'can_be_null' => false,
53    ),
54 
55  'websize_maxwidth' => array(
56    'default' => 800,
57    'min' => 100,
58    'max' => 1600,
59    'pattern' => '/^\d+$/',
60    'can_be_null' => true,
61    'error_message' => 'The websize maximum width must be a number between %d and %d',
62    ),
63 
64  'websize_maxheight' => array(
65    'default' => 600,
66    'min' => 100,
67    'max' => 1200,
68    'pattern' => '/^\d+$/',
69    'can_be_null' => true,
70    'error_message' => 'The websize maximum height must be a number between %d and %d',
71    ),
72 
73  'websize_quality' => array(
74    'default' => 95,
75    'min' => 50,
76    'max' => 100,
77    'pattern' => '/^\d+$/',
78    'can_be_null' => false,
79    'error_message' => 'The websize image quality must be a number between %d and %d',
80    ),
81 
82  'thumb_maxwidth' => array(
83    'default' => 128,
84    'min' => 50,
85    'max' => 300,
86    'pattern' => '/^\d+$/',
87    'can_be_null' => false,
88    'error_message' => 'The thumbnail maximum width must be a number between %d and %d',
89    ),
90 
91  'thumb_maxheight' => array(
92    'default' => 96,
93    'min' => 50,
94    'max' => 300,
95    'pattern' => '/^\d+$/',
96    'can_be_null' => false,
97    'error_message' => 'The thumbnail maximum height must be a number between %d and %d',
98    ),
99 
100  'thumb_quality' => array(
101    'default' => 95,
102    'min' => 50,
103    'max' => 100,
104    'pattern' => '/^\d+$/',
105    'can_be_null' => false,
106    'error_message' => 'The thumbnail image quality must be a number between %d and %d',
107    ),
108  );
109
110$inserts = array();
111
112foreach ($upload_form_config as $param_shortname => $param)
113{
114  $param_name = 'upload_form_'.$param_shortname;
115 
116  if (!isset($conf[$param_name]))
117  {
118    $param_value = boolean_to_string($param['default']);
119   
120    array_push(
121      $inserts,
122      array(
123        'param' => $param_name,
124        'value' => $param_value,
125        )
126      );
127    $conf[$param_name] = $param_value;
128  }
129}
130
131if (count($inserts) > 0)
132{
133  mass_inserts(
134    CONFIG_TABLE,
135    array_keys($inserts[0]),
136    $inserts
137    );
138}
139
140// +-----------------------------------------------------------------------+
141// |                                 Tabs                                  |
142// +-----------------------------------------------------------------------+
143
144$tabs = array(
145  array(
146    'code' => 'upload',
147    'label' => 'Upload Photos',
148    ),
149  array(
150    'code' => 'settings',
151    'label' => 'Settings',
152    )
153  );
154
155$tab_codes = array_map(
156  create_function('$a', 'return $a["code"];'),
157  $tabs
158  );
159
160if (isset($_GET['tab']) and in_array($_GET['tab'], $tab_codes))
161{
162  $page['tab'] = $_GET['tab'];
163}
164else
165{
166  $page['tab'] = $tabs[0]['code'];
167}
168
169$tabsheet = new tabsheet();
170foreach ($tabs as $tab)
171{
172  $tabsheet->add(
173    $tab['code'],
174    l10n($tab['label']),
175    UPLOAD_FORM_BASE_URL.'&amp;tab='.$tab['code']
176    );
177}
178$tabsheet->select($page['tab']);
179$tabsheet->assign();
180
181// +-----------------------------------------------------------------------+
182// |                             template init                             |
183// +-----------------------------------------------------------------------+
184
185$template->set_filenames(
186  array(
187    'plugin_admin_content' => dirname(__FILE__).'/'.$page['tab'].'.tpl'
188    )
189  );
190
191$template->append(
192  'head_elements',
193  '<link rel="stylesheet" type="text/css" href="'.UPLOAD_FORM_PATH.'upload.css">'."\n"
194  );
195
196// +-----------------------------------------------------------------------+
197// |                             Load the tab                              |
198// +-----------------------------------------------------------------------+
199
200include(UPLOAD_FORM_PATH.$page['tab'].'.php');
201?>
Note: See TracBrowser for help on using the repository browser.