function biblio_explode_keywords in Bibliography Module 7
Same name and namespace in other branches
- 6.2 includes/biblio.keywords.inc \biblio_explode_keywords()
- 6 biblio.keywords.inc \biblio_explode_keywords()
- 7.2 includes/biblio.keywords.inc \biblio_explode_keywords()
Parameters
string $string:
Return value
array
4 calls to biblio_explode_keywords()
- BiblioKeywordWebTestCase::testBiblioExplodeKeywords in tests/
BiblioKeywordWebTestCase.test - biblio_insert_keywords in includes/
biblio.keywords.inc - Insert keywords into the database.
- biblio_node_form_validate in ./
biblio.module - Implements hook_validate().
- _biblio_keyword_links in includes/
biblio_theme.inc
File
- includes/
biblio.keywords.inc, line 426 - Contains all keyword related functions.
Code
function biblio_explode_keywords($string) {
$sep = 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;
}