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

Last change on this file since 1014 was 1014, checked in by rvelices, 18 years ago

improvement: got rid of num= _GET param in category.php (use only start=) so
that links to category for search engines are the same as in category
pagination

feature 77: standard navigation link : HTML Link types

improvement: add go to first and last image buttons in picture page

improvement: do not increase image hit in picture.php when rating, adding to
favorites, caddie, ...

improvement: show number of hits in most_visited (as best_rated shows the rate)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 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: 2006-01-27 01:11:43 +0000 (Fri, 27 Jan 2006) $
10// | last modifier : $Author: rvelices $
11// | revision      : $Revision: 1014 $
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),path,file,date_available
42       ,tn_ext,name,filesize,storage_category_id,average_rate,hit
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 = 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
62while ($row = mysql_fetch_array($result))
63{
64  $thumbnail_url = get_thumbnail_src($row['path'], @$row['tn_ext']);
65 
66  // message in title for the thumbnail
67  $thumbnail_title = $row['file'];
68  if (isset($row['filesize']))
69  {
70    $thumbnail_title .= ' : '.$row['filesize'].' KB';
71  }
72  // url link on picture.php page
73  $url_link = PHPWG_ROOT_PATH.'picture.php?cat='.$page['cat'];
74  $url_link.= '&amp;image_id='.$row['id'];
75  if ($page['cat'] == 'search')
76  {
77    $url_link.= '&amp;search='.$_GET['search'];
78  }
79  else if ($page['cat'] == 'list')
80  {
81    $url_link.= '&amp;list='.$_GET['list'];
82  }
83   
84  $template->assign_block_vars(
85    'thumbnails.line.thumbnail',
86    array(
87      'IMAGE'              => $thumbnail_url,
88      'IMAGE_ALT'          => $row['file'],
89      'IMAGE_TITLE'        => $thumbnail_title,
90      'IMAGE_TS'           => get_icon($row['date_available']),
91     
92      'U_IMG_LINK'         => $url_link
93      )
94    );
95
96  if ($conf['show_thumbnail_caption'])
97  {
98    // name of the picture
99    if (isset($row['name']) and $row['name'] != '')
100    {
101      $name = $row['name'];
102    }
103    else
104    {
105      $name = str_replace('_', ' ', get_filename_wo_extension($row['file']));
106    }
107    if ($page['cat'] == 'best_rated')
108    {
109      $name = '('.$row['average_rate'].') '.$name;
110    }
111    else
112    if ($page['cat'] == 'most_visited')
113    {
114      $name = '('.$row['hit'].') '.$name;
115    }
116   
117    if ($page['cat'] == 'search')
118    {
119      $name = replace_search($name, $_GET['search']);
120    }
121 
122    $template->assign_block_vars(
123      'thumbnails.line.thumbnail.element_name',
124      array(
125        'NAME' => $name
126        )
127      );
128  }
129   
130  if ($user['show_nb_comments']
131      and is_numeric($page['cat'])
132      and $page['cat_commentable'])
133  {
134    $query = '
135SELECT COUNT(*) AS nb_comments
136  FROM '.COMMENTS_TABLE.'
137  WHERE image_id = '.$row['id'].'
138    AND validated = \'true\'
139;';
140    $row = mysql_fetch_array(pwg_query($query));
141    $template->assign_block_vars(
142      'thumbnails.line.thumbnail.nb_comments',
143      array('NB_COMMENTS'=>$row['nb_comments']));
144  }
145
146  // create a new line ?
147  if (++$row_number == $user['nb_image_line'])
148  {
149    $template->assign_block_vars('thumbnails.line', array());
150    $row_number = 0;
151  }
152}
153?>
Note: See TracBrowser for help on using the repository browser.