1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
5 | // | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net | |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | // | file : $Id: category_default.inc.php 2234 2008-03-01 14:24:04Z rvelices $ |
---|
8 | // | last update : $Date: 2008-03-01 14:24:04 +0000 (Sat, 01 Mar 2008) $ |
---|
9 | // | last modifier : $Author: rvelices $ |
---|
10 | // | revision : $Revision: 2234 $ |
---|
11 | // +-----------------------------------------------------------------------+ |
---|
12 | // | This program is free software; you can redistribute it and/or modify | |
---|
13 | // | it under the terms of the GNU General Public License as published by | |
---|
14 | // | the Free Software Foundation | |
---|
15 | // | | |
---|
16 | // | This program is distributed in the hope that it will be useful, but | |
---|
17 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
18 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
19 | // | General Public License for more details. | |
---|
20 | // | | |
---|
21 | // | You should have received a copy of the GNU General Public License | |
---|
22 | // | along with this program; if not, write to the Free Software | |
---|
23 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
24 | // | USA. | |
---|
25 | // +-----------------------------------------------------------------------+ |
---|
26 | |
---|
27 | /** |
---|
28 | * This file is included by the main page to show thumbnails for the default |
---|
29 | * case |
---|
30 | * |
---|
31 | */ |
---|
32 | |
---|
33 | $page['rank_of'] = array_flip($page['items']); |
---|
34 | |
---|
35 | $pictures = array(); |
---|
36 | |
---|
37 | $selection = array_slice( |
---|
38 | $page['items'], |
---|
39 | $page['start'], |
---|
40 | $page['nb_image_page'] |
---|
41 | ); |
---|
42 | |
---|
43 | if (count($selection) > 0) |
---|
44 | { |
---|
45 | $query = ' |
---|
46 | SELECT * |
---|
47 | FROM '.IMAGES_TABLE.' |
---|
48 | WHERE id IN ('.implode(',', $selection).') |
---|
49 | ;'; |
---|
50 | $result = pwg_query($query); |
---|
51 | while ($row = mysql_fetch_assoc($result)) |
---|
52 | { |
---|
53 | $row['rank'] = $page['rank_of'][ $row['id'] ]; |
---|
54 | |
---|
55 | array_push($pictures, $row); |
---|
56 | } |
---|
57 | |
---|
58 | usort($pictures, 'rank_compare'); |
---|
59 | } |
---|
60 | |
---|
61 | // template thumbnail initialization |
---|
62 | $template->set_filenames( array( 'thumbnails' => 'thumbnails.tpl',)); |
---|
63 | if (count($pictures) > 0) |
---|
64 | { |
---|
65 | // define category slideshow url |
---|
66 | $row = reset($pictures); |
---|
67 | $page['cat_slideshow_url'] = |
---|
68 | add_url_params( |
---|
69 | duplicate_picture_url( |
---|
70 | array( |
---|
71 | 'image_id' => $row['id'], |
---|
72 | 'image_file' => $row['file'] |
---|
73 | ), |
---|
74 | array('start') |
---|
75 | ), |
---|
76 | array('slideshow' => |
---|
77 | (isset($_GET['slideshow']) ? $_GET['slideshow'] |
---|
78 | : '' )) |
---|
79 | ); |
---|
80 | |
---|
81 | $template->clear_assign('thumbnails'); // category_default reuse them |
---|
82 | } |
---|
83 | |
---|
84 | trigger_action('loc_begin_index_thumbnails', $pictures); |
---|
85 | |
---|
86 | foreach ($pictures as $row) |
---|
87 | { |
---|
88 | $thumbnail_url = get_thumbnail_url($row); |
---|
89 | |
---|
90 | // link on picture.php page |
---|
91 | $url = duplicate_picture_url( |
---|
92 | array( |
---|
93 | 'image_id' => $row['id'], |
---|
94 | 'image_file' => $row['file'] |
---|
95 | ), |
---|
96 | array('start') |
---|
97 | ); |
---|
98 | |
---|
99 | $tpl_var = |
---|
100 | array( |
---|
101 | 'IMAGE' => $thumbnail_url, |
---|
102 | 'IMAGE_ALT' => $row['file'], |
---|
103 | 'IMAGE_TITLE' => get_thumbnail_title($row), |
---|
104 | 'IMAGE_TS' => get_icon($row['date_available']), |
---|
105 | |
---|
106 | 'U_IMG_LINK' => $url, |
---|
107 | |
---|
108 | 'CLASS' => 'thumbElmt', |
---|
109 | ); |
---|
110 | |
---|
111 | if ($user['show_nb_hits']) |
---|
112 | { |
---|
113 | $tpl_var['nb_hits'] = |
---|
114 | array( |
---|
115 | 'HITS'=> $row['hit'], |
---|
116 | 'CLASS'=> set_span_class($row['hit']), |
---|
117 | ); |
---|
118 | } |
---|
119 | |
---|
120 | if ($conf['show_thumbnail_caption']) |
---|
121 | { |
---|
122 | // name of the picture |
---|
123 | if (isset($row['name']) and $row['name'] != '') |
---|
124 | { |
---|
125 | $name = $row['name']; |
---|
126 | } |
---|
127 | else |
---|
128 | { |
---|
129 | $name = str_replace('_', ' ', get_filename_wo_extension($row['file'])); |
---|
130 | } |
---|
131 | |
---|
132 | switch ($page['section']) |
---|
133 | { |
---|
134 | case 'best_rated' : |
---|
135 | { |
---|
136 | $name = '('.$row['average_rate'].') '.$name; |
---|
137 | break; |
---|
138 | } |
---|
139 | case 'most_visited' : |
---|
140 | { |
---|
141 | if ( !$user['show_nb_hits']) { |
---|
142 | $name = '('.$row['hit'].') '.$name; |
---|
143 | } |
---|
144 | break; |
---|
145 | } |
---|
146 | } |
---|
147 | |
---|
148 | $tpl_var['ELEMENT_NAME'] = $name; |
---|
149 | } |
---|
150 | |
---|
151 | if ($user['show_nb_comments']) |
---|
152 | { |
---|
153 | $query = ' |
---|
154 | SELECT COUNT(*) AS nb_comments |
---|
155 | FROM '.COMMENTS_TABLE.' |
---|
156 | WHERE image_id = '.$row['id'].' |
---|
157 | AND validated = \'true\' |
---|
158 | ;'; |
---|
159 | list($row['nb_comments']) = mysql_fetch_array(pwg_query($query)); |
---|
160 | $tpl_var['nb_comments'] = |
---|
161 | array( |
---|
162 | 'NB_COMMENTS'=> $row['nb_comments'], |
---|
163 | 'CLASS'=> set_span_class($row['nb_comments']), |
---|
164 | ); |
---|
165 | } |
---|
166 | |
---|
167 | $template->append('thumbnails', $tpl_var); |
---|
168 | |
---|
169 | //plugins need to add/modify sth in this loop ? |
---|
170 | trigger_action('loc_index_thumbnail', $row, 'thumbnails' ); |
---|
171 | } |
---|
172 | |
---|
173 | trigger_action('loc_end_index_thumbnails', $pictures); |
---|
174 | $template->assign_var_from_handle('THUMBNAILS', 'thumbnails'); |
---|
175 | |
---|
176 | pwg_debug('end include/category_default.inc.php'); |
---|
177 | ?> |
---|