Index: feedaggregator_node.module =================================================================== --- feedaggregator_node.module (revision 980) +++ feedaggregator_node.module (working copy) @@ -9,8 +9,6 @@ function feedaggregator_node_help($section){ switch($section){ - case 'node/add#aggregator-item': - return t('A news item.'); case "admin/modules#description": return t('Feed Processor: Creates nodes from feed items'); } @@ -18,7 +16,13 @@ function feedaggregator_node_node_info() { - return array('aggregator-item' => array('name' => t('aggregator item'), 'base' => 'feedaggregator_node')); + return array( + 'aggregator-item' => array( + 'name' => t('aggregator item'), + 'module' => 'feedaggregator_node', + 'description' => t('A aggregator item is a post that was imported via RSS.'), + ) + ); } @@ -134,11 +138,11 @@ function feedaggregator_node_parsername() { - return array('aggregator-item'); + return array('aggregator-item'); } function feedaggregator_get_vocabulary() { - return db_result(db_query("SELECT v.vid FROM {vocabulary} v INNER JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE n.type = '%s' ORDER BY v.weight, v.name", 'aggregator-item')); + return db_result(db_query("SELECT v.vid FROM {vocabulary} v INNER JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE n.type = '%s' ORDER BY v.weight, v.name", 'aggregator-item')); } function feedaggregator_node_feedapi($feed, $op, $item = NULL) { @@ -146,8 +150,8 @@ static $cat_names = array(); switch($op) { - case 'processor_name': - return array('feedaggregator_node' => t('Nodes')); + case 'processor_name': + return array('feedaggregator_node' => t('Nodes')); case 'item_count': $total_items = db_result(db_query('SELECT COUNT(an.nid) FROM {node} n JOIN {aggregator_node} an ON n.nid = an.nid WHERE an.fid = %d AND n.status = 1', $feed['fid'])); @@ -158,110 +162,111 @@ $node['link'] = $item->get_link(); - // Check if the item already exists - $duplicate = db_fetch_array(db_query("SELECT nid FROM {aggregator_node} WHERE link = '%s'", $node['link'])); - if($duplicate) { - $old_node = (array)node_load(array('nid' => $duplicate['nid'])); + // Check if the item already exists + $duplicate = db_fetch_array(db_query("SELECT nid FROM {aggregator_node} WHERE link = '%s'", $node['link'])); + if($duplicate) { + $old_node = (array)node_load(array('nid' => $duplicate['nid'])); - // Should this feed honor updating of existing items? - if(!$feed['update_items'] || ( - strcasecmp($old_node['body'], $item->get_description()) == 0 - && strcasecmp($old_node['title'], $item->get_title()) == 0 - && strcasecmp($old_node['link'], $item->get_link()) == 0 - )) { - return FALSE; - } + // Should this feed honor updating of existing items? + if(!$feed['update_items'] || ( + strcasecmp($old_node['body'], $item->get_description()) == 0 + && strcasecmp($old_node['title'], $item->get_title()) == 0 + && strcasecmp($old_node['link'], $item->get_link()) == 0 + )) { + return FALSE; + } - $node['nid'] = $old_node['nid']; - $node['created'] = $old_node['created']; - } else { - // Set nodes default options - $options = variable_get('node_options_aggregator-item', array('status', 'promote')); - foreach($options as $option) { - $node[$option] = 1; - } + $node['nid'] = $old_node['nid']; + $node['created'] = $old_node['created']; + } + else { + // Set nodes default options + $options = variable_get('node_options_aggregator-item', array('status', 'promote')); + foreach($options as $option) { + $node[$option] = 1; + } - $item_time = $item->get_date('U'); - $node['created'] = $item_time ? $item_time : time(); + $item_time = $item->get_date('U'); + $node['created'] = $item_time ? $item_time : time(); $node['date'] = format_date($node['created'], 'custom', 'Y-m-d H:i:s O'); - } + } $title = $item->get_title(); $node += array( - 'type' => 'aggregator-item', - 'changed' => time(), - 'comment' => variable_get('comment_aggregator-item', 2), - 'title' => parse_entities($title), - 'teaser' => $item->get_description() ? node_teaser($item->get_description(), $feed['format']) : '', - 'body' => $item->get_description(), - 'fid' => $feed['fid'], - 'iid' => $item->data['iid'], - 'taxonomy' => $feed['taxonomy'], - 'format' => $feed['format'] - ); + 'type' => 'aggregator-item', + 'changed' => time(), + 'comment' => variable_get('comment_aggregator-item', 2), + 'title' => parse_entities($title), + 'teaser' => $item->get_description() ? node_teaser($item->get_description(), $feed['format']) : '', + 'body' => $item->get_description(), + 'fid' => $feed['fid'], + 'iid' => $item->data['iid'], + 'taxonomy' => $feed['taxonomy'], + 'format' => $feed['format'] + ); - // Assign the author as specified in this feeds settings + // Assign the author as specified in this feeds settings $account = user_load(array('name' => $feed['author'])); $node['uid'] = $account->uid; - // Convert Node array in to an object - $node = (object)$node; + // Convert Node array in to an object + $node = (object)$node; - if($feed['autotaxonomy'] && is_array($item->get_categories())) { - // Find the vocabulary associated with this node type - $vocab = feedaggregator_get_vocabulary(); + if($feed['autotaxonomy'] && is_array($item->get_categories())) { + // Find the vocabulary associated with this node type + $vocab = feedaggregator_get_vocabulary(); - // Process any feed item category tags - if($vocab) { - foreach ($item->get_categories() as $category_name) { - if (trim($category_name) != '') { + // Process any feed item category tags + if($vocab) { + foreach ($item->get_categories() as $category_name) { + if (trim($category_name) != '') { - // See if the term is already defined - if (!isset($cat_names[$category_name])) { - $cat_names[$category_name] = module_invoke('taxonomy', 'get_term_by_name', $category_name); - } + // See if the term is already defined + if (!isset($cat_names[$category_name])) { + $cat_names[$category_name] = module_invoke('taxonomy', 'get_term_by_name', $category_name); + } - // If there is no existing term, create a new one - if (count($cat_names[$category_name]) == 0) { - $term = array(); - $term['name'] = check_plain($category_name); - $term['description'] = ''; - $term['vid'] = $vocab; - $term['weight'] = 0; - module_invoke('taxonomy', 'save_term', $term); + // If there is no existing term, create a new one + if (count($cat_names[$category_name]) == 0) { + $term = array(); + $term['name'] = check_plain($category_name); + $term['description'] = ''; + $term['vid'] = $vocab; + $term['weight'] = 0; + module_invoke('taxonomy', 'save_term', $term); - // Assign the new term to our new node - $node->taxonomy[] = $term['tid']; - $cat_names[$category_name][0]->tid = $term['tid']; - } - else { - // Use the existing category term in the database - if (!in_array($cat_names[$category_name][0]->tid, $node->taxonomy)) { - $node->taxonomy[] = $cat_names[$category_name][0]->tid; - } - } - } - } - } - } + // Assign the new term to our new node + $node->taxonomy[] = $term['tid']; + $cat_names[$category_name][0]->tid = $term['tid']; + } + else { + // Use the existing category term in the database + if (!in_array($cat_names[$category_name][0]->tid, $node->taxonomy)) { + $node->taxonomy[] = $cat_names[$category_name][0]->tid; + } + } + } + } + } + } node_object_prepare($node); $node = node_submit($node); - node_save($node); - return array('item_save' => TRUE); + node_save($node); + return array('item_save' => TRUE); } break; case 'expire_items': - // Unpublish any old nodes - $result = db_query(db_rewrite_sql("UPDATE {node} n JOIN {aggregator_node} an ON n.nid = an.nid SET n.status = 0 WHERE an.fid = %d AND n.changed < %d"), $feed['fid'], time() - $feed['expires']); + // Unpublish any old nodes + $result = db_query(db_rewrite_sql("UPDATE {node} n JOIN {aggregator_node} an ON n.nid = an.nid SET n.status = 0 WHERE an.fid = %d AND n.changed < %d"), $feed['fid'], time() - $feed['expires']); break; case 'remove': $result = db_query("SELECT nid FROM {aggregator_node} WHERE fid = %d", $feed['fid']); while($node = db_fetch_object($result)) { - node_delete($node->nid); + node_delete($node->nid); } break; @@ -277,21 +282,22 @@ $feed = feedmanager_get_feed($form['fid']['#value']); $form['advanced']['author'] = array('#type' => 'textfield', '#title' => t('Authored by'), '#maxlength' => 60, '#autocomplete_path' => 'user/autocomplete', '#default_value' => $feed['author'] ? $feed['author'] : '', '#weight' => -1, '#description' => t('Assigns created nodes to a user. Leave blank for %anonymous.', array('%anonymous' => variable_get('anonymous', 'Anonymous') ))); - // AutoTaxonomy - if(feedaggregator_get_vocabulary()) { - $form['advanced']['autotaxonomy'] = array( - '#type' => 'checkbox', - '#title' => t('Use feed category tags'), - '#description' => t('Some feeds provide categories defined by the author. These can be added to your taxonomy, and the feed items tagged with the terms.'), - '#default_value' => $edit['autotaxonomy'] ? $edit['autotaxonomy'] : FALSE, - ); - } else { - $form['advanced']['autotaxonomy'] = array( + // AutoTaxonomy + if(feedaggregator_get_vocabulary()) { + $form['advanced']['autotaxonomy'] = array( + '#type' => 'checkbox', + '#title' => t('Use feed category tags'), + '#description' => t('Some feeds provide categories defined by the author. These can be added to your taxonomy, and the feed items tagged with the terms.'), + '#default_value' => $edit['autotaxonomy'] ? $edit['autotaxonomy'] : FALSE, + ); + } + else { + $form['advanced']['autotaxonomy'] = array( '#type' => 'markup', - '#value' => t('You can automatically use tags defined in this feed to categories your nodes as they are created. To do this you need to !url to the %type content-type.', + '#value' => t('You can automatically use tags defined in this feed to categories your nodes as they are created. To do this you need to !url to the %type content-type.', array('!url' => l(t('create a vocabulary and assign it'), 'admin/taxonomy'), '%type' => 'aggregator-item')) - ); - } + ); + } // Define what Filters to pass aggregator items through $form['advanced']['format'] = filter_form($feed['format'], 0, array('advanced', 'format')); Index: feedmanager.module =================================================================== --- feedmanager.module (revision 981) +++ feedmanager.module (working copy) @@ -88,7 +88,7 @@ 'type' => MENU_NORMAL_ITEM, ); } - else if (arg(2) == 'aggregator' && is_numeric(arg(5))) { + elseif (arg(2) == 'aggregator' && is_numeric(arg(5))) { if (arg(4) == 'feed') { $feed = feedmanager_get_feed(arg(5)); if ($feed) { @@ -166,9 +166,9 @@ $form['feedprocessing']['feedmanager_vocabulary'] = array( '#type' => 'select', '#multiple' => FALSE, - '#title' => t('Vocabulary'), - '#default_value' => variable_get('feedmanager_vocabulary', FALSE), - '#description' => t('Used to store taxonomy terms in for feeds.'), + '#title' => t('Vocabulary'), + '#default_value' => variable_get('feedmanager_vocabulary', FALSE), + '#description' => t('Used to store taxonomy terms in for feeds.'), '#options' => $vocabularies_list, ); @@ -384,23 +384,23 @@ $vid = variable_get('feedmanager_vocabulary', FALSE); if($vid && $vocabulary = taxonomy_get_vocabulary($vid)) { - if($terms) { - $typed_terms = array(); - foreach ($terms as $term) { - // Extract terms belonging to the vocabulary in question. - if ($term->vid == $vocabulary->vid) { + if($terms) { + $typed_terms = array(); + foreach ($terms as $term) { + // Extract terms belonging to the vocabulary in question. + if ($term->vid == $vocabulary->vid) { - // Commas and quotes in terms are special cases, so encode 'em. - if (preg_match('/,/', $term->name) || preg_match('/"/', $term->name)) { - $term->name = '"'.preg_replace('/"/', '""', $term->name).'"'; - } + // Commas and quotes in terms are special cases, so encode 'em. + if (preg_match('/,/', $term->name) || preg_match('/"/', $term->name)) { + $term->name = '"'.preg_replace('/"/', '""', $term->name).'"'; + } - $typed_terms[] = $term->name; - } - } + $typed_terms[] = $term->name; + } + } - $typed_string = implode(', ', $typed_terms) . (array_key_exists('tags', $terms) ? $terms['tags'][$vocabulary->vid] : NULL); - } + $typed_string = implode(', ', $typed_terms) . (array_key_exists('tags', $terms) ? $terms['tags'][$vocabulary->vid] : NULL); + } if ($vocabulary->help) { $help = $vocabulary->help; @@ -418,7 +418,8 @@ '#weight' => $vocabulary->weight, '#maxlength' => 255, ); - } else { + } + else { $form['taxonomy_help'] = array( '#value' => t('You can automatically use tags defined in this feed to categories your nodes as they are created. To do this you need to !url to the %type content-type.', array('!url' => l(t('create a vocabulary and assign it'), 'admin/content/taxonomy'), '%type' => 'aggregator-item')), ); @@ -524,9 +525,9 @@ if ($edit['fid'] && $edit['title']) { db_query("UPDATE {aggregator_feed} SET title = '%s', url = '%s', refresh = %d, description = '%s', expires = %d, data = '%s' WHERE fid = %d", $edit['title'], $edit['url'], $edit['refresh'], $edit['description'], $edit['expires'], $data, $edit['fid']); } - else if ($edit['fid']) { + elseif ($edit['fid']) { - // Delete all feed category items + // Delete all feed category items $result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = %d', $edit['fid']); while ($item = db_fetch_object($result)) { $items[] = "iid = $item->iid"; @@ -538,7 +539,7 @@ db_query('DELETE FROM {aggregator_feed} WHERE fid = %d', $edit['fid']); db_query('DELETE FROM {aggregator_item} WHERE fid = %d', $edit['fid']); } - else if ($edit['title']) { + elseif ($edit['title']) { // A single unique id for bundles and feeds, to use in blocks. $edit['fid'] = db_next_id('{aggregator_feed}_fid'); db_query("INSERT INTO {aggregator_feed} (fid, title, url, refresh, description, expires, data) VALUES (%d, '%s', '%s', %d, '%s', %d, '%s')", $edit['fid'], $edit['title'], $edit['url'], $edit['refresh'], $edit['description'], $edit['expires'], $data); @@ -591,7 +592,8 @@ } } } - } else { + } + else { drupal_set_message(t('Unable to add the feed due to incomplete details being provided.')); } } @@ -727,9 +729,11 @@ $feed['taxonomy'] = array(); while ($term = db_fetch_object($terms)) { - if ($term->fid) $feed['taxonomy'][] = taxonomy_get_term($term->cid); + if ($term->fid) { + $feed['taxonomy'][] = taxonomy_get_term($term->cid); + } } $feeds[$fid] = $feed; @@ -754,7 +758,8 @@ // If A Feed Processor Implements Listing of Items Provide A Link if(module_hook($feed['processor'], 'list_items')) { $item_list_link = l($feed['title'], "aggregator/sources/{$feed['fid']}"); - } else { + } + else { $item_list_link = check_plain($feed['title']); } @@ -806,7 +811,8 @@ $output .= theme('feedmanager_feed', $feed); $output .= module_invoke($feed['processor'], 'list_items', $feed); } - } else { + } + else { $result = db_query('SELECT fid FROM {aggregator_feed} ORDER BY title'); while ($fid = db_fetch_array($result)) { $feed = feedmanager_get_feed($fid['fid']); @@ -1014,13 +1020,13 @@ if ($ord < 128) { return chr($ord); } - else if ($ord < 2048) { + elseif ($ord < 2048) { $no_bytes = 2; } - else if ($ord < 65536) { + elseif ($ord < 65536) { $no_bytes = 3; } - else if ($ord < 1114112) { + elseif ($ord < 1114112) { $no_bytes = 4; } else { Index: feedaggregator_item.module =================================================================== --- feedaggregator_item.module (revision 980) +++ feedaggregator_item.module (working copy) @@ -80,7 +80,7 @@ 'weight' => 1); } } - else if (arg(1) == 'categories') { + elseif (arg(1) == 'categories') { $category = feedaggregator_get_category(arg(2)); if ($category) { $items[] = array('path' => 'aggregator/categories/'. $category['cid'] .'/view', @@ -109,28 +109,28 @@ function feedaggregator_item_feedapi($feed, $op, $item = NULL) { - switch($op) { - case 'processor_name': - return array('feedaggregator' => t('Aggregator Items')); + switch($op) { + case 'processor_name': + return array('feedaggregator' => t('Aggregator Items')); - case 'item_count': - $total_items = db_result(db_query('SELECT COUNT(iid) FROM {aggregator_item} WHERE fid = %d', $feed['fid'])); - return array('item_count' => $total_items); + case 'item_count': + $total_items = db_result(db_query('SELECT COUNT(iid) FROM {aggregator_item} WHERE fid = %d', $feed['fid'])); + return array('item_count' => $total_items); - case 'item_save': - if($feed['processor'] == 'feedaggregator') { - //feedaggregator_save_item($item); - } - break; + case 'item_save': + if($feed['processor'] == 'feedaggregator') { + //feedaggregator_save_item($item); + } + break; - case 'expire_items': - // Unpublish any old nodes + case 'expire_items': + // Unpublish any old nodes break; case 'remove': - feedaggregator_remove($feed); + feedaggregator_remove($feed); break; - } + } } @@ -153,7 +153,7 @@ $block['feed-'. $feed->fid]['info'] = t('%title feed latest items', array('%title' => theme('placeholder', $feed->title))); } } - else if ($op == 'configure') { + elseif ($op == 'configure') { list($type, $id) = explode('-', $delta); if ($type == 'category') { $value = db_result(db_query('SELECT block FROM {aggregator_category} WHERE cid = %d', $id)); @@ -164,7 +164,7 @@ $form['block'] = array('#type' => 'select', '#title' => t('Number of news items in block'), '#default_value' => $value, '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20))); return $form; } - else if ($op == 'save') { + elseif ($op == 'save') { list($type, $id) = explode('-', $delta); if ($type == 'category') { $value = db_query('UPDATE {aggregator_category} SET block = %d WHERE cid = %d', $edit['block'], $id); @@ -173,7 +173,7 @@ $value = db_query('UPDATE {aggregator_feed} SET block = %d WHERE fid = %d', $edit['block'], $id); } } - else if ($op == 'view') { + elseif ($op == 'view') { list($type, $id) = explode('-', $delta); switch ($type) { case 'feed': @@ -225,11 +225,11 @@ if ($edit['iid'] && $edit['title']) { db_query("UPDATE {aggregator_item} SET title = '%s', link = '%s', author = '%s', description = '%s' WHERE iid = %d", $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['iid']); } - else if ($edit['iid']) { + elseif ($edit['iid']) { db_query('DELETE FROM {aggregator_item} WHERE iid = %d', $edit['iid']); db_query('DELETE FROM {aggregator_category_item} WHERE iid = %d', $edit['iid']); } - else if ($edit['title'] && $edit['link']) { + elseif ($edit['title'] && $edit['link']) { $edit['iid'] = db_next_id('{aggregator_item}_iid'); db_query("INSERT INTO {aggregator_item} (iid, fid, title, link, author, description, timestamp) VALUES (%d, %d, '%s', '%s', '%s', '%s', %d)", $edit['iid'], $edit['fid'], $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['timestamp']); // file the items in the categories indicated by the feed Index: CVS/Entries =================================================================== --- CVS/Entries (revision 980) +++ CVS/Entries (working copy) @@ -1,5 +1,4 @@ /README.txt/1.3/Mon Dec 4 01:00:21 2006//TDRUPAL-5 -/feedaggregator_item.module/1.1/Thu Dec 14 01:57:49 2006//TDRUPAL-5 /feedaggregator_node.info/1.2/Mon Nov 20 00:47:29 2006//TDRUPAL-5 /feedaggregator_node.install/1.1/Mon Nov 20 21:40:09 2006//TDRUPAL-5 /feedaggregator_node.module/1.42.4.2/Fri May 4 01:23:18 2007//TDRUPAL-5 @@ -10,4 +9,5 @@ /feedmanager.install/1.9/Mon Nov 20 21:33:13 2006//TDRUPAL-5 /simplepie.inc/1.2/Tue Nov 28 23:46:58 2006/-ko/TDRUPAL-5 /feedmanager.module/1.47.4.7/Tue May 15 01:32:25 2007//TDRUPAL-5 +/feedaggregator_item.module/1.1/Thu Dec 14 01:57:49 2006//TDRUPAL-5 D