From 59a81b7e4a8a51b749647f91af56178a6fd075c6 Mon Sep 17 00:00:00 2001 From: Alex Barth <alex_b@53995.no-reply.drupal.org> Date: Fri, 17 Sep 2010 21:29:12 +0000 Subject: [PATCH] Use hook_taxonomy_term_N(), half ass change to term processor. --- feeds.module | 54 ++++++++++++++++++++++++++++++---- plugins/FeedsTermProcessor.inc | 2 +- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/feeds.module b/feeds.module index ecf5f9b6..db99305d 100644 --- a/feeds.module +++ b/feeds.module @@ -325,8 +325,8 @@ function feeds_feeds_plugins() { /** * Implements hook_node_load(). */ -function feeds_node_load($node) { - _feeds_node_processor_node_load($node); +function feeds_node_load($nodes) { + _feeds_node_processor_node_load($nodes); } /** @@ -424,9 +424,11 @@ function feeds_node_delete($node) { /** * FeedsNodeProcessor's hook_node_load(). */ -function _feeds_node_processor_node_load($node) { - if ($result = db_query("SELECT imported, guid, url, feed_nid FROM {feeds_node_item} WHERE nid = :nid", array(':nid' => $node->nid))->fetch()) { - $node->feeds_node_item = $result; +function _feeds_node_processor_node_load($nodes) { + if ($items = db_query("SELECT nid, imported, guid, url, feed_nid FROM {feeds_node_item} WHERE nid IN nids(:nids)", array(':nids' => array_keys($nodes)))) { + foreach ($items as $item) { + $node->{$item->nid} = $item; + } } } @@ -488,6 +490,48 @@ function feeds_taxonomy($op = NULL, $type = NULL, $term = NULL) { } } +/** + * Implements hook_taxonomy_term_update(). + */ +function feeds_taxonomy_term_update($term) { + if (isset($term->feeds_importer_id)) { + db_delete('feeds_term_item') + ->condition('tid', $term->tid) + ->execute(); + } +} + +/** + * Implements hook_taxonomy_term_insert(). + */ +function feeds_taxonomy_term_insert($term) { + if ($term->feeds_importer_id) { + $record = array( + 'id' => $term->feeds_importer_id, + 'tid' => $term->tid, + ); + drupal_write_record('feeds_term_item', $record); + } +} + +/** + * Implements hook_taxonomy_term_delete(). + */ +function feeds_taxonomy_term_delete($term) { + db_delete('feeds_term_item') + ->condition('tid', $term->tid) + ->execute(); +} + +/** + * Implements hook_taxonomy_delete(). + */ +function feeds_taxonomy_term_delete($term) { + db_delete('feeds_term_item') + ->condition('tid', $term->tid) + ->execute(); +} + /** * Implements hook_form_alter(). */ diff --git a/plugins/FeedsTermProcessor.inc b/plugins/FeedsTermProcessor.inc index 1ff82d7d..8bc9787e 100644 --- a/plugins/FeedsTermProcessor.inc +++ b/plugins/FeedsTermProcessor.inc @@ -47,7 +47,7 @@ class FeedsTermProcessor extends FeedsProcessor { } // Save the term. - $term['importer_id'] = $this->id; + $term['feeds_importer_id'] = $this->id; $term['feed_nid'] = $this->feed_nid; taxonomy_save_term($term); if ($tid) { -- GitLab