mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-03-28 17:42:57 +01:00
feature #379 multiple format, step 2: download formats
* if formats are available, replace the download link on picture.php by a switchBox with all formats * register format in the history table for future statistics
This commit is contained in:
33
action.php
33
action.php
@@ -57,11 +57,34 @@ function do_error( $code, $str )
|
||||
exit();
|
||||
}
|
||||
|
||||
if (isset($_GET['format']))
|
||||
{
|
||||
check_input_parameter('format', $_GET, false, PATTERN_ID);
|
||||
|
||||
$query = '
|
||||
SELECT
|
||||
*
|
||||
FROM '.IMAGE_FORMAT_TABLE.'
|
||||
WHERE format_id = '.$_GET['format'].'
|
||||
;';
|
||||
$formats = query2array($query);
|
||||
|
||||
if (count($formats) == 0)
|
||||
{
|
||||
do_error(400, 'Invalid request - format');
|
||||
}
|
||||
|
||||
$format = $formats[0];
|
||||
|
||||
$_GET['id'] = $format['image_id'];
|
||||
$_GET['part'] = 'f'; // "f" for "format"
|
||||
}
|
||||
|
||||
|
||||
if (!isset($_GET['id'])
|
||||
or !is_numeric($_GET['id'])
|
||||
or !isset($_GET['part'])
|
||||
or !in_array($_GET['part'], array('e','r') ) )
|
||||
or !in_array($_GET['part'], array('e','r','f') ) )
|
||||
{
|
||||
do_error(400, 'Invalid request - id/part');
|
||||
}
|
||||
@@ -116,6 +139,10 @@ switch ($_GET['part'])
|
||||
case 'r':
|
||||
$file = original_to_representative( get_element_path($element_info), $element_info['representative_ext'] );
|
||||
break;
|
||||
case 'f' :
|
||||
$file = original_to_format(get_element_path($element_info), $format['ext']);
|
||||
$element_info['file'] = get_filename_wo_extension($element_info['file']).'.'.$format['ext'];
|
||||
break;
|
||||
}
|
||||
|
||||
if ( empty($file) )
|
||||
@@ -130,6 +157,10 @@ else if ($_GET['part'] == 'e')
|
||||
{
|
||||
pwg_log($_GET['id'], 'other');
|
||||
}
|
||||
else if ($_GET['part'] == 'f')
|
||||
{
|
||||
pwg_log($_GET['id'], 'high', $format['format_id']);
|
||||
}
|
||||
|
||||
$http_headers = array();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user