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-2005 PhpWebGallery Team - http://phpwebgallery.net | |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | // | branch : BSF (Best So Far) |
---|
8 | // | file : $RCSfile$ |
---|
9 | // | last update : $Date: 2006-04-02 22:26:19 +0000 (Sun, 02 Apr 2006) $ |
---|
10 | // | last modifier : $Author: plg $ |
---|
11 | // | revision : $Revision: 1119 $ |
---|
12 | // +-----------------------------------------------------------------------+ |
---|
13 | // | This program is free software; you can redistribute it and/or modify | |
---|
14 | // | it under the terms of the GNU General Public License as published by | |
---|
15 | // | the Free Software Foundation | |
---|
16 | // | | |
---|
17 | // | This program is distributed in the hope that it will be useful, but | |
---|
18 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
19 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
20 | // | General Public License for more details. | |
---|
21 | // | | |
---|
22 | // | You should have received a copy of the GNU General Public License | |
---|
23 | // | along with this program; if not, write to the Free Software | |
---|
24 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
25 | // | USA. | |
---|
26 | // +-----------------------------------------------------------------------+ |
---|
27 | |
---|
28 | /** |
---|
29 | * This file is included by the main page to show thumbnails for the default |
---|
30 | * case |
---|
31 | * |
---|
32 | */ |
---|
33 | |
---|
34 | $page['rank_of'] = array_flip($page['items']); |
---|
35 | |
---|
36 | $pictures = array(); |
---|
37 | |
---|
38 | $selection = array_slice( |
---|
39 | $page['items'], |
---|
40 | $page['start'], |
---|
41 | $page['nb_image_page'] |
---|
42 | ); |
---|
43 | |
---|
44 | if (count($selection) > 0) |
---|
45 | { |
---|
46 | $query = ' |
---|
47 | SELECT * |
---|
48 | FROM '.IMAGES_TABLE.' |
---|
49 | WHERE id IN ('.implode(',', $selection).') |
---|
50 | ;'; |
---|
51 | $result = pwg_query($query); |
---|
52 | while ($row = mysql_fetch_array($result)) |
---|
53 | { |
---|
54 | $row['rank'] = $page['rank_of'][ $row['id'] ]; |
---|
55 | |
---|
56 | array_push($pictures, $row); |
---|
57 | } |
---|
58 | |
---|
59 | usort($pictures, 'rank_compare'); |
---|
60 | } |
---|
61 | |
---|
62 | // template thumbnail initialization |
---|
63 | if (count($pictures) > 0) |
---|
64 | { |
---|
65 | $template->assign_block_vars('thumbnails', array()); |
---|
66 | // first line |
---|
67 | $template->assign_block_vars('thumbnails.line', array()); |
---|
68 | // current row displayed |
---|
69 | $row_number = 0; |
---|
70 | } |
---|
71 | |
---|
72 | foreach ($pictures as $row) |
---|
73 | { |
---|
74 | $thumbnail_url = get_thumbnail_src($row['path'], @$row['tn_ext']); |
---|
75 | |
---|
76 | // message in title for the thumbnail |
---|
77 | $thumbnail_title = $row['file']; |
---|
78 | if (isset($row['filesize'])) |
---|
79 | { |
---|
80 | $thumbnail_title .= ' : '.$row['filesize'].' KB'; |
---|
81 | } |
---|
82 | |
---|
83 | // link on picture.php page |
---|
84 | $url = duplicate_picture_url( |
---|
85 | array( |
---|
86 | 'image_id' => $row['id'], |
---|
87 | 'image_file' => $row['file'] |
---|
88 | ), |
---|
89 | array('start') |
---|
90 | ); |
---|
91 | |
---|
92 | $template->assign_block_vars( |
---|
93 | 'thumbnails.line.thumbnail', |
---|
94 | array( |
---|
95 | 'IMAGE' => $thumbnail_url, |
---|
96 | 'IMAGE_ALT' => $row['file'], |
---|
97 | 'IMAGE_TITLE' => $thumbnail_title, |
---|
98 | 'IMAGE_TS' => get_icon($row['date_available']), |
---|
99 | |
---|
100 | 'U_IMG_LINK' => $url, |
---|
101 | |
---|
102 | 'CLASS' => 'thumbElmt', |
---|
103 | ) |
---|
104 | ); |
---|
105 | |
---|
106 | if ($conf['show_thumbnail_caption']) |
---|
107 | { |
---|
108 | // name of the picture |
---|
109 | if (isset($row['name']) and $row['name'] != '') |
---|
110 | { |
---|
111 | $name = $row['name']; |
---|
112 | } |
---|
113 | else |
---|
114 | { |
---|
115 | $name = str_replace('_', ' ', get_filename_wo_extension($row['file'])); |
---|
116 | } |
---|
117 | |
---|
118 | switch ($page['section']) |
---|
119 | { |
---|
120 | case 'best_rated' : |
---|
121 | { |
---|
122 | $name = '('.$row['average_rate'].') '.$name; |
---|
123 | break; |
---|
124 | } |
---|
125 | case 'most_visited' : |
---|
126 | { |
---|
127 | $name = '('.$row['hit'].') '.$name; |
---|
128 | break; |
---|
129 | } |
---|
130 | case 'search' : |
---|
131 | { |
---|
132 | $name = replace_search($name, $page['search']); |
---|
133 | break; |
---|
134 | } |
---|
135 | } |
---|
136 | |
---|
137 | $template->assign_block_vars( |
---|
138 | 'thumbnails.line.thumbnail.element_name', |
---|
139 | array( |
---|
140 | 'NAME' => $name |
---|
141 | ) |
---|
142 | ); |
---|
143 | } |
---|
144 | |
---|
145 | if ($user['show_nb_comments'] |
---|
146 | and isset($page['category']) |
---|
147 | and $page['cat_commentable']) |
---|
148 | { |
---|
149 | $query = ' |
---|
150 | SELECT COUNT(*) AS nb_comments |
---|
151 | FROM '.COMMENTS_TABLE.' |
---|
152 | WHERE image_id = '.$row['id'].' |
---|
153 | AND validated = \'true\' |
---|
154 | ;'; |
---|
155 | $row = mysql_fetch_array(pwg_query($query)); |
---|
156 | $template->assign_block_vars( |
---|
157 | 'thumbnails.line.thumbnail.nb_comments', |
---|
158 | array('NB_COMMENTS'=>$row['nb_comments'])); |
---|
159 | } |
---|
160 | |
---|
161 | // create a new line ? |
---|
162 | if (++$row_number == $user['nb_image_line']) |
---|
163 | { |
---|
164 | $template->assign_block_vars('thumbnails.line', array()); |
---|
165 | $row_number = 0; |
---|
166 | } |
---|
167 | } |
---|
168 | |
---|
169 | pwg_debug('end include/category_default.inc.php'); |
---|
170 | ?> |
---|