2004-06-25 22:27:09 +02:00
|
|
|
<?php
|
|
|
|
// +-----------------------------------------------------------------------+
|
2011-01-18 01:02:52 +01:00
|
|
|
// | Piwigo - a PHP based photo gallery |
|
2008-04-05 00:57:23 +02:00
|
|
|
// +-----------------------------------------------------------------------+
|
2013-01-01 13:35:02 +01:00
|
|
|
// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
|
2008-04-05 00:57:23 +02:00
|
|
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
|
|
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | This program is free software; you can redistribute it and/or modify |
|
|
|
|
// | it under the terms of the GNU General Public License as published by |
|
|
|
|
// | the Free Software Foundation |
|
|
|
|
// | |
|
2004-06-25 22:27:09 +02:00
|
|
|
// | This program is distributed in the hope that it will be useful, but |
|
|
|
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
|
|
|
// | General Public License for more details. |
|
|
|
|
// | |
|
|
|
|
// | You should have received a copy of the GNU General Public License |
|
|
|
|
// | along with this program; if not, write to the Free Software |
|
|
|
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
|
|
|
// | USA. |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
|
|
|
|
/**
|
2006-03-15 23:44:35 +01:00
|
|
|
* This file is included by the main page to show thumbnails for the default
|
2004-06-25 22:27:09 +02:00
|
|
|
* case
|
2006-03-21 02:27:21 +01:00
|
|
|
*
|
2004-06-25 22:27:09 +02:00
|
|
|
*/
|
|
|
|
|
2006-02-12 22:52:16 +01:00
|
|
|
$pictures = array();
|
|
|
|
|
|
|
|
$selection = array_slice(
|
|
|
|
$page['items'],
|
|
|
|
$page['start'],
|
|
|
|
$page['nb_image_page']
|
|
|
|
);
|
|
|
|
|
2012-02-18 21:26:52 +01:00
|
|
|
$selection = trigger_event('loc_index_thumbnails_selection', $selection);
|
|
|
|
|
2006-02-12 22:52:16 +01:00
|
|
|
if (count($selection) > 0)
|
|
|
|
{
|
2012-02-12 11:02:59 +01:00
|
|
|
$rank_of = array_flip($selection);
|
2009-02-05 04:03:30 +01:00
|
|
|
|
2006-02-12 22:52:16 +01:00
|
|
|
$query = '
|
|
|
|
SELECT *
|
|
|
|
FROM '.IMAGES_TABLE.'
|
2006-12-21 22:38:20 +01:00
|
|
|
WHERE id IN ('.implode(',', $selection).')
|
|
|
|
;';
|
2006-02-12 22:52:16 +01:00
|
|
|
$result = pwg_query($query);
|
2009-11-20 15:17:04 +01:00
|
|
|
while ($row = pwg_db_fetch_assoc($result))
|
2006-02-12 22:52:16 +01:00
|
|
|
{
|
2009-02-05 04:10:23 +01:00
|
|
|
$row['rank'] = $rank_of[ $row['id'] ];
|
2012-02-12 11:02:59 +01:00
|
|
|
$pictures[] = $row;
|
2006-02-12 22:52:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
usort($pictures, 'rank_compare');
|
2009-02-05 04:03:30 +01:00
|
|
|
unset($rank_of);
|
2006-02-12 22:52:16 +01:00
|
|
|
}
|
2004-06-25 22:27:09 +02:00
|
|
|
|
2006-02-12 22:52:16 +01:00
|
|
|
if (count($pictures) > 0)
|
2004-06-25 22:27:09 +02:00
|
|
|
{
|
2008-02-27 21:25:18 +01:00
|
|
|
// define category slideshow url
|
|
|
|
$row = reset($pictures);
|
|
|
|
$page['cat_slideshow_url'] =
|
|
|
|
add_url_params(
|
|
|
|
duplicate_picture_url(
|
|
|
|
array(
|
|
|
|
'image_id' => $row['id'],
|
|
|
|
'image_file' => $row['file']
|
|
|
|
),
|
|
|
|
array('start')
|
|
|
|
),
|
|
|
|
array('slideshow' =>
|
|
|
|
(isset($_GET['slideshow']) ? $_GET['slideshow']
|
|
|
|
: '' ))
|
|
|
|
);
|
2008-03-01 15:24:04 +01:00
|
|
|
|
2012-01-14 23:29:10 +01:00
|
|
|
if ($conf['activate_comments'] and $user['show_nb_comments'])
|
2008-03-11 03:04:27 +01:00
|
|
|
{
|
|
|
|
$query = '
|
|
|
|
SELECT image_id, COUNT(*) AS nb_comments
|
|
|
|
FROM '.COMMENTS_TABLE.'
|
|
|
|
WHERE validated = \'true\'
|
|
|
|
AND image_id IN ('.implode(',', $selection).')
|
|
|
|
GROUP BY image_id
|
|
|
|
;';
|
|
|
|
$nb_comments_of = simple_hash_from_query($query, 'image_id', 'nb_comments');
|
|
|
|
}
|
2004-06-25 22:27:09 +02:00
|
|
|
}
|
|
|
|
|
2008-03-11 03:04:27 +01:00
|
|
|
// template thumbnail initialization
|
|
|
|
$template->set_filenames( array( 'index_thumbnails' => 'thumbnails.tpl',));
|
|
|
|
|
2006-11-07 04:37:57 +01:00
|
|
|
trigger_action('loc_begin_index_thumbnails', $pictures);
|
2009-02-05 03:28:37 +01:00
|
|
|
$tpl_thumbnails_var = array();
|
2006-11-07 04:37:57 +01:00
|
|
|
|
2006-02-12 22:52:16 +01:00
|
|
|
foreach ($pictures as $row)
|
2004-06-25 22:27:09 +02:00
|
|
|
{
|
2006-03-21 02:27:21 +01:00
|
|
|
// link on picture.php page
|
|
|
|
$url = duplicate_picture_url(
|
|
|
|
array(
|
|
|
|
'image_id' => $row['id'],
|
|
|
|
'image_file' => $row['file']
|
2006-03-23 02:49:04 +01:00
|
|
|
),
|
|
|
|
array('start')
|
2006-03-21 02:27:21 +01:00
|
|
|
);
|
2009-07-01 23:10:42 +02:00
|
|
|
|
2012-01-17 07:09:32 +01:00
|
|
|
if (isset($nb_comments_of))
|
2011-08-26 13:02:11 +02:00
|
|
|
{
|
2012-01-17 07:09:32 +01:00
|
|
|
$row['NB_COMMENTS'] = $row['nb_comments'] = (int)@$nb_comments_of[$row['id']];
|
2011-08-26 13:02:11 +02:00
|
|
|
}
|
|
|
|
|
2012-01-17 22:58:18 +01:00
|
|
|
$name = render_element_name($row);
|
|
|
|
$desc = render_element_description($row);
|
2011-10-15 17:27:33 +02:00
|
|
|
|
2012-01-17 07:09:32 +01:00
|
|
|
$tpl_var = array_merge( $row, array(
|
2011-11-05 00:54:12 +01:00
|
|
|
'TN_ALT' => htmlspecialchars(strip_tags($name)),
|
2012-01-17 22:58:18 +01:00
|
|
|
'TN_TITLE' => get_thumbnail_title($row, $name, $desc),
|
2011-11-05 00:54:12 +01:00
|
|
|
'URL' => $url,
|
2012-01-17 22:58:18 +01:00
|
|
|
'DESCRIPTION' => $desc,
|
2012-01-17 07:09:32 +01:00
|
|
|
'src_image' => new SrcImage($row),
|
|
|
|
) );
|
2011-11-05 00:54:12 +01:00
|
|
|
|
2011-06-09 22:34:48 +02:00
|
|
|
if ($conf['index_new_icon'])
|
|
|
|
{
|
2011-07-01 23:14:04 +02:00
|
|
|
$tpl_var['icon_ts'] = get_icon($row['date_available']);
|
2011-06-09 22:34:48 +02:00
|
|
|
}
|
2008-03-01 15:24:04 +01:00
|
|
|
|
2007-02-28 00:24:53 +01:00
|
|
|
if ($user['show_nb_hits'])
|
2007-01-28 21:56:10 +01:00
|
|
|
{
|
2008-03-11 03:04:27 +01:00
|
|
|
$tpl_var['NB_HITS'] = $row['hit'];
|
2007-01-28 21:56:10 +01:00
|
|
|
}
|
2012-01-17 07:09:32 +01:00
|
|
|
|
2011-08-22 23:08:14 +02:00
|
|
|
switch ($page['section'])
|
|
|
|
{
|
|
|
|
case 'best_rated' :
|
|
|
|
{
|
|
|
|
$name = '('.$row['rating_score'].') '.$name;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'most_visited' :
|
|
|
|
{
|
|
|
|
if ( !$user['show_nb_hits'])
|
|
|
|
{
|
|
|
|
$name = '('.$row['hit'].') '.$name;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-01-17 07:09:32 +01:00
|
|
|
$tpl_var['NAME'] = $name;
|
2009-02-05 03:28:37 +01:00
|
|
|
$tpl_thumbnails_var[] = $tpl_var;
|
2004-06-25 22:27:09 +02:00
|
|
|
}
|
2006-11-07 04:37:57 +01:00
|
|
|
|
2012-01-17 07:09:32 +01:00
|
|
|
$template->assign( array(
|
2012-07-24 22:34:52 +02:00
|
|
|
'derivative_params' => trigger_event('get_index_derivative_params', ImageStdParams::get_by_type( pwg_get_session_var('index_deriv', IMG_THUMB) ) ),
|
2013-01-16 00:11:14 +01:00
|
|
|
'maxRequests' =>$conf['max_requests'],
|
2012-01-17 07:09:32 +01:00
|
|
|
'SHOW_THUMBNAIL_CAPTION' =>$conf['show_thumbnail_caption'],
|
|
|
|
) );
|
2009-02-05 03:28:37 +01:00
|
|
|
$tpl_thumbnails_var = trigger_event('loc_end_index_thumbnails', $tpl_thumbnails_var, $pictures);
|
|
|
|
$template->assign('thumbnails', $tpl_thumbnails_var);
|
2011-10-08 22:01:20 +02:00
|
|
|
|
2008-03-11 03:04:27 +01:00
|
|
|
$template->assign_var_from_handle('THUMBNAILS', 'index_thumbnails');
|
2012-01-17 07:09:32 +01:00
|
|
|
unset($pictures, $selection, $tpl_thumbnails_var);
|
2012-07-24 22:34:52 +02:00
|
|
|
$template->clear_assign( 'thumbnails' );
|
2006-02-12 22:52:16 +01:00
|
|
|
pwg_debug('end include/category_default.inc.php');
|
2009-02-04 03:30:48 +01:00
|
|
|
?>
|