aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2015-12-30 16:08:54 +0100
committerplegall <plg@piwigo.org>2015-12-30 16:08:54 +0100
commit6ba0148e646b2a193dc4111bb0a443d8c193e646 (patch)
tree382ecd35afae3522d07377df332f0ecfee1f5045 /include
parentf28420acfeb5d69e9ea39cd8d00cf9775d6cea54 (diff)
parent7b653c04d6cfb20366c3bb0e183a521b3c9d22d2 (diff)
Merge branch 'feature/379-multiple-format'
Diffstat (limited to 'include')
-rw-r--r--include/config_default.inc.php7
-rw-r--r--include/constants.php2
-rw-r--r--include/functions.inc.php19
3 files changed, 27 insertions, 1 deletions
diff --git a/include/config_default.inc.php b/include/config_default.inc.php
index 60a3da323..eafb9d5a9 100644
--- a/include/config_default.inc.php
+++ b/include/config_default.inc.php
@@ -63,6 +63,13 @@ $conf['file_ext'] = array_merge(
array('tiff', 'tif', 'mpg','zip','avi','mp3','ogg','pdf')
);
+// enable_formats: should Piwigo search for multiple formats?
+$conf['enable_formats'] = false;
+
+// format_ext : file extensions for formats, ie additional versions of a
+// photo (or nay other file). Formats are in sub-directory pwg_format.
+$conf['format_ext'] = array('cr2', 'tif', 'tiff', 'nef', 'dng', 'ai', 'psd');
+
// top_number : number of element to display for "best rated" and "most
// visited" categories
$conf['top_number'] = 15;
diff --git a/include/constants.php b/include/constants.php
index 83d8747bc..ef321a4bc 100644
--- a/include/constants.php
+++ b/include/constants.php
@@ -105,5 +105,7 @@ if (!defined('THEMES_TABLE'))
define('THEMES_TABLE', $prefixeTable.'themes');
if (!defined('LANGUAGES_TABLE'))
define('LANGUAGES_TABLE', $prefixeTable.'languages');
+if (!defined('IMAGE_FORMAT_TABLE'))
+ define('IMAGE_FORMAT_TABLE', $prefixeTable.'image_format');
?>
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 60a1885e5..2119abe8f 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -407,7 +407,7 @@ SELECT id, name
* @param string $image_type
* @return bool
*/
-function pwg_log($image_id = null, $image_type = null)
+function pwg_log($image_id = null, $image_type = null, $format_id = null)
{
global $conf, $user, $page;
@@ -445,6 +445,7 @@ INSERT INTO '.HISTORY_TABLE.'
category_id,
image_id,
image_type,
+ format_id,
tag_ids
)
VALUES
@@ -457,6 +458,7 @@ INSERT INTO '.HISTORY_TABLE.'
'.(isset($page['category']['id']) ? $page['category']['id'] : 'NULL').',
'.(isset($image_id) ? $image_id : 'NULL').',
'.(isset($image_type) ? "'".$image_type."'" : 'NULL').',
+ '.(isset($format_id) ? $format_id : 'NULL').',
'.(isset($tags_string) ? "'".$tags_string."'" : 'NULL').'
)
;';
@@ -953,6 +955,21 @@ function original_to_representative($path, $representative_ext)
}
/**
+ * Transforms an original path to its format
+ *
+ * @param string $path
+ * @param string $format_ext
+ * @return string
+ */
+function original_to_format($path, $format_ext)
+{
+ $pos = strrpos($path, '/');
+ $path = substr_replace($path, 'pwg_format/', $pos+1, 0);
+ $pos = strrpos($path, '.');
+ return substr_replace($path, $format_ext, $pos+1);
+}
+
+/**
* get the full path of an image
*
* @param array $element_info element information from db (at least 'path')