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

Last change on this file since 579 was 579, checked in by z0rglub, 20 years ago
  • refactoring of comments.php
  • creation of function get_thumbnail_src used everywhere a thumbnail must be displayed
  • creation of function parse_comment_content (used in comments.php and picture.php)
  • concerning undefined index on arrays retrieved in database, instead of testing possibly unset values, use of @ operator (smarter...)
  • add pre tag in default.css stylesheet for debugging purpose (need to have left aligned text)
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.1 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// |                      category_recent_cats.inc.php                     |
4// +-----------------------------------------------------------------------+
5// | application   : PhpWebGallery <http://phpwebgallery.net>              |
6// | branch        : BSF (Best So Far)                                     |
7// +-----------------------------------------------------------------------+
8// | file          : $RCSfile$
9// | last update   : $Date: 2004-10-23 17:56:46 +0000 (Sat, 23 Oct 2004) $
10// | last modifier : $Author: z0rglub $
11// | revision      : $Revision: 579 $
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 id AS category_id
39  FROM '.CATEGORIES_TABLE.'
40  WHERE date_last > SUBDATE(CURRENT_DATE
41                            ,INTERVAL '.$user['recent_period'].' DAY)';
42if ( $user['forbidden_categories'] != '' )
43{
44  $query.= '
45    AND id NOT IN ('.$user['forbidden_categories'].')';
46}
47$query.= '
48;';
49$result = mysql_query( $query );
50
51// template thumbnail initialization
52if (mysql_num_rows($result) > 0)
53{
54  $template->assign_block_vars('thumbnails', array());
55  // first line
56  $template->assign_block_vars('thumbnails.line', array());
57  // current row displayed
58  $row_number = 0;
59}
60
61// for each category, we have to search a recent picture to display and
62// the name to display
63while ( $row = mysql_fetch_array( $result ) )
64{
65  $cat_infos = get_cat_info( $row['category_id'] );
66  $name = get_cat_display_name($cat_infos['name'],'<br />','',false);
67 
68  $query = '
69SELECT id,file,tn_ext,storage_category_id
70  FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.'
71  WHERE category_id = '.$row['category_id'].'
72    AND date_available > SUBDATE(CURRENT_DATE
73                                 ,INTERVAL '.$user['recent_period'].' DAY)
74    AND id = image_id
75  ORDER BY RAND()
76  LIMIT 0,1
77;';
78  $subrow = mysql_fetch_array( mysql_query( $query ) );
79
80  $thumbnail_src = get_thumbnail_src($subrow['file'],
81                                     $subrow['storage_category_id'],
82                                     @$subrow['tn_ext']);
83 
84  $url_link = PHPWG_ROOT_PATH.'category.php?cat='.$row['category_id'];
85 
86  $template->assign_block_vars(
87    'thumbnails.line.thumbnail',
88    array(
89      'IMAGE'                   => $thumbnail_src,
90      'IMAGE_ALT'               => $subrow['file'],
91      'IMAGE_TITLE'             => $lang['hint_category'],
92      'IMAGE_NAME'              => '['.$name.']',
93      'IMAGE_STYLE'             => 'thumb_category',
94       
95      'U_IMG_LINK'              => add_session_id( $url_link )
96      )
97    );
98  $template->assign_block_vars('thumbnails.line.thumbnail.bullet',array());
99
100  // create a new line ?
101  if (++$row_number == $user['nb_image_line'])
102  {
103    $template->assign_block_vars('thumbnails.line', array());
104    $row_number = 0;
105  }
106}
107?>
Note: See TracBrowser for help on using the repository browser.