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 | |
---|
22 | if( !defined("PHPWG_ROOT_PATH") ) |
---|
23 | { |
---|
24 | die ("Hacking attempt!"); |
---|
25 | } |
---|
26 | |
---|
27 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
28 | include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); |
---|
29 | include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php'); |
---|
30 | |
---|
31 | define( |
---|
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 | |
---|
40 | check_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 | |
---|
110 | foreach ($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 | |
---|
129 | if (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 | array( |
---|
156 | 'code' => 'ftp', |
---|
157 | 'label' => l10n('FTP + Synchronization'), |
---|
158 | ), |
---|
159 | ); |
---|
160 | |
---|
161 | $tab_codes = array_map( |
---|
162 | create_function('$a', 'return $a["code"];'), |
---|
163 | $tabs |
---|
164 | ); |
---|
165 | |
---|
166 | if (isset($_GET['section']) and in_array($_GET['section'], $tab_codes)) |
---|
167 | { |
---|
168 | $page['tab'] = $_GET['section']; |
---|
169 | } |
---|
170 | else |
---|
171 | { |
---|
172 | $page['tab'] = $tabs[0]['code']; |
---|
173 | } |
---|
174 | |
---|
175 | $tabsheet = new tabsheet(); |
---|
176 | foreach ($tabs as $tab) |
---|
177 | { |
---|
178 | $tabsheet->add( |
---|
179 | $tab['code'], |
---|
180 | $tab['label'], |
---|
181 | PHOTOS_ADD_BASE_URL.'&section='.$tab['code'] |
---|
182 | ); |
---|
183 | } |
---|
184 | $tabsheet->select($page['tab']); |
---|
185 | $tabsheet->assign(); |
---|
186 | |
---|
187 | // +-----------------------------------------------------------------------+ |
---|
188 | // | template init | |
---|
189 | // +-----------------------------------------------------------------------+ |
---|
190 | |
---|
191 | $template->set_filenames( |
---|
192 | array( |
---|
193 | 'photos_add' => 'photos_add_'.$page['tab'].'.tpl' |
---|
194 | ) |
---|
195 | ); |
---|
196 | |
---|
197 | // $template->append( |
---|
198 | // 'head_elements', |
---|
199 | // '<link rel="stylesheet" type="text/css" href="'.UPLOAD_FORM_PATH.'upload.css">'."\n" |
---|
200 | // ); |
---|
201 | |
---|
202 | // +-----------------------------------------------------------------------+ |
---|
203 | // | Load the tab | |
---|
204 | // +-----------------------------------------------------------------------+ |
---|
205 | |
---|
206 | include(PHPWG_ROOT_PATH.'admin/photos_add_'.$page['tab'].'.php'); |
---|
207 | ?> |
---|