mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-05-07 05:44:58 +02:00
feature 2548 multisize - improved picture.php display (original...) + code cleanup
git-svn-id: http://piwigo.org/svn/trunk@12855 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
+6
-12
@@ -60,7 +60,7 @@ function do_error( $code, $str )
|
||||
if (!isset($_GET['id'])
|
||||
or !is_numeric($_GET['id'])
|
||||
or !isset($_GET['part'])
|
||||
or !in_array($_GET['part'], array('t','e','i','h') ) )
|
||||
or !in_array($_GET['part'], array('e','r') ) )
|
||||
{
|
||||
do_error(400, 'Invalid request - id/part');
|
||||
}
|
||||
@@ -102,21 +102,15 @@ include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
|
||||
$file='';
|
||||
switch ($_GET['part'])
|
||||
{
|
||||
case 't':
|
||||
$file = get_thumbnail_path($element_info);
|
||||
break;
|
||||
case 'e':
|
||||
$file = get_element_path($element_info);
|
||||
break;
|
||||
case 'i':
|
||||
$file = get_image_path($element_info);
|
||||
break;
|
||||
case 'h':
|
||||
if ( $user['enabled_high']!='true' )
|
||||
{
|
||||
do_error(401, 'Access denied h');
|
||||
}
|
||||
$file = get_high_path($element_info);
|
||||
$file = get_element_path($element_info);
|
||||
break;
|
||||
case 'r':
|
||||
$file = original_to_representative( get_element_path($element_info), $element_info['representative_ext'] );
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -175,7 +169,7 @@ if (!isset($ctype))
|
||||
|
||||
$http_headers[] = 'Content-Type: '.$ctype;
|
||||
|
||||
if (!isset($_GET['view']))
|
||||
if (isset($_GET['download']))
|
||||
{
|
||||
$http_headers[] = 'Content-Disposition: attachment; filename="'.$element_info['file'].'";';
|
||||
$http_headers[] = 'Content-Transfer-Encoding: binary';
|
||||
|
||||
@@ -200,21 +200,12 @@ SELECT
|
||||
$files = array();
|
||||
$files[] = get_element_path($row);
|
||||
|
||||
if (!empty($row['tn_ext']))
|
||||
{
|
||||
$files[] = get_thumbnail_path($row);
|
||||
}
|
||||
|
||||
if (!empty($row['has_high']) and get_boolean($row['has_high']))
|
||||
{
|
||||
$files[] = get_high_path($row);
|
||||
}
|
||||
|
||||
|
||||
if (!empty($row['representative_ext']))
|
||||
{
|
||||
$pi = pathinfo($row['path']);
|
||||
$file_wo_ext = get_filename_wo_extension($pi['basename']);
|
||||
$files[] = PHPWG_ROOT_PATH.$pi['dirname'].'/pwg_representative/'.$file_wo_ext.'.'.$row['representative_ext'];
|
||||
$files[] = original_to_representative( $files[0], $row['representative_ext']);
|
||||
}
|
||||
|
||||
$ok = true;
|
||||
|
||||
@@ -303,14 +303,6 @@ $template->assign(
|
||||
)
|
||||
);
|
||||
|
||||
if ($row['has_high'] == 'true')
|
||||
{
|
||||
$template->assign(array(
|
||||
'HIGH_FILESIZE' => isset($row['high_filesize']) ? $row['high_filesize'].' KB' : l10n('unknown'),
|
||||
'HIGH_DIMENSIONS' => isset($row['high_width']) ? $row['high_width'].' * '.$row['high_height'] : l10n('unknown'),
|
||||
));
|
||||
}
|
||||
|
||||
// image level options
|
||||
$selected_level = isset($_POST['level']) ? $_POST['level'] : $row['level'];
|
||||
$template->assign(
|
||||
|
||||
@@ -66,18 +66,6 @@ pwg_initialization_datepicker("#date_creation_day", "#date_creation_month", "#da
|
||||
<td>{$FILESIZE}</td>
|
||||
</tr>
|
||||
|
||||
{if isset($HIGH_FILESIZE) }
|
||||
<tr>
|
||||
<td><strong>{'High dimensions'|@translate}</strong></td>
|
||||
<td>{$HIGH_DIMENSIONS}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><strong>{'High filesize'|@translate}</strong></td>
|
||||
<td>{$HIGH_FILESIZE}</td>
|
||||
</tr>
|
||||
{/if}
|
||||
|
||||
<tr>
|
||||
<td><strong>{'Storage album'|@translate}</strong></td>
|
||||
<td>{$STORAGE_CATEGORY}</td>
|
||||
|
||||
@@ -138,9 +138,8 @@ final class DerivativeImage
|
||||
return get_root_url().$rel_url;
|
||||
}
|
||||
|
||||
static function get_all($infos)
|
||||
static function get_all($src_image)
|
||||
{
|
||||
$src_image = new SrcImage($infos);
|
||||
$ret = array();
|
||||
foreach (ImageStdParams::get_defined_type_map() as $type => $params)
|
||||
{
|
||||
|
||||
@@ -740,6 +740,20 @@ function original_to_representative($path, $representative_ext)
|
||||
return substr_replace($path, $representative_ext, $pos+1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param element_info array containing element information from db;
|
||||
* at least 'id', 'path' should be present
|
||||
*/
|
||||
function get_element_path($element_info)
|
||||
{
|
||||
$path = $element_info['path'];
|
||||
if ( !url_is_remote($path) )
|
||||
{
|
||||
$path = PHPWG_ROOT_PATH.$path;
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
|
||||
/* Returns the PATH to the thumbnail to be displayed. If the element does not
|
||||
* have a thumbnail, the default mime image path is returned. The PATH can be
|
||||
|
||||
@@ -21,48 +21,6 @@
|
||||
// | USA. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
/**
|
||||
* @param element_info array containing element information from db;
|
||||
* at least 'id', 'path' should be present
|
||||
*/
|
||||
function get_element_path($element_info)
|
||||
{
|
||||
$path = get_element_location($element_info);
|
||||
if ( !url_is_remote($path) )
|
||||
{
|
||||
$path = PHPWG_ROOT_PATH.$path;
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
/*
|
||||
* @param element_info array containing element information from db;
|
||||
* at least 'id', 'path' should be present
|
||||
*/
|
||||
function get_element_url($element_info)
|
||||
{
|
||||
$url = get_element_location($element_info);
|
||||
if ( !url_is_remote($url) )
|
||||
{
|
||||
$url = embellish_url(get_root_url().$url);
|
||||
}
|
||||
// plugins want another url ?
|
||||
return trigger_event('get_element_url', $url, $element_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the relative path of the element with regards to to the root
|
||||
* of PWG (not the current page). This function is not intended to be
|
||||
* called directly from code.
|
||||
* @param element_info array containing element information from db;
|
||||
* at least 'id', 'path' should be present
|
||||
*/
|
||||
function get_element_location($element_info)
|
||||
{
|
||||
// maybe a cached watermark ?
|
||||
return trigger_event('get_element_location',
|
||||
$element_info['path'], $element_info);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@@ -83,100 +41,6 @@ function get_image_name($name, $filename)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the PATH to the image to be displayed in the picture page. If the
|
||||
* element is not a picture, then the representative image or the default
|
||||
* mime image. The path can be used in the php script, but not sent to the
|
||||
* browser.
|
||||
* @param element_info array containing element information from db;
|
||||
* at least 'id', 'path', 'representative_ext' should be present
|
||||
*/
|
||||
function get_image_path($element_info)
|
||||
{
|
||||
global $conf;
|
||||
$ext = get_extension($element_info['path']);
|
||||
if (in_array($ext, $conf['picture_ext']))
|
||||
{
|
||||
if (isset($element_info['element_path']) )
|
||||
{
|
||||
return $element_info['element_path'];
|
||||
}
|
||||
return get_element_path($element_info);
|
||||
}
|
||||
|
||||
$path = get_image_location($element_info);
|
||||
if ( !url_is_remote($path) )
|
||||
{
|
||||
$path = PHPWG_ROOT_PATH.$path;
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URL of the image to be displayed in the picture page. If the
|
||||
* element is not a picture, then the representative image or the default
|
||||
* mime image. The URL can't be used in the php script, but can be sent to the
|
||||
* browser.
|
||||
* @param element_info array containing element information from db;
|
||||
* at least 'id', 'path', 'representative_ext' should be present
|
||||
*/
|
||||
function get_image_url($element_info)
|
||||
{
|
||||
global $conf;
|
||||
$ext = get_extension($element_info['path']);
|
||||
if (in_array($ext, $conf['picture_ext']))
|
||||
{
|
||||
if (isset($element_info['element_url']) )
|
||||
{
|
||||
return $element_info['element_url'];
|
||||
}
|
||||
return get_element_url($element_info);
|
||||
}
|
||||
|
||||
$url = get_image_location($element_info);
|
||||
if ( !url_is_remote($url) )
|
||||
{
|
||||
$url = embellish_url(get_root_url().$url);
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the relative path of the image (element/representative/mimetype)
|
||||
* with regards to the root of PWG (not the current page). This function
|
||||
* is not intended to be called directly from code.
|
||||
* @param element_info array containing element information from db;
|
||||
* at least 'id', 'path', 'representative_ext' should be present
|
||||
*/
|
||||
function get_image_location($element_info)
|
||||
{
|
||||
if (isset($element_info['representative_ext'])
|
||||
and $element_info['representative_ext'] != '')
|
||||
{
|
||||
$pi = pathinfo($element_info['path']);
|
||||
$file_wo_ext = get_filename_wo_extension($pi['basename']);
|
||||
$path =
|
||||
$pi['dirname'].'/pwg_representative/'
|
||||
.$file_wo_ext.'.'.$element_info['representative_ext'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$ext = get_extension($element_info['path']);
|
||||
$path = get_themeconf('mime_icon_dir');
|
||||
$path.= strtolower($ext).'.png';
|
||||
if ( !file_exists(PHPWG_ROOT_PATH.$path)
|
||||
and !empty($element_info['tn_ext']) )
|
||||
{
|
||||
$path = get_thumbnail_location($element_info);
|
||||
}
|
||||
}
|
||||
|
||||
// plugins want another location ?
|
||||
return trigger_event( 'get_image_location', $path, $element_info);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @param element_info array containing element information from db;
|
||||
* at least 'id', 'path', 'has_high' should be present
|
||||
@@ -222,23 +86,6 @@ function get_high_location($element_info)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param what_part string one of 't' (thumbnail), 'e' (element), 'i' (image),
|
||||
* 'h' (high resolution image)
|
||||
* @param element_info array containing element information from db;
|
||||
* at least 'id', 'path' should be present
|
||||
*/
|
||||
function get_download_url($what_part, $element_info)
|
||||
{
|
||||
$url = get_root_url().'action.php';
|
||||
$url = add_url_params($url,
|
||||
array(
|
||||
'id' => $element_info['id'],
|
||||
'part' => $what_part,
|
||||
)
|
||||
);
|
||||
return trigger_event( 'get_download_url', $url, $element_info);
|
||||
}
|
||||
|
||||
/*
|
||||
* get slideshow default params into array
|
||||
|
||||
@@ -660,6 +660,40 @@ function parse_well_known_params_url($tokens, &$i)
|
||||
return $page;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param id image id
|
||||
* @param what_part string one of 'e' (element), 'r' (representative)
|
||||
*/
|
||||
function get_action_url($id, $what_part, $download)
|
||||
{
|
||||
$params = array(
|
||||
'id' => $id,
|
||||
'part' => $what_part,
|
||||
);
|
||||
if ($download)
|
||||
{
|
||||
$params['download'] = null;
|
||||
}
|
||||
|
||||
return add_url_params(get_root_url().'action.php', $params);
|
||||
}
|
||||
|
||||
/*
|
||||
* @param element_info array containing element information from db;
|
||||
* at least 'id', 'path' should be present
|
||||
*/
|
||||
function get_element_url($element_info)
|
||||
{
|
||||
$url = $element_info['path'];
|
||||
if ( !url_is_remote($url) )
|
||||
{
|
||||
$url = embellish_url(get_root_url().$url);
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Indicate to build url with full path
|
||||
*
|
||||
|
||||
@@ -147,13 +147,16 @@ function ws_std_image_sql_order( $params, $tbl_name='' )
|
||||
function ws_std_get_urls($image_row)
|
||||
{
|
||||
$ret = array();
|
||||
|
||||
$src_image = new SrcImage($image_row);
|
||||
|
||||
global $user;
|
||||
if ($user['enabled_high'])
|
||||
{
|
||||
$ret['element_url'] = get_element_url($image_row);
|
||||
}
|
||||
|
||||
$derivatives = DerivativeImage::get_all($image_row);
|
||||
$derivatives = DerivativeImage::get_all($src_image);
|
||||
$derivatives_arr = array();
|
||||
foreach($derivatives as $type=>$derivative)
|
||||
{
|
||||
|
||||
+19
-15
@@ -162,7 +162,8 @@ function default_picture_content($content, $element_info)
|
||||
$deriv_type = pwg_get_session_var('picture_deriv', IMG_LARGE);
|
||||
$selected_derivative = $element_info['derivatives'][$deriv_type];
|
||||
|
||||
$available_derivatives = array();
|
||||
$unique_derivatives = array();
|
||||
$show_original = isset($element_info['element_url']);
|
||||
$added = array();
|
||||
foreach($element_info['derivatives'] as $type => $derivative)
|
||||
{
|
||||
@@ -170,14 +171,20 @@ function default_picture_content($content, $element_info)
|
||||
if (isset($added[$url]))
|
||||
continue;
|
||||
$added[$url] = 1;
|
||||
$available_derivatives[] = $type;
|
||||
$show_original &= !($derivative->same_as_source());
|
||||
$unique_derivatives[$type]= $derivative;
|
||||
}
|
||||
|
||||
global $user, $page, $template;
|
||||
global $page, $template;
|
||||
|
||||
if ($show_original)
|
||||
{
|
||||
$template->assign( 'U_ORIGINAL', $element_info['element_url'] );
|
||||
}
|
||||
|
||||
$template->append('current', array(
|
||||
'selected_derivative' => $selected_derivative,
|
||||
'available_derivative_types' => $available_derivatives,
|
||||
'unique_derivatives' => $unique_derivatives,
|
||||
), true);
|
||||
|
||||
|
||||
@@ -491,27 +498,24 @@ while ($row = pwg_db_fetch_assoc($result))
|
||||
$i = 'current';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$row['derivatives'] = DerivativeImage::get_all($row);
|
||||
$row['src_image'] = $row['derivatives'][IMG_THUMB]->src_image;
|
||||
$row['src_image'] = new SrcImage($row);
|
||||
$row['derivatives'] = DerivativeImage::get_all($row['src_image']);
|
||||
|
||||
// ------ build element_path and element_url
|
||||
$row['element_path'] = get_element_path($row);
|
||||
$row['element_url'] = get_element_url($row);
|
||||
|
||||
if ($i=='current')
|
||||
{
|
||||
$row['element_path'] = get_element_path($row);
|
||||
|
||||
if ( $row['src_image']->is_original() )
|
||||
{
|
||||
{// we have a photo
|
||||
if ( $user['enabled_high']=='true' )
|
||||
{
|
||||
$row['download_url'] = get_download_url('e',$row);
|
||||
$row['element_url'] = $row['src_image']->get_url();
|
||||
$row['download_url'] = get_action_url($row['id'], 'e', true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // not a pic - need download link
|
||||
$row['download_url'] = $row['element_url'];
|
||||
$row['download_url'] = $row['element_url'] = get_element_url($row);;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{if isset($COMMENT_IMG)}
|
||||
title="{$COMMENT_IMG|@strip_tags:false|@replace:'"':' '}" {else} title="{$current.TITLE|@replace:'"':' '} - {$ALT_IMG}"
|
||||
{/if}>
|
||||
{if count($current.available_derivative_types)>1}
|
||||
{if count($current.unique_derivatives)>1}
|
||||
{footer_script}{literal}
|
||||
function changeImgSrc(url,type,display)
|
||||
{
|
||||
@@ -34,8 +34,11 @@ function toggleDerivativeSwitchBox()
|
||||
{/literal}{/footer_script}
|
||||
<a id="derivativeSwitchLink" onclick="toggleDerivativeSwitchBox()" style="cursor:pointer">{$current.selected_derivative->get_type()|@translate}</a>
|
||||
<div id="derivativeSwitchBox" onclick="toggleDerivativeSwitchBox()" style="display:none">
|
||||
{foreach from=$current.available_derivative_types item=derivative_type}
|
||||
<a onclick="changeImgSrc('{$current.derivatives[$derivative_type]->get_url()|@escape:javascript}', '{$derivative_type}', '{$derivative_type|@translate|@escape:javascript}')" style="cursor:pointer">{$derivative_type|@translate} ({$current.derivatives[$derivative_type]->get_size_hr()})</a><br>
|
||||
{foreach from=$current.unique_derivatives item=derivative key=derivative_type}
|
||||
<a href="javascript:changeImgSrc('{$derivative->get_url()|@escape:javascript}', '{$derivative_type}', '{$derivative->get_type()|@translate|@escape:javascript}')" style="cursor:pointer">{$derivative->get_type()|@translate} ({$derivative->get_size_hr()})</a><br>
|
||||
{/foreach}
|
||||
{if isset($U_ORIGINAL)}
|
||||
<a href="javascript:phpWGOpenWindow('{$U_ORIGINAL}','xxx','scrollbars=yes,toolbar=no,status=no,resizable=yes')" title="{'Click on the photo to see it in high definition'|@translate}">{'original'|@translate}</a>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
@@ -160,12 +160,6 @@ array(
|
||||
'vars' => array('string' => 'url', 'array' => 'element_info'),
|
||||
'files' => array('include\functions_picture.inc.php (get_download_url'),
|
||||
),
|
||||
array(
|
||||
'name' => 'get_element_location',
|
||||
'type' => 'trigger_event',
|
||||
'vars' => array('string' => 'path', 'array' => 'element_info'),
|
||||
'files' => array('include\functions_picture.inc.php (get_element_location)'),
|
||||
),
|
||||
array(
|
||||
'name' => 'get_element_metadata_available',
|
||||
'type' => 'trigger_event',
|
||||
|
||||
Reference in New Issue
Block a user