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

Last change on this file since 452 was 452, checked in by z0rglub, 20 years ago

replacement of short_period and long_period by recent_period

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 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-07-09 21:00:00 +0000 (Fri, 09 Jul 2004) $
10// | last modifier : $Author: z0rglub $
11// | revision      : $Revision: 452 $
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  $file = get_filename_wo_extension( $subrow['file'] );
81   
82  // creating links for thumbnail and associated category
83  $thumbnail_link = get_complete_dir( $subrow['storage_category_id'] );
84  $thumbnail_link.= 'thumbnail/'.$conf['prefix_thumbnail'];
85  $thumbnail_link.= $file.'.'.$subrow['tn_ext'];
86 
87  $url_link = PHPWG_ROOT_PATH.'category.php?cat='.$row['category_id'];
88 
89  $template->assign_block_vars(
90    'thumbnails.line.thumbnail',
91    array(
92      'IMAGE'                   => $thumbnail_link,
93      'IMAGE_ALT'               => $subrow['file'],
94      'IMAGE_TITLE'             => $lang['hint_category'],
95      'IMAGE_NAME'              => '['.$name.']',
96      'IMAGE_STYLE'             => 'thumb_category',
97       
98      'U_IMG_LINK'              => add_session_id( $url_link )
99      )
100    );
101  $template->assign_block_vars('thumbnails.line.thumbnail.bullet',array());
102
103  // create a new line ?
104  if (++$row_number == $user['nb_image_line'])
105  {
106    $template->assign_block_vars('thumbnails.line', array());
107    $row_number = 0;
108  }
109}
110?>
Note: See TracBrowser for help on using the repository browser.