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 | * Management of elements set. Elements can belong to a category or to the |
---|
26 | * user caddie. |
---|
27 | * |
---|
28 | */ |
---|
29 | |
---|
30 | if (!defined('PHPWG_ROOT_PATH')) |
---|
31 | { |
---|
32 | die('Hacking attempt!'); |
---|
33 | } |
---|
34 | |
---|
35 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
36 | |
---|
37 | // +-----------------------------------------------------------------------+ |
---|
38 | // | Check Access and exit when user status is not ok | |
---|
39 | // +-----------------------------------------------------------------------+ |
---|
40 | |
---|
41 | check_status(ACCESS_ADMINISTRATOR); |
---|
42 | |
---|
43 | trigger_action('loc_begin_element_set_global'); |
---|
44 | |
---|
45 | check_input_parameter('del_tags', $_POST, true, PATTERN_ID); |
---|
46 | check_input_parameter('associate', $_POST, false, PATTERN_ID); |
---|
47 | check_input_parameter('dissociate', $_POST, false, PATTERN_ID); |
---|
48 | |
---|
49 | // +-----------------------------------------------------------------------+ |
---|
50 | // | current selection | |
---|
51 | // +-----------------------------------------------------------------------+ |
---|
52 | |
---|
53 | $collection = array(); |
---|
54 | if (isset($_POST['setSelected'])) |
---|
55 | { |
---|
56 | $collection = $page['cat_elements_id']; |
---|
57 | } |
---|
58 | else if (isset($_POST['selection'])) |
---|
59 | { |
---|
60 | $collection = $_POST['selection']; |
---|
61 | } |
---|
62 | |
---|
63 | // +-----------------------------------------------------------------------+ |
---|
64 | // | global mode form submission | |
---|
65 | // +-----------------------------------------------------------------------+ |
---|
66 | |
---|
67 | // $page['prefilter'] is a shortcut to test if the current filter contains a |
---|
68 | // given prefilter. The idea is to make conditions simpler to write in the |
---|
69 | // code. |
---|
70 | $page['prefilter'] = 'none'; |
---|
71 | if (isset($_SESSION['bulk_manager_filter']['prefilter'])) |
---|
72 | { |
---|
73 | $page['prefilter'] = $_SESSION['bulk_manager_filter']['prefilter']; |
---|
74 | } |
---|
75 | |
---|
76 | // $page['category'] is a shortcut to test if the current filter contains a |
---|
77 | // given category. The idea is the same as for prefilter |
---|
78 | $page['category'] = -1; |
---|
79 | if (isset($_SESSION['bulk_manager_filter']['category'])) |
---|
80 | { |
---|
81 | $page['category'] = $_SESSION['bulk_manager_filter']['category']; |
---|
82 | } |
---|
83 | |
---|
84 | $redirect_url = get_root_url().'admin.php?page='.$_GET['page']; |
---|
85 | |
---|
86 | if (isset($_POST['submit'])) |
---|
87 | { |
---|
88 | // if the user tries to apply an action, it means that there is at least 1 |
---|
89 | // photo in the selection |
---|
90 | if (count($collection) == 0) |
---|
91 | { |
---|
92 | array_push($page['errors'], l10n('Select at least one photo')); |
---|
93 | } |
---|
94 | |
---|
95 | $action = $_POST['selectAction']; |
---|
96 | |
---|
97 | if ('remove_from_caddie' == $action) |
---|
98 | { |
---|
99 | $query = ' |
---|
100 | DELETE |
---|
101 | FROM '.CADDIE_TABLE.' |
---|
102 | WHERE element_id IN ('.implode(',', $collection).') |
---|
103 | AND user_id = '.$user['id'].' |
---|
104 | ;'; |
---|
105 | pwg_query($query); |
---|
106 | |
---|
107 | if ('caddie' == $page['prefilter']) |
---|
108 | { |
---|
109 | redirect($redirect_url); |
---|
110 | } |
---|
111 | |
---|
112 | // if we are here in the code, it means that the user is currently |
---|
113 | // displaying the caddie content, so we have to remove the current |
---|
114 | // selection from the current set |
---|
115 | $page['cat_elements_id'] = array_diff($page['cat_elements_id'], $collection); |
---|
116 | } |
---|
117 | |
---|
118 | if ('add_tags' == $action) |
---|
119 | { |
---|
120 | if (empty($_POST['add_tags'])) |
---|
121 | { |
---|
122 | array_push($page['errors'], l10n('Select at least one tag')); |
---|
123 | } |
---|
124 | else |
---|
125 | { |
---|
126 | $tag_ids = get_fckb_tag_ids($_POST['add_tags']); |
---|
127 | add_tags($tag_ids, $collection); |
---|
128 | |
---|
129 | if ('with no tag' == $page['prefilter']) |
---|
130 | { |
---|
131 | redirect(get_root_url().'admin.php?page='.$_GET['page']); |
---|
132 | } |
---|
133 | } |
---|
134 | } |
---|
135 | |
---|
136 | if ('del_tags' == $action) |
---|
137 | { |
---|
138 | if (count($_POST['del_tags']) == 0) |
---|
139 | { |
---|
140 | array_push($page['errors'], l10n('Select at least one tag')); |
---|
141 | } |
---|
142 | |
---|
143 | $query = ' |
---|
144 | DELETE |
---|
145 | FROM '.IMAGE_TAG_TABLE.' |
---|
146 | WHERE image_id IN ('.implode(',', $collection).') |
---|
147 | AND tag_id IN ('.implode(',', $_POST['del_tags']).') |
---|
148 | ;'; |
---|
149 | pwg_query($query); |
---|
150 | } |
---|
151 | |
---|
152 | if ('associate' == $action) |
---|
153 | { |
---|
154 | associate_images_to_categories( |
---|
155 | $collection, |
---|
156 | array($_POST['associate']) |
---|
157 | ); |
---|
158 | |
---|
159 | $_SESSION['page_infos'] = array( |
---|
160 | l10n('Information data registered in database') |
---|
161 | ); |
---|
162 | |
---|
163 | // let's refresh the page because we the current set might be modified |
---|
164 | if ('with no album' == $page['prefilter']) |
---|
165 | { |
---|
166 | redirect($redirect_url); |
---|
167 | } |
---|
168 | |
---|
169 | if ('with no virtual album' == $page['prefilter']) |
---|
170 | { |
---|
171 | $category_info = get_cat_info($_POST['associate']); |
---|
172 | if (empty($category_info['dir'])) |
---|
173 | { |
---|
174 | redirect($redirect_url); |
---|
175 | } |
---|
176 | } |
---|
177 | } |
---|
178 | |
---|
179 | if ('dissociate' == $action) |
---|
180 | { |
---|
181 | // physical links must not be broken, so we must first retrieve image_id |
---|
182 | // which create virtual links with the category to "dissociate from". |
---|
183 | $query = ' |
---|
184 | SELECT id |
---|
185 | FROM '.IMAGE_CATEGORY_TABLE.' |
---|
186 | INNER JOIN '.IMAGES_TABLE.' ON image_id = id |
---|
187 | WHERE category_id = '.$_POST['dissociate'].' |
---|
188 | AND id IN ('.implode(',', $collection).') |
---|
189 | AND ( |
---|
190 | category_id != storage_category_id |
---|
191 | OR storage_category_id IS NULL |
---|
192 | ) |
---|
193 | ;'; |
---|
194 | $dissociables = array_from_query($query, 'id'); |
---|
195 | |
---|
196 | if (!empty($dissociables)) |
---|
197 | { |
---|
198 | $query = ' |
---|
199 | DELETE |
---|
200 | FROM '.IMAGE_CATEGORY_TABLE.' |
---|
201 | WHERE category_id = '.$_POST['dissociate'].' |
---|
202 | AND image_id IN ('.implode(',', $dissociables).') |
---|
203 | '; |
---|
204 | pwg_query($query); |
---|
205 | |
---|
206 | update_category($_POST['dissociate']); |
---|
207 | |
---|
208 | $_SESSION['page_infos'] = array( |
---|
209 | l10n('Information data registered in database') |
---|
210 | ); |
---|
211 | |
---|
212 | // let's refresh the page because we the current set might be modified |
---|
213 | redirect($redirect_url); |
---|
214 | } |
---|
215 | } |
---|
216 | |
---|
217 | // author |
---|
218 | if ('author' == $action) |
---|
219 | { |
---|
220 | if (isset($_POST['remove_author'])) |
---|
221 | { |
---|
222 | $_POST['author'] = null; |
---|
223 | } |
---|
224 | |
---|
225 | $datas = array(); |
---|
226 | foreach ($collection as $image_id) |
---|
227 | { |
---|
228 | array_push( |
---|
229 | $datas, |
---|
230 | array( |
---|
231 | 'id' => $image_id, |
---|
232 | 'author' => $_POST['author'] |
---|
233 | ) |
---|
234 | ); |
---|
235 | } |
---|
236 | |
---|
237 | mass_updates( |
---|
238 | IMAGES_TABLE, |
---|
239 | array('primary' => array('id'), 'update' => array('author')), |
---|
240 | $datas |
---|
241 | ); |
---|
242 | } |
---|
243 | |
---|
244 | // title |
---|
245 | if ('title' == $action) |
---|
246 | { |
---|
247 | if (isset($_POST['remove_title'])) |
---|
248 | { |
---|
249 | $_POST['title'] = null; |
---|
250 | } |
---|
251 | |
---|
252 | $datas = array(); |
---|
253 | foreach ($collection as $image_id) |
---|
254 | { |
---|
255 | array_push( |
---|
256 | $datas, |
---|
257 | array( |
---|
258 | 'id' => $image_id, |
---|
259 | 'name' => $_POST['title'] |
---|
260 | ) |
---|
261 | ); |
---|
262 | } |
---|
263 | |
---|
264 | mass_updates( |
---|
265 | IMAGES_TABLE, |
---|
266 | array('primary' => array('id'), 'update' => array('name')), |
---|
267 | $datas |
---|
268 | ); |
---|
269 | } |
---|
270 | |
---|
271 | // date_creation |
---|
272 | if ('date_creation' == $action) |
---|
273 | { |
---|
274 | $date_creation = sprintf( |
---|
275 | '%u-%u-%u', |
---|
276 | $_POST['date_creation_year'], |
---|
277 | $_POST['date_creation_month'], |
---|
278 | $_POST['date_creation_day'] |
---|
279 | ); |
---|
280 | |
---|
281 | if (isset($_POST['remove_date_creation'])) |
---|
282 | { |
---|
283 | $date_creation = null; |
---|
284 | } |
---|
285 | |
---|
286 | $datas = array(); |
---|
287 | foreach ($collection as $image_id) |
---|
288 | { |
---|
289 | array_push( |
---|
290 | $datas, |
---|
291 | array( |
---|
292 | 'id' => $image_id, |
---|
293 | 'date_creation' => $date_creation |
---|
294 | ) |
---|
295 | ); |
---|
296 | } |
---|
297 | |
---|
298 | mass_updates( |
---|
299 | IMAGES_TABLE, |
---|
300 | array('primary' => array('id'), 'update' => array('date_creation')), |
---|
301 | $datas |
---|
302 | ); |
---|
303 | } |
---|
304 | |
---|
305 | // privacy_level |
---|
306 | if ('level' == $action) |
---|
307 | { |
---|
308 | $datas = array(); |
---|
309 | foreach ($collection as $image_id) |
---|
310 | { |
---|
311 | array_push( |
---|
312 | $datas, |
---|
313 | array( |
---|
314 | 'id' => $image_id, |
---|
315 | 'level' => $_POST['level'] |
---|
316 | ) |
---|
317 | ); |
---|
318 | } |
---|
319 | |
---|
320 | mass_updates( |
---|
321 | IMAGES_TABLE, |
---|
322 | array('primary' => array('id'), 'update' => array('level')), |
---|
323 | $datas |
---|
324 | ); |
---|
325 | |
---|
326 | if (isset($_SESSION['bulk_manager_filter']['level'])) |
---|
327 | { |
---|
328 | if ($_POST['level'] < $_SESSION['bulk_manager_filter']['level']) |
---|
329 | { |
---|
330 | redirect($redirect_url); |
---|
331 | } |
---|
332 | } |
---|
333 | } |
---|
334 | |
---|
335 | // add_to_caddie |
---|
336 | if ('add_to_caddie' == $action) |
---|
337 | { |
---|
338 | fill_caddie($collection); |
---|
339 | } |
---|
340 | |
---|
341 | // delete |
---|
342 | if ('delete' == $action) |
---|
343 | { |
---|
344 | if (isset($_POST['confirm_deletion']) and 1 == $_POST['confirm_deletion']) |
---|
345 | { |
---|
346 | $deleted_count = delete_elements($collection, true); |
---|
347 | if ($deleted_count > 0) |
---|
348 | { |
---|
349 | $_SESSION['page_infos'] = array( |
---|
350 | sprintf( |
---|
351 | l10n_dec( |
---|
352 | '%d photo was deleted', |
---|
353 | '%d photos were deleted', |
---|
354 | $deleted_count |
---|
355 | ), |
---|
356 | $deleted_count |
---|
357 | ) |
---|
358 | ); |
---|
359 | |
---|
360 | $redirect_url = get_root_url().'admin.php?page='.$_GET['page']; |
---|
361 | redirect($redirect_url); |
---|
362 | } |
---|
363 | else |
---|
364 | { |
---|
365 | array_push($page['errors'], l10n('No photo can be deleted')); |
---|
366 | } |
---|
367 | } |
---|
368 | else |
---|
369 | { |
---|
370 | array_push($page['errors'], l10n('You need to confirm deletion')); |
---|
371 | } |
---|
372 | } |
---|
373 | |
---|
374 | // synchronize metadata |
---|
375 | if ('metadata' == $action) |
---|
376 | { |
---|
377 | $query = ' |
---|
378 | SELECT id, path |
---|
379 | FROM '.IMAGES_TABLE.' |
---|
380 | WHERE id IN ('.implode(',', $collection).') |
---|
381 | ;'; |
---|
382 | $id_to_path = array(); |
---|
383 | $result = pwg_query($query); |
---|
384 | while ($row = pwg_db_fetch_assoc($result)) |
---|
385 | { |
---|
386 | $id_to_path[$row['id']] = $row['path']; |
---|
387 | } |
---|
388 | |
---|
389 | update_metadata($id_to_path); |
---|
390 | |
---|
391 | array_push( |
---|
392 | $page['infos'], |
---|
393 | l10n('Metadata synchronized from file') |
---|
394 | ); |
---|
395 | } |
---|
396 | |
---|
397 | trigger_action('element_set_global_action', $action, $collection); |
---|
398 | } |
---|
399 | |
---|
400 | // +-----------------------------------------------------------------------+ |
---|
401 | // | template init | |
---|
402 | // +-----------------------------------------------------------------------+ |
---|
403 | $template->set_filenames(array('batch_manager_global' => 'batch_manager_global.tpl')); |
---|
404 | |
---|
405 | $base_url = get_root_url().'admin.php'; |
---|
406 | |
---|
407 | $template->assign( |
---|
408 | array( |
---|
409 | 'filter' => $_SESSION['bulk_manager_filter'], |
---|
410 | 'selection' => $collection, |
---|
411 | 'U_DISPLAY'=>$base_url.get_query_string_diff(array('display')), |
---|
412 | 'F_ACTION'=>$base_url.get_query_string_diff(array('cat')), |
---|
413 | ) |
---|
414 | ); |
---|
415 | |
---|
416 | // +-----------------------------------------------------------------------+ |
---|
417 | // | caddie options | |
---|
418 | // +-----------------------------------------------------------------------+ |
---|
419 | |
---|
420 | $in_caddie = false; |
---|
421 | if (isset($_SESSION['bulk_manager_filter']['prefilter']) |
---|
422 | and 'caddie' == $_SESSION['bulk_manager_filter']['prefilter']) |
---|
423 | { |
---|
424 | $in_caddie = true; |
---|
425 | } |
---|
426 | $template->assign('IN_CADDIE', $in_caddie); |
---|
427 | |
---|
428 | // +-----------------------------------------------------------------------+ |
---|
429 | // | deletion form | |
---|
430 | // +-----------------------------------------------------------------------+ |
---|
431 | |
---|
432 | // we can only remove photos that have no storage_category_id, in other |
---|
433 | // word, it currently (Butterfly) means that the photo was added with |
---|
434 | // pLoader |
---|
435 | if (count($page['cat_elements_id']) > 0) |
---|
436 | { |
---|
437 | $query = ' |
---|
438 | SELECT |
---|
439 | id |
---|
440 | FROM '.IMAGES_TABLE.' |
---|
441 | WHERE id IN ('.implode(',', $page['cat_elements_id']).') |
---|
442 | AND file NOT LIKE \'http%\' |
---|
443 | LIMIT 1 |
---|
444 | ;'; |
---|
445 | ; |
---|
446 | |
---|
447 | if ( pwg_db_fetch_row(pwg_query($query)) ) |
---|
448 | { |
---|
449 | $template->assign('show_delete_form', true); |
---|
450 | } |
---|
451 | } |
---|
452 | |
---|
453 | // +-----------------------------------------------------------------------+ |
---|
454 | // | global mode form | |
---|
455 | // +-----------------------------------------------------------------------+ |
---|
456 | |
---|
457 | // privacy level |
---|
458 | $template->assign( |
---|
459 | array( |
---|
460 | 'filter_level_options'=> get_privacy_level_options(), |
---|
461 | 'filter_level_options_selected' => isset($_SESSION['bulk_manager_filter']['level']) |
---|
462 | ? $_SESSION['bulk_manager_filter']['level'] |
---|
463 | : 0, |
---|
464 | ) |
---|
465 | ); |
---|
466 | |
---|
467 | // Virtualy associate a picture to a category |
---|
468 | $query = ' |
---|
469 | SELECT id,name,uppercats,global_rank |
---|
470 | FROM '.CATEGORIES_TABLE.' |
---|
471 | ;'; |
---|
472 | display_select_cat_wrapper($query, array(), 'associate_options', true); |
---|
473 | |
---|
474 | // in the filter box, which category to select by default |
---|
475 | $selected_category = array(); |
---|
476 | |
---|
477 | if (isset($_SESSION['bulk_manager_filter']['category'])) |
---|
478 | { |
---|
479 | $selected_category = array($_SESSION['bulk_manager_filter']['category']); |
---|
480 | } |
---|
481 | else |
---|
482 | { |
---|
483 | // we need to know the category in which the last photo was added |
---|
484 | $selected_category = array(); |
---|
485 | |
---|
486 | $query = ' |
---|
487 | SELECT |
---|
488 | category_id, |
---|
489 | id_uppercat |
---|
490 | FROM '.IMAGES_TABLE.' AS i |
---|
491 | JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON image_id = i.id |
---|
492 | JOIN '.CATEGORIES_TABLE.' AS c ON category_id = c.id |
---|
493 | ORDER BY i.id DESC |
---|
494 | LIMIT 1 |
---|
495 | ;'; |
---|
496 | $result = pwg_query($query); |
---|
497 | if (pwg_db_num_rows($result) > 0) |
---|
498 | { |
---|
499 | $row = pwg_db_fetch_assoc($result); |
---|
500 | |
---|
501 | $selected_category = array($row['category_id']); |
---|
502 | } |
---|
503 | } |
---|
504 | |
---|
505 | $query = ' |
---|
506 | SELECT id,name,uppercats,global_rank |
---|
507 | FROM '.CATEGORIES_TABLE.' |
---|
508 | ;'; |
---|
509 | display_select_cat_wrapper($query, $selected_category, 'filter_category_options', true); |
---|
510 | |
---|
511 | // Dissociate from a category : categories listed for dissociation can only |
---|
512 | // represent virtual links. We can't create orphans. Links to physical |
---|
513 | // categories can't be broken. |
---|
514 | if (count($page['cat_elements_id']) > 0) |
---|
515 | { |
---|
516 | $query = ' |
---|
517 | SELECT |
---|
518 | DISTINCT(category_id) AS id, |
---|
519 | c.name, |
---|
520 | c.uppercats, |
---|
521 | c.global_rank |
---|
522 | FROM '.IMAGE_CATEGORY_TABLE.' AS ic |
---|
523 | JOIN '.CATEGORIES_TABLE.' AS c ON c.id = ic.category_id |
---|
524 | JOIN '.IMAGES_TABLE.' AS i ON i.id = ic.image_id |
---|
525 | WHERE ic.image_id IN ('.implode(',', $page['cat_elements_id']).') |
---|
526 | AND ( |
---|
527 | ic.category_id != i.storage_category_id |
---|
528 | OR i.storage_category_id IS NULL |
---|
529 | ) |
---|
530 | ;'; |
---|
531 | display_select_cat_wrapper($query, array(), 'dissociate_options', true); |
---|
532 | } |
---|
533 | |
---|
534 | if (count($page['cat_elements_id']) > 0) |
---|
535 | { |
---|
536 | // remove tags |
---|
537 | $tags = get_common_tags($page['cat_elements_id'], -1); |
---|
538 | |
---|
539 | $template->assign( |
---|
540 | array( |
---|
541 | 'DEL_TAG_SELECTION' => get_html_tag_selection($tags, 'del_tags'), |
---|
542 | ) |
---|
543 | ); |
---|
544 | } |
---|
545 | |
---|
546 | // creation date |
---|
547 | $day = |
---|
548 | empty($_POST['date_creation_day']) ? date('j') : $_POST['date_creation_day']; |
---|
549 | |
---|
550 | $month = |
---|
551 | empty($_POST['date_creation_month']) ? date('n') : $_POST['date_creation_month']; |
---|
552 | |
---|
553 | $year = |
---|
554 | empty($_POST['date_creation_year']) ? date('Y') : $_POST['date_creation_year']; |
---|
555 | |
---|
556 | $month_list = $lang['month']; |
---|
557 | $month_list[0]='------------'; |
---|
558 | ksort($month_list); |
---|
559 | $template->assign( array( |
---|
560 | 'month_list' => $month_list, |
---|
561 | 'DATE_CREATION_DAY' => (int)$day, |
---|
562 | 'DATE_CREATION_MONTH'=> (int)$month, |
---|
563 | 'DATE_CREATION_YEAR' => (int)$year, |
---|
564 | ) |
---|
565 | ); |
---|
566 | |
---|
567 | // image level options |
---|
568 | $template->assign( |
---|
569 | array( |
---|
570 | 'level_options'=> get_privacy_level_options(), |
---|
571 | 'level_options_selected' => 0, |
---|
572 | ) |
---|
573 | ); |
---|
574 | |
---|
575 | // metadata |
---|
576 | include_once( PHPWG_ROOT_PATH.'admin/site_reader_local.php'); |
---|
577 | $site_reader = new LocalSiteReader('./'); |
---|
578 | $used_metadata = implode( ', ', $site_reader->get_metadata_attributes()); |
---|
579 | |
---|
580 | $template->assign( |
---|
581 | array( |
---|
582 | 'used_metadata' => $used_metadata, |
---|
583 | ) |
---|
584 | ); |
---|
585 | |
---|
586 | // +-----------------------------------------------------------------------+ |
---|
587 | // | global mode thumbnails | |
---|
588 | // +-----------------------------------------------------------------------+ |
---|
589 | |
---|
590 | // how many items to display on this page |
---|
591 | if (!empty($_GET['display'])) |
---|
592 | { |
---|
593 | if ('all' == $_GET['display']) |
---|
594 | { |
---|
595 | $page['nb_images'] = count($page['cat_elements_id']); |
---|
596 | } |
---|
597 | else |
---|
598 | { |
---|
599 | $page['nb_images'] = intval($_GET['display']); |
---|
600 | } |
---|
601 | } |
---|
602 | else |
---|
603 | { |
---|
604 | $page['nb_images'] = 20; |
---|
605 | } |
---|
606 | |
---|
607 | $nb_thumbs_page = 0; |
---|
608 | |
---|
609 | if (count($page['cat_elements_id']) > 0) |
---|
610 | { |
---|
611 | $nav_bar = create_navigation_bar( |
---|
612 | $base_url.get_query_string_diff(array('start')), |
---|
613 | count($page['cat_elements_id']), |
---|
614 | $page['start'], |
---|
615 | $page['nb_images'] |
---|
616 | ); |
---|
617 | $template->assign('navbar', $nav_bar); |
---|
618 | |
---|
619 | $is_category = false; |
---|
620 | if (isset($_SESSION['bulk_manager_filter']['category']) |
---|
621 | and !isset($_SESSION['bulk_manager_filter']['category_recursive'])) |
---|
622 | { |
---|
623 | $is_category = true; |
---|
624 | } |
---|
625 | |
---|
626 | if (isset($_SESSION['bulk_manager_filter']['prefilter']) |
---|
627 | and 'duplicates' == $_SESSION['bulk_manager_filter']['prefilter']) |
---|
628 | { |
---|
629 | $conf['order_by'] = ' ORDER BY file, id'; |
---|
630 | } |
---|
631 | |
---|
632 | |
---|
633 | $query = ' |
---|
634 | SELECT id,path,tn_ext,file,filesize,level,name |
---|
635 | FROM '.IMAGES_TABLE; |
---|
636 | |
---|
637 | if ($is_category) |
---|
638 | { |
---|
639 | $category_info = get_cat_info($_SESSION['bulk_manager_filter']['category']); |
---|
640 | |
---|
641 | $conf['order_by'] = $conf['order_by_inside_category']; |
---|
642 | if (!empty($category_info['image_order'])) |
---|
643 | { |
---|
644 | $conf['order_by'] = ' ORDER BY '.$category_info['image_order']; |
---|
645 | } |
---|
646 | |
---|
647 | $query.= ' |
---|
648 | JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id'; |
---|
649 | } |
---|
650 | |
---|
651 | $query.= ' |
---|
652 | WHERE id IN ('.implode(',', $page['cat_elements_id']).')'; |
---|
653 | |
---|
654 | if ($is_category) |
---|
655 | { |
---|
656 | $query.= ' |
---|
657 | AND category_id = '.$_SESSION['bulk_manager_filter']['category']; |
---|
658 | } |
---|
659 | |
---|
660 | $query.= ' |
---|
661 | '.$conf['order_by'].' |
---|
662 | LIMIT '.$page['nb_images'].' OFFSET '.$page['start'].' |
---|
663 | ;'; |
---|
664 | $result = pwg_query($query); |
---|
665 | |
---|
666 | // template thumbnail initialization |
---|
667 | while ($row = pwg_db_fetch_assoc($result)) |
---|
668 | { |
---|
669 | $nb_thumbs_page++; |
---|
670 | $src = get_thumbnail_url($row); |
---|
671 | |
---|
672 | $title = $row['name']; |
---|
673 | if (empty($title)) |
---|
674 | { |
---|
675 | $title = get_name_from_file($row['file']); |
---|
676 | } |
---|
677 | |
---|
678 | $template->append( |
---|
679 | 'thumbnails', |
---|
680 | array( |
---|
681 | 'ID' => $row['id'], |
---|
682 | 'TN_SRC' => $src, |
---|
683 | 'FILE' => $row['file'], |
---|
684 | 'TITLE' => $title, |
---|
685 | 'LEVEL' => $row['level'] |
---|
686 | ) |
---|
687 | ); |
---|
688 | } |
---|
689 | } |
---|
690 | |
---|
691 | $template->assign( |
---|
692 | array( |
---|
693 | 'nb_thumbs_page' => $nb_thumbs_page, |
---|
694 | 'nb_thumbs_set' => count($page['cat_elements_id']), |
---|
695 | ) |
---|
696 | ); |
---|
697 | |
---|
698 | trigger_action('loc_end_element_set_global'); |
---|
699 | |
---|
700 | //----------------------------------------------------------- sending html code |
---|
701 | $template->assign_var_from_handle('ADMIN_CONTENT', 'batch_manager_global'); |
---|
702 | ?> |
---|