diff options
author | plegall <plg@piwigo.org> | 2015-04-21 12:07:14 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2015-04-21 12:07:14 +0000 |
commit | b3541bf16bc5efe665c0d64ddc5e18766d4ee2a6 (patch) | |
tree | c2b695ad6a9b9f059fa797a480b546c98ac0cd8b /admin/include/functions_metadata.php | |
parent | 796ac2f531600fdafa648ffd178056be3874c5dc (diff) |
feature 2955: make the keywords separator configurable
git-svn-id: http://piwigo.org/svn/trunk@31097 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin/include/functions_metadata.php')
-rw-r--r-- | admin/include/functions_metadata.php | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/admin/include/functions_metadata.php b/admin/include/functions_metadata.php index d969d06b1..da0703774 100644 --- a/admin/include/functions_metadata.php +++ b/admin/include/functions_metadata.php @@ -68,20 +68,7 @@ function get_sync_iptc_data($file) if (isset($iptc['keywords'])) { - // official keywords separator is the comma - $iptc['keywords'] = preg_replace('/[.;]/', ',', $iptc['keywords']); - $iptc['keywords'] = preg_replace('/,+/', ',', $iptc['keywords']); - $iptc['keywords'] = preg_replace('/^,+|,+$/', '', $iptc['keywords']); - - $iptc['keywords'] = implode( - ',', - array_unique( - explode( - ',', - $iptc['keywords'] - ) - ) - ); + $iptc['keywords'] = metadata_normalize_keywords_string($iptc['keywords']); } foreach ($iptc as $pwg_key => $value) @@ -122,6 +109,12 @@ function get_sync_exif_data($file) continue; } } + + if (in_array($pwg_key, array('keywords', 'tags'))) + { + $exif[$pwg_key] = metadata_normalize_keywords_string($exif[$pwg_key]); + } + $exif[$pwg_key] = addslashes($exif[$pwg_key]); } @@ -351,4 +344,31 @@ SELECT id, path, representative_ext return hash_from_query($query, 'id'); } +/** + * Returns the list of keywords (future tags) correctly separated with + * commas. Other separators are converted into commas. + * + * @param string $keywords_string + * @return string + */ +function metadata_normalize_keywords_string($keywords_string) +{ + global $conf; + + $keywords_string = preg_replace($conf['metadata_keyword_separator_regex'], ',', $keywords_string); + $keywords_string = preg_replace('/,+/', ',', $keywords_string); + $keywords_string = preg_replace('/^,+|,+$/', '', $keywords_string); + + $keywords_string = implode( + ',', + array_unique( + explode( + ',', + $keywords_string + ) + ) + ); + + return $keywords_string; +} ?>
\ No newline at end of file |