source: trunk/include/category_recent_cats.inc.php @ 707

Last change on this file since 707 was 705, checked in by plg, 20 years ago
  • bug 74 fixed : wrong link in thumbnail title representing a recent category
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
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-01-17 21:49:48 +0000 (Mon, 17 Jan 2005) $
10// | last modifier : $Author: plg $
11// | revision      : $Revision: 705 $
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 = '
38SELECT 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)';
43if ( $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
53if (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
66while ( $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      'IMAGE_NAME'              => '['.$name.']',
81      'IMAGE_STYLE'             => 'thumb_category',
82       
83      'U_IMG_LINK'              => add_session_id($url_link)
84      )
85    );
86  $template->assign_block_vars('thumbnails.line.thumbnail.bullet',array());
87
88  // create a new line ?
89  if (++$row_number == $user['nb_image_line'])
90  {
91    $template->assign_block_vars('thumbnails.line', array());
92    $row_number = 0;
93  }
94}
95$conf['level_separator'] = $old_level_separator;
96?>
Note: See TracBrowser for help on using the repository browser.