Index: developer/hooks/core.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/docs/developer/hooks/core.php,v retrieving revision 1.218 diff -u -r1.218 core.php --- developer/hooks/core.php 5 Nov 2008 18:50:58 -0000 1.218 +++ developer/hooks/core.php 7 Nov 2008 23:46:26 -0000 @@ -2429,5 +2429,87 @@ } /** + * Implement this hook to create an alternative parser for aggregator module. + * + * A parser downloads and normalizes feed data. Aggregator calls first the active + * parser and then passes the result of the parsing stage to all enabled processors. + * + * Modules that define this hook can be set as active parser on + * admin/content/aggregator/settings. + * + * @param $feed + * The $feed object that describes the resource to be parsed. $feed->url contains + * the URL of the feed. Download data from $feed->url and expose it to other modules + * by creating an array of data items on $feed->items. + */ +function hook_aggregator_parse($feed) { + $data = drupal_http_request($feed->url); + $feed->items = mymodule_parse($data); +} + +/** + * Use this hook to expose a title and a short description of your parser. + * + * The title and the description provided are shown most importantly on + * admin/content/aggregator/settings . Use as title the human readable name of + * the parser and as description a brief (40 to 80 characters) explanation of + * the functionality. + * + * A parser downloads and normalizes feed data. Aggregator calls first the active + * parser and then passes the result of the parsing stage to all enabled processors. + * + * This hook is only called if your module implements hook_aggregator_parse(). + * + * @return + * An associative array defining a title and a description string. + */ +function hook_aggregator_parse_info() { + return array( + 'title' => t('Default Parser'), + 'description' => t('Default parser for RSS, Atom and RDF feeds.'), + ); +} + +/** + * Implement this hook to create a processor for aggregator module. + * + * A processor acts on aggregated feed items. Aggregator calls first the active + * parser and then passes the result of the parsing stage to all enabled + * processors. + * + * Modules that define this hook can be activated as processor on + * admin/content/aggregator/settings. + * + * @param $feed + * The $feed object that describes the resource to be processed. $feed->items + * contains an array of data items downloaded and parsed at the parsing + * stage. + */ +function hook_aggregator_process($feed) { + foreach ($feed->items as $item) { + mymodule_save($item); + } +} + +/** + * Use this hook to expose a title and a short description of your processor. + * + * The title and the description provided are shown most importantly on + * admin/content/aggregator/settings . Use as title the natural name of the processor + * and as description a brief (40 to 80 characters) explanation of the functionality. + * + * This hook is only called if your module implements hook_aggregator_process(). + * + * @return + * An associative array defining a title and a description string. + */ +function hook_aggregator_process_info($feed) { + return array( + 'title' => t('Default processor'), + 'description' => t('Creates lightweight records of feed items.'), + ); +} + +/** * @} End of "addtogroup hooks". */