function taxonomy_patterns_prepare in Patterns 7.2
Same name and namespace in other branches
- 7 patterns_components/components/taxonomy.inc \taxonomy_patterns_prepare()
File
- patterns_components/
components/ taxonomy.inc, line 94 - Patterns component for taxonomy vocabularies and terms.
Code
function taxonomy_patterns_prepare($action, $tag, &$data) {
// dirty fix for the int <-> string problem
if (isset($data['name'])) {
$data['name'] = strval($data['name']);
}
if (isset($data['machine_name'])) {
$data['machine_name'] = '' . $data['machine_name'];
}
if (isset($data['old_machine_name'])) {
$data['old_machine_name'] = '' . $data['old_machine_name'];
}
if (isset($data['descr'])) {
$data['description'] = $data['descr'];
unset($data['descr']);
}
// VOCABULARY
if ($tag == 'vocabulary') {
if ($action == PATTERNS_DELETE) {
$data = _taxonomy_patterns_prepare_vocabulary_delete($action, $data);
}
else {
// Create or Modify
$data = _taxonomy_patterns_prepare_vocabulary($action, $data);
}
}
elseif ($tag == 'term') {
$data = _taxonomy_patterns_prepare_term($action, $data);
}
elseif ($tag == 'terms') {
// Get the vid first, so that we do not re-request always
if (isset($data['vid'])) {
$vid = $data['vid'];
}
elseif (isset($data['vocabulary'])) {
$taxo = taxonomy_vocabulary_machine_name_load($data['vocabulary']);
$vid = $taxo->vid;
}
if (isset($vid)) {
foreach ($data as $term) {
$terms[] = _taxonomy_patterns_prepare_term($data, $vid);
}
}
}
// End vocabulary,term,terms
return patterns_results();
}