diff options
-rw-r--r-- | modules/forum.module | 4 | ||||
-rw-r--r-- | modules/forum/forum.module | 4 | ||||
-rw-r--r-- | modules/taxonomy.module | 32 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.module | 32 |
4 files changed, 52 insertions, 20 deletions
diff --git a/modules/forum.module b/modules/forum.module index 07232f441..69e96621d 100644 --- a/modules/forum.module +++ b/modules/forum.module @@ -434,6 +434,10 @@ function forum_link($type, $node = 0, $main = 0) { return $links; } +function forum_term_path($term) { + return 'forum/'. $term->tid; +} + /** * Implementation of hook_menu(). */ diff --git a/modules/forum/forum.module b/modules/forum/forum.module index 07232f441..69e96621d 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -434,6 +434,10 @@ function forum_link($type, $node = 0, $main = 0) { return $links; } +function forum_term_path($term) { + return 'forum/'. $term->tid; +} + /** * Implementation of hook_menu(). */ diff --git a/modules/taxonomy.module b/modules/taxonomy.module index 7d5808ceb..d4c4431ff 100644 --- a/modules/taxonomy.module +++ b/modules/taxonomy.module @@ -30,18 +30,26 @@ function taxonomy_link($type, $node = NULL) { if (array_key_exists('taxonomy', $node)) { foreach ($node->taxonomy as $tid) { $term = taxonomy_get_term($tid); - $links[] = l($term->name, 'taxonomy/term/'. $term->tid); + $links[] = l($term->name, taxonomy_term_path($term)); } } else { foreach (taxonomy_node_get_terms($node->nid) as $term) { - $links[] = l($term->name, 'taxonomy/term/'. $term->tid); + $links[] = l($term->name, taxonomy_term_path($term)); } } return $links; } } +function taxonomy_term_path($term) { + $vocabulary = taxonomy_get_vocabulary($term->vid); + if ($vocabulary->module != 'taxonomy' && $path = module_invoke($vocabulary->module, 'term_path', $term)) { + return $path; + } + return 'taxonomy/term/'. $term->tid; +} + /** * Implementation of hook_menu(). */ @@ -866,16 +874,20 @@ function taxonomy_get_term_by_name($name) { * Return the vocabulary object matching a vocabulary ID. */ function taxonomy_get_vocabulary($vid) { - $result = db_query('SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE v.vid = %d ORDER BY v.weight, v.name', $vid); - $node_types = array(); - while ($voc = db_fetch_object($result)) { - $node_types[] = $voc->type; - unset($voc->type); - $voc->nodes = $node_types; - $vocabulary = $voc; + static $vocabularies = array(); + + if (!array_key_exists($vid, $vocabularies)) { + $result = db_query('SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE v.vid = %d ORDER BY v.weight, v.name', $vid); + $node_types = array(); + while ($voc = db_fetch_object($result)) { + $node_types[] = $voc->type; + unset($voc->type); + $voc->nodes = $node_types; + $vocabularies[$vid] = $voc; + } } - return $vocabulary; + return $vocabularies[$vid]; } /** diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 7d5808ceb..d4c4431ff 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -30,18 +30,26 @@ function taxonomy_link($type, $node = NULL) { if (array_key_exists('taxonomy', $node)) { foreach ($node->taxonomy as $tid) { $term = taxonomy_get_term($tid); - $links[] = l($term->name, 'taxonomy/term/'. $term->tid); + $links[] = l($term->name, taxonomy_term_path($term)); } } else { foreach (taxonomy_node_get_terms($node->nid) as $term) { - $links[] = l($term->name, 'taxonomy/term/'. $term->tid); + $links[] = l($term->name, taxonomy_term_path($term)); } } return $links; } } +function taxonomy_term_path($term) { + $vocabulary = taxonomy_get_vocabulary($term->vid); + if ($vocabulary->module != 'taxonomy' && $path = module_invoke($vocabulary->module, 'term_path', $term)) { + return $path; + } + return 'taxonomy/term/'. $term->tid; +} + /** * Implementation of hook_menu(). */ @@ -866,16 +874,20 @@ function taxonomy_get_term_by_name($name) { * Return the vocabulary object matching a vocabulary ID. */ function taxonomy_get_vocabulary($vid) { - $result = db_query('SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE v.vid = %d ORDER BY v.weight, v.name', $vid); - $node_types = array(); - while ($voc = db_fetch_object($result)) { - $node_types[] = $voc->type; - unset($voc->type); - $voc->nodes = $node_types; - $vocabulary = $voc; + static $vocabularies = array(); + + if (!array_key_exists($vid, $vocabularies)) { + $result = db_query('SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE v.vid = %d ORDER BY v.weight, v.name', $vid); + $node_types = array(); + while ($voc = db_fetch_object($result)) { + $node_types[] = $voc->type; + unset($voc->type); + $voc->nodes = $node_types; + $vocabularies[$vid] = $voc; + } } - return $vocabulary; + return $vocabularies[$vid]; } /** |