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

Last change on this file since 13115 was 13115, checked in by rvelices, 12 years ago

improvement of picture title on picture page, drop boxes on index page ...
sharpening uses a zider scale range

  • Property svn:eol-style set to LF
File size: 5.0 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2012 Piwigo Team                  http://piwigo.org |
6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
8// +-----------------------------------------------------------------------+
9// | This program is free software; you can redistribute it and/or modify  |
10// | it under the terms of the GNU General Public License as published by  |
11// | the Free Software Foundation                                          |
12// |                                                                       |
13// | This program is distributed in the hope that it will be useful, but   |
14// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
15// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
16// | General Public License for more details.                              |
17// |                                                                       |
18// | You should have received a copy of the GNU General Public License     |
19// | along with this program; if not, write to the Free Software           |
20// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
21// | USA.                                                                  |
22// +-----------------------------------------------------------------------+
23
24/**
25 * This file is included by the main page to show thumbnails for the default
26 * case
27 *
28 */
29
30$pictures = array();
31
32$selection = array_slice(
33  $page['items'],
34  $page['start'],
35  $page['nb_image_page']
36  );
37
38if (count($selection) > 0)
39{
40  $rank_of = array_flip($selection);
41
42  $query = '
43SELECT *
44  FROM '.IMAGES_TABLE.'
45  WHERE id IN ('.implode(',', $selection).')
46;';
47  $result = pwg_query($query);
48  while ($row = pwg_db_fetch_assoc($result))
49  {
50    $row['rank'] = $rank_of[ $row['id'] ];
51    $pictures[] = $row;
52  }
53
54  usort($pictures, 'rank_compare');
55  unset($rank_of);
56}
57
58if (count($pictures) > 0)
59{
60  // define category slideshow url
61  $row = reset($pictures);
62  $page['cat_slideshow_url'] =
63    add_url_params(
64      duplicate_picture_url(
65        array(
66          'image_id' => $row['id'],
67          'image_file' => $row['file']
68        ),
69        array('start')
70      ),
71      array('slideshow' =>
72        (isset($_GET['slideshow']) ? $_GET['slideshow']
73                                   : '' ))
74    );
75
76  if ($conf['activate_comments'] and $user['show_nb_comments'])
77  {
78    $query = '
79SELECT image_id, COUNT(*) AS nb_comments
80  FROM '.COMMENTS_TABLE.'
81  WHERE validated = \'true\'
82    AND image_id IN ('.implode(',', $selection).')
83  GROUP BY image_id
84;';
85    $nb_comments_of = simple_hash_from_query($query, 'image_id', 'nb_comments');
86  }
87}
88
89// template thumbnail initialization
90$template->set_filenames( array( 'index_thumbnails' => 'thumbnails.tpl',));
91
92trigger_action('loc_begin_index_thumbnails', $pictures);
93$tpl_thumbnails_var = array();
94
95foreach ($pictures as $row)
96{
97  // link on picture.php page
98  $url = duplicate_picture_url(
99        array(
100          'image_id' => $row['id'],
101          'image_file' => $row['file']
102        ),
103        array('start')
104      );
105
106  if (isset($nb_comments_of))
107  {
108    $row['NB_COMMENTS'] = $row['nb_comments'] = (int)@$nb_comments_of[$row['id']];
109  }
110
111  $name = render_element_name($row);
112  $desc = render_element_description($row);
113
114  $tpl_var = array_merge( $row, array(
115    'TN_ALT' => htmlspecialchars(strip_tags($name)),
116    'TN_TITLE' => get_thumbnail_title($row, $name, $desc),
117    'URL' => $url,
118    'DESCRIPTION' => $desc,
119    'src_image' => new SrcImage($row),
120    ) );
121
122  if ($conf['index_new_icon'])
123  {
124    $tpl_var['icon_ts'] = get_icon($row['date_available']);
125  }
126
127  if ($user['show_nb_hits'])
128  {
129    $tpl_var['NB_HITS'] = $row['hit'];
130  }
131
132  switch ($page['section'])
133  {
134    case 'best_rated' :
135    {
136      $name = '('.$row['rating_score'].') '.$name;
137      break;
138    }
139    case 'most_visited' :
140    {
141      if ( !$user['show_nb_hits'])
142      {
143        $name = '('.$row['hit'].') '.$name;
144      }
145      break;
146    }
147  }
148  $tpl_var['NAME'] = $name;
149  $tpl_thumbnails_var[] = $tpl_var;
150}
151
152$derivative_params = trigger_event('get_index_derivative_params', ImageStdParams::get_by_type( pwg_get_session_var('index_deriv', IMG_THUMB) ) );
153
154$template->assign( array(
155  'derivative_params' =>$derivative_params,
156  'SHOW_THUMBNAIL_CAPTION' =>$conf['show_thumbnail_caption'],
157    ) );
158$tpl_thumbnails_var = trigger_event('loc_end_index_thumbnails', $tpl_thumbnails_var, $pictures);
159$template->assign('thumbnails', $tpl_thumbnails_var);
160
161$template->assign_var_from_handle('THUMBNAILS', 'index_thumbnails');
162unset($pictures, $selection, $tpl_thumbnails_var);
163$template->clear_assign( array('thumbnails', 'derivative_params') );
164pwg_debug('end include/category_default.inc.php');
165?>
Note: See TracBrowser for help on using the repository browser.