diff options
author | plegall <plg@piwigo.org> | 2015-12-07 10:54:18 +0100 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2015-12-07 10:54:18 +0100 |
commit | c3b748ecbfd1a359f6e95e7fd691ac5c11c3c4de (patch) | |
tree | cd8710c9a1684fde5616f9332b8a4a90ce09348f /action.php | |
parent | 8e098d502a8f0e413b9c085db27d6a62a6c0909f (diff) |
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
Diffstat (limited to 'action.php')
-rw-r--r-- | action.php | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/action.php b/action.php index 4b92e056c..de326e8b6 100644 --- a/action.php +++ b/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(); |