'));
+ $value = preg_replace('/\Wstyle\s*=[^>]+?>/i', '>', $value);
+ $value = preg_replace('/\Wclass\s*=[^>]+?>/i', '>', $value);
+ $value = preg_replace('/\Won[a-z]+\s*=[^>]+?>/i', '>', $value);
+ if (stristr($key, 'CONTENT')) {
+ $item['DESCRIPTION'] = $value;
+ }
+ else if ($key != 'DESCRIPTION') {
$value = filter_xss($value);
+ }
+ else {
+ $output_format = variable_get('aggregator_default_filter', FILTER_FORMAT_DEFAULT);
+ $value = check_markup($value, $output_format);
+ }
+ $item[$key] = $value;
$item[$key] = $value;
}
@@ -533,7 +583,6 @@
** up to 40 characters of the description ending at a word
** boundary but not splitting potential entities.
*/
-
if ($item['TITLE']) {
$title = $item['TITLE'];
}
@@ -544,7 +593,6 @@
/*
** Resolve the items link.
*/
-
if ($item['LINK']) {
$link = $item['LINK'];
}
@@ -556,28 +604,22 @@
}
/**
- * Atom feeds have a CONTENT and/or SUMMARY tag instead of a DESCRIPTION tag
+ * Get author information if it's there
*/
- if ($item['CONTENT']) {
- $item['DESCRIPTION'] = $item['CONTENT'];
- }
- else if ($item['SUMMARY']) {
- $item['DESCRIPTION'] = $item['SUMMARY'];
- }
+ if ($item['DC:CREATOR']) $item['AUTHOR'] = $item['DC:CREATOR'];
+ else if($item['NAME']) $item['AUTHOR'] = $item['NAME'];
/*
** 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
- 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
+ else if ($item['PUBLISHED']) $date = $item['PUBLISHED']; // Atom
+ else if ($item['CREATED']) $date = $item['CREATED']; // Atom
else $date = 'now';
$timestamp = strtotime($date); // strtotime() returns -1 on failure
@@ -593,15 +635,18 @@
** possible. If we find a duplicate entry, we resolve it and
** pass along it's ID such that we can update it if needed.
*/
-
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));
+ $entry = db_fetch_object(db_query(
+ "SELECT iid FROM {aggregator_item} WHERE fid = %d AND link = '%s'", $feed['fid'], $link));
}
else {
- $entry = db_fetch_object(db_query("SELECT iid FROM {aggregator_item} WHERE fid = %d AND title = '%s'", $feed['fid'], $title));
+ $entry = db_fetch_object(db_query(
+ "SELECT iid FROM {aggregator_item} WHERE fid = %d AND title = '%s'", $feed['fid'], $title));
}
- aggregator_save_item(array('iid' => $entry->iid, 'fid' => $feed['fid'], 'timestamp' => $timestamp, 'title' => $title, 'link' => $link, 'author' => $item['AUTHOR'], 'description' => $item['DESCRIPTION']));
+ aggregator_save_item(array('iid' => $entry->iid, 'fid' => $feed['fid'], 'timestamp' => $timestamp,
+ 'title' => $title, 'link' => $link, 'author' => $item['AUTHOR'], 'description' => $item['DESCRIPTION'],
+ 'categories' => $item['CATEGORIES'], 'enclosure' => $item['ENCLOSURE']));
}
/*
@@ -616,7 +661,6 @@
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);
}
@@ -625,7 +669,7 @@
function aggregator_save_item($edit) {
if ($edit['iid'] && $edit['title']) {
- db_query('UPDATE {aggregator_item} SET title = \'%s\', link = \'%s\', author = \'%s\', description = \'%s\' WHERE iid = %d', $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['iid']);
+ db_query('UPDATE {aggregator_item} SET title = \'%s\', link = \'%s\', author = \'%s\', description = \'%s\', categories = \'%s\', enclosure = \'%s\' WHERE iid = %d', $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['categories'], $edit['enclosure'], $edit['iid']);
}
else if ($edit['iid']) {
db_query('DELETE FROM {aggregator_item} WHERE iid = %d', $edit['iid']);
@@ -633,7 +677,10 @@
}
else if ($edit['title'] && $edit['link']) {
$edit['iid'] = db_next_id('{aggregator_item}_iid');
- db_query('INSERT INTO {aggregator_item} (iid, fid, title, link, author, description, timestamp) VALUES (%d, %d, \'%s\', \'%s\', \'%s\', \'%s\', %d)', $edit['iid'], $edit['fid'], $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['timestamp']);
+ db_query('INSERT INTO {aggregator_item} (iid, fid, title, link, author, description, timestamp, categories, enclosure)
+ VALUES (%d, %d, \'%s\', \'%s\', \'%s\', \'%s\', %d, \'%s\', \'%s\')',
+ $edit['iid'], $edit['fid'], $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['timestamp']
+ , $edit['categories'], $edit['enclosure']);
// 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)) {
@@ -811,7 +858,6 @@
return $output;
}
-
/**
* Menu callback; displays the category edit form, or saves changes and
* redirects to the overview page.
@@ -1015,8 +1061,6 @@
drupal_goto($_GET['q']);
}
-
-
/**
* Menu callback; displays all the feeds used by the aggregator.
*/
@@ -1216,7 +1260,6 @@
*/
function theme_aggregator_page_item($item) {
static $last;
-
$date = format_date($item->timestamp, 'custom', 'Ymd');
if ($date != $last) {
$last = $date;
@@ -1226,30 +1269,41 @@
$output .= "