2003-05-09 14:42:42 +02:00
|
|
|
<?php
|
2004-02-07 20:36:44 +01:00
|
|
|
// +-----------------------------------------------------------------------+
|
2008-04-05 00:57:23 +02:00
|
|
|
// | Piwigo - a PHP based picture gallery |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | Copyright(C) 2008 Piwigo Team http://piwigo.org |
|
|
|
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
|
|
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
|
|
|
// +-----------------------------------------------------------------------+
|
2004-02-07 20:36:44 +01:00
|
|
|
// | 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 |
|
|
|
|
// | |
|
|
|
|
// | 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. |
|
|
|
|
// +-----------------------------------------------------------------------+
|
2004-05-20 23:22:44 +02:00
|
|
|
|
2004-02-19 01:31:09 +01:00
|
|
|
define('PHPWG_ROOT_PATH','./');
|
2004-11-21 13:42:55 +01:00
|
|
|
include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
|
2006-03-15 23:44:35 +01:00
|
|
|
include(PHPWG_ROOT_PATH.'include/section_init.inc.php');
|
2006-11-17 05:26:10 +01:00
|
|
|
include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
|
2006-02-23 06:12:32 +01:00
|
|
|
|
2006-03-15 23:44:35 +01:00
|
|
|
// Check Access and exit when user status is not ok
|
2006-03-09 23:46:28 +01:00
|
|
|
check_status(ACCESS_GUEST);
|
|
|
|
|
2006-03-15 23:44:35 +01:00
|
|
|
// access authorization check
|
|
|
|
if (isset($page['category']))
|
2006-02-12 22:52:16 +01:00
|
|
|
{
|
2007-02-27 02:56:16 +01:00
|
|
|
check_restrictions($page['category']['id']);
|
2006-02-12 22:52:16 +01:00
|
|
|
}
|
2006-03-15 23:44:35 +01:00
|
|
|
|
2008-05-03 03:52:08 +02:00
|
|
|
$page['rank_of'] = array_flip($page['items']);
|
|
|
|
|
2006-02-12 22:52:16 +01:00
|
|
|
// if this image_id doesn't correspond to this category, an error message is
|
|
|
|
// displayed, and execution is stopped
|
2008-05-03 03:52:08 +02:00
|
|
|
if ( !isset($page['rank_of'][$page['image_id']]) )
|
2006-02-12 22:52:16 +01:00
|
|
|
{
|
2008-07-12 02:33:12 +02:00
|
|
|
$query = '
|
2008-07-22 03:29:38 +02:00
|
|
|
SELECT id, file, level
|
2008-07-12 02:33:12 +02:00
|
|
|
FROM '.IMAGES_TABLE.'
|
|
|
|
WHERE ';
|
|
|
|
if ($page['image_id']>0)
|
|
|
|
{
|
|
|
|
$query .= 'id = '.$page['image_id'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{// url given by file name
|
|
|
|
assert( !empty($page['image_file']) );
|
|
|
|
$query .= 'file LIKE "' . $page['image_file'] . '.%" ESCAPE "|" LIMIT 1';
|
|
|
|
}
|
|
|
|
if ( ! ( $row = mysql_fetch_array(pwg_query($query)) ) )
|
|
|
|
{// element does not exist
|
|
|
|
page_not_found( 'The requested image does not exist',
|
|
|
|
duplicate_index_url()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if ($row['level']>$user['level'])
|
|
|
|
{
|
|
|
|
access_denied();
|
|
|
|
}
|
|
|
|
list($page['image_id'], $page['image_file']) = $row;
|
|
|
|
if ( !isset($page['rank_of'][$page['image_id']]) )
|
|
|
|
{// the image can still be non accessible (filter/cat perm) and/or not in the set
|
|
|
|
global $filter;
|
2008-07-22 03:29:38 +02:00
|
|
|
if ( !empty($filter['visible_images']) and
|
2008-07-12 02:33:12 +02:00
|
|
|
!in_array($page['image_id'], explode(',',$filter['visible_images']) ) )
|
|
|
|
{
|
|
|
|
page_not_found( 'The requested image is filtered',
|
|
|
|
duplicate_index_url()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if ('categories'==$page['section'] and !isset($page['category']) )
|
|
|
|
{// flat view - all items
|
|
|
|
access_denied();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{// try to see if we can access it differently
|
|
|
|
$query = '
|
|
|
|
SELECT id
|
|
|
|
FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id=image_id
|
|
|
|
WHERE id='.$page['image_id']
|
|
|
|
. get_sql_condition_FandF(
|
|
|
|
array('forbidden_categories' => 'category_id'),
|
|
|
|
" AND"
|
|
|
|
).'
|
|
|
|
LIMIT 1';
|
|
|
|
if ( mysql_num_rows( pwg_query($query) ) == 0 )
|
|
|
|
{
|
|
|
|
access_denied();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ('best_rated'==$page['section'])
|
|
|
|
{
|
|
|
|
$page['rank_of'][$page['image_id']] = count($page['items']);
|
|
|
|
array_push($page['items'], $page['image_id'] );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$url = make_picture_url(
|
|
|
|
array(
|
|
|
|
'image_id' => $page['image_id'],
|
|
|
|
'image_file' => $page['image_file'],
|
|
|
|
'section' => 'categories',
|
|
|
|
'flat' => true,
|
|
|
|
)
|
|
|
|
);
|
|
|
|
set_status_header( 'recent_pics'==$page['section'] ? 301 : 302);
|
|
|
|
redirect_http( $url );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-02-12 22:52:16 +01:00
|
|
|
}
|
|
|
|
|
2008-06-28 15:59:26 +02:00
|
|
|
// There is cookie, so we must handle it at the beginning
|
|
|
|
if ( isset($_GET['metadata']) )
|
|
|
|
{
|
|
|
|
if ( pwg_get_session_var('show_metadata') == null )
|
|
|
|
{
|
|
|
|
pwg_set_session_var('show_metadata', 1, 86400, cookie_path());
|
|
|
|
} else {
|
|
|
|
pwg_unset_session_var('show_metadata');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-11-01 06:54:35 +01:00
|
|
|
// add default event handler for rendering element content
|
2007-02-07 22:23:33 +01:00
|
|
|
add_event_handler(
|
|
|
|
'render_element_content',
|
|
|
|
'default_picture_content',
|
|
|
|
EVENT_HANDLER_PRIORITY_NEUTRAL,
|
|
|
|
2
|
|
|
|
);
|
2007-08-26 01:10:12 +02:00
|
|
|
// add default event handler for rendering element description
|
|
|
|
add_event_handler('render_element_description', 'nl2br');
|
|
|
|
|
2006-11-01 06:54:35 +01:00
|
|
|
trigger_action('loc_begin_picture');
|
|
|
|
|
|
|
|
// this is the default handler that generates the display for the element
|
|
|
|
function default_picture_content($content, $element_info)
|
|
|
|
{
|
|
|
|
if ( !empty($content) )
|
|
|
|
{// someone hooked us - so we skip;
|
|
|
|
return $content;
|
|
|
|
}
|
|
|
|
if (!isset($element_info['image_url']))
|
|
|
|
{ // nothing to do
|
|
|
|
return $content;
|
|
|
|
}
|
2007-02-09 02:41:49 +01:00
|
|
|
|
2007-03-09 04:37:56 +01:00
|
|
|
global $user, $page, $template;
|
2007-02-09 02:41:49 +01:00
|
|
|
|
2007-03-09 04:37:56 +01:00
|
|
|
$template->set_filenames(
|
2007-02-07 22:23:33 +01:00
|
|
|
array('default_content'=>'picture_content.tpl')
|
|
|
|
);
|
2006-11-01 06:54:35 +01:00
|
|
|
|
2008-02-27 21:25:18 +01:00
|
|
|
if ( !$page['slideshow'] and isset($element_info['high_url']) )
|
2006-11-01 06:54:35 +01:00
|
|
|
{
|
|
|
|
$uuid = uniqid(rand());
|
2008-02-29 02:25:13 +01:00
|
|
|
$template->assign(
|
2006-11-01 06:54:35 +01:00
|
|
|
'high',
|
|
|
|
array(
|
|
|
|
'U_HIGH' => $element_info['high_url'],
|
|
|
|
'UUID' => $uuid,
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2008-02-29 02:25:13 +01:00
|
|
|
$template->assign( array(
|
2006-11-01 06:54:35 +01:00
|
|
|
'SRC_IMG' => $element_info['image_url'],
|
|
|
|
'ALT_IMG' => $element_info['file'],
|
2006-11-07 04:37:57 +01:00
|
|
|
'WIDTH_IMG' => @$element_info['scaled_width'],
|
|
|
|
'HEIGHT_IMG' => @$element_info['scaled_height'],
|
2006-11-01 06:54:35 +01:00
|
|
|
)
|
|
|
|
);
|
2007-03-09 04:37:56 +01:00
|
|
|
return $template->parse( 'default_content', true);
|
2006-11-01 06:54:35 +01:00
|
|
|
}
|
|
|
|
|
2006-03-15 23:44:35 +01:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | initialization |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
|
2006-02-12 22:52:16 +01:00
|
|
|
// caching first_rank, last_rank, current_rank in the displayed
|
|
|
|
// section. This should also help in readability.
|
|
|
|
$page['first_rank'] = 0;
|
|
|
|
$page['last_rank'] = count($page['items']) - 1;
|
2006-03-15 23:44:35 +01:00
|
|
|
$page['current_rank'] = $page['rank_of'][ $page['image_id'] ];
|
2006-02-12 22:52:16 +01:00
|
|
|
|
|
|
|
// caching current item : readability purpose
|
2006-03-15 23:44:35 +01:00
|
|
|
$page['current_item'] = $page['image_id'];
|
2005-11-16 22:18:56 +01:00
|
|
|
|
2006-02-12 22:52:16 +01:00
|
|
|
if ($page['current_rank'] != $page['first_rank'])
|
2005-11-16 22:18:56 +01:00
|
|
|
{
|
2006-03-17 05:13:19 +01:00
|
|
|
// caching first & previous item : readability purpose
|
2006-02-12 22:52:16 +01:00
|
|
|
$page['previous_item'] = $page['items'][ $page['current_rank'] - 1 ];
|
2006-03-17 05:13:19 +01:00
|
|
|
$page['first_item'] = $page['items'][ $page['first_rank'] ];
|
2005-11-16 22:18:56 +01:00
|
|
|
}
|
|
|
|
|
2006-02-12 22:52:16 +01:00
|
|
|
if ($page['current_rank'] != $page['last_rank'])
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2006-03-17 05:13:19 +01:00
|
|
|
// caching next & last item : readability purpose
|
2006-02-12 22:52:16 +01:00
|
|
|
$page['next_item'] = $page['items'][ $page['current_rank'] + 1 ];
|
2006-03-17 05:13:19 +01:00
|
|
|
$page['last_item'] = $page['items'][ $page['last_rank'] ];
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
2006-02-12 22:52:16 +01:00
|
|
|
|
2006-07-26 23:00:16 +02:00
|
|
|
$url_up = duplicate_index_url(
|
2006-03-15 23:44:35 +01:00
|
|
|
array(
|
|
|
|
'start' =>
|
|
|
|
floor($page['current_rank'] / $user['nb_image_page'])
|
|
|
|
* $user['nb_image_page']
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'start',
|
|
|
|
)
|
|
|
|
);
|
2005-09-03 18:36:05 +02:00
|
|
|
|
2006-07-26 23:00:16 +02:00
|
|
|
$url_self = duplicate_picture_url();
|
2005-09-03 18:36:05 +02:00
|
|
|
|
2006-03-15 23:44:35 +01:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | actions |
|
|
|
|
// +-----------------------------------------------------------------------+
|
2005-09-03 18:36:05 +02:00
|
|
|
|
2006-03-15 23:44:35 +01:00
|
|
|
/**
|
|
|
|
* Actions are favorite adding, user comment deletion, setting the picture
|
|
|
|
* as representative of the current category...
|
|
|
|
*
|
|
|
|
* Actions finish by a redirection
|
|
|
|
*/
|
2006-02-14 02:14:31 +01:00
|
|
|
|
2006-11-01 06:54:35 +01:00
|
|
|
if (isset($_GET['action']))
|
2006-02-14 02:14:31 +01:00
|
|
|
{
|
2006-03-15 23:44:35 +01:00
|
|
|
switch ($_GET['action'])
|
2006-02-14 02:14:31 +01:00
|
|
|
{
|
2006-03-15 23:44:35 +01:00
|
|
|
case 'add_to_favorites' :
|
2006-02-14 02:14:31 +01:00
|
|
|
{
|
2006-03-15 23:44:35 +01:00
|
|
|
$query = '
|
|
|
|
INSERT INTO '.FAVORITES_TABLE.'
|
|
|
|
(image_id,user_id)
|
|
|
|
VALUES
|
|
|
|
('.$page['image_id'].','.$user['id'].')
|
|
|
|
;';
|
|
|
|
pwg_query($query);
|
|
|
|
|
|
|
|
redirect($url_self);
|
2006-03-17 05:13:19 +01:00
|
|
|
|
2006-03-15 23:44:35 +01:00
|
|
|
break;
|
2006-02-14 02:14:31 +01:00
|
|
|
}
|
2006-03-15 23:44:35 +01:00
|
|
|
case 'remove_from_favorites' :
|
|
|
|
{
|
|
|
|
$query = '
|
|
|
|
DELETE FROM '.FAVORITES_TABLE.'
|
|
|
|
WHERE user_id = '.$user['id'].'
|
|
|
|
AND image_id = '.$page['image_id'].'
|
|
|
|
;';
|
|
|
|
pwg_query($query);
|
2006-02-14 02:14:31 +01:00
|
|
|
|
2006-03-15 23:44:35 +01:00
|
|
|
if ('favorites' == $page['section'])
|
|
|
|
{
|
|
|
|
redirect($url_up);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
redirect($url_self);
|
|
|
|
}
|
2006-03-17 05:13:19 +01:00
|
|
|
|
2006-03-15 23:44:35 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'set_as_representative' :
|
2006-02-14 02:14:31 +01:00
|
|
|
{
|
2006-11-01 06:54:35 +01:00
|
|
|
if (is_admin() and !is_adviser() and isset($page['category']))
|
2006-03-15 23:44:35 +01:00
|
|
|
{
|
2006-02-14 02:14:31 +01:00
|
|
|
$query = '
|
2006-03-15 23:44:35 +01:00
|
|
|
UPDATE '.CATEGORIES_TABLE.'
|
|
|
|
SET representative_picture_id = '.$page['image_id'].'
|
2007-02-27 02:56:16 +01:00
|
|
|
WHERE id = '.$page['category']['id'].'
|
2006-03-15 23:44:35 +01:00
|
|
|
;';
|
|
|
|
pwg_query($query);
|
|
|
|
}
|
2006-03-17 05:13:19 +01:00
|
|
|
|
2006-03-15 23:44:35 +01:00
|
|
|
redirect($url_self);
|
2006-03-17 05:13:19 +01:00
|
|
|
|
2006-03-15 23:44:35 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'toggle_metadata' :
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'add_to_caddie' :
|
|
|
|
{
|
2006-03-27 23:19:31 +02:00
|
|
|
fill_caddie(array($page['image_id']));
|
2006-03-15 23:44:35 +01:00
|
|
|
redirect($url_self);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'rate' :
|
|
|
|
{
|
2006-03-28 03:26:37 +02:00
|
|
|
include_once(PHPWG_ROOT_PATH.'include/functions_rate.inc.php');
|
2007-02-07 22:23:33 +01:00
|
|
|
rate_picture(
|
|
|
|
$page['image_id'],
|
|
|
|
isset($_POST['rate']) ? $_POST['rate'] : $_GET['rate']
|
|
|
|
);
|
2006-03-15 23:44:35 +01:00
|
|
|
redirect($url_self);
|
|
|
|
}
|
|
|
|
case 'delete_comment' :
|
|
|
|
{
|
|
|
|
if (isset($_GET['comment_to_delete'])
|
|
|
|
and is_numeric($_GET['comment_to_delete'])
|
2006-11-01 06:54:35 +01:00
|
|
|
and is_admin() and !is_adviser() )
|
2006-03-15 23:44:35 +01:00
|
|
|
{
|
|
|
|
$query = '
|
|
|
|
DELETE FROM '.COMMENTS_TABLE.'
|
|
|
|
WHERE id = '.$_GET['comment_to_delete'].'
|
2006-02-14 02:14:31 +01:00
|
|
|
;';
|
2006-03-15 23:44:35 +01:00
|
|
|
pwg_query( $query );
|
|
|
|
}
|
|
|
|
|
|
|
|
redirect($url_self);
|
|
|
|
}
|
|
|
|
}
|
2006-02-14 02:14:31 +01:00
|
|
|
}
|
|
|
|
|
2006-03-15 23:44:35 +01:00
|
|
|
// incrementation of the number of hits, we do this only if no action
|
2007-10-30 00:39:41 +01:00
|
|
|
if (trigger_event('allow_increment_element_hit_count', !isset($_POST['content']) ) )
|
2007-06-30 03:40:19 +02:00
|
|
|
{
|
|
|
|
$query = '
|
2006-03-15 23:44:35 +01:00
|
|
|
UPDATE
|
|
|
|
'.IMAGES_TABLE.'
|
|
|
|
SET hit = hit+1
|
|
|
|
WHERE id = '.$page['image_id'].'
|
|
|
|
;';
|
2007-06-30 03:40:19 +02:00
|
|
|
pwg_query($query);
|
|
|
|
}
|
2005-03-12 11:27:43 +01:00
|
|
|
//---------------------------------------------------------- related categories
|
|
|
|
$query = '
|
|
|
|
SELECT category_id,uppercats,commentable,global_rank
|
|
|
|
FROM '.IMAGE_CATEGORY_TABLE.'
|
|
|
|
INNER JOIN '.CATEGORIES_TABLE.' ON category_id = id
|
2006-03-15 23:44:35 +01:00
|
|
|
WHERE image_id = '.$page['image_id'].'
|
2006-12-21 22:38:20 +01:00
|
|
|
'.get_sql_condition_FandF
|
|
|
|
(
|
|
|
|
array
|
|
|
|
(
|
|
|
|
'forbidden_categories' => 'category_id',
|
|
|
|
'visible_categories' => 'category_id'
|
|
|
|
),
|
|
|
|
'AND'
|
|
|
|
).'
|
2005-03-12 11:27:43 +01:00
|
|
|
;';
|
|
|
|
$result = pwg_query($query);
|
|
|
|
$related_categories = array();
|
|
|
|
while ($row = mysql_fetch_array($result))
|
|
|
|
{
|
|
|
|
array_push($related_categories, $row);
|
|
|
|
}
|
|
|
|
usort($related_categories, 'global_rank_compare');
|
2006-03-17 05:13:19 +01:00
|
|
|
//-------------------------first, prev, current, next & last picture management
|
2004-03-30 00:40:21 +02:00
|
|
|
$picture = array();
|
2004-02-21 12:02:06 +01:00
|
|
|
|
2006-03-15 23:44:35 +01:00
|
|
|
$ids = array($page['image_id']);
|
2006-02-12 22:52:16 +01:00
|
|
|
if (isset($page['previous_item']))
|
2004-08-05 19:31:36 +02:00
|
|
|
{
|
2006-02-12 22:52:16 +01:00
|
|
|
array_push($ids, $page['previous_item']);
|
2006-03-17 05:13:19 +01:00
|
|
|
array_push($ids, $page['first_item']);
|
2004-08-05 19:31:36 +02:00
|
|
|
}
|
2006-02-12 22:52:16 +01:00
|
|
|
if (isset($page['next_item']))
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2006-02-12 22:52:16 +01:00
|
|
|
array_push($ids, $page['next_item']);
|
2006-03-17 05:13:19 +01:00
|
|
|
array_push($ids, $page['last_item']);
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
2004-02-02 01:55:18 +01:00
|
|
|
|
2004-07-26 22:42:48 +02:00
|
|
|
$query = '
|
2006-02-12 22:52:16 +01:00
|
|
|
SELECT *
|
|
|
|
FROM '.IMAGES_TABLE.'
|
|
|
|
WHERE id IN ('.implode(',', $ids).')
|
|
|
|
;';
|
2004-02-02 01:55:18 +01:00
|
|
|
|
2006-02-12 22:52:16 +01:00
|
|
|
$result = pwg_query($query);
|
2004-03-30 00:40:21 +02:00
|
|
|
|
2006-11-07 04:37:57 +01:00
|
|
|
while ($row = mysql_fetch_assoc($result))
|
2004-02-21 12:02:06 +01:00
|
|
|
{
|
2006-02-12 22:52:16 +01:00
|
|
|
if (isset($page['previous_item']) and $row['id'] == $page['previous_item'])
|
2004-08-05 19:31:36 +02:00
|
|
|
{
|
2006-03-17 05:13:19 +01:00
|
|
|
$i = 'previous';
|
2004-08-05 19:31:36 +02:00
|
|
|
}
|
2006-02-12 22:52:16 +01:00
|
|
|
else if (isset($page['next_item']) and $row['id'] == $page['next_item'])
|
2004-08-05 19:31:36 +02:00
|
|
|
{
|
2006-02-12 22:52:16 +01:00
|
|
|
$i = 'next';
|
2004-08-05 19:31:36 +02:00
|
|
|
}
|
2006-03-17 05:13:19 +01:00
|
|
|
else if (isset($page['first_item']) and $row['id'] == $page['first_item'])
|
|
|
|
{
|
|
|
|
$i = 'first';
|
|
|
|
}
|
|
|
|
else if (isset($page['last_item']) and $row['id'] == $page['last_item'])
|
|
|
|
{
|
|
|
|
$i = 'last';
|
|
|
|
}
|
2006-02-12 22:52:16 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$i = 'current';
|
|
|
|
}
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2006-11-07 04:37:57 +01:00
|
|
|
$picture[$i] = $row;
|
2004-08-05 19:31:36 +02:00
|
|
|
|
|
|
|
$picture[$i]['is_picture'] = false;
|
|
|
|
if (in_array(get_extension($row['file']), $conf['picture_ext']))
|
|
|
|
{
|
|
|
|
$picture[$i]['is_picture'] = true;
|
|
|
|
}
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2006-11-01 06:54:35 +01:00
|
|
|
// ------ build element_path and element_url
|
2006-11-17 05:26:10 +01:00
|
|
|
$picture[$i]['element_path'] = get_element_path($picture[$i]);
|
|
|
|
$picture[$i]['element_url'] = get_element_url($picture[$i]);
|
|
|
|
|
|
|
|
// ------ build image_path and image_url
|
|
|
|
if ($i=='current' or $i=='next')
|
2004-08-05 19:31:36 +02:00
|
|
|
{
|
2006-11-17 05:26:10 +01:00
|
|
|
$picture[$i]['image_path'] = get_image_path( $picture[$i] );
|
|
|
|
$picture[$i]['image_url'] = get_image_url( $picture[$i] );
|
2004-08-05 19:31:36 +02:00
|
|
|
}
|
2006-11-01 06:54:35 +01:00
|
|
|
|
2006-11-17 05:26:10 +01:00
|
|
|
if ($i=='current')
|
2004-08-05 19:31:36 +02:00
|
|
|
{
|
2006-11-17 05:26:10 +01:00
|
|
|
if ( $picture[$i]['is_picture'] )
|
2004-09-24 10:37:29 +02:00
|
|
|
{
|
2006-11-17 05:26:10 +01:00
|
|
|
if ( $user['enabled_high']=='true' )
|
2004-09-24 10:37:29 +02:00
|
|
|
{
|
2006-11-17 05:26:10 +01:00
|
|
|
$hi_url=get_high_url($picture[$i]);
|
|
|
|
if ( !empty($hi_url) )
|
2006-03-21 02:27:21 +01:00
|
|
|
{
|
2006-11-17 05:26:10 +01:00
|
|
|
$picture[$i]['high_url'] = $hi_url;
|
|
|
|
$picture[$i]['download_url'] = get_download_url('h',$picture[$i]);
|
2006-03-21 02:27:21 +01:00
|
|
|
}
|
2004-09-24 10:37:29 +02:00
|
|
|
}
|
|
|
|
}
|
2006-11-01 06:54:35 +01:00
|
|
|
else
|
2006-11-17 05:26:10 +01:00
|
|
|
{ // not a pic - need download link
|
|
|
|
$picture[$i]['download_url'] = get_download_url('e',$picture[$i]);
|
2006-11-01 06:54:35 +01:00
|
|
|
}
|
2004-08-05 19:31:36 +02:00
|
|
|
}
|
|
|
|
|
2006-11-07 04:37:57 +01:00
|
|
|
$picture[$i]['thumbnail'] = get_thumbnail_url($row);
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2004-03-30 00:40:21 +02:00
|
|
|
if ( !empty( $row['name'] ) )
|
2004-02-02 01:55:18 +01:00
|
|
|
{
|
2004-08-05 19:31:36 +02:00
|
|
|
$picture[$i]['name'] = $row['name'];
|
2004-02-02 01:55:18 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-11-17 05:26:10 +01:00
|
|
|
$file_wo_ext = get_filename_wo_extension($row['file']);
|
2004-08-05 19:31:36 +02:00
|
|
|
$picture[$i]['name'] = str_replace('_', ' ', $file_wo_ext);
|
2004-02-02 01:55:18 +01:00
|
|
|
}
|
|
|
|
|
2006-07-26 23:00:16 +02:00
|
|
|
$picture[$i]['url'] = duplicate_picture_url(
|
2006-03-15 23:44:35 +01:00
|
|
|
array(
|
|
|
|
'image_id' => $row['id'],
|
2006-03-21 02:27:21 +01:00
|
|
|
'image_file' => $row['file'],
|
2006-03-15 23:44:35 +01:00
|
|
|
),
|
|
|
|
array(
|
|
|
|
'start',
|
|
|
|
)
|
|
|
|
);
|
2006-03-17 05:13:19 +01:00
|
|
|
|
|
|
|
if ('previous'==$i and $page['previous_item']==$page['first_item'])
|
|
|
|
{
|
|
|
|
$picture['first'] = $picture[$i];
|
|
|
|
}
|
|
|
|
if ('next'==$i and $page['next_item']==$page['last_item'])
|
|
|
|
{
|
|
|
|
$picture['last'] = $picture[$i];
|
|
|
|
}
|
2004-11-16 00:13:24 +01:00
|
|
|
}
|
2004-02-02 01:55:18 +01:00
|
|
|
|
2006-11-01 06:54:35 +01:00
|
|
|
// calculation of width and height for the current picture
|
|
|
|
if (empty($picture['current']['width']))
|
|
|
|
{
|
|
|
|
$taille_image = @getimagesize($picture['current']['image_path']);
|
|
|
|
if ($taille_image!==false)
|
|
|
|
{
|
|
|
|
$picture['current']['width'] = $taille_image[0];
|
|
|
|
$picture['current']['height']= $taille_image[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($picture['current']['width']))
|
|
|
|
{
|
2007-02-07 22:23:33 +01:00
|
|
|
list(
|
|
|
|
$picture['current']['scaled_width'],
|
|
|
|
$picture['current']['scaled_height']
|
|
|
|
) = get_picture_size(
|
2006-11-01 06:54:35 +01:00
|
|
|
$picture['current']['width'],
|
|
|
|
$picture['current']['height'],
|
|
|
|
@$user['maxwidth'],
|
|
|
|
@$user['maxheight']
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2006-02-12 22:52:16 +01:00
|
|
|
$url_admin =
|
2006-03-21 02:27:21 +01:00
|
|
|
get_root_url().'admin.php?page=picture_modify'
|
2007-02-27 02:56:16 +01:00
|
|
|
.'&cat_id='.(isset($page['category']) ? $page['category']['id'] : '')
|
2006-03-15 23:44:35 +01:00
|
|
|
.'&image_id='.$page['image_id']
|
|
|
|
;
|
2004-09-23 18:42:11 +02:00
|
|
|
|
2008-02-27 21:25:18 +01:00
|
|
|
$slideshow_params = array();
|
|
|
|
$slideshow_url_params = array();
|
2007-02-09 02:41:49 +01:00
|
|
|
|
2008-02-27 21:25:18 +01:00
|
|
|
if (isset($_GET['slideshow']))
|
2007-02-09 02:41:49 +01:00
|
|
|
{
|
|
|
|
$page['slideshow'] = true;
|
2008-02-27 21:25:18 +01:00
|
|
|
$page['meta_robots'] = array('noindex'=>1, 'nofollow'=>1);
|
|
|
|
|
|
|
|
$slideshow_params = decode_slideshow_params($_GET['slideshow']);
|
|
|
|
$slideshow_url_params['slideshow'] = encode_slideshow_params($slideshow_params);
|
|
|
|
|
|
|
|
if ($slideshow_params['play'])
|
|
|
|
{
|
|
|
|
$id_pict_redirect = '';
|
|
|
|
if (isset($page['next_item']))
|
|
|
|
{
|
|
|
|
$id_pict_redirect = 'next';
|
|
|
|
}
|
|
|
|
else
|
2007-11-23 00:49:36 +01:00
|
|
|
{
|
2008-02-27 21:25:18 +01:00
|
|
|
if ($slideshow_params['repeat'] and isset($page['first_item']))
|
|
|
|
{
|
|
|
|
$id_pict_redirect = 'first';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($id_pict_redirect))
|
|
|
|
{
|
|
|
|
// $redirect_msg, $refresh, $url_link and $title are required for creating
|
|
|
|
// an automated refresh page in header.tpl
|
|
|
|
$refresh = $slideshow_params['period'];
|
|
|
|
$url_link = add_url_params(
|
|
|
|
$picture[$id_pict_redirect]['url'],
|
|
|
|
$slideshow_url_params
|
|
|
|
);
|
|
|
|
$redirect_msg = nl2br(l10n('redirect_msg'));
|
2007-11-23 00:49:36 +01:00
|
|
|
}
|
2007-02-09 02:41:49 +01:00
|
|
|
}
|
2008-02-27 21:25:18 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$page['slideshow'] = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$template->set_filenames(
|
|
|
|
array(
|
|
|
|
'picture' =>
|
|
|
|
(($page['slideshow'] and $conf['light_slideshow']) ? 'slideshow.tpl' : 'picture.tpl'),
|
2008-02-29 02:25:13 +01:00
|
|
|
));
|
2008-02-27 21:25:18 +01:00
|
|
|
|
2004-02-21 12:02:06 +01:00
|
|
|
|
2007-02-09 02:41:49 +01:00
|
|
|
$title = $picture['current']['name'];
|
2007-02-15 01:10:41 +01:00
|
|
|
$title_nb = ($page['current_rank'] + 1).'/'.count($page['items']);
|
2003-05-09 14:42:42 +02:00
|
|
|
|
2004-09-23 18:42:11 +02:00
|
|
|
// metadata
|
2006-07-26 23:00:16 +02:00
|
|
|
$url_metadata = duplicate_picture_url();
|
2008-06-28 15:59:26 +02:00
|
|
|
$url_metadata = add_url_params( $url_metadata, array('metadata'=>null) );
|
|
|
|
|
2006-11-01 06:54:35 +01:00
|
|
|
|
|
|
|
// do we have a plugin that can show metadata for something else than images?
|
2007-02-07 22:23:33 +01:00
|
|
|
$metadata_showable = trigger_event(
|
|
|
|
'get_element_metadata_available',
|
|
|
|
(
|
|
|
|
($conf['show_exif'] or $conf['show_iptc'])
|
|
|
|
and isset($picture['current']['image_path'])
|
2006-11-01 06:54:35 +01:00
|
|
|
),
|
2007-02-07 22:23:33 +01:00
|
|
|
$picture['current']['path']
|
|
|
|
);
|
|
|
|
|
2008-06-28 15:59:26 +02:00
|
|
|
if ( $metadata_showable and pwg_get_session_var('show_metadata') )
|
2004-09-23 18:42:11 +02:00
|
|
|
{
|
2008-06-28 15:59:26 +02:00
|
|
|
$page['meta_robots']=array('noindex'=>1, 'nofollow'=>1);
|
2004-09-23 18:42:11 +02:00
|
|
|
}
|
2006-11-01 06:54:35 +01:00
|
|
|
|
2008-06-28 15:59:26 +02:00
|
|
|
|
|
|
|
|
2006-11-01 06:54:35 +01:00
|
|
|
$page['body_id'] = 'thePicturePage';
|
|
|
|
|
2007-03-09 04:37:56 +01:00
|
|
|
// allow plugins to change what we computed before passing data to template
|
|
|
|
$picture = trigger_event('picture_pictures_data', $picture);
|
|
|
|
|
2007-02-07 22:23:33 +01:00
|
|
|
|
|
|
|
if (isset($picture['next']['image_url'])
|
2008-01-31 02:14:25 +01:00
|
|
|
and $picture['next']['is_picture'] )
|
2004-09-23 18:42:11 +02:00
|
|
|
{
|
2008-02-29 02:25:13 +01:00
|
|
|
$template->assign('U_PREFETCH', $picture['next']['image_url'] );
|
2004-09-23 18:42:11 +02:00
|
|
|
}
|
2007-01-18 00:08:41 +01:00
|
|
|
|
2006-02-12 22:52:16 +01:00
|
|
|
//------------------------------------------------------- navigation management
|
2008-02-29 02:25:13 +01:00
|
|
|
foreach (array('first','previous','next','last', 'current') as $which_image)
|
2006-02-01 03:46:26 +01:00
|
|
|
{
|
2006-03-17 05:13:19 +01:00
|
|
|
if (isset($picture[$which_image]))
|
|
|
|
{
|
2008-02-29 02:25:13 +01:00
|
|
|
$template->assign(
|
2006-03-17 05:13:19 +01:00
|
|
|
$which_image,
|
2008-07-02 03:11:26 +02:00
|
|
|
array_merge(
|
|
|
|
$picture[$which_image],
|
|
|
|
array(
|
|
|
|
'TITLE' => $picture[$which_image]['name'],
|
|
|
|
'THUMB_SRC' => $picture[$which_image]['thumbnail'],
|
|
|
|
// Params slideshow was transmit to navigation buttons
|
|
|
|
'U_IMG' =>
|
|
|
|
add_url_params(
|
|
|
|
$picture[$which_image]['url'], $slideshow_url_params),
|
|
|
|
'U_DOWNLOAD' => @$picture['current']['download_url'],
|
|
|
|
)
|
2006-03-17 05:13:19 +01:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2006-02-01 03:46:26 +01:00
|
|
|
}
|
|
|
|
|
2008-02-27 21:25:18 +01:00
|
|
|
|
|
|
|
if ($page['slideshow'])
|
|
|
|
{
|
2008-02-29 02:25:13 +01:00
|
|
|
// Add local-slideshow.css file if exists
|
|
|
|
// Not only for ligth
|
|
|
|
$css = PHPWG_ROOT_PATH . get_themeconf('template_dir') . '/theme/'
|
|
|
|
. get_themeconf('theme') . '/local-slideshow.css';
|
|
|
|
if (file_exists($css))
|
|
|
|
{
|
|
|
|
//TODO CORRECT THIS $template->assign_block_vars('slideshow', array());
|
|
|
|
}
|
|
|
|
|
|
|
|
$tpl_slideshow = array();
|
|
|
|
|
2008-02-27 21:25:18 +01:00
|
|
|
//slideshow end
|
2008-02-29 02:25:13 +01:00
|
|
|
$template->assign(
|
2008-02-27 21:25:18 +01:00
|
|
|
array(
|
2008-02-29 02:25:13 +01:00
|
|
|
'U_SLIDESHOW_STOP' => $picture['current']['url'],
|
2008-02-27 21:25:18 +01:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
foreach (array('repeat', 'play') as $p)
|
|
|
|
{
|
2008-02-29 02:25:13 +01:00
|
|
|
$var_name =
|
|
|
|
'U_'
|
|
|
|
.($slideshow_params[$p] ? 'STOP_' : 'START_')
|
|
|
|
.strtoupper($p);
|
|
|
|
|
|
|
|
$tpl_slideshow[$var_name] =
|
2008-02-27 21:25:18 +01:00
|
|
|
add_url_params(
|
|
|
|
$picture['current']['url'],
|
|
|
|
array('slideshow' =>
|
|
|
|
encode_slideshow_params(
|
2008-02-29 02:25:13 +01:00
|
|
|
array_merge($slideshow_params,
|
2008-02-27 21:25:18 +01:00
|
|
|
array($p => ! $slideshow_params[$p]))
|
|
|
|
)
|
|
|
|
)
|
2008-02-29 02:25:13 +01:00
|
|
|
);
|
2008-02-27 21:25:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach (array('dec', 'inc') as $op)
|
|
|
|
{
|
|
|
|
$new_period = $slideshow_params['period'] + ((($op == 'dec') ? -1 : 1) * $conf['slideshow_period_step']);
|
|
|
|
$new_slideshow_params =
|
|
|
|
correct_slideshow_params(
|
2008-02-29 02:25:13 +01:00
|
|
|
array_merge($slideshow_params,
|
2008-02-27 21:25:18 +01:00
|
|
|
array('period' => $new_period)));
|
|
|
|
|
|
|
|
if ($new_slideshow_params['period'] === $new_period)
|
|
|
|
{
|
2008-02-29 02:25:13 +01:00
|
|
|
$var_name = 'U_'.strtoupper($op).'_PERIOD';
|
|
|
|
$tpl_slideshow[$var_name] =
|
2008-02-27 21:25:18 +01:00
|
|
|
add_url_params(
|
|
|
|
$picture['current']['url'],
|
|
|
|
array('slideshow' => encode_slideshow_params($new_slideshow_params)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2008-02-29 02:25:13 +01:00
|
|
|
$template->assign('slideshow', $tpl_slideshow );
|
2008-02-27 21:25:18 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-02-29 02:25:13 +01:00
|
|
|
$template->assign(
|
2008-02-27 21:25:18 +01:00
|
|
|
array(
|
2008-02-29 02:25:13 +01:00
|
|
|
'U_SLIDESHOW_START' =>
|
2008-02-27 21:25:18 +01:00
|
|
|
add_url_params(
|
|
|
|
$picture['current']['url'],
|
|
|
|
array( 'slideshow'=>''))
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2008-02-29 02:25:13 +01:00
|
|
|
$template->assign(
|
2006-03-15 23:44:35 +01:00
|
|
|
array(
|
2006-04-05 22:55:26 +02:00
|
|
|
'SECTION_TITLE' => $page['title'],
|
2006-03-15 23:44:35 +01:00
|
|
|
'PHOTO' => $title_nb,
|
2008-02-29 02:25:13 +01:00
|
|
|
'SHOW_PICTURE_NAME_ON_TITLE' => $conf['show_picture_name_on_title'],
|
2006-03-15 23:44:35 +01:00
|
|
|
|
|
|
|
'LEVEL_SEPARATOR' => $conf['level_separator'],
|
2008-04-26 01:38:04 +02:00
|
|
|
|
2008-02-29 02:25:13 +01:00
|
|
|
'FILE_PICTURE_NAV_BUTTONS' => 'picture_nav_buttons.tpl',
|
2006-03-15 23:44:35 +01:00
|
|
|
|
2006-07-26 23:00:16 +02:00
|
|
|
'U_HOME' => make_index_url(),
|
2008-02-29 02:25:13 +01:00
|
|
|
'U_UP' => $url_up,
|
2006-03-15 23:44:35 +01:00
|
|
|
'U_METADATA' => $url_metadata,
|
|
|
|
)
|
|
|
|
);
|
2005-07-17 16:58:42 +02:00
|
|
|
|
|
|
|
|
2004-09-24 10:37:29 +02:00
|
|
|
//------------------------------------------------------- upper menu management
|
2006-03-15 23:44:35 +01:00
|
|
|
|
2008-02-29 02:25:13 +01:00
|
|
|
// admin links
|
2006-03-09 00:14:53 +01:00
|
|
|
if (is_admin())
|
2005-09-03 18:36:05 +02:00
|
|
|
{
|
2008-02-29 02:25:13 +01:00
|
|
|
if (isset($page['category']))
|
|
|
|
{
|
|
|
|
$template->assign(
|
|
|
|
array(
|
|
|
|
'U_SET_AS_REPRESENTATIVE' => add_url_params($url_self,
|
|
|
|
array('action'=>'set_as_representative')
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2008-04-26 01:38:04 +02:00
|
|
|
|
2008-02-29 02:25:13 +01:00
|
|
|
$template->assign(
|
2005-09-03 18:36:05 +02:00
|
|
|
array(
|
2008-02-29 02:25:13 +01:00
|
|
|
'U_CADDIE' => add_url_params($url_self,
|
2006-03-23 02:49:04 +01:00
|
|
|
array('action'=>'add_to_caddie')
|
2008-02-29 02:25:13 +01:00
|
|
|
),
|
|
|
|
'U_ADMIN' => $url_admin,
|
2006-03-15 23:44:35 +01:00
|
|
|
)
|
2005-09-03 18:36:05 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2006-03-15 23:44:35 +01:00
|
|
|
// favorite manipulation
|
2007-06-06 00:01:15 +02:00
|
|
|
if (!is_a_guest())
|
2004-09-23 18:42:11 +02:00
|
|
|
{
|
|
|
|
// verify if the picture is already in the favorite of the user
|
2006-03-15 23:44:35 +01:00
|
|
|
$query = '
|
|
|
|
SELECT COUNT(*) AS nb_fav
|
|
|
|
FROM '.FAVORITES_TABLE.'
|
|
|
|
WHERE image_id = '.$page['image_id'].'
|
|
|
|
AND user_id = '.$user['id'].'
|
|
|
|
;';
|
|
|
|
$result = pwg_query($query);
|
|
|
|
$row = mysql_fetch_array($result);
|
2006-03-17 05:13:19 +01:00
|
|
|
|
2006-03-15 23:44:35 +01:00
|
|
|
if ($row['nb_fav'] == 0)
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2008-02-29 02:25:13 +01:00
|
|
|
$template->assign(
|
2004-09-23 18:42:11 +02:00
|
|
|
'favorite',
|
|
|
|
array(
|
2007-02-15 22:20:52 +01:00
|
|
|
'FAVORITE_IMG' =>
|
|
|
|
get_root_url().get_themeconf('icon_dir').'/favorite.png',
|
2007-05-15 22:23:09 +02:00
|
|
|
'FAVORITE_HINT' => l10n('add_favorites_hint'),
|
2006-03-23 02:49:04 +01:00
|
|
|
'U_FAVORITE' => add_url_params(
|
2007-02-15 22:20:52 +01:00
|
|
|
$url_self,
|
|
|
|
array('action'=>'add_to_favorites')
|
|
|
|
),
|
2006-03-15 23:44:35 +01:00
|
|
|
)
|
|
|
|
);
|
2004-09-23 18:42:11 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-02-29 02:25:13 +01:00
|
|
|
$template->assign(
|
2004-09-23 18:42:11 +02:00
|
|
|
'favorite',
|
|
|
|
array(
|
2007-02-15 22:20:52 +01:00
|
|
|
'FAVORITE_IMG' =>
|
|
|
|
get_root_url().get_themeconf('icon_dir').'/del_favorite.png',
|
2007-05-15 22:23:09 +02:00
|
|
|
'FAVORITE_HINT' => l10n('del_favorites_hint'),
|
2006-03-23 02:49:04 +01:00
|
|
|
'U_FAVORITE' => add_url_params(
|
2007-02-15 22:20:52 +01:00
|
|
|
$url_self,
|
|
|
|
array('action'=>'remove_from_favorites')
|
|
|
|
),
|
2006-03-15 23:44:35 +01:00
|
|
|
)
|
|
|
|
);
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
|
|
|
}
|
2004-02-21 12:02:06 +01:00
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
//--------------------------------------------------------- picture information
|
2004-03-20 01:52:37 +01:00
|
|
|
// legend
|
2004-08-05 19:31:36 +02:00
|
|
|
if (isset($picture['current']['comment'])
|
|
|
|
and !empty($picture['current']['comment']))
|
2004-03-20 01:52:37 +01:00
|
|
|
{
|
2008-02-29 02:25:13 +01:00
|
|
|
$template->assign(
|
|
|
|
'COMMENT_IMG',
|
2007-08-26 01:10:12 +02:00
|
|
|
trigger_event('render_element_description',
|
|
|
|
$picture['current']['comment'])
|
2008-02-29 02:25:13 +01:00
|
|
|
);
|
2004-08-05 19:31:36 +02:00
|
|
|
}
|
2004-09-23 18:42:11 +02:00
|
|
|
|
2005-08-21 13:32:12 +02:00
|
|
|
$infos = array();
|
|
|
|
|
|
|
|
// author
|
|
|
|
if (!empty($picture['current']['author']))
|
2003-07-28 23:30:19 +02:00
|
|
|
{
|
2005-08-21 13:32:12 +02:00
|
|
|
$infos['INFO_AUTHOR'] =
|
2007-02-15 22:20:52 +01:00
|
|
|
// FIXME because of search engine partial rewrite, giving the author
|
|
|
|
// name threw GET is not supported anymore. This feature should come
|
|
|
|
// back later, with a better design
|
2006-01-20 15:34:37 +01:00
|
|
|
// '<a href="'.
|
|
|
|
// PHPWG_ROOT_PATH.'category.php?cat=search'.
|
|
|
|
// '&search=author:'.$picture['current']['author']
|
|
|
|
// .'">'.$picture['current']['author'].'</a>';
|
|
|
|
$picture['current']['author'];
|
2005-08-21 13:32:12 +02:00
|
|
|
}
|
2005-04-26 16:24:08 +02:00
|
|
|
|
2005-08-21 13:32:12 +02:00
|
|
|
// creation date
|
|
|
|
if (!empty($picture['current']['date_creation']))
|
- on picture.php, related categories under the element are displayed in
global_rank order
- when adding a new virtual category, initializes its global_rank
- bug fixed : in admin/cat_list, false next rank
- in admin/cat_modify, complete directory is calculated only if category is
not virtual
- admin/picture_modify rewritten : graphically nearer to admin/cat_modify,
virtual associations are back
- update_category partially rewritten : take an array of categories in
parameter, becomes optionnaly recursive, use the set_random_representant
function, set a random representant for categories with elements and no
representant
- bug fixed : on a search results screen, elements belonging to more than 1
category were shown more than once
- bug fixed : in admin/cat_modify, changing a value in a textefield and
hitting enter was setting a new random representant
git-svn-id: http://piwigo.org/svn/trunk@635 68402e56-0260-453c-a942-63ccdbb3a9ee
2004-12-05 22:28:40 +01:00
|
|
|
{
|
2006-02-23 03:30:19 +01:00
|
|
|
$val = format_date($picture['current']['date_creation']);
|
2006-07-26 23:00:16 +02:00
|
|
|
$url = make_index_url(
|
2007-02-15 22:20:52 +01:00
|
|
|
array(
|
|
|
|
'chronology_field'=>'created',
|
|
|
|
'chronology_style'=>'monthly',
|
|
|
|
'chronology_view'=>'list',
|
|
|
|
'chronology_date' => explode('-', $picture['current']['date_creation'])
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$infos['INFO_CREATION_DATE'] =
|
|
|
|
'<a href="'.$url.'" rel="nofollow">'.$val.'</a>';
|
2005-08-21 13:32:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// date of availability
|
2006-02-23 03:30:19 +01:00
|
|
|
$val = format_date($picture['current']['date_available'], 'mysql_datetime');
|
2006-07-26 23:00:16 +02:00
|
|
|
$url = make_index_url(
|
2007-02-15 22:20:52 +01:00
|
|
|
array(
|
|
|
|
'chronology_field'=>'posted',
|
|
|
|
'chronology_style'=>'monthly',
|
|
|
|
'chronology_view'=>'list',
|
|
|
|
'chronology_date' => explode(
|
|
|
|
'-',
|
|
|
|
substr($picture['current']['date_available'], 0, 10)
|
2006-03-21 02:27:21 +01:00
|
|
|
)
|
2007-02-15 22:20:52 +01:00
|
|
|
)
|
|
|
|
);
|
2006-04-08 21:42:11 +02:00
|
|
|
$infos['INFO_POSTED_DATE'] = '<a href="'.$url.'" rel="nofollow">'.$val.'</a>';
|
2005-08-21 13:32:12 +02:00
|
|
|
|
|
|
|
// size in pixels
|
2006-11-01 06:54:35 +01:00
|
|
|
if ($picture['current']['is_picture'] and isset($picture['current']['width']) )
|
2005-08-21 13:32:12 +02:00
|
|
|
{
|
2006-11-01 06:54:35 +01:00
|
|
|
if ($picture['current']['scaled_width'] !== $picture['current']['width'] )
|
- on picture.php, related categories under the element are displayed in
global_rank order
- when adding a new virtual category, initializes its global_rank
- bug fixed : in admin/cat_list, false next rank
- in admin/cat_modify, complete directory is calculated only if category is
not virtual
- admin/picture_modify rewritten : graphically nearer to admin/cat_modify,
virtual associations are back
- update_category partially rewritten : take an array of categories in
parameter, becomes optionnaly recursive, use the set_random_representant
function, set a random representant for categories with elements and no
representant
- bug fixed : on a search results screen, elements belonging to more than 1
category were shown more than once
- bug fixed : in admin/cat_modify, changing a value in a textefield and
hitting enter was setting a new random representant
git-svn-id: http://piwigo.org/svn/trunk@635 68402e56-0260-453c-a942-63ccdbb3a9ee
2004-12-05 22:28:40 +01:00
|
|
|
{
|
2005-08-21 13:32:12 +02:00
|
|
|
$infos['INFO_DIMENSIONS'] =
|
2006-11-01 06:54:35 +01:00
|
|
|
'<a href="'.$picture['current']['image_url'].'" title="'.
|
2005-08-21 13:32:12 +02:00
|
|
|
l10n('Original dimensions').'">'.
|
2006-11-01 06:54:35 +01:00
|
|
|
$picture['current']['width'].'*'.$picture['current']['height'].'</a>';
|
- on picture.php, related categories under the element are displayed in
global_rank order
- when adding a new virtual category, initializes its global_rank
- bug fixed : in admin/cat_list, false next rank
- in admin/cat_modify, complete directory is calculated only if category is
not virtual
- admin/picture_modify rewritten : graphically nearer to admin/cat_modify,
virtual associations are back
- update_category partially rewritten : take an array of categories in
parameter, becomes optionnaly recursive, use the set_random_representant
function, set a random representant for categories with elements and no
representant
- bug fixed : on a search results screen, elements belonging to more than 1
category were shown more than once
- bug fixed : in admin/cat_modify, changing a value in a textefield and
hitting enter was setting a new random representant
git-svn-id: http://piwigo.org/svn/trunk@635 68402e56-0260-453c-a942-63ccdbb3a9ee
2004-12-05 22:28:40 +01:00
|
|
|
}
|
|
|
|
else
|
2004-10-21 23:17:07 +02:00
|
|
|
{
|
2006-11-01 06:54:35 +01:00
|
|
|
$infos['INFO_DIMENSIONS'] =
|
|
|
|
$picture['current']['width'].'*'.$picture['current']['height'];
|
2004-11-13 14:43:53 +01:00
|
|
|
}
|
2004-10-21 23:17:07 +02:00
|
|
|
}
|
2005-08-21 13:32:12 +02:00
|
|
|
|
|
|
|
// filesize
|
|
|
|
if (!empty($picture['current']['filesize']))
|
|
|
|
{
|
|
|
|
$infos['INFO_FILESIZE'] =
|
|
|
|
sprintf(l10n('%d Kb'), $picture['current']['filesize']);
|
|
|
|
}
|
|
|
|
|
|
|
|
// number of visits
|
|
|
|
$infos['INFO_VISITS'] = $picture['current']['hit'];
|
|
|
|
|
|
|
|
// file
|
|
|
|
$infos['INFO_FILE'] = $picture['current']['file'];
|
|
|
|
|
2008-02-29 02:25:13 +01:00
|
|
|
$template->assign($infos);
|
|
|
|
|
|
|
|
// related tags
|
2007-02-16 04:06:41 +01:00
|
|
|
$tags = get_common_tags( array($page['image_id']), -1);
|
|
|
|
if ( count($tags) )
|
2005-08-21 13:32:12 +02:00
|
|
|
{
|
2008-02-29 02:25:13 +01:00
|
|
|
foreach ($tags as $tag)
|
2006-04-03 00:26:19 +02:00
|
|
|
{
|
2008-02-29 02:25:13 +01:00
|
|
|
$template->append(
|
|
|
|
'related_tags',
|
2008-07-02 03:11:26 +02:00
|
|
|
array_merge( $tag,
|
|
|
|
array(
|
|
|
|
'URL' => make_index_url(
|
2008-02-29 02:25:13 +01:00
|
|
|
array(
|
|
|
|
'tags' => array($tag)
|
|
|
|
)
|
|
|
|
),
|
2008-07-02 03:11:26 +02:00
|
|
|
'U_TAG_IMAGE' => duplicate_picture_url(
|
2008-02-29 02:25:13 +01:00
|
|
|
array(
|
|
|
|
'section' => 'tags',
|
|
|
|
'tags' => array($tag)
|
|
|
|
)
|
|
|
|
)
|
2006-04-03 00:26:19 +02:00
|
|
|
)
|
2008-07-02 03:11:26 +02:00
|
|
|
)
|
2008-02-29 02:25:13 +01:00
|
|
|
);
|
2006-04-03 00:26:19 +02:00
|
|
|
}
|
2005-08-21 13:32:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// related categories
|
2008-04-26 01:38:04 +02:00
|
|
|
if ( count($related_categories)==1 and
|
|
|
|
isset($page['category']) and
|
|
|
|
$related_categories[0]['category_id']==$page['category']['id'] )
|
|
|
|
{ // no need to go to db, we have all the info
|
2008-02-29 02:25:13 +01:00
|
|
|
$template->append(
|
2008-04-26 01:38:04 +02:00
|
|
|
'related_categories',
|
|
|
|
get_cat_display_name( $page['category']['upper_names'] )
|
2005-08-21 13:32:12 +02:00
|
|
|
);
|
|
|
|
}
|
2008-04-26 01:38:04 +02:00
|
|
|
else
|
|
|
|
{ // use only 1 sql query to get names for all related categories
|
|
|
|
$ids = array();
|
|
|
|
foreach ($related_categories as $category)
|
|
|
|
{// add all uppercats to $ids
|
|
|
|
$ids = array_merge($ids, explode(',', $category['uppercats']) );
|
|
|
|
}
|
|
|
|
$ids = array_unique($ids);
|
|
|
|
$query = '
|
|
|
|
SELECT id, name, permalink
|
|
|
|
FROM '.CATEGORIES_TABLE.'
|
|
|
|
WHERE id IN ('.implode(',',$ids).')';
|
|
|
|
$cat_map = hash_from_query($query, 'id');
|
|
|
|
foreach ($related_categories as $category)
|
|
|
|
{
|
|
|
|
$cats = array();
|
|
|
|
foreach ( explode(',', $category['uppercats']) as $id )
|
|
|
|
{
|
|
|
|
$cats[] = $cat_map[$id];
|
|
|
|
}
|
|
|
|
$template->append('related_categories', get_cat_display_name($cats) );
|
|
|
|
}
|
|
|
|
}
|
2005-04-26 16:24:08 +02:00
|
|
|
|
2007-03-09 04:37:56 +01:00
|
|
|
// maybe someone wants a special display (call it before page_header so that
|
|
|
|
// they can add stylesheets)
|
|
|
|
$element_content = trigger_event(
|
|
|
|
'render_element_content',
|
|
|
|
'',
|
|
|
|
$picture['current']
|
|
|
|
);
|
2008-02-29 02:25:13 +01:00
|
|
|
$template->assign( 'ELEMENT_CONTENT', $element_content );
|
2007-03-09 04:37:56 +01:00
|
|
|
|
2008-07-02 03:11:26 +02:00
|
|
|
if (is_admin())
|
|
|
|
{
|
|
|
|
$template->assign('available_permission_levels', $conf['available_permission_levels']);
|
|
|
|
}
|
2006-03-15 23:44:35 +01:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | sub pages |
|
|
|
|
// +-----------------------------------------------------------------------+
|
2006-02-14 02:14:31 +01:00
|
|
|
|
2006-03-15 23:44:35 +01:00
|
|
|
include(PHPWG_ROOT_PATH.'include/picture_rate.inc.php');
|
|
|
|
include(PHPWG_ROOT_PATH.'include/picture_comment.inc.php');
|
2008-06-28 15:59:26 +02:00
|
|
|
if ($metadata_showable and pwg_get_session_var('show_metadata') <> null )
|
2006-03-28 03:26:37 +02:00
|
|
|
{
|
|
|
|
include(PHPWG_ROOT_PATH.'include/picture_metadata.inc.php');
|
|
|
|
}
|
2004-02-02 01:55:18 +01:00
|
|
|
|
2006-12-02 17:46:15 +01:00
|
|
|
include(PHPWG_ROOT_PATH.'include/page_header.php');
|
2007-02-09 02:41:49 +01:00
|
|
|
trigger_action('loc_end_picture');
|
2008-02-29 02:25:13 +01:00
|
|
|
$template->pparse('picture');
|
2008-05-03 03:52:08 +02:00
|
|
|
//------------------------------------------------------------ log informations
|
|
|
|
pwg_log($picture['current']['id'], 'picture');
|
2004-02-22 03:43:13 +01:00
|
|
|
include(PHPWG_ROOT_PATH.'include/page_tail.php');
|
2004-02-12 00:20:38 +01:00
|
|
|
?>
|