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

Last change on this file since 1606 was 1596, checked in by rvelices, 18 years ago
  • deprecated get_thumbnail_src (still there for compatibility). use rather

get_thumbnail_path or get_thumbnail_url (these allow plugins to override)

  • plugins can hook into index thumbnail display (items only so far)
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.0 KB
RevLine 
[440]1<?php
2// +-----------------------------------------------------------------------+
[593]3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
[675]5// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
[440]6// +-----------------------------------------------------------------------+
[593]7// | branch        : BSF (Best So Far)
[440]8// | file          : $RCSfile$
9// | last update   : $Date: 2006-11-07 03:37:57 +0000 (Tue, 07 Nov 2006) $
10// | last modifier : $Author: rvelices $
11// | revision      : $Revision: 1596 $
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/**
[1082]29 * This file is included by the main page to show thumbnails for the default
[440]30 * case
[1090]31 *
[440]32 */
33
[1036]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).')
[440]50;';
[1036]51  $result = pwg_query($query);
[1596]52  while ($row = mysql_fetch_assoc($result))
[1036]53  {
54    $row['rank'] = $page['rank_of'][ $row['id'] ];
[1090]55
[1036]56    array_push($pictures, $row);
57  }
[440]58
[1036]59  usort($pictures, 'rank_compare');
60}
61
[440]62// template thumbnail initialization
[1596]63$template->set_filenames( array( 'thumbnails' => 'thumbnails.tpl',));
[1036]64if (count($pictures) > 0)
[440]65{
66  // first line
67  $template->assign_block_vars('thumbnails.line', array());
68  // current row displayed
69  $row_number = 0;
70}
71
[1596]72trigger_action('loc_begin_index_thumbnails', $pictures);
73
[1036]74foreach ($pictures as $row)
[440]75{
[1596]76  $thumbnail_url = get_thumbnail_url($row);
[1090]77
[440]78  // message in title for the thumbnail
79  $thumbnail_title = $row['file'];
[526]80  if (isset($row['filesize']))
[440]81  {
[526]82    $thumbnail_title .= ' : '.$row['filesize'].' KB';
[440]83  }
[1596]84
[1090]85  // link on picture.php page
86  $url = duplicate_picture_url(
87        array(
88          'image_id' => $row['id'],
89          'image_file' => $row['file']
[1094]90        ),
91        array('start')
[1090]92      );
93
[440]94  $template->assign_block_vars(
95    'thumbnails.line.thumbnail',
96    array(
97      'IMAGE'              => $thumbnail_url,
98      'IMAGE_ALT'          => $row['file'],
99      'IMAGE_TITLE'        => $thumbnail_title,
100      'IMAGE_TS'           => get_icon($row['date_available']),
[1090]101
[1098]102      'U_IMG_LINK'         => $url,
103
104      'CLASS'              => 'thumbElmt',
[440]105      )
106    );
[803]107
108  if ($conf['show_thumbnail_caption'])
109  {
110    // name of the picture
111    if (isset($row['name']) and $row['name'] != '')
112    {
113      $name = $row['name'];
114    }
115    else
116    {
117      $name = str_replace('_', ' ', get_filename_wo_extension($row['file']));
118    }
[1082]119
120    switch ($page['section'])
[803]121    {
[1082]122      case 'best_rated' :
[1056]123      {
124        $name = '('.$row['average_rate'].') '.$name;
[1082]125        break;
[1056]126      }
[1082]127      case 'most_visited' :
[1056]128      {
129        $name = '('.$row['hit'].') '.$name;
[1082]130        break;
[1056]131      }
[1082]132      case 'search' :
[1056]133      {
[1092]134        $name = replace_search($name, $page['search']);
[1082]135        break;
[1056]136      }
[803]137    }
[1090]138
[803]139    $template->assign_block_vars(
140      'thumbnails.line.thumbnail.element_name',
141      array(
142        'NAME' => $name
143        )
144      );
145  }
[1090]146
[602]147  if ($user['show_nb_comments']
[1082]148      and isset($page['category'])
[602]149      and $page['cat_commentable'])
[440]150  {
151    $query = '
152SELECT COUNT(*) AS nb_comments
153  FROM '.COMMENTS_TABLE.'
154  WHERE image_id = '.$row['id'].'
155    AND validated = \'true\'
156;';
[587]157    $row = mysql_fetch_array(pwg_query($query));
[440]158    $template->assign_block_vars(
159      'thumbnails.line.thumbnail.nb_comments',
160      array('NB_COMMENTS'=>$row['nb_comments']));
161  }
162
[1596]163  //plugins need to add/modify sth in this loop ?
164  trigger_action('loc_index_thumbnail', $row, 'thumbnails.line.thumbnail' );
165
[440]166  // create a new line ?
167  if (++$row_number == $user['nb_image_line'])
168  {
169    $template->assign_block_vars('thumbnails.line', array());
170    $row_number = 0;
171  }
172}
[1596]173
174trigger_action('loc_end_index_thumbnails', $pictures);
[1384]175$template->assign_var_from_handle('THUMBNAILS', 'thumbnails');
[1036]176
177pwg_debug('end include/category_default.inc.php');
[1098]178?>
Note: See TracBrowser for help on using the repository browser.