Index: feedapi_node/feedapi_node.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/feedapi/feedapi_node/Attic/feedapi_node.module,v retrieving revision 1.1.2.18.2.8 diff -u -r1.1.2.18.2.8 feedapi_node.module --- feedapi_node/feedapi_node.module 11 Apr 2008 19:42:51 -0000 1.1.2.18.2.8 +++ feedapi_node/feedapi_node.module 25 Apr 2008 16:40:41 -0000 @@ -30,13 +30,13 @@ $node->feedapi_node = $f; $feed_nids[$f->feed_nid] = $f->feed_nid; } - if ($node->feedapi_node) { + if (isset($node->feedapi_node)) { $node->feedapi_node->feed_nids = $feed_nids; unset($node->feedapi_node->feed_nid); } break; case 'insert': - if ($node->feedapi_node->feed_item) { + if (isset($node->feedapi_node) && $node->feedapi_node->feed_item) { // Why do we stick the nid on the feed item here? $node->feedapi_node->feed_item->nid = $node->nid; foreach ($node->feedapi_node->feed_nids as $feed_nid) { @@ -55,7 +55,7 @@ } break; case 'update': - if ($node->feedapi_node) { + if (isset($node->feedapi_node)) { if ($node->feedapi_node->feed_item) { $feed_item = $node->feedapi_node->feed_item; db_query("UPDATE {feedapi_node_item} SET url = '%s', timestamp = %d, guid = '%s' WHERE nid = %d", $feed_item->options->original_url, $feed_item->options->timestamp, $feed_item->options->guid, $node->nid); @@ -67,7 +67,7 @@ } break; case 'delete': - if ($node->feedapi_node) { + if (isset($node->feedapi_node)) { db_query('DELETE FROM {feedapi_node_item} WHERE nid = %d', $node->nid); db_query('DELETE FROM {feedapi_node_item_feed} WHERE feed_item_nid = %d', $node->nid); } @@ -80,7 +80,7 @@ */ function feedapi_node_link($type, $node = NULL) { if ($type == 'node') { - if ($node->feedapi_node) { + if (isset($node->feedapi_node)) { $result = db_query("SELECT n.title, n.nid FROM {node} n WHERE n.nid IN (%s) ORDER BY title DESC", implode(', ', $node->feedapi_node->feed_nids)); $owner_feeds_num = count($node->feedapi_node->feed_nids); while ($feed = db_fetch_object($result)) { @@ -106,7 +106,9 @@ * to return different forms for parsers and processors. * There might be a better term for parsers and processors than $type. */ -function feedapi_node_feedapi_settings_form($type) { +function feedapi_node_feedapi_settings_form($type) { + $form = array(); + switch ($type) { case 'processors': $ct_types = node_get_types(); Index: feedapi_node/feedapi_node.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/feedapi/feedapi_node/Attic/feedapi_node.install,v retrieving revision 1.1.2.13.2.2 diff -u -r1.1.2.13.2.2 feedapi_node.install --- feedapi_node/feedapi_node.install 3 Mar 2008 22:04:56 -0000 1.1.2.13.2.2 +++ feedapi_node/feedapi_node.install 25 Apr 2008 16:40:41 -0000 @@ -49,6 +49,7 @@ drupal_install_schema('feedapi_node'); // Creating the content-types for the FeedAPI $info->type = 'feedapi_node'; + $info->orig_type = 'feedapi_node'; $info->name = t('Feed'); $info->description = t('Aggregates RSS or Atom feeds. Items from these feeds will be turned into nodes.'); $info->module = 'node'; @@ -58,6 +59,8 @@ $info->body_label = t('Body'); $info->min_word_count = 0; $info->custom = TRUE; + $info->modified = TRUE; + $info->locked = FALSE; node_type_save($info); // Adding default FeedAPI settings $preset = unserialize('a:3:{s:7:"enabled";s:1:"1";s:12:"items_delete";s:1:"0";s:10:"processors";a:1:{s:12:"feedapi_node";a:7:{s:7:"enabled";s:1:"1";s:6:"weight";s:1:"0";s:12:"content_type";s:5:"story";s:9:"node_date";s:4:"feed";s:7:"promote";s:1:"0";s:9:"list_feed";s:1:"3";s:4:"user";s:5:"admin";}}}'); Index: parser_common_syndication/parser_common_syndication.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/feedapi/parser_common_syndication/parser_common_syndication.module,v retrieving revision 1.6.2.23.2.7 diff -u -r1.6.2.23.2.7 parser_common_syndication.module --- parser_common_syndication/parser_common_syndication.module 11 Apr 2008 19:42:51 -0000 1.6.2.23.2.7 +++ parser_common_syndication/parser_common_syndication.module 25 Apr 2008 16:40:42 -0000 @@ -32,7 +32,7 @@ return FALSE; } $url = $args[1]->url; - $downloaded_string = _parser_common_syndication_download($url, $op); + $downloaded_string = _parser_common_syndication_download($url); if (is_object($downloaded_string)) { return $downloaded_string->type; } @@ -84,7 +84,7 @@ $xml = $feed; } else { - $downloaded_string = _parser_common_syndication_download($feed->url, 'parse'); + $downloaded_string = _parser_common_syndication_download($feed->url); if ($downloaded_string === FALSE || is_object($downloaded_string)) { return $downloaded_string; } @@ -127,23 +127,28 @@ * The data pulled from the URL or FALSE if the feed does not need refresh */ function _parser_common_syndication_feedapi_get($url, $username = NULL, $password = NULL) { - $method = 'GET'; - $follow = 3; - $data = NULL; - // Only download and parse data if really needs refresh. Based on Last-Modified and If-Modified-Since + $record_exists = FALSE; + + // Only download and parse data if really needs refresh. + // Based on "Last-Modified" and "If-Modified-Since". $headers = array(); - $validate = db_fetch_array(db_query("SELECT etag, last_modified FROM {parser_common_syndication} WHERE url = '%s'", $url)); - if (!empty($validate['etag'])) { - $headers['If-None-Match'] = $validate['etag']; - } - if (!empty($validate['last_modified'])) { - $headers['If-Modified-Since'] = $validate['last_modified']; - } - if (!empty($username)) { - $headers['Authorization'] = 'Basic '. base64_encode("$username:$password"); + $db_result = db_query("SELECT etag, last_modified FROM {parser_common_syndication} WHERE url = '%s'", $url); + while ($validate = db_fetch_array($db_result)) { + $record_exists = TRUE; + if (!empty($validate['etag'])) { + $headers['If-None-Match'] = $validate['etag']; + } + if (!empty($validate['last_modified'])) { + $headers['If-Modified-Since'] = $validate['last_modified']; + } + if (!empty($username)) { + $headers['Authorization'] = 'Basic '. base64_encode("$username:$password"); + } } - $result = drupal_http_request($url, $headers, $method, $data, $follow); - // In this case return the cached data + + $result = drupal_http_request($url, $headers); + + // In this case return the cached data. if ($result->code == 304) { $cache_file = _parser_common_syndication_sanitize_cache() .'/'. md5($url); if (file_exists($cache_file)) { @@ -155,21 +160,21 @@ return $cached_data; } else { - // It's a tragedy, this file has to be exist and contains good data. In this case, repeat the stuff without cache + // It's a tragedy, this file has to be exist and contain good data. + // In this case, repeat the stuff without cache. db_query("DELETE FROM {parser_common_syndication} WHERE url = '%s'", $url); return _parser_common_syndication_feedapi_get($url, $username, $password); } } - if (db_result(db_query("SELECT COUNT(*) FROM {parser_common_syndication} WHERE url = '%s'", $url)) == 0) { - db_query("INSERT INTO {parser_common_syndication} (etag, last_modified, url) VALUES ('%s', '%s', '%s')", $result->headers['ETag'], $result->headers['Last-Modified'], $url); + if ($record_exists) { + db_query("UPDATE {parser_common_syndication} SET etag = '%s', last_modified = '%s' WHERE url = '%s'", $result->headers['ETag'], $result->headers['Last-Modified'], $url); } else { - db_query("UPDATE {parser_common_syndication} SET etag = '%s', last_modified = '%s' WHERE url = '%s'", $result->headers['ETag'], $result->headers['Last-Modified'], $url); + db_query("INSERT INTO {parser_common_syndication} (etag, last_modified, url) VALUES ('%s', '%s', '%s')", $result->headers['ETag'], $result->headers['Last-Modified'], $url); } - - return $result->data; + return empty($result->data) ? FALSE : $result->data; } /** @@ -228,7 +233,7 @@ * @return * string - the downloaded data, FALSE - if the URL is not reachable */ -function _parser_common_syndication_download($url, $op) { +function _parser_common_syndication_download($url) { // Handle password protected feeds $url_parts = parse_url($url); $password = $username = NULL; @@ -237,19 +242,19 @@ $username = $url_parts['user']; } - $downloaded_string = _parser_common_syndication_feedapi_get($url, $username, $password, $op); + $downloaded_string = _parser_common_syndication_feedapi_get($url, $username, $password); - // Cannot get the feed, pass the problem to one level upper - if ($downloaded_string == "") { + // Cannot get the feed, pass the problem to one level up. + if ($downloaded_string == FALSE) { return FALSE; } - // The data comes from cache, just pass one level upper + // The data comes from cache, just pass one level up. else if (is_object($downloaded_string)) { return $downloaded_string; } - // Do the autodiscovery at this level, pass back the real data - // Maybe it's HTML. If it's not HTML, not worth to take a look into the downloaded string + // Do the autodiscovery at this level, pass back the real data. + // Maybe it's HTML. If it's not HTML, not worth to take a look into the downloaded string. if (strpos(strtolower($downloaded_string), " 'feedapi_refresh', 'page arguments' => array(1), 'type' => MENU_LOCAL_TASK, - 'access callback' => 'feedapi_access_op', + 'access callback' => '_feedapi_op_access', 'access arguments' => array(1), ); $items['node/%node/purge'] = array( @@ -84,14 +84,13 @@ 'page callback' => 'feedapi_invoke_feedapi', 'page arguments' => array("purge", 1, 'items'), 'type' => MENU_LOCAL_TASK, - 'access callback' => 'feedapi_access_op', + 'access callback' => '_feedapi_op_access', 'access arguments' => array(1), ); return $items; } -function feedapi_access_op($nid) { - $node = node_load($nid); +function _feedapi_op_access($node) { global $user; $own_feed = $node->uid == $user->uid && user_access('edit own '. $node->type .' content') ? TRUE : FALSE; return user_access('administer feedapi') || $own_feed; @@ -165,7 +164,7 @@ case 'list': foreach ($names as $type => $name) { $blocks[$type]['info'] = t('FeedAPI: Quick create !preset', array('!preset' => $name)); - $blocks['type']['cache'] = BLOCK_CACHE_GLOBAL; + $blocks[$type]['cache'] = BLOCK_CACHE_GLOBAL; } break; case 'view': @@ -353,7 +352,7 @@ /** * Implementation of hook_form_alter(). */ -function feedapi_form_alter(&$form, &$form_state, $form_id) { +function feedapi_form_alter(&$form, $form_state, $form_id) { // Content type form. if ($form_id == 'node_type_form' && isset($form['identity']['type'])) { if (!$node_type_settings = feedapi_get_settings($form['#node_type']->type)) { @@ -471,7 +470,7 @@ } // FeedAPI-enabled node form. - if ($form['type']['#value'] .'_node_form' == $form_id && feedapi_enabled($form['type']['#value'])) { + if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id && feedapi_enabled($form['type']['#value'])) { $form['#validate'][] = 'feedapi_form_autodownload'; $form['title']['#required'] = FALSE; $form['title']['#description'] = t('This field will be populated with the feed title. You can override by filling in this field.'); @@ -483,13 +482,14 @@ '#collapsed' => FALSE, '#tree' => TRUE, ); - if ($form_state['values']['feedapi']['url']) { + $feedapi_url_default = ''; + if (isset($form_state['values']) && $form_state['values']['feedapi']['url']) { $feedapi_url_default = $form_state['values']['feedapi_url']; } - else if ($form['#node']->feed->url) { + else if (isset($form['#node']->feed->url)) { $feedapi_url_default = $form['#node']->feed->url; } - else if ($form_state['values']['feedapi']['feedapi_url']) { + else if (isset($form_state['values']) && $form_state['values']['feedapi']['feedapi_url']) { $feedapi_url_default = $form_state['values']['feedapi']['feedapi_url']; } $form['feedapi']['feedapi_url'] = array( @@ -516,7 +516,7 @@ foreach (array("parsers" => "feedapi_feed", "processors" => "feedapi_item") as $type => $requirement) { $suitable_handlers = module_implements($requirement, TRUE); foreach ($suitable_handlers as $module) { - if ($node_type_settings[$type][$module]['enabled']) { + if (isset($node_type_settings[$type][$module]) && $node_type_settings[$type][$module]['enabled']) { $result = array(); $result = module_invoke($module, 'feedapi_settings_form', $type); if (is_array($result)) { @@ -540,7 +540,10 @@ } } // If we are on a node form, get per node settings and populate form. - if (!$settings = feedapi_get_settings($form['type']['#value'], $form['#node']->nid)) { + if (isset($form['#node']->nid)) { + $settings = feedapi_get_settings($form['type']['#value'], $form['#node']->nid); + } + else { $settings = $node_type_settings; } $form['feedapi'] = _feedapi_populate($form['feedapi'], $settings); Index: feedapi_inherit/feedapi_inherit.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/feedapi/feedapi_inherit/Attic/feedapi_inherit.module,v retrieving revision 1.1.2.14.2.1 diff -u -r1.1.2.14.2.1 feedapi_inherit.module --- feedapi_inherit/feedapi_inherit.module 29 Feb 2008 16:09:47 -0000 1.1.2.14.2.1 +++ feedapi_inherit/feedapi_inherit.module 25 Apr 2008 16:40:41 -0000 @@ -28,6 +28,10 @@ * Implementation of hook_nodeapi(). */ function feedapi_inherit_nodeapi(&$node, $op) { + if (!isset($node->feedapi_node)) { + return; + } + switch ($op) { case 'prepare': if ($node->feedapi_node->feed_nids) { @@ -57,7 +61,9 @@ * to return different forms for parsers and processors. * There might be a better term for parsers and processors than $type. */ -function feedapi_inherit_feedapi_settings_form($type) { +function feedapi_inherit_feedapi_settings_form($type) { + $form = array(); + switch ($type) { case 'processors': if (module_exists('og')) {