1 | <?php |
---|
2 | defined('USER_COLLEC_PATH') or die('Hacking attempt!'); |
---|
3 | |
---|
4 | |
---|
5 | // collections orders |
---|
6 | if (isset($_GET['uc_collection_order'])) |
---|
7 | { |
---|
8 | if ( (int)$_GET['uc_collection_order'] > 0) |
---|
9 | { |
---|
10 | pwg_set_session_var('uc_collection_order', (int)$_GET['uc_collection_order']); |
---|
11 | } |
---|
12 | else |
---|
13 | { |
---|
14 | pwg_unset_session_var('uc_collection_order'); |
---|
15 | } |
---|
16 | redirect(USER_COLLEC_PUBLIC); |
---|
17 | } |
---|
18 | |
---|
19 | $col_order_id = pwg_get_session_var('uc_collection_order', 0); |
---|
20 | $orders = get_collections_preferred_orders(); |
---|
21 | |
---|
22 | // get sorted collections |
---|
23 | $query = ' |
---|
24 | SELECT * |
---|
25 | FROM '.COLLECTIONS_TABLE.' |
---|
26 | WHERE user_id = '.$user['id'].' |
---|
27 | ORDER BY '.$orders[$col_order_id][1].' |
---|
28 | '; |
---|
29 | $categories = hash_from_query($query, 'id'); |
---|
30 | |
---|
31 | $template->assign('COLLECTIONS_COUNT', count($categories)); |
---|
32 | |
---|
33 | // order menu |
---|
34 | if (count($categories)) |
---|
35 | { |
---|
36 | $url = add_url_params(USER_COLLEC_PUBLIC, array('uc_collection_order' => '')); |
---|
37 | |
---|
38 | foreach ($orders as $order_id => $order) |
---|
39 | { |
---|
40 | if ($order[2]) |
---|
41 | { |
---|
42 | $template->append( |
---|
43 | 'image_orders', |
---|
44 | array( |
---|
45 | 'DISPLAY' => $order[0], |
---|
46 | 'URL' => $url.$order_id, |
---|
47 | 'SELECTED' => ($col_order_id == $order_id ? true:false), |
---|
48 | ) |
---|
49 | ); |
---|
50 | } |
---|
51 | } |
---|
52 | } |
---|
53 | |
---|
54 | |
---|
55 | if (count($categories)) |
---|
56 | { |
---|
57 | $query = ' |
---|
58 | SELECT * FROM ( |
---|
59 | SELECT |
---|
60 | i.*, |
---|
61 | ci.col_id |
---|
62 | FROM '.IMAGES_TABLE.' AS i |
---|
63 | INNER JOIN '.COLLECTION_IMAGES_TABLE.' AS ci |
---|
64 | ON i.id = ci.image_id |
---|
65 | WHERE col_id IN('.implode(',', array_keys($categories)).') |
---|
66 | ORDER BY ci.add_date DESC |
---|
67 | ) AS t |
---|
68 | GROUP BY col_id |
---|
69 | ;'; |
---|
70 | $thumbnails = hash_from_query($query, 'col_id'); |
---|
71 | |
---|
72 | $thumbnails[0] = array( |
---|
73 | 'id' => 0, |
---|
74 | 'path' => 'themes/default/icon/img_small.png', |
---|
75 | 'picture_ext' => 'png', |
---|
76 | 'width' => 32, |
---|
77 | 'height' => 32, |
---|
78 | 'rotation' => 0, |
---|
79 | ); |
---|
80 | |
---|
81 | foreach ($thumbnails as &$info) |
---|
82 | { |
---|
83 | $info['src_image'] = new SrcImage($info); |
---|
84 | } |
---|
85 | unset($info); |
---|
86 | |
---|
87 | $tpl_thumbnails_var = array(); |
---|
88 | |
---|
89 | foreach ($categories as $category) |
---|
90 | { |
---|
91 | $thumb = empty($thumbnails[ $category['id'] ]) ? $thumbnails[0] : $thumbnails[ $category['id'] ]; |
---|
92 | $counter = get_display_images_count($category['nb_images'], $category['nb_images'], 0); |
---|
93 | |
---|
94 | $tpl_var = array_merge( $category, array( |
---|
95 | 'representative' => $thumb, |
---|
96 | 'TN_ALT' => strip_tags($category['name']), |
---|
97 | 'URL' => USER_COLLEC_PUBLIC.'edit/'.$category['id'], |
---|
98 | 'CAPTION_NB_IMAGES' => empty($counter) ? sprintf(l10n('%d photo'), 0) : $counter, |
---|
99 | 'NAME' => trigger_event('render_category_name', $category['name']), |
---|
100 | 'DESCRIPTION' => trigger_event('render_category_description', $category['comment'], 'subcatify_category_description'), |
---|
101 | 'INFO_DATES' => format_date($category['date_creation'], true), |
---|
102 | 'U_DELETE' => add_url_params(USER_COLLEC_PUBLIC, array('action'=>'delete','col_id'=>$category['id'])), |
---|
103 | )); |
---|
104 | |
---|
105 | $tpl_thumbnails_var[] = $tpl_var; |
---|
106 | } |
---|
107 | |
---|
108 | $derivative_params = trigger_event('get_index_album_derivative_params', ImageStdParams::get_by_type(IMG_THUMB) ); |
---|
109 | $template->assign(array( |
---|
110 | 'maxRequests' =>$conf['max_requests'], |
---|
111 | 'category_thumbnails' => $tpl_thumbnails_var, |
---|
112 | 'derivative_params' => $derivative_params, |
---|
113 | )); |
---|
114 | |
---|
115 | $template->set_filename('index_category_thumbnails', 'mainpage_categories.tpl'); |
---|
116 | $template->assign_var_from_handle('CATEGORIES', 'index_category_thumbnails'); |
---|
117 | } |
---|
118 | |
---|
119 | ?> |
---|