Changeset 31097


Ignore:
Timestamp:
Apr 21, 2015, 2:07:14 PM (9 years ago)
Author:
plg
Message:

feature 2955: make the keywords separator configurable

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions_metadata.php

    r26946 r31097  
    6969  if (isset($iptc['keywords']))
    7070  {
    71     // official keywords separator is the comma
    72     $iptc['keywords'] = preg_replace('/[.;]/', ',', $iptc['keywords']);
    73     $iptc['keywords'] = preg_replace('/,+/', ',', $iptc['keywords']);
    74     $iptc['keywords'] = preg_replace('/^,+|,+$/', '', $iptc['keywords']);
    75 
    76     $iptc['keywords'] = implode(
    77       ',',
    78       array_unique(
    79         explode(
    80           ',',
    81           $iptc['keywords']
    82           )
    83         )
    84       );
     71    $iptc['keywords'] = metadata_normalize_keywords_string($iptc['keywords']);
    8572  }
    8673
     
    123110      }
    124111    }
     112
     113    if (in_array($pwg_key, array('keywords', 'tags')))
     114    {
     115      $exif[$pwg_key] = metadata_normalize_keywords_string($exif[$pwg_key]);
     116    }
     117   
    125118    $exif[$pwg_key] = addslashes($exif[$pwg_key]);
    126119  }
     
    352345}
    353346
     347/**
     348 * Returns the list of keywords (future tags) correctly separated with
     349 * commas. Other separators are converted into commas.
     350 *
     351 * @param string $keywords_string
     352 * @return string
     353 */
     354function metadata_normalize_keywords_string($keywords_string)
     355{
     356  global $conf;
     357 
     358  $keywords_string = preg_replace($conf['metadata_keyword_separator_regex'], ',', $keywords_string);
     359  $keywords_string = preg_replace('/,+/', ',', $keywords_string);
     360  $keywords_string = preg_replace('/^,+|,+$/', '', $keywords_string);
     361     
     362  $keywords_string = implode(
     363    ',',
     364    array_unique(
     365      explode(
     366        ',',
     367        $keywords_string
     368        )
     369      )
     370    );
     371
     372  return $keywords_string;
     373}
    354374?>
  • trunk/include/config_default.inc.php

    r29762 r31097  
    371371// javascript)
    372372$conf['allow_html_in_metadata'] = false;
     373
     374// decide which characters can be used as keyword separators (works in EXIF
     375// and IPTC). Coma "," cannot be removed from this list.
     376$conf['metadata_keyword_separator_regex'] = '/[.,;]/';
    373377
    374378// +-----------------------------------------------------------------------+
Note: See TracChangeset for help on using the changeset viewer.