public function FeedsNodeProcessor::clear in Feeds 6
Same name and namespace in other branches
- 7 plugins/FeedsNodeProcessor.inc \FeedsNodeProcessor::clear()
Implementation of FeedsProcessor::clear().
Overrides FeedsProcessor::clear
File
- plugins/
FeedsNodeProcessor.inc, line 100 - Class definition of FeedsNodeProcessor.
Class
- FeedsNodeProcessor
- Creates nodes from feed items.
Code
public function clear(FeedsBatch $batch, FeedsSource $source) {
if (!$batch
->getTotal(FEEDS_CLEARING)) {
$total = db_result(db_query("SELECT COUNT(nid) FROM {feeds_node_item} WHERE id = '%s' AND feed_nid = %d", $source->id, $source->feed_nid));
$batch
->setTotal(FEEDS_CLEARING, $total);
}
$result = db_query_range("SELECT nid FROM {feeds_node_item} WHERE id = '%s' AND feed_nid = %d", $source->id, $source->feed_nid, 0, variable_get('feeds_node_batch_size', FEEDS_NODE_BATCH_SIZE));
while ($node = db_fetch_object($result)) {
_feeds_node_delete($node->nid);
$batch->deleted++;
}
if (db_result(db_query_range("SELECT nid FROM {feeds_node_item} WHERE id = '%s' AND feed_nid = %d", $source->id, $source->feed_nid, 0, 1))) {
$batch
->setProgress(FEEDS_CLEARING, $batch->deleted);
return;
}
// Set message.
drupal_get_messages('status');
if ($batch->deleted) {
drupal_set_message(format_plural($batch->deleted, 'Deleted @number node.', 'Deleted @number nodes.', array(
'@number' => $batch->deleted,
)));
}
else {
drupal_set_message(t('There is no content to be deleted.'));
}
$batch
->setProgress(FEEDS_CLEARING, FEEDS_BATCH_COMPLETE);
}