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-2004 PhpWebGallery Team - http://phpwebgallery.net | |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | // | branch : BSF (Best So Far) |
---|
8 | // | file : $RCSfile$ |
---|
9 | // | last update : $Date: 2004-11-20 17:23:42 +0000 (Sat, 20 Nov 2004) $ |
---|
10 | // | last modifier : $Author: plg $ |
---|
11 | // | revision : $Revision: 610 $ |
---|
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 category.php to show thumbnails for a category |
---|
30 | * that have only subcategories |
---|
31 | * |
---|
32 | */ |
---|
33 | |
---|
34 | $query = ' |
---|
35 | SELECT id, name, date_last |
---|
36 | FROM '.CATEGORIES_TABLE.' |
---|
37 | WHERE id_uppercat '; |
---|
38 | if (!isset($page['cat']) or !is_numeric($page['cat'])) |
---|
39 | { |
---|
40 | $query.= 'is NULL'; |
---|
41 | } |
---|
42 | else |
---|
43 | { |
---|
44 | $query.= '= '.$page['cat']; |
---|
45 | } |
---|
46 | // we must not show pictures of a forbidden category |
---|
47 | if ($user['forbidden_categories'] != '') |
---|
48 | { |
---|
49 | $query.= ' AND id NOT IN ('.$user['forbidden_categories'].')'; |
---|
50 | } |
---|
51 | $query.= ' |
---|
52 | ORDER BY rank |
---|
53 | ;'; |
---|
54 | $result = pwg_query($query); |
---|
55 | |
---|
56 | // template thumbnail initialization |
---|
57 | if (mysql_num_rows($result) > 0) |
---|
58 | { |
---|
59 | $template->assign_block_vars('thumbnails', array()); |
---|
60 | // first line |
---|
61 | $template->assign_block_vars('thumbnails.line', array()); |
---|
62 | // current row displayed |
---|
63 | $row_number = 0; |
---|
64 | } |
---|
65 | |
---|
66 | while ($row = mysql_fetch_array($result)) |
---|
67 | { |
---|
68 | $query = ' |
---|
69 | SELECT path, tn_ext |
---|
70 | FROM '.CATEGORIES_TABLE.' AS c INNER JOIN '.IMAGES_TABLE.' AS i |
---|
71 | ON i.id = c.representative_picture_id |
---|
72 | WHERE uppercats REGEXP \'(^|,)'.$row['id'].'(,|$)\' |
---|
73 | ORDER BY RAND() |
---|
74 | LIMIT 0,1 |
---|
75 | ;'; |
---|
76 | $element_result = pwg_query($query); |
---|
77 | if (mysql_num_rows($element_result) == 0) |
---|
78 | { |
---|
79 | continue; |
---|
80 | } |
---|
81 | $element_row = mysql_fetch_array($element_result); |
---|
82 | |
---|
83 | $thumbnail_link = get_thumbnail_src($element_row['path'], |
---|
84 | @$element_row['tn_ext']); |
---|
85 | |
---|
86 | $thumbnail_title = $lang['hint_category']; |
---|
87 | |
---|
88 | $url_link = PHPWG_ROOT_PATH.'category.php?cat='.$row['id']; |
---|
89 | |
---|
90 | $template->assign_block_vars( |
---|
91 | 'thumbnails.line.thumbnail', |
---|
92 | array( |
---|
93 | 'IMAGE' => $thumbnail_link, |
---|
94 | 'IMAGE_ALT' => $row['name'], |
---|
95 | 'IMAGE_TITLE' => $thumbnail_title, |
---|
96 | 'IMAGE_NAME' => '['.$row['name'].']', |
---|
97 | 'IMAGE_TS' => get_icon(@$row['date_last']), |
---|
98 | 'IMAGE_STYLE' => 'thumb_category', |
---|
99 | |
---|
100 | 'U_IMG_LINK' => add_session_id($url_link) |
---|
101 | ) |
---|
102 | ); |
---|
103 | $template->assign_block_vars('thumbnails.line.thumbnail.bullet',array()); |
---|
104 | |
---|
105 | // create a new line ? |
---|
106 | if (++$row_number == $user['nb_image_line']) |
---|
107 | { |
---|
108 | $template->assign_block_vars('thumbnails.line', array()); |
---|
109 | $row_number = 0; |
---|
110 | } |
---|
111 | } |
---|
112 | ?> |
---|