function biblio_explode_keywords in Bibliography Module 6.2
Same name and namespace in other branches
- 6 biblio.keywords.inc \biblio_explode_keywords()
- 7 includes/biblio.keywords.inc \biblio_explode_keywords()
- 7.2 includes/biblio.keywords.inc \biblio_explode_keywords()
Parameters
$string:
$sep: (optional)
Return value
none
4 calls to biblio_explode_keywords()
- BiblioKeywordUnitTest::testBiblioExplodeKeywords in tests/
keyword.test - biblio_form_validate in ./
biblio.module - Implementation of hook_validate().
- biblio_insert_keywords in includes/
biblio.keywords.inc - _biblio_keyword_links in includes/
biblio.pages.inc - Creates an HTML string with links to an array of biblio keywords.
File
- includes/
biblio.keywords.inc, line 317 - Keywords related functions for Drupal biblio module.
Code
function biblio_explode_keywords($string, $sep = NULL) {
if (!$sep) {
$sep = check_plain(variable_get('biblio_keyword_sep', ','));
}
$regexp = '%(?:^|' . $sep . '\\ *)("(?>[^"]*)(?>""[^"]* )*"|(?: [^"' . $sep . ']*))%x';
preg_match_all($regexp, $string, $matches);
$keyword_array = array_unique($matches[1]);
$keywords = array();
foreach ($keyword_array as $keyword) {
// If a user has escaped a term (to demonstrate that it is a group,
// or includes a comma or quote character), we remove the escape
// formatting so to save the term into the database as the user intends.
$keyword = trim(str_replace('""', '"', preg_replace('/^"(.*)"$/', '\\1', $keyword)));
if ($keyword != "") {
$keywords[] = $keyword;
}
}
return $keywords;
}