source: trunk/include/category_default.inc.php @ 526

Last change on this file since 526 was 526, checked in by z0rglub, 20 years ago
  • new version of create_file_listing.php for future 1.4 branch
  • new feature : remote site management (generate listing, update, clean, delete)
  • on category page, no display of filesize if info not available in database
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// |                        category_default.inc.php                       |
4// +-----------------------------------------------------------------------+
5// | application   : PhpWebGallery <http://phpwebgallery.net>              |
6// | branch        : BSF (Best So Far)                                     |
7// +-----------------------------------------------------------------------+
8// | file          : $RCSfile$
9// | last update   : $Date: 2004-09-18 16:09:47 +0000 (Sat, 18 Sep 2004) $
10// | last modifier : $Author: z0rglub $
11// | revision      : $Revision: 526 $
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 the default
30 * case
31 *
32 */
33
34/**
35 * $array_cat_directories is a cache hash associating category id with their
36 * complete directory
37 */
38$array_cat_directories = array();
39 
40$query = '
41SELECT DISTINCT(id),file,date_available,category_id
42       ,tn_ext,name,filesize,storage_category_id,average_rate
43  FROM '.IMAGES_TABLE.' AS i
44    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=ic.image_id
45  '.$page['where'].'
46  '.$conf['order_by'].'
47  LIMIT '.$page['start'].','.$page['nb_image_page'].'
48;';
49// echo '<pre>'.$query.'</pre>';
50$result = mysql_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
62while ($row = mysql_fetch_array($result))
63{
64  // retrieving the storage dir of the picture
65  if (!isset($array_cat_directories[$row['storage_category_id']]))
66  {
67    $array_cat_directories[$row['storage_category_id']] =
68      get_complete_dir($row['storage_category_id']);
69  }
70  $cat_directory = $array_cat_directories[$row['storage_category_id']];
71
72  $file = get_filename_wo_extension($row['file']);
73  // name of the picture
74  if (isset($row['name']) and $row['name'] != '')
75  {
76    $name = $row['name'];
77  }
78  else
79  {
80    $name = str_replace('_', ' ', $file);
81  }
82  if ($page['cat'] == 'best_rated')
83  {
84    $name = '('.$row['average_rate'].') '.$name;
85  }
86
87  if ($page['cat'] == 'search')
88  {
89    $name = replace_search($name, $_GET['search']);
90  }
91  // thumbnail url
92  if (isset($row['tn_ext']) and $row['tn_ext'] != '')
93  {
94    $thumbnail_url = $cat_directory;
95    $thumbnail_url.= 'thumbnail/'.$conf['prefix_thumbnail'];
96    $thumbnail_url.= $file.'.'.$row['tn_ext'];
97  }
98  else
99  {
100    $thumbnail_url = './template/'.$user['template'].'/mimetypes/';
101    $thumbnail_url.= strtolower(get_extension($row['file'])).'.png';
102  }
103 
104  // message in title for the thumbnail
105  $thumbnail_title = $row['file'];
106  if (isset($row['filesize']))
107  {
108    $thumbnail_title .= ' : '.$row['filesize'].' KB';
109  }
110  // url link on picture.php page
111  $url_link = PHPWG_ROOT_PATH.'picture.php?';
112  if ($page['cat'] == 'random')
113  {
114    $url_link.= 'cat='.$row['category_id'];
115  }
116  else
117  {
118   $url_link.= 'cat='.$page['cat'];
119  }
120  $url_link.= '&amp;image_id='.$row['id'];
121  if ($page['cat'] == 'search')
122  {
123    $url_link.= '&amp;search='.$_GET['search'];
124  }
125   
126  $template->assign_block_vars(
127    'thumbnails.line.thumbnail',
128    array(
129      'IMAGE'              => $thumbnail_url,
130      'IMAGE_ALT'          => $row['file'],
131      'IMAGE_TITLE'        => $thumbnail_title,
132      'IMAGE_NAME'         => $name,
133      'IMAGE_TS'           => get_icon($row['date_available']),
134      'IMAGE_STYLE'        => 'thumb_picture',
135     
136      'U_IMG_LINK'         => add_session_id($url_link)
137      )
138    );
139   
140  if ($conf['show_comments'] and $user['show_nb_comments'])
141  {
142    $query = '
143SELECT COUNT(*) AS nb_comments
144  FROM '.COMMENTS_TABLE.'
145  WHERE image_id = '.$row['id'].'
146    AND validated = \'true\'
147;';
148    $row = mysql_fetch_array(mysql_query($query));
149    $template->assign_block_vars(
150      'thumbnails.line.thumbnail.nb_comments',
151      array('NB_COMMENTS'=>$row['nb_comments']));
152  }
153
154  // create a new line ?
155  if (++$row_number == $user['nb_image_line'])
156  {
157    $template->assign_block_vars('thumbnails.line', array());
158    $row_number = 0;
159  }
160}
161?>
Note: See TracBrowser for help on using the repository browser.