1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based photo gallery | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2008-2011 Piwigo Team http://piwigo.org | |
---|
6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | // | This program is free software; you can redistribute it and/or modify | |
---|
10 | // | it under the terms of the GNU General Public License as published by | |
---|
11 | // | the Free Software Foundation | |
---|
12 | // | | |
---|
13 | // | This program is distributed in the hope that it will be useful, but | |
---|
14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
16 | // | General Public License for more details. | |
---|
17 | // | | |
---|
18 | // | You should have received a copy of the GNU General Public License | |
---|
19 | // | along with this program; if not, write to the Free Software | |
---|
20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
21 | // | USA. | |
---|
22 | // +-----------------------------------------------------------------------+ |
---|
23 | |
---|
24 | |
---|
25 | // +-----------------------------------------------------------------------+ |
---|
26 | // | Uploaded photos | |
---|
27 | // +-----------------------------------------------------------------------+ |
---|
28 | |
---|
29 | if (isset($page['thumbnails'])) |
---|
30 | { |
---|
31 | $template->assign( |
---|
32 | array( |
---|
33 | 'thumbnails' => $page['thumbnails'], |
---|
34 | ) |
---|
35 | ); |
---|
36 | |
---|
37 | // only display the batch link if we have more than 1 photo |
---|
38 | if (count($page['thumbnails']) > 1) |
---|
39 | { |
---|
40 | $template->assign( |
---|
41 | array( |
---|
42 | 'batch_link' => $page['batch_link'], |
---|
43 | 'batch_label' => sprintf( |
---|
44 | l10n('Manage this set of %d photos'), |
---|
45 | count($page['thumbnails']) |
---|
46 | ), |
---|
47 | ) |
---|
48 | ); |
---|
49 | } |
---|
50 | } |
---|
51 | |
---|
52 | // +-----------------------------------------------------------------------+ |
---|
53 | // | Photo selection | |
---|
54 | // +-----------------------------------------------------------------------+ |
---|
55 | |
---|
56 | $uploadify_path = PHPWG_ROOT_PATH.'admin/include/uploadify'; |
---|
57 | |
---|
58 | $template->assign( |
---|
59 | array( |
---|
60 | 'F_ADD_ACTION'=> PHOTOS_ADD_BASE_URL, |
---|
61 | 'uploadify_path' => $uploadify_path, |
---|
62 | 'upload_max_filesize' => min( |
---|
63 | get_ini_size('upload_max_filesize'), |
---|
64 | get_ini_size('post_max_size') |
---|
65 | ), |
---|
66 | ) |
---|
67 | ); |
---|
68 | |
---|
69 | $upload_modes = array('html', 'multiple'); |
---|
70 | $upload_mode = isset($conf['upload_mode']) ? $conf['upload_mode'] : 'multiple'; |
---|
71 | |
---|
72 | if (isset($_GET['upload_mode']) and in_array($_GET['upload_mode'], $upload_modes)) |
---|
73 | { |
---|
74 | $upload_mode = $_GET['upload_mode']; |
---|
75 | conf_update_param('upload_mode', $upload_mode); |
---|
76 | } |
---|
77 | |
---|
78 | // what is the upload switch mode |
---|
79 | $index_of_upload_mode = array_flip($upload_modes); |
---|
80 | $upload_mode_index = $index_of_upload_mode[$upload_mode]; |
---|
81 | $upload_switch = $upload_modes[ ($upload_mode_index + 1) % 2 ]; |
---|
82 | |
---|
83 | $template->assign( |
---|
84 | array( |
---|
85 | 'upload_mode' => $upload_mode, |
---|
86 | 'form_action' => PHOTOS_ADD_BASE_URL.'&upload_mode='.$upload_mode.'&processed=1', |
---|
87 | 'switch_url' => PHOTOS_ADD_BASE_URL.'&upload_mode='.$upload_switch, |
---|
88 | 'upload_id' => md5(rand()), |
---|
89 | 'session_id' => session_id(), |
---|
90 | 'pwg_token' => get_pwg_token(), |
---|
91 | 'another_upload_link' => PHOTOS_ADD_BASE_URL.'&upload_mode='.$upload_mode, |
---|
92 | ) |
---|
93 | ); |
---|
94 | |
---|
95 | // +-----------------------------------------------------------------------+ |
---|
96 | // | Categories | |
---|
97 | // +-----------------------------------------------------------------------+ |
---|
98 | |
---|
99 | // we need to know the category in which the last photo was added |
---|
100 | $selected_category = array(); |
---|
101 | $selected_parent = array(); |
---|
102 | |
---|
103 | $query = ' |
---|
104 | SELECT |
---|
105 | category_id, |
---|
106 | id_uppercat |
---|
107 | FROM '.IMAGES_TABLE.' AS i |
---|
108 | JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON image_id = i.id |
---|
109 | JOIN '.CATEGORIES_TABLE.' AS c ON category_id = c.id |
---|
110 | ORDER BY i.id DESC |
---|
111 | LIMIT 1 |
---|
112 | ;'; |
---|
113 | $result = pwg_query($query); |
---|
114 | if (pwg_db_num_rows($result) > 0) |
---|
115 | { |
---|
116 | $row = pwg_db_fetch_assoc($result); |
---|
117 | |
---|
118 | $selected_category = array($row['category_id']); |
---|
119 | |
---|
120 | if (!empty($row['id_uppercat'])) |
---|
121 | { |
---|
122 | $selected_parent = array($row['id_uppercat']); |
---|
123 | } |
---|
124 | } |
---|
125 | |
---|
126 | // existing album |
---|
127 | $query = ' |
---|
128 | SELECT id,name,uppercats,global_rank |
---|
129 | FROM '.CATEGORIES_TABLE.' |
---|
130 | ;'; |
---|
131 | |
---|
132 | display_select_cat_wrapper( |
---|
133 | $query, |
---|
134 | $selected_category, |
---|
135 | 'category_options' |
---|
136 | ); |
---|
137 | |
---|
138 | // new category |
---|
139 | display_select_cat_wrapper( |
---|
140 | $query, |
---|
141 | $selected_parent, |
---|
142 | 'category_parent_options' |
---|
143 | ); |
---|
144 | |
---|
145 | |
---|
146 | // image level options |
---|
147 | $selected_level = isset($_POST['level']) ? $_POST['level'] : 0; |
---|
148 | $template->assign( |
---|
149 | array( |
---|
150 | 'level_options'=> get_privacy_level_options(), |
---|
151 | 'level_options_selected' => array($selected_level) |
---|
152 | ) |
---|
153 | ); |
---|
154 | |
---|
155 | // +-----------------------------------------------------------------------+ |
---|
156 | // | Setup errors/warnings | |
---|
157 | // +-----------------------------------------------------------------------+ |
---|
158 | |
---|
159 | // Errors |
---|
160 | $setup_errors = array(); |
---|
161 | |
---|
162 | $error_message = ready_for_upload_message(); |
---|
163 | if (!empty($error_message)) |
---|
164 | { |
---|
165 | array_push($setup_errors, $error_message); |
---|
166 | } |
---|
167 | |
---|
168 | if (!function_exists('gd_info')) |
---|
169 | { |
---|
170 | array_push($setup_errors, l10n('GD library is missing')); |
---|
171 | } |
---|
172 | |
---|
173 | $template->assign( |
---|
174 | array( |
---|
175 | 'setup_errors'=> $setup_errors, |
---|
176 | ) |
---|
177 | ); |
---|
178 | |
---|
179 | // Warnings |
---|
180 | if (isset($_GET['hide_warnings'])) |
---|
181 | { |
---|
182 | $_SESSION['upload_hide_warnings'] = true; |
---|
183 | } |
---|
184 | |
---|
185 | if (!isset($_SESSION['upload_hide_warnings'])) |
---|
186 | { |
---|
187 | $setup_warnings = array(); |
---|
188 | |
---|
189 | if ($conf['use_exif'] and !function_exists('read_exif_data')) |
---|
190 | { |
---|
191 | array_push( |
---|
192 | $setup_warnings, |
---|
193 | l10n('Exif extension not available, admin should disable exif use') |
---|
194 | ); |
---|
195 | } |
---|
196 | |
---|
197 | if (get_ini_size('upload_max_filesize') > get_ini_size('post_max_size')) |
---|
198 | { |
---|
199 | array_push( |
---|
200 | $setup_warnings, |
---|
201 | sprintf( |
---|
202 | l10n('In your php.ini file, the upload_max_filesize (%sB) is bigger than post_max_size (%sB), you should change this setting'), |
---|
203 | get_ini_size('upload_max_filesize', false), |
---|
204 | get_ini_size('post_max_size', false) |
---|
205 | ) |
---|
206 | ); |
---|
207 | } |
---|
208 | |
---|
209 | $template->assign( |
---|
210 | array( |
---|
211 | 'setup_warnings' => $setup_warnings, |
---|
212 | 'hide_warnings_link' => PHOTOS_ADD_BASE_URL.'&upload_mode='.$upload_mode.'&hide_warnings=1' |
---|
213 | ) |
---|
214 | ); |
---|
215 | } |
---|
216 | |
---|
217 | ?> |
---|