summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2006-01-10 12:35:20 +0000
committerDries Buytaert <dries@buytaert.net>2006-01-10 12:35:20 +0000
commit92acb92699bf2127569125689fc522f6edaf7c1c (patch)
tree23068980407a7142f3f34168301ee7a7bc24c869
parentf36b456c1a59564ae4ed1ec89ac28c07a1bb35df (diff)
downloadbrdo-92acb92699bf2127569125689fc522f6edaf7c1c.tar.gz
brdo-92acb92699bf2127569125689fc522f6edaf7c1c.tar.bz2
- Patch #33747 by Ber and Moshe: bugfix + code improvement: clean up some of the taxonomy loading code.
-rw-r--r--modules/blogapi.module5
-rw-r--r--modules/blogapi/blogapi.module5
-rw-r--r--modules/forum.module3
-rw-r--r--modules/forum/forum.module3
-rw-r--r--modules/taxonomy.module14
-rw-r--r--modules/taxonomy/taxonomy.module14
6 files changed, 12 insertions, 32 deletions
diff --git a/modules/blogapi.module b/modules/blogapi.module
index 8fa29326e..ce7edce8d 100644
--- a/modules/blogapi.module
+++ b/modules/blogapi.module
@@ -274,11 +274,6 @@ function blogapi_blogger_edit_post($appkey, $postid, $username, $password, $cont
return blogapi_error(implode("\n", $errors));
}
- $terms = module_invoke('taxonomy', 'node_get_terms', $node->nid, 'tid');
- foreach ($terms as $term) {
- $node->taxonomy[] = $term->tid;
- }
-
$node = node_submit($node);
node_save($node);
if ($node->nid) {
diff --git a/modules/blogapi/blogapi.module b/modules/blogapi/blogapi.module
index 8fa29326e..ce7edce8d 100644
--- a/modules/blogapi/blogapi.module
+++ b/modules/blogapi/blogapi.module
@@ -274,11 +274,6 @@ function blogapi_blogger_edit_post($appkey, $postid, $username, $password, $cont
return blogapi_error(implode("\n", $errors));
}
- $terms = module_invoke('taxonomy', 'node_get_terms', $node->nid, 'tid');
- foreach ($terms as $term) {
- $node->taxonomy[] = $term->tid;
- }
-
$node = node_submit($node);
node_save($node);
if ($node->nid) {
diff --git a/modules/forum.module b/modules/forum.module
index 0b2aba5c1..b73d85cc8 100644
--- a/modules/forum.module
+++ b/modules/forum.module
@@ -535,8 +535,7 @@ function forum_submit(&$node) {
}
}
if ($node->tid && $node->shadow) {
- $terms = array_keys(taxonomy_node_get_terms($node->nid));
- if (!in_array($node->tid, $terms)) {
+ if (!in_array($node->tid, $node->taxonomy)) {
$terms[] = $node->tid;
}
$node->taxonomy = $terms;
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index 0b2aba5c1..b73d85cc8 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -535,8 +535,7 @@ function forum_submit(&$node) {
}
}
if ($node->tid && $node->shadow) {
- $terms = array_keys(taxonomy_node_get_terms($node->nid));
- if (!in_array($node->tid, $terms)) {
+ if (!in_array($node->tid, $node->taxonomy)) {
$terms[] = $node->tid;
}
$node->taxonomy = $terms;
diff --git a/modules/taxonomy.module b/modules/taxonomy.module
index f56fa8338..de8b86404 100644
--- a/modules/taxonomy.module
+++ b/modules/taxonomy.module
@@ -28,13 +28,7 @@ function taxonomy_link($type, $node = NULL) {
if ($type == 'taxonomy terms' && $node != NULL) {
$links = array();
if (array_key_exists('taxonomy', $node)) {
- foreach ($node->taxonomy as $tid) {
- $term = taxonomy_get_term($tid);
- $links[] = l($term->name, taxonomy_term_path($term), array('rel' => 'tag', 'title' => $term->description));
- }
- }
- else {
- foreach (taxonomy_node_get_terms($node->nid) as $term) {
+ foreach ($node->taxonomy as $term) {
$links[] = l($term->name, taxonomy_term_path($term), array('rel' => 'tag', 'title' => $term->description));
}
}
@@ -1009,6 +1003,9 @@ function taxonomy_render_nodes($result) {
*/
function taxonomy_nodeapi($node, $op, $arg = 0) {
switch ($op) {
+ case 'load':
+ $output['taxonomy'] = taxonomy_node_get_terms($node->nid);
+ return $output;
case 'insert':
taxonomy_node_save($node->nid, $node->taxonomy);
break;
@@ -1184,8 +1181,7 @@ function taxonomy_admin() {
*/
function taxonomy_rss_item($node) {
$output = array();
- $terms = taxonomy_node_get_terms($node->nid);
- foreach ($terms as $term) {
+ foreach ($node->taxonomy as $term) {
$output[] = array('key' => 'category',
'value' => check_plain($term->name),
'attributes' => array('domain' => url('taxonomy/term/'. $term->tid, NULL, NULL, TRUE)));
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index f56fa8338..de8b86404 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -28,13 +28,7 @@ function taxonomy_link($type, $node = NULL) {
if ($type == 'taxonomy terms' && $node != NULL) {
$links = array();
if (array_key_exists('taxonomy', $node)) {
- foreach ($node->taxonomy as $tid) {
- $term = taxonomy_get_term($tid);
- $links[] = l($term->name, taxonomy_term_path($term), array('rel' => 'tag', 'title' => $term->description));
- }
- }
- else {
- foreach (taxonomy_node_get_terms($node->nid) as $term) {
+ foreach ($node->taxonomy as $term) {
$links[] = l($term->name, taxonomy_term_path($term), array('rel' => 'tag', 'title' => $term->description));
}
}
@@ -1009,6 +1003,9 @@ function taxonomy_render_nodes($result) {
*/
function taxonomy_nodeapi($node, $op, $arg = 0) {
switch ($op) {
+ case 'load':
+ $output['taxonomy'] = taxonomy_node_get_terms($node->nid);
+ return $output;
case 'insert':
taxonomy_node_save($node->nid, $node->taxonomy);
break;
@@ -1184,8 +1181,7 @@ function taxonomy_admin() {
*/
function taxonomy_rss_item($node) {
$output = array();
- $terms = taxonomy_node_get_terms($node->nid);
- foreach ($terms as $term) {
+ foreach ($node->taxonomy as $term) {
$output[] = array('key' => 'category',
'value' => check_plain($term->name),
'attributes' => array('domain' => url('taxonomy/term/'. $term->tid, NULL, NULL, TRUE)));