| 1 |
<?php
|
| 2 |
// $Id:$
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Taxonomy helper functions.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Helper function for retrieving vid.
|
| 11 |
*/
|
| 12 |
function _mtk_get_vid($vocabulary_name, $node_type) {
|
| 13 |
static $vocabularies;
|
| 14 |
if (isset($vocabularies[$vocabulary_name][$node_type])) {
|
| 15 |
return $vocabularies[$vocabulary_name][$node_type];
|
| 16 |
}
|
| 17 |
else if ($vid = db_result(db_query('SELECT v.vid FROM vocabulary v JOIN vocabulary_node_types vn ON vn.vid = v.vid WHERE v.name = "%s" AND vn.type = "%s"', $vocabulary_name, $node_type))) {
|
| 18 |
$vocabularies[$vocabulary_name][$node_type] = $vid;
|
| 19 |
return $vocabularies[$vocabulary_name][$node_type];
|
| 20 |
}
|
| 21 |
drupal_set_message(t('Error retrieving vocabulary id for !vname - vocabulary name changed?', array('!vname' => $vocabulary_name)), 'error');
|
| 22 |
return FALSE;
|
| 23 |
}
|
| 24 |
|
| 25 |
/**
|
| 26 |
* Clean taxonomy term tags.
|
| 27 |
*/
|
| 28 |
function _mtk_clean_tag($tag) {
|
| 29 |
$tag = str_replace(',', ' - ', $tag);
|
| 30 |
return str_replace(' ', ' ', $tag);
|
| 31 |
}
|