- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
<?php
2005-08-11 13:02:08 +00:00
// $Id$
2003-08-20 21:00:31 +00:00
2004-08-21 06:42:38 +00:00
/**
* @file
* Used to aggregate syndicated content (RSS and RDF).
*/
2004-05-11 20:10:14 +00:00
/**
* Implementation of hook_help().
*/
2004-01-07 19:52:10 +00:00
function aggregator_help($section) {
2003-08-20 21:00:31 +00:00
switch ($section) {
2004-01-06 13:32:59 +00:00
case 'admin/help#aggregator':
2005-11-01 10:17:34 +00:00
$output = '<p>'. t('The news aggregator is a powerful on-site RSS syndicator/news reader that can gather fresh content from news sites and weblogs around the web.') .'</p>';
$output .= '<p>'. t('Users can view the latest news chronologically in the <a href="%aggregator">main news aggregator display</a> or by <a href="%aggregator-sources">source</a>. Administrators can add, edit and delete feeds and choose how often to check for newly updated news for each individual feed. Administrators can also tag individual feeds with categories, offering selective grouping of some feeds into separate displays. Listings of the latest news for individual sources or categorized sources can be enabled as blocks for display in the sidebar through the <a href="%admin-block">block administration page</a>. The news aggregator requires cron to check for the latest news from the sites to which you have subscribed. Drupal also provides a <a href="%aggregator-opml">machine-readable OPML file</a> of all of your subscribed feeds.', array('%aggregator' => url('aggregator'), '%aggregator-sources' => url('aggregator/sources'), '%admin-block' => url('admin/block'), '%aggregator-opml' => url('aggregator/opml'))) .'</p>';
$output .= t('<p>You can</p>
<ul>
<li>administer your list of news feeds <a href="%admin-aggregator">administer >> aggregator</a>.</li>
<li>add a new feed <a href="%admin-aggregator-add-feed">administer >> aggregator >> add feed</a>.</li>
<li>add a new category <a href="%admin-aggregator-add-category">administer >> aggregator >> add category</a>.</li>
<li>configure global settings for the news aggregator <a href="%admin-settings-aggregator">administer >> settings >> aggregator</a>.</li>
<li>control access to the aggregator module through access permissions <a href="%admin-access">administer >> access control >> permissions</a>.</li>
<li>set permissions to access new feeds for user roles such as anonymous users at <a href="%admin-access">administer >> access control</a>.</li>
<li>view the <a href="%aggregator">aggregator page</a>.</li>
</ul>
', array('%admin-aggregator' => url('admin/aggregator'), '%admin-aggregator-add-feed' => url('admin/aggregator/add/feed'), '%admin-aggregator-add-category' => url('admin/aggregator/add/category'), '%admin-settings-aggregator' => url('admin/settings/aggregator'), '%admin-access' => url('admin/access'), '%aggregator' => url('aggregator')));
$output .= '<p>'. t('For more information please read the configuration and customization handbook <a href="%aggregator">Aggregator page</a>.', array('%aggregator' => 'http://www.drupal.org/handbook/modules/aggregator/')) .'</p>';
return $output;
2004-06-18 15:04:37 +00:00
case 'admin/modules#description':
2005-04-01 15:55:02 +00:00
return t('Aggregates syndicated content (RSS and RDF feeds).');
2004-05-20 12:43:28 +00:00
case 'admin/aggregator':
2004-11-23 22:20:41 +00:00
return t('<p>Thousands of sites (particularly news sites and weblogs) publish their latest headlines and/or stories in a machine-readable format so that other sites can easily link to them. This content is usually in the form of an <a href="http://blogs.law.harvard.edu/tech/rss">RSS</a> feed (which is an XML-based syndication standard). To display the feed or category in a block you must decide how many items to show by editing the feed or block and turning on the <a href="%block">feed\'s block</a>.</p>', array('%block' => url('admin/block')));
2004-05-20 12:43:28 +00:00
case 'admin/aggregator/add/feed':
2004-11-23 22:20:41 +00:00
return t('<p>Add a site that has an RSS/RDF feed. The URL is the full path to the RSS feed file. For the feed to update automatically you must run "cron.php" on a regular basis. If you already have a feed with the URL you are planning to use, the system will not accept another feed with the same URL.</p>');
2004-05-20 12:43:28 +00:00
case 'admin/aggregator/add/category':
2004-11-23 22:20:41 +00:00
return t('<p>Categories provide a way to group items from different news feeds together. Each news category has its own feed page and block. For example, you could tag various sport-related feeds as belonging to a category called <em>Sports</em>. News items can be added to a category automatically by setting a feed to automatically place its item into that category, or by using the categorize items link in any listing of news items.</p>');
2003-08-20 21:00:31 +00:00
}
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
}
2005-02-10 20:33:18 +00:00
function aggregator_settings() {
2004-08-17 17:37:26 +00:00
$items = array(0 => t('none')) + drupal_map_assoc(array(3, 5, 10, 15, 20, 25), '_aggregator_items');
2005-02-10 20:33:18 +00:00
$period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval');
2004-01-07 19:52:10 +00:00
2005-10-07 06:11:12 +00:00
$form['aggregator_allowed_html_tags'] = array(
2005-10-11 19:44:35 +00:00
'#type' => 'textfield', '#title' => t('Allowed HTML tags'), '#size' => 80, '#maxlength' => 255,
'#default_value' => variable_get('aggregator_allowed_html_tags', '<a> <b> <br> <dd> <dl> <dt> <em> <i> <li> <ol> <p> <strong> <u> <ul>'),
'#description' => t('The list of tags which are allowed in feeds, i.e., which will not be removed by Drupal.')
2005-10-07 06:11:12 +00:00
);
$form['aggregator_summary_items'] = array(
2005-10-11 19:44:35 +00:00
'#type' => 'select', '#title' => t('Items shown in sources and categories pages') ,
'#default_value' => variable_get('aggregator_summary_items', 3), '#options' => $items,
'#description' => t('The number of items which will be shown with each feed or category in the feed and category summary pages.')
2005-10-07 06:11:12 +00:00
);
$form['aggregator_clear'] = array(
2005-10-11 19:44:35 +00:00
'#type' => 'select', '#title' => t('Discard news items older than'),
'#default_value' => variable_get('aggregator_clear', 9676800), '#options' => $period,
'#description' => t('Older news items will be automatically discarded. Requires crontab.')
2005-10-07 06:11:12 +00:00
);
2005-10-07 06:51:43 +00:00
2005-10-07 06:11:12 +00:00
$form['aggregator_category_selector'] = array(
2005-10-11 19:44:35 +00:00
'#type' => 'radios', '#title' => t('Category selection type'), '#default_value' => variable_get('aggregator_category_selector', 'check'),
'#options' => array('check' => t('checkboxes'), 'select' => t('multiple selector')),
'#description' => t('The type of category selection widget which is shown on categorization pages. Checkboxes are easier to use; a multiple selector is good for working with large numbers of categories.')
2005-10-07 06:11:12 +00:00
);
return $form;
2001-07-11 22:06:24 +00:00
}
2004-08-17 17:37:26 +00:00
/**
* Helper function for drupal_map_assoc.
*/
function _aggregator_items($count) {
return format_plural($count, '1 item', '%count items');
}
2004-05-11 20:10:14 +00:00
/**
* Implementation of hook_perm().
*/
2004-01-06 13:32:59 +00:00
function aggregator_perm() {
2004-01-07 19:52:10 +00:00
return array('administer news feeds', 'access news feeds');
2001-06-29 22:08:57 +00:00
}
2004-06-18 15:04:37 +00:00
/**
* Implementation of hook_menu().
*/
2004-09-16 07:17:56 +00:00
function aggregator_menu($may_cache) {
2004-06-18 15:04:37 +00:00
$items = array();
2005-04-26 16:29:31 +00:00
$edit = user_access('administer news feeds');
$view = user_access('access news feeds');
2001-07-11 22:06:24 +00:00
2004-09-16 07:17:56 +00:00
if ($may_cache) {
$items[] = array('path' => 'admin/aggregator', 'title' => t('aggregator'),
'callback' => 'aggregator_admin_overview', 'access' => $edit);
$items[] = array('path' => 'admin/aggregator/edit/feed', 'title' => t('edit feed'),
'callback' => 'aggregator_admin_edit_feed', 'access' => $edit,
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/aggregator/edit/category', 'title' => t('edit category'),
'callback' => 'aggregator_admin_edit_category', 'access' => $edit,
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/aggregator/remove', 'title' => t('remove items'),
'callback' => 'aggregator_admin_remove_feed', 'access' => $edit,
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/aggregator/update', 'title' => t('update items'),
'callback' => 'aggregator_admin_refresh_feed', 'access' => $edit,
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/aggregator/list', 'title' => t('list'),
'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
$items[] = array('path' => 'admin/aggregator/add/feed', 'title' => t('add feed'),
'callback' => 'aggregator_admin_edit_feed', 'access' => $edit,
'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'admin/aggregator/add/category', 'title' => t('add category'),
'callback' => 'aggregator_admin_edit_category', 'access' => $edit,
'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'aggregator', 'title' => t('news aggregator'),
'callback' => 'aggregator_page_last', 'access' => $view,
'weight' => 5);
$items[] = array('path' => 'aggregator/sources', 'title' => t('sources'),
'callback' => 'aggregator_page_sources', 'access' => $view);
$items[] = array('path' => 'aggregator/categories', 'title' => t('categories'),
'callback' => 'aggregator_page_categories', 'access' => $view,
'type' => MENU_ITEM_GROUPING);
2005-09-02 19:18:14 +00:00
$items[] = array('path' => 'aggregator/rss', 'title' => t('RSS feed'),
'callback' => 'aggregator_page_rss', 'access' => $view,
'type' => MENU_CALLBACK);
$items[] = array('path' => 'aggregator/opml', 'title' => t('OPML feed'),
2004-09-16 07:17:56 +00:00
'callback' => 'aggregator_page_opml', 'access' => $view,
'type' => MENU_CALLBACK);
}
2005-04-26 16:29:31 +00:00
else {
if (arg(0) == 'aggregator' && is_numeric(arg(2))) {
if (arg(1) == 'sources') {
$feed = db_fetch_object(db_query('SELECT title, fid FROM {aggregator_feed} WHERE fid = %d', arg(2)));
if ($feed) {
$items[] = array('path' => 'aggregator/sources/'. $feed->fid, 'title' => $feed->title,
'callback' => 'aggregator_page_source', 'access' => $view);
$items[] = array('path' => 'aggregator/sources/'. $feed->fid .'/view', 'title' => t('view'),
'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
$items[] = array('path' => 'aggregator/sources/'. $feed->fid .'/categorize', 'title' => t('categorize'),
'callback' => 'aggregator_page_source', 'access' => $edit,
'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'aggregator/sources/'. $feed->fid .'/configure', 'title' => t('configure'),
'callback' => 'aggregator_edit', 'access' => $edit,
'type' => MENU_LOCAL_TASK,
'weight' => 1);
}
}
else if (arg(1) == 'categories') {
$category = db_fetch_object(db_query('SELECT title, cid FROM {aggregator_category} WHERE cid = %d', arg(2)));
if ($category) {
$items[] = array('path' => 'aggregator/categories/'. $category->cid, 'title' => $category->title,
'callback' => 'aggregator_page_category', 'access' => $view);
$items[] = array('path' => 'aggregator/categories/'. $category->cid .'/view', 'title' => t('view'),
'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
$items[] = array('path' => 'aggregator/categories/'. $category->cid .'/categorize', 'title' => t('categorize'),
'callback' => 'aggregator_page_category', 'access' => $edit,
'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'aggregator/categories/'. $category->cid .'/configure', 'title' => t('configure'),
'callback' => 'aggregator_edit', 'access' => $edit,
'type' => MENU_LOCAL_TASK,
'weight' => 1);
}
}
}
}
2004-06-18 15:04:37 +00:00
return $items;
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
}
2004-05-11 20:10:14 +00:00
/**
* Implementation of hook_cron().
*
* Checks news feeds for updates once their refresh interval has elapsed.
*/
2004-04-27 20:10:09 +00:00
function aggregator_cron() {
2004-05-11 20:10:14 +00:00
$result = db_query('SELECT * FROM {aggregator_feed} WHERE checked + refresh < %d', time());
2004-04-27 20:10:09 +00:00
while ($feed = db_fetch_array($result)) {
aggregator_refresh($feed);
2001-07-09 18:13:53 +00:00
}
}
2004-05-11 20:10:14 +00:00
/**
* Implementation of hook_block().
*
* Generates blocks for the latest news items in each category and feed.
*/
2005-03-02 08:13:15 +00:00
function aggregator_block($op, $delta = 0, $edit = array()) {
2004-01-07 19:52:10 +00:00
if (user_access('access news feeds')) {
2004-04-27 20:10:09 +00:00
if ($op == 'list') {
2004-12-04 12:02:09 +00:00
$result = db_query('SELECT cid, title FROM {aggregator_category} ORDER BY title');
2004-04-27 20:10:09 +00:00
while ($category = db_fetch_object($result)) {
2005-05-06 06:33:45 +00:00
$block['category-'. $category->cid]['info'] = t('%title category latest items', array('%title' => theme('placeholder', $category->title)));
2004-01-06 13:32:59 +00:00
}
2004-12-04 12:02:09 +00:00
$result = db_query('SELECT fid, title FROM {aggregator_feed} ORDER BY fid');
2004-01-06 13:32:59 +00:00
while ($feed = db_fetch_object($result)) {
2005-05-06 06:33:45 +00:00
$block['feed-'. $feed->fid]['info'] = t('%title feed latest items', array('%title' => theme('placeholder', $feed->title)));
2004-01-06 13:32:59 +00:00
}
2002-10-26 15:17:26 +00:00
}
2004-12-04 12:02:09 +00:00
else if ($op == 'configure') {
2005-05-09 22:46:05 +00:00
list($type, $id) = explode('-', $delta);
2004-12-04 12:02:09 +00:00
if ($type == 'category') {
$value = db_result(db_query('SELECT block FROM {aggregator_category} WHERE cid = %d', $id));
}
else {
$value = db_result(db_query('SELECT block FROM {aggregator_feed} WHERE fid = %d', $id));
}
2005-10-11 19:44:35 +00:00
$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)));
2005-10-07 06:11:12 +00:00
return $form;
2004-12-04 12:02:09 +00:00
}
else if ($op == 'save') {
2005-05-09 22:46:05 +00:00
list($type, $id) = explode('-', $delta);
2004-12-04 12:02:09 +00:00
if ($type == 'category') {
$value = db_query('UPDATE {aggregator_category} SET block = %d WHERE cid = %d', $edit['block'], $id);
}
else {
$value = db_query('UPDATE {aggregator_feed} SET block = %d WHERE fid = %d', $edit['block'], $id);
}
}
2004-10-31 07:34:47 +00:00
else if ($op == 'view') {
2005-05-09 22:46:05 +00:00
list($type, $id) = explode('-', $delta);
2004-01-06 13:32:59 +00:00
switch ($type) {
2004-04-27 20:10:09 +00:00
case 'feed':
2005-03-03 20:05:46 +00:00
if ($feed = db_fetch_object(db_query('SELECT fid, title, block FROM {aggregator_feed} WHERE fid = %d', $id))) {
2005-03-31 09:25:33 +00:00
$block['subject'] = check_plain($feed->title);
2005-03-03 20:05:46 +00:00
$result = db_query_range('SELECT * FROM {aggregator_item} WHERE fid = %d ORDER BY timestamp DESC, iid DESC', $feed->fid, 0, $feed->block);
$block['content'] = '<div class="more-link">'. l(t('more'), 'aggregator/sources/'. $feed->fid, array('title' => t('View this feed\'s recent news.'))) .'</div>';
}
2004-01-06 13:32:59 +00:00
break;
2005-03-03 20:05:46 +00:00
2004-04-27 20:10:09 +00:00
case 'category':
2005-03-03 20:05:46 +00:00
if ($category = db_fetch_object(db_query('SELECT cid, title, block FROM {aggregator_category} WHERE cid = %d', $id))) {
2005-03-31 09:25:33 +00:00
$block['subject'] = check_plain($category->title);
2005-03-03 20:05:46 +00:00
$result = db_query_range('SELECT i.* FROM {aggregator_category_item} ci LEFT JOIN {aggregator_item} i ON ci.iid = i.iid WHERE ci.cid = %d ORDER BY i.timestamp DESC, i.iid DESC', $category->cid, 0, $category->block);
$block['content'] = '<div class="more-link">'. l(t('more'), 'aggregator/categories/'. $category->cid, array('title' => t('View this category\'s recent news.'))) .'</div>';
}
2004-01-06 13:32:59 +00:00
break;
}
2004-04-27 20:10:09 +00:00
$items = array();
while ($item = db_fetch_object($result)) {
2004-05-11 20:10:14 +00:00
$items[] = theme('aggregator_block_item', $item);
2004-04-27 20:10:09 +00:00
}
2004-05-11 20:10:14 +00:00
$block['content'] = theme('item_list', $items) . $block['content'];
2002-10-26 15:17:26 +00:00
}
2004-04-27 20:10:09 +00:00
return $block;
2002-10-26 15:17:26 +00:00
}
2001-07-11 22:06:24 +00:00
}
2004-04-27 20:10:09 +00:00
function aggregator_remove($feed) {
$result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = %d', $feed['fid']);
while ($item = db_fetch_object($result)) {
$items[] = "iid = $item->iid";
2001-05-28 18:53:48 +00:00
}
2004-04-27 20:10:09 +00:00
if ($items) {
db_query('DELETE FROM {aggregator_category_item} WHERE '. implode(' OR ', $items));
2001-07-11 22:06:24 +00:00
}
2004-04-27 20:10:09 +00:00
db_query('DELETE FROM {aggregator_item} WHERE fid = %d', $feed['fid']);
2004-04-29 21:10:12 +00:00
db_query("UPDATE {aggregator_feed} SET checked = 0, etag = '', modified = 0 WHERE fid = %d", $feed['fid']);
2005-05-05 22:22:46 +00:00
drupal_set_message(t('The news items from %site have been removed.', array('%site' => theme('placeholder', $feed['title']))));
2001-06-09 11:05:13 +00:00
}
2004-05-11 20:10:14 +00:00
/**
* Call-back function used by the XML parser.
*/
2004-01-06 13:32:59 +00:00
function aggregator_element_start($parser, $name, $attributes) {
2005-08-11 13:12:44 +00:00
global $item, $element, $tag, $items, $channel;
2003-03-23 11:48:53 +00:00
switch ($name) {
2004-05-11 20:10:14 +00:00
case 'IMAGE':
case 'TEXTINPUT':
2005-08-11 13:12:44 +00:00
case 'CONTENT':
case 'SUMMARY':
case 'TAGLINE':
case 'SUBTITLE':
case 'LOGO':
case 'INFO':
2003-03-23 11:48:53 +00:00
$element = $name;
break;
2005-09-08 20:08:42 +00:00
case 'ID':
if ($element != 'ITEM') {
$element = $name;
}
2005-08-11 13:12:44 +00:00
case 'LINK':
if ($attributes['REL'] == 'alternate') {
if ($element == 'ITEM') {
$items[$item]['LINK'] = $attributes['HREF'];
}
else {
$channel['LINK'] = $attributes['HREF'];
}
}
break;
2004-05-11 20:10:14 +00:00
case 'ITEM':
2003-03-23 11:48:53 +00:00
$element = $name;
$item += 1;
2005-08-11 13:12:44 +00:00
break;
case 'ENTRY':
$element = 'ITEM';
$item += 1;
break;
2003-03-23 09:35:32 +00:00
}
$tag = $name;
}
2004-05-11 20:10:14 +00:00
/**
* Call-back function used by the XML parser.
*/
2004-01-06 13:32:59 +00:00
function aggregator_element_end($parser, $name) {
2003-03-23 11:48:53 +00:00
global $element;
2004-01-07 19:52:10 +00:00
switch ($name) {
2004-05-11 20:10:14 +00:00
case 'IMAGE':
case 'TEXTINPUT':
case 'ITEM':
2005-08-11 13:12:44 +00:00
case 'ENTRY':
case 'CONTENT':
case 'INFO':
2005-09-08 20:08:42 +00:00
$element = '';
break;
2005-08-11 13:12:44 +00:00
case 'ID':
2005-09-08 20:08:42 +00:00
if ($element == 'ID') {
2004-05-11 20:10:14 +00:00
$element = '';
2003-03-23 11:48:53 +00:00
}
2003-03-23 09:35:32 +00:00
}
2005-09-08 20:08:42 +00:00
}
2003-03-23 09:35:32 +00:00
2004-05-11 20:10:14 +00:00
/**
* Call-back function used by the XML parser.
*/
2004-01-06 13:32:59 +00:00
function aggregator_element_data($parser, $data) {
2004-01-11 15:05:21 +00:00
global $channel, $element, $items, $item, $image, $tag;
2003-03-23 11:48:53 +00:00
switch ($element) {
2004-05-11 20:10:14 +00:00
case 'ITEM':
2003-03-23 11:48:53 +00:00
$items[$item][$tag] .= $data;
break;
2004-05-11 20:10:14 +00:00
case 'IMAGE':
2005-08-11 13:12:44 +00:00
case 'LOGO':
2004-01-11 15:05:21 +00:00
$image[$tag] .= $data;
break;
2005-08-11 13:12:44 +00:00
case 'LINK':
if ($data) {
$items[$item][$tag] .= $data;
}
break;
case 'CONTENT':
2005-08-23 05:16:50 +00:00
$items[$item]['CONTENT'] .= $data;
2005-08-11 13:12:44 +00:00
break;
case 'SUMMARY':
2005-08-23 05:16:50 +00:00
$items[$item]['SUMMARY'] .= $data;
2005-08-11 13:12:44 +00:00
break;
case 'TAGLINE':
case 'SUBTITLE':
$channel['DESCRIPTION'] .= $data;
break;
case 'INFO':
case 'ID':
2004-05-11 20:10:14 +00:00
case 'TEXTINPUT':
// The sub-element is not supported. However, we must recognize
// it or its contents will end up in the item array.
2003-03-23 11:48:53 +00:00
break;
default:
$channel[$tag] .= $data;
2003-03-23 09:35:32 +00:00
}
}
2004-05-11 20:10:14 +00:00
/**
* Checks a news feed for new items.
*/
2004-01-06 13:32:59 +00:00
function aggregator_refresh($feed) {
2004-01-11 15:05:21 +00:00
global $channel, $image;
2004-01-07 19:52:10 +00:00
// Generate conditional GET headers.
$headers = array();
if ($feed['etag']) {
$headers['If-None-Match'] = $feed['etag'];
}
if ($feed['modified']) {
2004-05-11 20:10:14 +00:00
$headers['If-Modified-Since'] = gmdate('D, d M Y H:i:s', $feed['modified']) .' GMT';
2004-01-07 19:52:10 +00:00
}
// Request feed.
$result = drupal_http_request($feed['url'], $headers);
2004-06-20 19:43:28 +00:00
// Process HTTP response code.
2004-01-07 19:52:10 +00:00
switch ($result->code) {
case 304:
2004-05-11 20:10:14 +00:00
db_query('UPDATE {aggregator_feed} SET checked = %d WHERE fid = %d', time(), $feed['fid']);
2005-05-05 22:22:46 +00:00
drupal_set_message(t('There is no new syndicated content from %site.', array('%site' => theme('placeholder', $feed['title']))));
2004-01-17 17:18:36 +00:00
break;
2004-01-07 19:52:10 +00:00
case 301:
$feed['url'] = $result->redirect_url;
2005-03-31 09:25:33 +00:00
watchdog('aggregator', t('Updated URL for feed %title to %url.', array('%title' => theme('placeholder', $feed['title']), '%url' => theme('placeholder', $feed['url']))));
2004-12-02 18:37:04 +00:00
break;
2004-01-07 19:52:10 +00:00
case 200:
case 302:
case 307:
// Filter the input data:
2004-05-13 21:43:40 +00:00
if (aggregator_parse_feed($result->data, $feed)) {
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
2004-01-17 17:18:36 +00:00
if ($result->headers['Last-Modified']) {
$modified = strtotime($result->headers['Last-Modified']);
}
2003-03-23 19:12:38 +00:00
2004-10-03 10:03:52 +00:00
/*
** Prepare the channel data:
*/
foreach ($channel as $key => $value) {
$channel[$key] = trim(strip_tags($value));
}
2004-01-17 17:18:36 +00:00
/*
** Prepare the image data (if any):
*/
2001-07-15 09:29:22 +00:00
2004-01-17 17:18:36 +00:00
foreach ($image as $key => $value) {
$image[$key] = trim($value);
}
2004-01-11 15:05:21 +00:00
2004-01-17 17:18:36 +00:00
if ($image['LINK'] && $image['URL'] && $image['TITLE']) {
2004-05-11 20:10:14 +00:00
$image = '<a href="'. $image['LINK'] .'"><img src="'. $image['URL'] .'" alt="'. $image['TITLE'] .'" /></a>';
2004-01-17 17:18:36 +00:00
}
2004-01-24 15:47:44 +00:00
else {
$image = NULL;
}
2004-01-11 15:05:21 +00:00
2004-01-17 17:18:36 +00:00
/*
** Update the feed data:
*/
2004-01-11 15:05:21 +00:00
2004-10-03 10:03:52 +00:00
db_query("UPDATE {aggregator_feed} SET url = '%s', checked = %d, link = '%s', description = '%s', image = '%s', etag = '%s', modified = %d WHERE fid = %d", $feed['url'], time(), $channel['LINK'], $channel['DESCRIPTION'], $image, $result->headers['ETag'], $modified, $feed['fid']);
2004-01-11 15:05:21 +00:00
2004-01-17 17:18:36 +00:00
/*
** Clear the cache:
*/
2004-01-11 15:05:21 +00:00
2004-01-17 17:18:36 +00:00
cache_clear_all();
2004-01-11 15:05:21 +00:00
2005-12-26 11:15:57 +00:00
watchdog('aggregator', t('There is new syndicated content from %site.', array('%site' => theme('placeholder', $feed['title']))));
drupal_set_message(t('There is new syndicated content from %site.', array('%site' => theme('placeholder', $feed['title']))));
2004-01-17 17:18:36 +00:00
}
break;
2004-01-07 19:52:10 +00:00
default:
2005-05-05 22:22:46 +00:00
watchdog('aggregator', t('The RSS-feed from %site seems to be broken, due to "%error".', array('%site' => theme('placeholder', $feed['title']), '%error' => theme('placeholder', $result->code .' '. $result->error))), WATCHDOG_WARNING);
drupal_set_message(t('The RSS-feed from %site seems to be broken, because of error "%error".', array('%site' => theme('placeholder', $feed['title']), '%error' => theme('placeholder', $result->code .' '. $result->error))));
2001-07-15 09:29:22 +00:00
}
2004-01-07 19:52:10 +00:00
}
2001-07-15 09:29:22 +00:00
2004-07-26 18:42:31 +00:00
/**
* Parse the W3C date/time format, a subset of ISO 8601. PHP date parsing
* functions do not handle this format.
* See http://www.w3.org/TR/NOTE-datetime for more information.
2005-03-31 21:18:08 +00:00
* Originally from MagpieRSS (http://magpierss.sourceforge.net/).
2004-07-26 18:42:31 +00:00
*
* @param $date_str A string with a potentially W3C DTF date.
2004-10-19 18:02:31 +00:00
* @return A timestamp if parsed successfully or -1 if not.
2004-07-26 18:42:31 +00:00
*/
function aggregator_parse_w3cdtf($date_str) {
if (preg_match('/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/', $date_str, $match)) {
list($year, $month, $day, $hours, $minutes, $seconds) = array($match[1], $match[2], $match[3], $match[4], $match[5], $match[6]);
// calc epoch for current date assuming GMT
$epoch = gmmktime($hours, $minutes, $seconds, $month, $day, $year);
if ($match[10] != 'Z') { // Z is zulu time, aka GMT
list($tz_mod, $tz_hour, $tz_min) = array($match[8], $match[9], $match[10]);
// zero out the variables
if (!$tz_hour) {
$tz_hour = 0;
}
if (!$tz_min) {
$tz_min = 0;
}
$offset_secs = (($tz_hour * 60) + $tz_min) * 60;
// is timezone ahead of GMT? then subtract offset
if ($tz_mod == '+') {
$offset_secs *= -1;
}
$epoch += $offset_secs;
}
return $epoch;
}
else {
2005-12-15 16:02:50 +00:00
return FALSE;
2004-07-26 18:42:31 +00:00
}
}
2004-01-07 19:52:10 +00:00
function aggregator_parse_feed(&$data, $feed) {
2004-01-11 15:05:21 +00:00
global $items, $image, $channel;
2003-06-22 07:36:06 +00:00
2004-01-07 19:52:10 +00:00
// Unset the global variables before we use them:
2004-05-11 20:10:14 +00:00
unset($GLOBALS['element'], $GLOBALS['item'], $GLOBALS['tag']);
2004-01-07 19:52:10 +00:00
$items = array();
2004-01-11 15:05:21 +00:00
$image = array();
2004-01-07 19:52:10 +00:00
$channel = array();
2003-03-23 09:35:32 +00:00
2004-01-07 19:52:10 +00:00
// parse the data:
$xml_parser = drupal_xml_parser_create($data);
2004-05-11 20:10:14 +00:00
xml_set_element_handler($xml_parser, 'aggregator_element_start', 'aggregator_element_end');
xml_set_character_data_handler($xml_parser, 'aggregator_element_data');
2001-07-09 18:13:53 +00:00
2004-01-07 19:52:10 +00:00
if (!xml_parse($xml_parser, $data, 1)) {
2005-05-05 22:22:46 +00:00
watchdog('aggregator', t('The RSS-feed from %site seems to be broken, due to an error "%error" on line %line.', array('%site' => theme('placeholder', $feed['title']), '%error' => xml_error_string(xml_get_error_code($xml_parser)), '%line' => xml_get_current_line_number($xml_parser))), WATCHDOG_WARNING);
drupal_set_message(t('The RSS-feed from %site seems to be broken, because of error "%error" on line %line.', array('%site' => theme('placeholder', $feed['title']), '%error' => xml_error_string(xml_get_error_code($xml_parser)), '%line' => xml_get_current_line_number($xml_parser))), 'error');
2004-01-17 17:18:36 +00:00
return 0;
2004-01-07 19:52:10 +00:00
}
xml_parser_free($xml_parser);
2001-06-09 11:05:13 +00:00
2004-01-07 19:52:10 +00:00
/*
** We reverse the array such that we store the first item last,
** and the last item first. In the database, the newest item
** should be at the top.
*/
2001-07-11 22:06:24 +00:00
2004-01-07 19:52:10 +00:00
$items = array_reverse($items);
2001-07-07 13:07:03 +00:00
2004-01-07 19:52:10 +00:00
foreach ($items as $item) {
unset($title, $link, $author, $description);
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
2004-01-07 19:52:10 +00:00
// Prepare the item:
foreach ($item as $key => $value) {
2005-04-07 22:46:55 +00:00
$value = decode_entities(trim($value));
2005-08-22 19:45:42 +00:00
$value = strip_tags($value, variable_get('aggregator_allowed_html_tags', '<a> <b> <br> <dd> <dl> <dt> <em> <i> <li> <ol> <p> <strong> <u> <ul>'));
2005-11-30 11:03:58 +00:00
$value = filter_xss($value);
The Input formats - filter patch has landed. I still need to make update instructions for modules and update the hook docs.
Here's an overview of the changes:
1) Multiple Input formats: they are complete filter configurations (what filters to use, in what order and with which settings). Input formats are admin-definable, and usage of them is role-dependant. For example, you can set it up so that regular users can only use limited HTML, while admins can free HTML without any tag limitations.
The input format can be chosen per content item (nodes, comments, blocks, ...) when you add/edit them. If only a single format is available, there is no choice, and nothing changes with before.
The default install (and the upgrade) contains a basic set of formats which should satisfy the average user's needs.
2) Filters have toggles
Because now you might want to enable a filter only on some input formats, an explicit toggle is provided by the filter system. Modules do not need to worry about it and filters that still have their own on/off switch should get rid of it.
3) Multiple filters per module
This was necessary to accomodate the next change, and it's also a logical extension of the filter system.
4) Embedded PHP is now a filter
Thanks to the multiple input formats, I was able to move the 'embedded PHP' feature from block.module, page.module and book.module into a simple filter which executes PHP code. This filter is part of filter.module, and by default there is an input format 'PHP', restricted to the administrator only, which contains this filter.
This change means that block.module now passes custom block contents through the filter system.
As well as from reducing code duplication and avoiding two type selectors for page/book nodes, you can now combine PHP code with other filters.
5) User-supplied PHP code now requires <?php ?> tags.
This is required for teasers to work with PHP code. Because PHP evaluation is now just another step in the filter process, we can't do this. Also, because teasers are generated before filtering, this would result in errors when the teaser generation would cut off a piece of PHP code.
Also, regular PHP syntax explicitly includes the <?php ?> tags for PHP files, so it makes sense to use the same convention for embedded PHP in Drupal.
6) Filter caching was added.
Benchmarking shows that even for a simple setup (basic html filtering + legacy URL rewriting), filtercache can offer speedups. Unlike the old filtercache, this uses the normal cache table.
7) Filtertips were moved from help into a hook_filter_tips(). This was required to accomodate the fact that there are multiple filters per module, and that filter settings are format dependant. Shoehorning filter tips into _help was ugly and silly. The display of the filter tips is done through the input format selector, so filter_tips_short() no longer exists.
8) A more intelligent linebreak convertor was added, which doesn't stop working if you use block-level tags and which adds <p> tags.
2004-08-10 18:34:29 +00:00
$item[$key] = $value;
2004-01-07 19:52:10 +00:00
}
2005-11-30 11:03:58 +00:00
2004-01-11 15:05:21 +00:00
/*
** Resolve the item's title. If no title is found, we use
** up to 40 characters of the description ending at a word
** boundary but not splitting potential entities.
*/
2004-05-11 20:10:14 +00:00
if ($item['TITLE']) {
$title = $item['TITLE'];
2004-01-07 19:52:10 +00:00
}
else {
2004-05-11 20:10:14 +00:00
$title = preg_replace('/^(.*)[^\w;&].*?$/', "\\1", truncate_utf8($item['DESCRIPTION'], 40));
2004-01-07 19:52:10 +00:00
}
2002-01-05 21:48:14 +00:00
2004-01-11 15:05:21 +00:00
/*
** Resolve the items link.
*/
2004-05-11 20:10:14 +00:00
if ($item['LINK']) {
$link = $item['LINK'];
2004-01-07 19:52:10 +00:00
}
2004-05-11 20:10:14 +00:00
elseif ($item['GUID'] && (strncmp($item['GUID'], 'http://', 7) == 0)) {
$link = $item['GUID'];
2004-01-07 19:52:10 +00:00
}
else {
2004-05-11 20:10:14 +00:00
$link = $feed['link'];
2004-01-07 19:52:10 +00:00
}
2003-03-23 09:35:32 +00:00
2005-08-23 05:16:50 +00:00
/**
* Atom feeds have a CONTENT and/or SUMMARY tag instead of a DESCRIPTION tag
*/
if ($item['CONTENT']) {
$item['DESCRIPTION'] = $item['CONTENT'];
}
else if ($item['SUMMARY']) {
$item['DESCRIPTION'] = $item['SUMMARY'];
}
2004-01-11 15:05:21 +00:00
/*
** Try to resolve and parse the item's publication date. If no
** date is found, we use the current date instead.
*/
if ($item['PUBDATE']) $date = $item['PUBDATE']; // RSS 2.0
else if ($item['DC:DATE']) $date = $item['DC:DATE']; // Dublin core
else if ($item['DCTERMS:ISSUED']) $date = $item['DCTERMS:ISSUED']; // Dublin core
else if ($item['DCTERMS:CREATED']) $date = $item['DCTERMS:CREATED']; // Dublin core
else if ($item['DCTERMS:MODIFIED']) $date = $item['DCTERMS:MODIFIED']; // Dublin core
2005-11-24 20:20:53 +00:00
else if ($item['ISSUED']) $date = $item['ISSUED']; // Atom XML
else if ($item['CREATED']) $date = $item['CREATED']; // Atom XML
else if ($item['MODIFIED']) $date = $item['MODIFIED']; // Atom XML
2004-02-04 21:23:07 +00:00
else $date = 'now';
2004-01-11 15:05:21 +00:00
2005-12-15 16:02:50 +00:00
$timestamp = strtotime($date); // As of PHP 5.1.0, strtotime returns FALSE on failure instead of -1.
if ($timestamp <= 0) {
$timestamp = aggregator_parse_w3cdtf($date); // Returns FALSE on failure
if (!$timestamp) {
2004-07-26 18:42:31 +00:00
$timestamp = time(); // better than nothing
}
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
}
2001-12-24 10:51:25 +00:00
/*
2004-01-07 19:52:10 +00:00
** Save this item. Try to avoid duplicate entries as much as
** possible. If we find a duplicate entry, we resolve it and
** pass along it's ID such that we can update it if needed.
2001-12-24 10:51:25 +00:00
*/
2004-05-11 20:10:14 +00:00
if ($link && $link != $feed['link'] && $link != $feed['url']) {
$entry = db_fetch_object(db_query("SELECT iid FROM {aggregator_item} WHERE fid = %d AND link = '%s'", $feed['fid'], $link));
2004-01-07 19:52:10 +00:00
}
else {
2004-05-11 20:10:14 +00:00
$entry = db_fetch_object(db_query("SELECT iid FROM {aggregator_item} WHERE fid = %d AND title = '%s'", $feed['fid'], $title));
2004-01-07 19:52:10 +00:00
}
2001-12-24 10:51:25 +00:00
2005-11-30 11:03:58 +00:00
aggregator_save_item(array('iid' => $entry->iid, 'fid' => $feed['fid'], 'timestamp' => $timestamp, 'title' => $title, 'link' => $link, 'author' => $item['AUTHOR'], 'description' => $item['DESCRIPTION']));
2004-01-07 19:52:10 +00:00
}
2004-01-11 15:05:21 +00:00
2004-01-07 19:52:10 +00:00
/*
2005-02-10 20:33:18 +00:00
** Remove all items that are older than flush item timer:
2004-01-07 19:52:10 +00:00
*/
2001-12-24 10:51:25 +00:00
2005-02-10 20:33:18 +00:00
$age = time() - variable_get('aggregator_clear', 9676800);
2004-05-13 18:47:27 +00:00
$result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = %d AND timestamp < %d', $feed['fid'], $age);
2001-12-24 10:51:25 +00:00
2004-05-13 21:43:40 +00:00
if (db_num_rows($result)) {
$items = array();
while ($item = db_fetch_object($result)) {
$items[] = $item->iid;
}
db_query('DELETE FROM {aggregator_category_item} WHERE iid IN ('. implode(', ', $items) .')');
db_query('DELETE FROM {aggregator_item} WHERE fid = %d AND timestamp < %d', $feed['fid'], $age);
2001-08-04 13:37:41 +00:00
}
2004-01-17 17:18:36 +00:00
return 1;
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
}
2004-01-06 13:32:59 +00:00
function aggregator_save_item($edit) {
2004-05-11 20:10:14 +00:00
if ($edit['iid'] && $edit['title']) {
2004-07-26 18:42:31 +00:00
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']);
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
}
2004-05-11 20:10:14 +00:00
else if ($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']);
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
}
2004-05-11 20:10:14 +00:00
else if ($edit['title'] && $edit['link']) {
2004-07-26 18:42:31 +00:00
$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']);
2004-04-27 20:10:09 +00:00
// file the items in the categories indicated by the feed
$categories = db_query('SELECT cid FROM {aggregator_category_feed} WHERE fid = %d', $edit['fid']);
while ($category = db_fetch_object($categories)) {
2004-07-26 18:42:31 +00:00
db_query('INSERT INTO {aggregator_category_item} (cid, iid) VALUES (%d, %d)', $category->cid, $edit['iid']);
2004-04-27 20:10:09 +00:00
}
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
}
}
2004-04-27 20:10:09 +00:00
function aggregator_form_category($edit = array()) {
2005-11-12 11:26:16 +00:00
$form['title'] = array('#type' => 'textfield', '#title' => t('Title'), '#default_value' => $edit['title'], '#maxlength' => 64);
$form['description'] = array('#type' => 'textarea', '#title' => t('Description'), '#default_value' => $edit['description']);
2005-10-11 19:44:35 +00:00
$form['submit'] = array('#type' => 'submit', '#value' =>t('Submit'));
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
2004-04-27 20:10:09 +00:00
if ($edit['cid']) {
2005-10-11 19:44:35 +00:00
$form['delete'] = array('#type' => 'submit', '#value' =>t('Delete'));
$form['cid'] = array('#type' => 'hidden', '#value' => $edit['cid']);
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
}
2005-10-07 06:11:12 +00:00
return drupal_get_form('aggregator_form_category', $form);
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
}
2004-04-27 20:10:09 +00:00
function aggregator_save_category($edit) {
if ($edit['cid'] && $edit['title']) {
2004-12-04 12:02:09 +00:00
db_query('UPDATE {aggregator_category} SET title = \'%s\', description = \'%s\' WHERE cid = %d', $edit['title'], $edit['description'], $edit['cid']);
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
}
2004-04-27 20:10:09 +00:00
else if ($edit['cid']) {
db_query('DELETE FROM {aggregator_category} WHERE cid = %d', $edit['cid']);
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
}
2004-04-27 20:10:09 +00:00
else if ($edit['title']) {
2002-10-26 15:17:26 +00:00
// a single unique id for bundles and feeds, to use in blocks
2004-04-27 20:10:09 +00:00
$next_id = db_next_id('{aggregator_category}_cid');
2004-12-04 12:02:09 +00:00
db_query('INSERT INTO {aggregator_category} (cid, title, description, block) VALUES (%d, \'%s\', \'%s\', 5)', $next_id, $edit['title'], $edit['description']);
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
}
}
2004-01-06 13:32:59 +00:00
function aggregator_form_feed($edit = array()) {
2004-05-11 20:10:14 +00:00
$period = drupal_map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
2004-05-11 20:10:14 +00:00
if ($edit['refresh'] == '') {
$edit['refresh'] = 3600;
2001-12-30 16:16:38 +00:00
}
2001-07-11 22:06:24 +00:00
2005-10-07 06:51:43 +00:00
2005-11-12 11:26:16 +00:00
$form['title'] = array('#type' => 'textfield', '#title' => t('Title'), '#default_value' => $edit['title'], '#maxlength' => 64, '#description' => t('The name of the feed; typically the name of the web site you syndicate content from.'));
$form['url'] = array('#type' => 'textfield', '#title' => t('URL'), '#default_value' => $edit['url'], '#maxlength' => 255, '#description' => t('The fully-qualified URL of the feed.'));
2005-10-11 19:44:35 +00:00
$form['refresh'] = array('#type' => 'select', '#title' => t('Update interval'), '#default_value' => $edit['refresh'], '#options' => $period, '#description' => t('The refresh interval indicating how often you want to update this feed. Requires crontab.'));
2004-12-04 12:02:09 +00:00
// Handling of categories:
$options = array();
$values = array();
2004-05-11 20:10:14 +00:00
$categories = db_query('SELECT c.cid, c.title, f.fid FROM {aggregator_category} c LEFT JOIN {aggregator_category_feed} f ON c.cid = f.cid AND f.fid = %d ORDER BY title', $edit['fid']);
2004-04-27 20:10:09 +00:00
while ($category = db_fetch_object($categories)) {
2004-12-04 12:02:09 +00:00
$options[$category->cid] = $category->title;
2005-03-31 09:25:33 +00:00
if ($category->fid) $values[] = check_plain($category->cid);
2004-04-27 20:10:09 +00:00
}
2004-12-04 12:02:09 +00:00
if ($options) {
2005-10-11 19:44:35 +00:00
$form['category'] = array('#type' => 'checkboxes', '#title' => t('Categorize news items'), '#default_value' => $values, '#options' => $options, '#description' => t('New items in this feed will be automatically filed in the checked categories as they are received.'));
2004-04-27 20:10:09 +00:00
}
2005-10-11 19:44:35 +00:00
$form['submit'] = array('#type' => 'submit', '#value' =>t('Submit'));
2004-12-07 16:55:38 +00:00
2004-05-11 20:10:14 +00:00
if ($edit['fid']) {
2005-10-11 19:44:35 +00:00
$form['delete'] = array('#type' => 'submit', '#value' =>t('Delete'));
$form['fid'] = array('#type' => 'hidden', '#value' => $edit['fid']);
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
}
2005-10-07 06:11:12 +00:00
return drupal_get_form('aggregator_form_feed', $form);
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
}
2004-01-06 13:32:59 +00:00
function aggregator_save_feed($edit) {
2004-04-27 20:10:09 +00:00
if ($edit['fid']) {
2004-06-20 19:43:28 +00:00
// an existing feed is being modified, delete the category listings
2004-04-27 20:10:09 +00:00
db_query('DELETE FROM {aggregator_category_feed} WHERE fid = %d', $edit['fid']);
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
}
2004-04-27 20:10:09 +00:00
if ($edit['fid'] && $edit['title']) {
2004-12-04 12:02:09 +00:00
db_query('UPDATE {aggregator_feed} SET title = \'%s\', url = \'%s\', refresh = %d WHERE fid = %d', $edit['title'], $edit['url'], $edit['refresh'], $edit['fid']);
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
}
2004-04-27 20:10:09 +00:00
else if ($edit['fid']) {
$result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = %d', $edit['fid']);
while ($item = db_fetch_object($result)) {
$items[] = "iid = $item->iid";
}
if ($items) {
db_query('DELETE FROM {aggregator_category_item} WHERE '. implode(' OR ', $items));
}
db_query('DELETE FROM {aggregator_feed} WHERE fid = %d', $edit['fid']);
db_query('DELETE FROM {aggregator_item} WHERE fid = %d', $edit['fid']);
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
}
2004-04-27 20:10:09 +00:00
else if ($edit['title']) {
// a single unique id for bundles and feeds, to use in blocks
$edit['fid'] = db_next_id('{aggregator_feed}_fid');
2004-12-04 12:02:09 +00:00
db_query('INSERT INTO {aggregator_feed} (fid, title, url, refresh, block) VALUES (%d, \'%s\', \'%s\', %d, 5)', $edit['fid'], $edit['title'], $edit['url'], $edit['refresh']);
2004-04-27 20:10:09 +00:00
}
if ($edit['title']) {
// the feed is being saved, save the categories as well
2004-05-17 22:11:12 +00:00
if ($edit['category']) {
2005-12-14 14:03:05 +00:00
foreach ($edit['category'] as $cid => $value) {
2004-12-04 12:02:09 +00:00
db_query('INSERT INTO {aggregator_category_feed} (fid, cid) VALUES (%d, %d)', $edit['fid'], $cid);
2004-04-27 20:10:09 +00:00
}
}
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
}
}
2004-01-06 13:32:59 +00:00
function aggregator_get_feed($fid) {
2004-05-11 20:10:14 +00:00
return db_fetch_array(db_query('SELECT * FROM {aggregator_feed} WHERE fid = %d', $fid));
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
}
2004-04-27 20:10:09 +00:00
function aggregator_get_category($cid) {
2004-05-11 20:10:14 +00:00
return db_fetch_array(db_query('SELECT * FROM {aggregator_category} WHERE cid = %d', $cid));
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
}
2004-01-06 13:32:59 +00:00
function aggregator_view() {
2004-09-20 17:58:14 +00:00
$result = db_query('SELECT f.*, COUNT(i.iid) AS items FROM {aggregator_feed} f LEFT JOIN {aggregator_item} i ON f.fid = i.fid GROUP BY f.fid, f.title, f.url, f.refresh, f.checked, f.link, f.description, f.etag, f.modified, f.image, f.block ORDER BY f.title');
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
2004-05-11 20:10:14 +00:00
$output .= '<h3>'. t('Feed overview') .'</h3>';
2002-12-29 16:54:31 +00:00
2004-11-15 11:16:39 +00:00
$header = array(t('Title'), t('Items'), t('Last update'), t('Next update'), array('data' => t('Operations'), 'colspan' => '3'));
2004-01-07 19:52:10 +00:00
$rows = array();
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
while ($feed = db_fetch_object($result)) {
2004-08-05 05:40:53 +00:00
$rows[] = array(l($feed->title, "aggregator/sources/$feed->fid"), format_plural($feed->items, '1 item', '%count items'), ($feed->checked ? t('%time ago', array('%time' => format_interval(time() - $feed->checked))) : t('never')), ($feed->checked ? t('%time left', array('%time' => format_interval($feed->checked + $feed->refresh - time()))) : t('never')), l(t('edit'), "admin/aggregator/edit/feed/$feed->fid"), l(t('remove items'), "admin/aggregator/remove/$feed->fid"), l(t('update items'), "admin/aggregator/update/$feed->fid"));
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
}
2004-05-11 20:10:14 +00:00
$output .= theme('table', $header, $rows);
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
2004-09-20 17:58:14 +00:00
$result = db_query('SELECT c.cid, c.title, count(ci.iid) as items FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid GROUP BY c.cid, c.title ORDER BY title');
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
2004-05-11 20:10:14 +00:00
$output .= '<h3>'. t('Category overview') .'</h3>';
2002-12-29 16:54:31 +00:00
2004-08-19 15:41:57 +00:00
$header = array(t('Title'), t('Items'), t('Operations'));
2004-01-07 19:52:10 +00:00
$rows = array();
2004-04-27 20:10:09 +00:00
while ($category = db_fetch_object($result)) {
2004-08-05 05:40:53 +00:00
$rows[] = array(l($category->title, "aggregator/categories/$category->cid"), format_plural($category->items, '1 item', '%count items'), l(t('edit'), "admin/aggregator/edit/category/$category->cid"));
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
}
2004-05-11 20:10:14 +00:00
$output .= theme('table', $header, $rows);
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
return $output;
}
2004-06-18 15:04:37 +00:00
function aggregator_edit() {
if ($_POST['op'] == t('Submit')) {
if (arg(1) == 'categories') {
aggregator_save_category($_POST['edit']);
drupal_set_message(t('The category has been updated.'));
}
else {
aggregator_save_feed($_POST['edit']);
drupal_set_message(t('The feed has been updated.'));
}
2004-06-28 23:16:59 +00:00
2004-09-18 02:09:03 +00:00
menu_rebuild();
2004-06-28 23:16:59 +00:00
drupal_goto($_GET['q']);
2004-06-18 15:04:37 +00:00
}
else if ($_POST['op'] == t('Delete')) {
// Unset the title:
unset($_POST['edit']['title']);
if (arg(1) == 'categories') {
aggregator_save_category($_POST['edit']);
drupal_set_message(t('The category has been deleted.'));
}
else {
aggregator_save_feed($_POST['edit']);
drupal_set_message(t('The feed has been deleted.'));
}
2004-09-18 02:09:03 +00:00
menu_rebuild();
2004-06-28 23:16:59 +00:00
drupal_goto('aggregator/'. arg(1));
2004-06-18 15:04:37 +00:00
}
if (arg(1) == 'categories') {
$output = aggregator_form_category(aggregator_get_category(arg(2)));
}
else {
$output = aggregator_form_feed(aggregator_get_feed(arg(2)));
}
2005-04-24 16:34:36 +00:00
return $output;
2004-06-18 15:04:37 +00:00
}
2004-05-11 20:10:14 +00:00
/**
2004-05-17 22:00:06 +00:00
* Menu callback; displays the category edit form, or saves changes and
2004-06-28 23:16:59 +00:00
* redirects to the overview page.
2004-05-11 20:10:14 +00:00
*/
function aggregator_admin_edit_category($category = 0) {
$edit = $_POST['edit'];
$op = $_POST['op'];
switch ($op) {
case t('Delete'):
$edit['title'] = 0;
// Fall through:
case t('Submit'):
aggregator_save_category($edit);
2005-05-05 22:22:46 +00:00
drupal_set_message($edit['title'] ? t('The category has been updated.') : t('The category has been removed.'));
2004-09-18 02:09:03 +00:00
menu_rebuild();
2004-06-28 23:16:59 +00:00
drupal_goto('admin/aggregator');
break;
2004-05-11 20:10:14 +00:00
default:
if ($category) {
$output = aggregator_form_category(aggregator_get_category($category));
2004-02-15 20:09:46 +00:00
}
else {
2004-05-11 20:10:14 +00:00
$output = aggregator_form_category();
2004-02-15 20:09:46 +00:00
}
2004-05-11 20:10:14 +00:00
}
2005-04-24 16:34:36 +00:00
return $output;
2004-05-11 20:10:14 +00:00
}
/**
2004-05-17 22:00:06 +00:00
* Menu callback; displays the feed edit form.
*
2004-06-28 23:16:59 +00:00
* After editing, saves changes and redirects to the overview page.
2004-05-11 20:10:14 +00:00
*/
function aggregator_admin_edit_feed($feed = 0) {
$edit = $_POST['edit'];
$op = $_POST['op'];
switch ($op) {
case t('Delete'):
$edit['title'] = 0;
// Fall through:
case t('Submit'):
aggregator_save_feed($edit);
2005-05-05 22:22:46 +00:00
drupal_set_message($edit['title'] ? t('The feed has been updated.') : t('The feed has been removed.'));
2004-09-18 02:09:03 +00:00
menu_rebuild();
2004-06-28 23:16:59 +00:00
drupal_goto('admin/aggregator');
break;
2004-05-11 20:10:14 +00:00
default:
if ($feed) {
$output = aggregator_form_feed(aggregator_get_feed($feed));
2004-02-15 20:09:46 +00:00
}
else {
2004-05-11 20:10:14 +00:00
$output = aggregator_form_feed();
2004-02-15 20:09:46 +00:00
}
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
}
2005-04-24 16:34:36 +00:00
return $output;
2004-05-11 20:10:14 +00:00
}
/**
2004-06-28 23:16:59 +00:00
* Menu callback; removes all items from a feed, then redirects to the overview page.
2004-05-11 20:10:14 +00:00
*/
function aggregator_admin_remove_feed($feed) {
aggregator_remove(aggregator_get_feed($feed));
2004-06-28 23:16:59 +00:00
drupal_goto('admin/aggregator');
2004-05-11 20:10:14 +00:00
}
/**
2004-06-28 23:16:59 +00:00
* Menu callback; refreshes a feed, then redirects to the overview page.
2004-05-11 20:10:14 +00:00
*/
function aggregator_admin_refresh_feed($feed) {
aggregator_refresh(aggregator_get_feed($feed));
2004-06-28 23:16:59 +00:00
drupal_goto('admin/aggregator');
2004-05-11 20:10:14 +00:00
}
/**
2004-05-17 22:00:06 +00:00
* Menu callback; displays the aggregator administration page.
2004-05-11 20:10:14 +00:00
*/
function aggregator_admin_overview() {
2005-04-24 16:34:36 +00:00
return aggregator_view();
- Rewrote the headline module from scratch. Note that the old
headline code is still in place 'till the new code has proven
to be stable. See "syndication.module" for the new code.
Changes:
+ Improved the parser and tested it against RSS 0.9, RSS 0.91,
RSS 0.92, RSS 1.0, RDF and XML feeds.
+ Improved the administration interface. It might be a bit fuzzy
at first. Maybe some native English like Julian, Michael (or any
one else with knowledge in the field) can help out by suggesting
better naming, terminology or descriptions - as well as by
writing the help section for this module? I'd have no idea how
much this would be appreciated.
+ We can *easily* recognize new tags or extensions: we parse out
"link", "title", "description" and "author" right now, but we
will have to revise which tags to support and which not. New
tags can be added in less than 10 minutes (if you are familiar
with the code). Read: we have something we can build on.
+ Within each item, tags can now appear is random order which is
or was not the case with the old headline code where we expect
<link>s prior to <description>s for example.
+ Feed updates only (ie. always) happen through cron. Neither do
we use one global cron for updating all feeds; instead, every
feed can specify his own update-interval.
+ Newly fetched headlines are "appended" to the pool of existing
headlines (read: we don't replace the whole feed), and headlines
automatically "expire" after x days or hours. (Every headline
has a timestamp.)
+ Got rid of backend.class; it is integrated in the module.
+ Switched to more generic names: "headline" became "item" and
"backend" became "feed". This should ease future non-headline
oriented syndication.
+ You can associate attributes or keyword lists with every feed.
At the moment new items will automatically inherit their feeds
attributes but in future we can use heuristics to make these
attributes "mutate" when and where we see fit. The attributes
can be maintained by hand as well.
+ We don't export any blocks yet; we will soon do as soon this
new code has been tested for a bit more. We will only export
bundles though so if you want to export by feed/source, you
will have to make a source-specific bundle.
- Polished a bit on a few other modules: nothing major.
2001-05-26 18:26:56 +00:00
}
2004-05-11 20:10:14 +00:00
/**
2004-05-17 22:00:06 +00:00
* Menu callback; displays the most recent items gathered from any feed.
2004-05-11 20:10:14 +00:00
*/
2004-05-07 07:26:31 +00:00
function aggregator_page_last() {
2005-04-25 17:49:43 +00:00
return _aggregator_page_list('SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_item} i INNER JOIN {aggregator_feed} f ON i.fid = f.fid ORDER BY i.timestamp DESC, i.iid DESC', arg(1));
2001-07-11 22:06:24 +00:00
}
2004-05-11 20:10:14 +00:00
/**
2004-05-17 22:00:06 +00:00
* Menu callback; displays all the items captured from a particular feed.
2004-05-11 20:10:14 +00:00
*/
2004-05-07 07:26:31 +00:00
function aggregator_page_source() {
2004-05-11 20:10:14 +00:00
$feed = db_fetch_object(db_query('SELECT * FROM {aggregator_feed} WHERE fid = %d', arg(2)));
2004-01-11 15:05:21 +00:00
$info = theme('aggregator_feed', $feed);
2001-07-11 22:06:24 +00:00
2005-04-25 17:49:43 +00:00
return _aggregator_page_list('SELECT * FROM {aggregator_item} WHERE fid = '. $feed->fid .' ORDER BY timestamp DESC, iid DESC', arg(3), "<div class=\"feed\">$info</div>");
2001-07-11 22:06:24 +00:00
}
2004-05-11 20:10:14 +00:00
/**
2004-05-17 22:00:06 +00:00
* Menu callback; displays all the items aggregated in a particular category.
2004-05-11 20:10:14 +00:00
*/
2004-05-07 07:26:31 +00:00
function aggregator_page_category() {
2004-05-11 20:10:14 +00:00
$category = db_fetch_object(db_query('SELECT cid, title FROM {aggregator_category} WHERE cid = %d', arg(2)));
2001-07-14 19:02:36 +00:00
2005-04-25 17:49:43 +00:00
return _aggregator_page_list('SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_category_item} c LEFT JOIN {aggregator_item} i ON c.iid = i.iid LEFT JOIN {aggregator_feed} f ON i.fid = f.fid WHERE cid = '. $category->cid .' ORDER BY timestamp DESC, iid DESC', arg(3));
2004-04-27 20:10:09 +00:00
}
2001-07-11 22:06:24 +00:00
2004-05-11 20:10:14 +00:00
/**
* Prints an aggregator page listing a number of feed items. Various
* menu callbacks use this function to print their feeds.
*/
2004-05-13 18:47:27 +00:00
function _aggregator_page_list($sql, $op, $header = '') {
2005-10-07 06:11:12 +00:00
$categorize = (user_access('administer news feeds') && ($op == 'categorize'));
2001-07-11 22:06:24 +00:00
2004-04-27 20:10:09 +00:00
$output = '<div id="aggregator">';
2004-05-13 18:47:27 +00:00
2005-10-11 19:44:35 +00:00
$form['header'] = array('#value' => $header);
$output .= $form['header']['#value'];
2004-05-13 18:47:27 +00:00
2005-10-07 06:11:12 +00:00
$result = pager_query($sql, 20);
2004-04-27 20:10:09 +00:00
$categories = array();
2001-07-11 22:06:24 +00:00
while ($item = db_fetch_object($result)) {
2005-10-11 19:44:35 +00:00
$form['items'][$item->iid] = array('#value' => theme('aggregator_page_item', $item));
$output .= $form['items'][$item->iid]['#value'];
2005-10-07 06:11:12 +00:00
$form['categories'][$item->iid] = array();
2004-04-27 20:10:09 +00:00
if ($categorize) {
2005-10-07 06:11:12 +00:00
2004-04-27 20:10:09 +00:00
$categories_result = db_query('SELECT c.cid, c.title, ci.iid FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid AND ci.iid = %d', $item->iid);
2005-10-07 06:11:12 +00:00
$selected = array();
while ($category = db_fetch_object($categories_result)) {
if (!$done) {
$categories[$category->cid] = check_plain($category->title);
2004-04-27 20:10:09 +00:00
}
2005-10-07 06:11:12 +00:00
if ($category->iid) {
$selected[] = $category->cid;
2004-04-27 20:10:09 +00:00
}
}
2005-10-07 06:11:12 +00:00
$done = true;
$form['categories'][$item->iid] = array(
2005-10-11 19:44:35 +00:00
'#type' => variable_get('aggregator_category_selector', 'checkboxes'),
'#default_value' => $selected, '#options' => $categories,
'#size' => 10, '#multiple' => true
2005-10-07 06:11:12 +00:00
);
2004-04-27 20:10:09 +00:00
}
2001-07-11 22:06:24 +00:00
}
2005-10-07 06:51:43 +00:00
$output .= '</div>';
2005-10-11 19:44:35 +00:00
$form['submit'] = array('#type' => 'submit', '#value' => t('Save categories'));
$form['pager'] = array('#value' => theme('pager', NULL, 20, 0));
$output .= $form['pager']['#value'];
2004-05-13 18:47:27 +00:00
2005-09-01 19:50:18 +00:00
// arg(1) is undefined if we are at the top aggregator URL
// is there a better way to do this?
if (!arg(1)) {
2005-12-29 04:46:40 +00:00
$form['feed_icon'] = array('#value' => theme('feed_icon', url('aggregator/rss')));
2005-09-01 19:50:18 +00:00
}
elseif (arg(1) == 'categories' && arg(2) && !arg(3)) {
2005-12-29 04:46:40 +00:00
$form['feed_icon'] = array('#value' => theme('feed_icon', url('aggregator/rss/' . arg(2))));
2005-09-01 19:50:18 +00:00
}
2005-12-29 04:46:40 +00:00
$output .= $form['feed_icon']['#value'];
2005-10-07 06:11:12 +00:00
return ($categorize) ? drupal_get_form('aggregator_page_list', $form) : $output;
}
2005-09-01 19:50:18 +00:00
2005-10-07 06:11:12 +00:00
function theme_aggregator_page_list($form) {
$output = '<div id="aggregator">';
$output .= form_render($form['header']);
$rows = array();
if ($form['items']) {
foreach (element_children($form['items']) as $key) {
if (is_array($form['items'][$key])) {
$rows[] = array(form_render($form['items'][$key]), array('data' => form_render($form['categories'][$key]), 'class' => 'categorize-item'));
}
}
}
$output .= theme('table', array('', t('Categorize')), $rows);
$output .= form_render($form['submit']);
$output .= '</div>';
$output .= form_render($form);
2005-04-24 16:34:36 +00:00
return $output;
2001-07-11 22:06:24 +00:00
}
2005-10-07 06:11:12 +00:00
function aggregator_page_list_validate($form_id, &$form) {
if (!user_access('administer news feeds')) {
form_error($form, t('You are not allowed to categorize this feed item.'));
}
}
2005-12-02 15:21:01 +00:00
function aggregator_page_list_submit($form_id, $form) {
2005-10-07 06:11:12 +00:00
global $form_values;
foreach ($form_values['categories'] as $iid => $selection) {
db_query('DELETE FROM {aggregator_category_item} WHERE iid = %d', $iid);
foreach ($selection as $cid) {
if ($cid) {
db_query('INSERT INTO {aggregator_category_item} (cid, iid) VALUES (%d, %d)', $cid, $iid);
}
}
}
drupal_set_message(t('The categories have been saved.'));
drupal_goto($_GET['q']);
}
2004-05-11 20:10:14 +00:00
/**
2004-05-17 22:00:06 +00:00
* Menu callback; displays all the feeds used by the aggregator.
2004-05-11 20:10:14 +00:00
*/
2004-01-06 13:32:59 +00:00
function aggregator_page_sources() {
2006-01-15 17:03:34 +00:00
$result = db_query('SELECT f.fid, f.title, f.description, f.image, MAX(i.timestamp) AS last FROM {aggregator_feed} f LEFT JOIN {aggregator_item} i ON f.fid = i.fid GROUP BY f.fid, f.title, f.description, f.image ORDER BY last DESC, f.title');
2004-07-25 18:49:57 +00:00
$output = "<div id=\"aggregator\">\n";
2001-07-15 11:32:46 +00:00
while ($feed = db_fetch_object($result)) {
2005-03-31 09:25:33 +00:00
$output .= '<h2>'. check_plain($feed->title) ."</h2>\n";
2004-04-27 20:10:09 +00:00
// Most recent items:
$list = array();
if (variable_get('aggregator_summary_items', 3)) {
$items = db_query_range('SELECT i.title, i.timestamp, i.link FROM {aggregator_item} i WHERE i.fid = %d ORDER BY i.timestamp DESC', $feed->fid, 0, variable_get('aggregator_summary_items', 3));
while ($item = db_fetch_object($items)) {
2004-07-25 18:49:57 +00:00
$list[] = theme('aggregator_summary_item', $item);
2004-04-27 20:10:09 +00:00
}
}
$output .= theme('item_list', $list);
2004-07-25 18:49:57 +00:00
$output .= '<div class="links">'. theme('links', array(l(t('more'), 'aggregator/sources/'. $feed->fid))) ."</div>\n";
2001-07-15 11:32:46 +00:00
}
2004-01-11 15:05:21 +00:00
$output .= theme('xml_icon', url('aggregator/opml'));
2004-04-27 20:10:09 +00:00
$output .= '</div>';
2005-04-24 16:34:36 +00:00
return $output;
2001-07-15 11:32:46 +00:00
}
2005-09-01 19:50:18 +00:00
/**
* Menu callback; generate an RSS 0.92 feed of aggregator items or categories.
*/
function aggregator_page_rss() {
global $base_url;
// arg(2) is the passed cid, only select for that category
$result = NULL;
if (arg(2)) {
$category = db_fetch_object(db_query('SELECT cid, title FROM {aggregator_category} WHERE cid = %d', arg(2)));
$url = '/categories/' . $category->cid;
$title = ' ' . t('in category') . ' ' . $category->title;
$sql = 'SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_category_item} c LEFT JOIN {aggregator_item} i ON c.iid = i.iid LEFT JOIN {aggregator_feed} f ON i.fid = f.fid WHERE cid = %d ORDER BY timestamp DESC, iid DESC';
2005-09-18 10:37:57 +00:00
$result = db_query_range($sql, $category->cid, 0, variable_get('feed_default_items', 10));
2005-09-01 19:50:18 +00:00
}
// or, get the default aggregator items
else {
$sql = 'SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_item} i INNER JOIN {aggregator_feed} f ON i.fid = f.fid ORDER BY i.timestamp DESC, i.iid DESC';
2005-09-18 10:37:57 +00:00
$result = db_query_range($sql, 0, variable_get('feed_default_items', 10));
2005-09-01 19:50:18 +00:00
}
while ($item = db_fetch_object($result)) {
2005-09-18 10:37:57 +00:00
switch (variable_get('feed_item_length', 'teaser')) {
case 'teaser':
$teaser = node_teaser($item->description);
if ($teaser != $item_description) {
$teaser .= '<p><a href="'. check_url($item->link) .'">'. t('read more') ."</a></p>\n";
}
$item->description = $teaser;
break;
case 'title':
$item->description = '';
break;
}
2005-09-01 19:50:18 +00:00
$items .= format_rss_item($item->ftitle . ': ' . $item->title, $item->link, $item->description, array('pubDate' => date('r', $item->timestamp)));
}
$output .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
2005-09-18 10:37:57 +00:00
$output .= "<rss version=\"2.0\">\n";
2005-09-01 19:50:18 +00:00
$output .= format_rss_channel(variable_get('site_name', t('Drupal')) . ' ' . t('aggregator'), $base_url . '/' . url('aggregator' . $url), variable_get('site_name', t('Drupal')) . ' - ' . t('aggregated feeds') . $title, $items, 'en');
$output .= "</rss>\n";
drupal_set_header('Content-Type: text/xml; charset=utf-8');
print $output;
}
2004-05-11 20:10:14 +00:00
/**
2004-05-17 22:00:06 +00:00
* Menu callback; generates an OPML representation of all feeds.
2004-05-11 20:10:14 +00:00
*/
2005-08-23 05:45:08 +00:00
function aggregator_page_opml($cid = NULL) {
if ($cid) {
$result = db_query('SELECT f.title, f.url FROM {aggregator_feed} f LEFT JOIN {aggregator_category_feed} c on f.fid = c.fid WHERE c.cid = %d ORDER BY title', $cid);
}
else {
$result = db_query('SELECT * FROM {aggregator_feed} ORDER BY title');
}
2001-08-04 13:37:41 +00:00
2004-01-07 19:52:10 +00:00
$output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
$output .= "<opml version=\"1.1\">\n";
$output .= "<head>\n";
2005-03-31 09:25:33 +00:00
$output .= '<title>'. check_plain(variable_get('site_name', 'Drupal')) ."</title>\n";
2004-05-11 20:10:14 +00:00
$output .= '<dateModified>'. gmdate('r') ."</dateModified>\n";
2004-01-07 19:52:10 +00:00
$output .= "</head>\n";
$output .= "<body>\n";
2001-08-04 13:37:41 +00:00
while ($feed = db_fetch_object($result)) {
2005-03-31 09:25:33 +00:00
$output .= '<outline text="'. check_plain($feed->title) .'" xmlUrl="'. check_url($feed->url) ."\" />\n";
2001-08-04 13:37:41 +00:00
}
2004-01-07 19:52:10 +00:00
$output .= "</body>\n";
$output .= "</opml>\n";
2001-08-05 08:43:58 +00:00
2004-05-11 20:10:14 +00:00
drupal_set_header('Content-Type: text/xml; charset=utf-8');
2001-08-04 13:37:41 +00:00
print $output;
}
2004-05-11 20:10:14 +00:00
/**
2004-05-17 22:00:06 +00:00
* Menu callback; displays all the categories used by the aggregator.
2004-05-11 20:10:14 +00:00
*/
2004-04-27 20:10:09 +00:00
function aggregator_page_categories() {
2004-10-03 10:03:52 +00:00
$result = db_query('SELECT c.cid, c.title, c.description FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid LEFT JOIN {aggregator_item} i ON ci.iid = i.iid GROUP BY c.cid, c.title, c.description');
2004-04-27 20:10:09 +00:00
$output = "<div id=\"aggregator\">\n";
2002-10-26 15:17:26 +00:00
2004-04-27 20:10:09 +00:00
while ($category = db_fetch_object($result)) {
2005-03-31 09:25:33 +00:00
$output .= '<h2>'. check_plain($category->title) ."</h2>\n";
2004-04-27 20:10:09 +00:00
if (variable_get('aggregator_summary_items', 3)) {
$list = array();
$items = db_query_range('SELECT i.title, i.timestamp, i.link, f.title as feed_title, f.link as feed_link FROM {aggregator_category_item} ci LEFT JOIN {aggregator_item} i ON i.iid = ci.iid LEFT JOIN {aggregator_feed} f ON i.fid = f.fid WHERE ci.cid = %d ORDER BY i.timestamp DESC', $category->cid, 0, variable_get('aggregator_summary_items', 3));
while ($item = db_fetch_object($items)) {
2004-07-25 18:49:57 +00:00
$list[] = theme('aggregator_summary_item', $item);
2002-10-26 15:17:26 +00:00
}
2004-04-27 20:10:09 +00:00
$output .= theme('item_list', $list);
2002-10-26 15:17:26 +00:00
}
2004-07-25 18:49:57 +00:00
$output .= '<div class="links">'. theme('links', array(l(t('more'), 'aggregator/categories/'. $category->cid))) ."</div>\n";
2002-10-26 15:17:26 +00:00
}
2004-05-11 20:10:14 +00:00
$output .= '</div>';
2002-10-26 15:17:26 +00:00
2005-04-24 16:34:36 +00:00
return $output;
2001-07-11 22:06:24 +00:00
}
2001-11-01 11:00:51 +00:00
2004-01-10 15:31:26 +00:00
/**
2004-09-09 05:51:08 +00:00
* Format a news feed.
*
* @ingroup themeable
2004-01-10 15:31:26 +00:00
*/
2004-01-11 15:05:21 +00:00
function theme_aggregator_feed($feed) {
2004-05-11 20:10:14 +00:00
$output = '';
2004-01-11 15:05:21 +00:00
if ($feed->image) {
$output .= $feed->image;
}
$output .= $feed->description;
2004-05-11 20:10:14 +00:00
$output .= '<h3>'. t('URL') ."</h3>\n";
2004-01-11 15:05:21 +00:00
$output .= theme('xml_icon', $feed->url);
2005-03-31 09:25:33 +00:00
$output .= '<a href="'. check_url($feed->link) .'">'. check_plain($feed->link) ."</a>\n";
2004-05-11 20:10:14 +00:00
$output .= '<h3>'. t('Last update') ."</h3>\n";
$updated = t('%time ago', array('%time' => format_interval(time() - $feed->checked)));
2004-01-11 15:05:21 +00:00
if (user_access('administer news feeds')) {
2004-05-20 12:43:28 +00:00
$output .= l($updated, 'admin/aggregator');
2004-01-11 15:05:21 +00:00
}
else {
$output .= $updated;
}
return $output;
}
2004-09-09 05:51:08 +00:00
/**
* Format an individual feed item for display in the block.
*
* @ingroup themeable
*/
2004-01-10 15:31:26 +00:00
function theme_aggregator_block_item($item, $feed = 0) {
global $user;
2004-07-13 20:40:46 +00:00
if ($user->uid && module_exist('blog') && user_access('edit own blog')) {
2004-10-29 19:43:51 +00:00
if ($image = theme('image', 'misc/blog.png', t('blog it'), t('blog it'))) {
2005-03-31 09:25:33 +00:00
$output .= '<div class="icon">'. l($image, 'node/add/blog', array('title' => t('Comment on this news item in your personal blog.'), 'class' => 'blog-it'), "iid=$item->iid", NULL, FALSE, TRUE) .'</div>';
2004-08-04 20:40:01 +00:00
}
2004-01-10 15:31:26 +00:00
}
2004-09-09 05:51:08 +00:00
// Display the external link to the item.
2005-03-31 09:25:33 +00:00
$output .= '<a href="'. check_url($item->link) .'">'. check_plain($item->title) ."</a>\n";
2004-01-10 15:31:26 +00:00
return $output;
}
2004-07-25 18:49:57 +00:00
/**
2004-09-09 05:51:08 +00:00
* Return a themed item heading for summary pages located at "aggregator/sources"
* and "aggregator/categories".
2004-07-25 18:49:57 +00:00
*
* @param $item The item object from the aggregator module.
* @return A string containing the output.
2004-09-09 05:51:08 +00:00
*
* @ingroup themeable
2004-07-25 18:49:57 +00:00
*/
function theme_aggregator_summary_item($item) {
2005-03-31 09:25:33 +00:00
$output = '<a href="'. check_url($item->link) .'">'. check_plain($item->title) .'</a> <span class="age">'. t('%age old', array('%age' => format_interval(time() - $item->timestamp))) .'</span>';
2004-07-25 18:49:57 +00:00
if ($item->feed_link) {
$output .= ', <span class="source"><a href="'. $item->feed_link .'">'. $item->feed_title .'</a></span>';
}
return $output ."\n";
}
2004-09-09 05:51:08 +00:00
/**
* Format an individual feed item for display on the aggregator page.
*
* @ingroup themeable
*/
2004-01-10 15:31:26 +00:00
function theme_aggregator_page_item($item) {
static $last;
2005-06-01 04:03:54 +00:00
$date = format_date($item->timestamp, 'custom', 'Ymd');
2004-01-10 15:31:26 +00:00
if ($date != $last) {
$last = $date;
2005-06-01 04:03:54 +00:00
$output .= '<h3>'. format_date($item->timestamp, 'custom', 'F j, Y') ."</h3>\n";
2004-01-10 15:31:26 +00:00
}
$output .= "<div class=\"news-item\">\n";
2005-06-01 04:03:54 +00:00
$output .= ' <div class="date">'. format_date($item->timestamp, 'custom', 'H:i') ."</div>\n";
2004-01-10 15:31:26 +00:00
$output .= " <div class=\"body\">\n";
2005-09-02 19:18:14 +00:00
$source = '';
if ($item->ftitle && $item->fid) {
$source = '<span class="source">'. l($item->ftitle, "aggregator/sources/$item->fid") .":</span>\n";
}
$output .= ' <div class="title">'. $source .'<a href="'. check_url($item->link) .'">'. check_plain($item->title) ."</a></div>\n";
2004-01-10 15:31:26 +00:00
if ($item->description) {
2005-04-07 22:46:55 +00:00
$output .= ' <div class="description">'. $item->description ."</div>\n";
2004-01-10 15:31:26 +00:00
}
2004-04-27 20:10:09 +00:00
$result = db_query('SELECT c.title, c.cid FROM {aggregator_category_item} ci LEFT JOIN {aggregator_category} c ON ci.cid = c.cid WHERE ci.iid = %d ORDER BY c.title', $item->iid);
$categories = array();
while ($category = db_fetch_object($result)) {
$categories[] = l($category->title, 'aggregator/categories/'. $category->cid);
}
if ($categories) {
2004-05-11 20:10:14 +00:00
$output .= ' <div class="categories">'. t('Categories') .': '. implode(', ', $categories) ."</div>\n";
2004-04-27 20:10:09 +00:00
}
2004-01-10 15:31:26 +00:00
$output .= " </div>\n";
$output .= "</div>\n";
return $output;
}
2005-08-25 21:14:17 +00:00