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: 2005-03-26 22:35:07 +0000 (Sat, 26 Mar 2005) $ |
---|
10 | // | last modifier : $Author: plg $ |
---|
11 | // | revision : $Revision: 760 $ |
---|
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 recent_cats |
---|
30 | * category |
---|
31 | * |
---|
32 | */ |
---|
33 | |
---|
34 | // retrieving categories recently update, ie containing pictures added |
---|
35 | // recently. The calculated table field categories.date_last will be |
---|
36 | // easier to use |
---|
37 | $query = ' |
---|
38 | SELECT c.id AS category_id,uppercats,representative_picture_id,path,file,tn_ext |
---|
39 | FROM '.CATEGORIES_TABLE.' AS c INNER JOIN '.IMAGES_TABLE.' AS i |
---|
40 | ON i.id = c.representative_picture_id |
---|
41 | WHERE date_last > SUBDATE(CURRENT_DATE |
---|
42 | ,INTERVAL '.$user['recent_period'].' DAY)'; |
---|
43 | if ( $user['forbidden_categories'] != '' ) |
---|
44 | { |
---|
45 | $query.= ' |
---|
46 | AND c.id NOT IN ('.$user['forbidden_categories'].')'; |
---|
47 | } |
---|
48 | $query.= ' |
---|
49 | ;'; |
---|
50 | $result = pwg_query( $query ); |
---|
51 | |
---|
52 | // template thumbnail initialization |
---|
53 | if (mysql_num_rows($result) > 0) |
---|
54 | { |
---|
55 | $template->assign_block_vars('thumbnails', array()); |
---|
56 | // first line |
---|
57 | $template->assign_block_vars('thumbnails.line', array()); |
---|
58 | // current row displayed |
---|
59 | $row_number = 0; |
---|
60 | } |
---|
61 | |
---|
62 | $old_level_separator = $conf['level_separator']; |
---|
63 | $conf['level_separator'] = '<br />'; |
---|
64 | // for each category, we have to search a recent picture to display and |
---|
65 | // the name to display |
---|
66 | while ( $row = mysql_fetch_array( $result ) ) |
---|
67 | { |
---|
68 | $name = get_cat_display_name_cache($row['uppercats'], '', false); |
---|
69 | |
---|
70 | $thumbnail_src = get_thumbnail_src($row['path'], @$row['tn_ext']); |
---|
71 | |
---|
72 | $url_link = PHPWG_ROOT_PATH.'category.php?cat='.$row['category_id']; |
---|
73 | |
---|
74 | $template->assign_block_vars( |
---|
75 | 'thumbnails.line.thumbnail', |
---|
76 | array( |
---|
77 | 'IMAGE' => $thumbnail_src, |
---|
78 | 'IMAGE_ALT' => $row['file'], |
---|
79 | 'IMAGE_TITLE' => $lang['hint_category'], |
---|
80 | |
---|
81 | 'U_IMG_LINK' => add_session_id($url_link) |
---|
82 | ) |
---|
83 | ); |
---|
84 | |
---|
85 | $template->assign_block_vars( |
---|
86 | 'thumbnails.line.thumbnail.category_name', |
---|
87 | array( |
---|
88 | 'NAME' => $name |
---|
89 | ) |
---|
90 | ); |
---|
91 | |
---|
92 | // create a new line ? |
---|
93 | if (++$row_number == $user['nb_image_line']) |
---|
94 | { |
---|
95 | $template->assign_block_vars('thumbnails.line', array()); |
---|
96 | $row_number = 0; |
---|
97 | } |
---|
98 | } |
---|
99 | $conf['level_separator'] = $old_level_separator; |
---|
100 | ?> |
---|