From 83f267dc95eddb11e32e3e51984589615872c84a Mon Sep 17 00:00:00 2001 From: plegall Date: Mon, 6 Oct 2014 09:28:37 +0000 Subject: merge r29901 from trunk to branch 2.7 bug 3156 fixed: avoid warning on PHP 5.2 for nl2br second parameter git-svn-id: http://piwigo.org/svn/branches/2.7@29902 68402e56-0260-453c-a942-63ccdbb3a9ee --- picture.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'picture.php') diff --git a/picture.php b/picture.php index a0eadf3e8..94c2b3ea3 100644 --- a/picture.php +++ b/picture.php @@ -137,7 +137,17 @@ if ( isset($_GET['metadata']) ) // add default event handler for rendering element content add_event_handler('render_element_content', 'default_picture_content'); // add default event handler for rendering element description -add_event_handler('render_element_description', 'nl2br'); +add_event_handler('render_element_description', 'pwg_nl2br'); + +/** + * pwg_nl2br is useful for PHP 5.2 which doesn't accept more than 1 + * parameter on nl2br() (and anyway the second parameter of nl2br does not + * match what Piwigo gives. + */ +function pwg_nl2br($string) +{ + return nl2br($string); +} trigger_notify('loc_begin_picture'); -- cgit v1.2.3 From c3b748ecbfd1a359f6e95e7fd691ac5c11c3c4de Mon Sep 17 00:00:00 2001 From: plegall Date: Mon, 7 Dec 2015 10:54:18 +0100 Subject: 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 --- picture.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'picture.php') diff --git a/picture.php b/picture.php index 94c2b3ea3..a6c6defb7 100644 --- a/picture.php +++ b/picture.php @@ -662,6 +662,26 @@ foreach (array('first','previous','next','last', 'current') as $which_image) if ($conf['picture_download_icon'] and !empty($picture['current']['download_url'])) { $template->append('current', array('U_DOWNLOAD' => $picture['current']['download_url']), true); + + $query = ' +SELECT * + FROM '.IMAGE_FORMAT_TABLE.' + WHERE image_id = '.$picture['current']['id'].' +;'; + $formats = query2array($query); + + if (!empty($formats)) + { + foreach ($formats as &$format) + { + $format['download_url'] = 'action.php?format='.$format['format_id']; + $format['download_url'].= '&download='.substr(md5(time()), 0, 6); // a random string to avoid browser cache + + $format['filesize'] = sprintf('%.1fMB', $format['filesize']/1024); + } + } + + $template->append('current', array('formats' => $formats), true); } -- cgit v1.2.3 From 0f8d85491f656440e7cc66ecca70f7af8dff0022 Mon Sep 17 00:00:00 2001 From: plegall Date: Thu, 17 Dec 2015 14:08:53 +0100 Subject: feature #379, multiple format, hide formats when disabled --- picture.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'picture.php') diff --git a/picture.php b/picture.php index a6c6defb7..f2dfecf0e 100644 --- a/picture.php +++ b/picture.php @@ -663,25 +663,28 @@ if ($conf['picture_download_icon'] and !empty($picture['current']['download_url' { $template->append('current', array('U_DOWNLOAD' => $picture['current']['download_url']), true); - $query = ' + if ($conf['enable_formats']) + { + $query = ' SELECT * FROM '.IMAGE_FORMAT_TABLE.' WHERE image_id = '.$picture['current']['id'].' ;'; - $formats = query2array($query); + $formats = query2array($query); - if (!empty($formats)) - { - foreach ($formats as &$format) + if (!empty($formats)) { - $format['download_url'] = 'action.php?format='.$format['format_id']; - $format['download_url'].= '&download='.substr(md5(time()), 0, 6); // a random string to avoid browser cache - - $format['filesize'] = sprintf('%.1fMB', $format['filesize']/1024); + foreach ($formats as &$format) + { + $format['download_url'] = 'action.php?format='.$format['format_id']; + $format['download_url'].= '&download='.substr(md5(time()), 0, 6); // a random string to avoid browser cache + + $format['filesize'] = sprintf('%.1fMB', $format['filesize']/1024); + } } - } - $template->append('current', array('formats' => $formats), true); + $template->append('current', array('formats' => $formats), true); + } } -- cgit v1.2.3 From 89bc74b3f30e169ab51e5b2728767f02a94a991c Mon Sep 17 00:00:00 2001 From: plegall Date: Sun, 20 Dec 2015 15:44:01 +0100 Subject: feature #379, multiple format, labels Ability to customize, with $lang['format CR2'] = 'RAW Canon' (in LocalFiles Editor) for example --- picture.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'picture.php') diff --git a/picture.php b/picture.php index f2dfecf0e..093e4b271 100644 --- a/picture.php +++ b/picture.php @@ -679,6 +679,13 @@ SELECT * $format['download_url'] = 'action.php?format='.$format['format_id']; $format['download_url'].= '&download='.substr(md5(time()), 0, 6); // a random string to avoid browser cache + $format['label'] = strtoupper($format['ext']); + $lang_key = 'format '.strtoupper($format['ext']); + if (isset($lang[$lang_key])) + { + $format['label'] = $lang[$lang_key]; + } + $format['filesize'] = sprintf('%.1fMB', $format['filesize']/1024); } } -- cgit v1.2.3 From 11f37b24b48ed9307ecdb2ac19f5809876d9227a Mon Sep 17 00:00:00 2001 From: plegall Date: Sun, 20 Dec 2015 17:49:12 +0100 Subject: feature #379, multiple format, no browser cache No need random string in URL to avoid browser cache, coding tip by @modus75 --- picture.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'picture.php') diff --git a/picture.php b/picture.php index 093e4b271..75b7cdaf2 100644 --- a/picture.php +++ b/picture.php @@ -677,7 +677,7 @@ SELECT * foreach ($formats as &$format) { $format['download_url'] = 'action.php?format='.$format['format_id']; - $format['download_url'].= '&download='.substr(md5(time()), 0, 6); // a random string to avoid browser cache + $format['download_url'].= '&download'; $format['label'] = strtoupper($format['ext']); $lang_key = 'format '.strtoupper($format['ext']); -- cgit v1.2.3 From e439de1612eb471571c5a1503fba7f6531a90c08 Mon Sep 17 00:00:00 2001 From: plegall Date: Tue, 22 Dec 2015 19:04:00 +0100 Subject: feature #379, multiple format, consider the original as a format --- picture.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'picture.php') diff --git a/picture.php b/picture.php index 75b7cdaf2..d88e6e262 100644 --- a/picture.php +++ b/picture.php @@ -674,10 +674,23 @@ SELECT * if (!empty($formats)) { + // let's add the original as a format among others. It will just have + // a specific download URL + array_unshift( + $formats, + array( + 'download_url' => $picture['current']['download_url'], + 'ext' => get_extension($picture['current']['file']), + 'filesize' => $picture['current']['filesize'], + ) + ); + foreach ($formats as &$format) { - $format['download_url'] = 'action.php?format='.$format['format_id']; - $format['download_url'].= '&download'; + if (!isset($format['download_url'])) + { + $format['download_url'] = 'action.php?format='.$format['format_id'].'&download'; + } $format['label'] = strtoupper($format['ext']); $lang_key = 'format '.strtoupper($format['ext']); -- cgit v1.2.3 From 7b653c04d6cfb20366c3bb0e183a521b3c9d22d2 Mon Sep 17 00:00:00 2001 From: plegall Date: Wed, 30 Dec 2015 16:04:32 +0100 Subject: feature #379, multiple format, download original as format If multiple format feature is enabled, always put the original file in the formats list. --- picture.php | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) (limited to 'picture.php') diff --git a/picture.php b/picture.php index d88e6e262..d993fe3f2 100644 --- a/picture.php +++ b/picture.php @@ -671,36 +671,33 @@ SELECT * WHERE image_id = '.$picture['current']['id'].' ;'; $formats = query2array($query); + + // let's add the original as a format among others. It will just have a + // specific download URL + array_unshift( + $formats, + array( + 'download_url' => $picture['current']['download_url'], + 'ext' => get_extension($picture['current']['file']), + 'filesize' => $picture['current']['filesize'], + ) + ); - if (!empty($formats)) + foreach ($formats as &$format) { - // let's add the original as a format among others. It will just have - // a specific download URL - array_unshift( - $formats, - array( - 'download_url' => $picture['current']['download_url'], - 'ext' => get_extension($picture['current']['file']), - 'filesize' => $picture['current']['filesize'], - ) - ); + if (!isset($format['download_url'])) + { + $format['download_url'] = 'action.php?format='.$format['format_id'].'&download'; + } - foreach ($formats as &$format) + $format['label'] = strtoupper($format['ext']); + $lang_key = 'format '.strtoupper($format['ext']); + if (isset($lang[$lang_key])) { - if (!isset($format['download_url'])) - { - $format['download_url'] = 'action.php?format='.$format['format_id'].'&download'; - } - - $format['label'] = strtoupper($format['ext']); - $lang_key = 'format '.strtoupper($format['ext']); - if (isset($lang[$lang_key])) - { - $format['label'] = $lang[$lang_key]; - } - - $format['filesize'] = sprintf('%.1fMB', $format['filesize']/1024); + $format['label'] = $lang[$lang_key]; } + + $format['filesize'] = sprintf('%.1fMB', $format['filesize']/1024); } $template->append('current', array('formats' => $formats), true); -- cgit v1.2.3 From c789347c514e89b32c9ceefa0a9c9ac819cbc677 Mon Sep 17 00:00:00 2001 From: plegall Date: Thu, 14 Jan 2016 12:17:58 +0100 Subject: happy new year 2016, all headers updated --- picture.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'picture.php') diff --git a/picture.php b/picture.php index d993fe3f2..db58c12e7 100644 --- a/picture.php +++ b/picture.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2016 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 | // +-----------------------------------------------------------------------+ -- cgit v1.2.3