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

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

URL rewriting: capable of fully working with urls without ?

URL rewriting: works with image file instead of image id (change
make_picture_url to generate urls with file name instead of image id)

URL rewriting: completely works with category/best_rated and
picture/best_rated/534 (change 'category.php?' to 'category' in make_index_url
and 'picture.php?' to 'picture' in make_picture_url to see it)

fix: picture category display in upper bar

fix: function rate_picture variables and use of the new user type

fix: caddie icon appears now on category page

fix: admin element_set sql query was using storage_category_id column
(column has moved to #image_categories)

fix: replaced some old $_GET[xxx] with $page[xxx]

fix: pictures have metadata url (use ? parameter - might change later)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 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-03-22 01:01:47 +0000 (Wed, 22 Mar 2006) $
10// | last modifier : $Author: rvelices $
11// | revision      : $Revision: 1092 $
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 the main page to show thumbnails for the default
30 * case
31 *
32 */
33
34$page['rank_of'] = array_flip($page['items']);
35
36$pictures = array();
37
38$selection = array_slice(
39  $page['items'],
40  $page['start'],
41  $page['nb_image_page']
42  );
43
44if (count($selection) > 0)
45{
46  $query = '
47SELECT *
48  FROM '.IMAGES_TABLE.'
49  WHERE id IN ('.implode(',', $selection).')
50;';
51  $result = pwg_query($query);
52  while ($row = mysql_fetch_array($result))
53  {
54    $row['rank'] = $page['rank_of'][ $row['id'] ];
55
56    array_push($pictures, $row);
57  }
58
59  usort($pictures, 'rank_compare');
60}
61
62// template thumbnail initialization
63if (count($pictures) > 0)
64{
65  $template->assign_block_vars('thumbnails', array());
66  // first line
67  $template->assign_block_vars('thumbnails.line', array());
68  // current row displayed
69  $row_number = 0;
70}
71
72foreach ($pictures as $row)
73{
74  $thumbnail_url = get_thumbnail_src($row['path'], @$row['tn_ext']);
75
76  // message in title for the thumbnail
77  $thumbnail_title = $row['file'];
78  if (isset($row['filesize']))
79  {
80    $thumbnail_title .= ' : '.$row['filesize'].' KB';
81  }
82
83  // link on picture.php page
84  $url = duplicate_picture_url(
85        array(
86          'image_id' => $row['id'],
87          'image_file' => $row['file']
88        )
89      );
90
91  $template->assign_block_vars(
92    'thumbnails.line.thumbnail',
93    array(
94      'IMAGE'              => $thumbnail_url,
95      'IMAGE_ALT'          => $row['file'],
96      'IMAGE_TITLE'        => $thumbnail_title,
97      'IMAGE_TS'           => get_icon($row['date_available']),
98
99      'U_IMG_LINK'         => $url
100      )
101    );
102
103  if ($conf['show_thumbnail_caption'])
104  {
105    // name of the picture
106    if (isset($row['name']) and $row['name'] != '')
107    {
108      $name = $row['name'];
109    }
110    else
111    {
112      $name = str_replace('_', ' ', get_filename_wo_extension($row['file']));
113    }
114
115    switch ($page['section'])
116    {
117      case 'best_rated' :
118      {
119        $name = '('.$row['average_rate'].') '.$name;
120        break;
121      }
122      case 'most_visited' :
123      {
124        $name = '('.$row['hit'].') '.$name;
125        break;
126      }
127      case 'search' :
128      {
129        $name = replace_search($name, $page['search']);
130        break;
131      }
132    }
133
134    $template->assign_block_vars(
135      'thumbnails.line.thumbnail.element_name',
136      array(
137        'NAME' => $name
138        )
139      );
140  }
141
142  if ($user['show_nb_comments']
143      and isset($page['category'])
144      and $page['cat_commentable'])
145  {
146    $query = '
147SELECT COUNT(*) AS nb_comments
148  FROM '.COMMENTS_TABLE.'
149  WHERE image_id = '.$row['id'].'
150    AND validated = \'true\'
151;';
152    $row = mysql_fetch_array(pwg_query($query));
153    $template->assign_block_vars(
154      'thumbnails.line.thumbnail.nb_comments',
155      array('NB_COMMENTS'=>$row['nb_comments']));
156  }
157
158  // create a new line ?
159  if (++$row_number == $user['nb_image_line'])
160  {
161    $template->assign_block_vars('thumbnails.line', array());
162    $row_number = 0;
163  }
164}
165
166pwg_debug('end include/category_default.inc.php');
167?>
Note: See TracBrowser for help on using the repository browser.