summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-05-15 21:27:32 +0000
committerDries Buytaert <dries@buytaert.net>2008-05-15 21:27:32 +0000
commit6b88e61700f87c98442534e4c9a2604b1cd8a057 (patch)
treec0b81015fd3a743639eab0f366b0bec188055fb6
parent7cd8427f65b870300e1aa8ea1229dd61beff18d3 (diff)
downloadbrdo-6b88e61700f87c98442534e4c9a2604b1cd8a057.tar.gz
brdo-6b88e61700f87c98442534e4c9a2604b1cd8a057.tar.bz2
- Patch #256793 by Senpai and flobruit: code clean up.
-rw-r--r--modules/aggregator/aggregator-feed-source.tpl.php4
-rw-r--r--modules/aggregator/aggregator-item.tpl.php2
-rw-r--r--modules/aggregator/aggregator-summary-item.tpl.php9
-rw-r--r--modules/aggregator/aggregator-summary-items.tpl.php2
-rw-r--r--modules/aggregator/aggregator-wrapper.tpl.php2
-rw-r--r--modules/aggregator/aggregator.admin.inc36
-rw-r--r--modules/aggregator/aggregator.info1
-rw-r--r--modules/aggregator/aggregator.install2
-rw-r--r--modules/aggregator/aggregator.module66
-rw-r--r--modules/aggregator/aggregator.pages.inc27
-rw-r--r--modules/aggregator/aggregator.test8
11 files changed, 94 insertions, 65 deletions
diff --git a/modules/aggregator/aggregator-feed-source.tpl.php b/modules/aggregator/aggregator-feed-source.tpl.php
index 77bb51eaf..46894e9fe 100644
--- a/modules/aggregator/aggregator-feed-source.tpl.php
+++ b/modules/aggregator/aggregator-feed-source.tpl.php
@@ -2,10 +2,10 @@
// $Id$
/**
- * @file aggregator-feed-source.tpl.php
+ * @file
* Default theme implementation to present the source of the feed.
*
- * The contents are render above feed listings when browsing source feeds.
+ * The contents are rendered above feed listings when browsing source feeds.
* For example, "example.com/aggregator/sources/1".
*
* Available variables:
diff --git a/modules/aggregator/aggregator-item.tpl.php b/modules/aggregator/aggregator-item.tpl.php
index 924b8e3d9..854e3fa9e 100644
--- a/modules/aggregator/aggregator-item.tpl.php
+++ b/modules/aggregator/aggregator-item.tpl.php
@@ -2,7 +2,7 @@
// $Id$
/**
- * @file aggregator-item.tpl.php
+ * @file
* Default theme implementation to format an individual feed item for display
* on the aggregator page.
*
diff --git a/modules/aggregator/aggregator-summary-item.tpl.php b/modules/aggregator/aggregator-summary-item.tpl.php
index 6e68dfcef..ec96b9a4f 100644
--- a/modules/aggregator/aggregator-summary-item.tpl.php
+++ b/modules/aggregator/aggregator-summary-item.tpl.php
@@ -2,7 +2,7 @@
// $Id$
/**
- * @file aggregator-summary-item.tpl.php
+ * @file
* Default theme implementation to present a linked feed item for summaries.
*
* Available variables:
@@ -16,4 +16,9 @@
* @see template_preprocess_aggregator_summary_item()
*/
?>
-<a href="<?php print $feed_url; ?>"><?php print $feed_title; ?></a> <span class="age"><?php print $feed_age; ?></span><?php if ($source_url) : ?>, <span class="source"><a href="<?php print $source_url; ?>"><?php print $source_title; ?></a></span><?php endif; ?>
+<a href="<?php print $feed_url; ?>"><?php print $feed_title; ?></a>
+<span class="age"><?php print $feed_age; ?></span>
+
+<?php if ($source_url) : ?>,
+<span class="source"><a href="<?php print $source_url; ?>"><?php print $source_title; ?></a></span>
+<?php endif; ?>
diff --git a/modules/aggregator/aggregator-summary-items.tpl.php b/modules/aggregator/aggregator-summary-items.tpl.php
index 135e01b1c..8f5e18d2b 100644
--- a/modules/aggregator/aggregator-summary-items.tpl.php
+++ b/modules/aggregator/aggregator-summary-items.tpl.php
@@ -2,7 +2,7 @@
// $Id$
/**
- * @file aggregator-summary-items.tpl.php
+ * @file
* Default theme implementation to present feeds as list items.
*
* Each iteration generates a single feed source or category.
diff --git a/modules/aggregator/aggregator-wrapper.tpl.php b/modules/aggregator/aggregator-wrapper.tpl.php
index 652dee2b5..3e7a4684f 100644
--- a/modules/aggregator/aggregator-wrapper.tpl.php
+++ b/modules/aggregator/aggregator-wrapper.tpl.php
@@ -2,7 +2,7 @@
// $Id$
/**
- * @file comment-wrapper.tpl.php
+ * @file
* Default theme implementation to wrap aggregator content.
*
* Available variables:
diff --git a/modules/aggregator/aggregator.admin.inc b/modules/aggregator/aggregator.admin.inc
index 5c78c8584..abbe9ca19 100644
--- a/modules/aggregator/aggregator.admin.inc
+++ b/modules/aggregator/aggregator.admin.inc
@@ -80,7 +80,7 @@ function aggregator_form_feed(&$form_state, $edit = array('refresh' => 900, 'tit
'#description' => t('The length of time between feed updates. (Requires a correctly configured <a href="@cron">cron maintenance task</a>.)', array('@cron' => url('admin/reports/status'))),
);
- // Handling of categories:
+ // Handling of categories.
$options = array();
$values = array();
$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']);
@@ -89,25 +89,35 @@ function aggregator_form_feed(&$form_state, $edit = array('refresh' => 900, 'tit
if ($category->fid) $values[] = $category->cid;
}
if ($options) {
- $form['category'] = array('#type' => 'checkboxes',
+ $form['category'] = array(
+ '#type' => 'checkboxes',
'#title' => t('Categorize news items'),
'#default_value' => $values,
'#options' => $options,
'#description' => t('New feed items are automatically filed in the checked categories.'),
);
}
- $form['submit'] = array('#type' => 'submit', '#value' => t('Save'));
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Save'),
+ );
if ($edit['fid']) {
- $form['delete'] = array('#type' => 'submit', '#value' => t('Delete'));
- $form['fid'] = array('#type' => 'hidden', '#value' => $edit['fid']);
+ $form['delete'] = array(
+ '#type' => 'submit',
+ '#value' => t('Delete'),
+ );
+ $form['fid'] = array(
+ '#type' => 'hidden',
+ '#value' => $edit['fid'],
+ );
}
return $form;
}
/**
- * Validate aggregator_form_feed form submissions.
+ * Validate aggregator_form_feed() form submissions.
*/
function aggregator_form_feed_validate($form, &$form_state) {
if ($form_state['values']['op'] == t('Save')) {
@@ -134,14 +144,14 @@ function aggregator_form_feed_validate($form, &$form_state) {
}
/**
- * Process aggregator_form_feed form submissions.
+ * Process aggregator_form_feed() form submissions.
*
* @todo Add delete confirmation dialog.
*/
function aggregator_form_feed_submit($form, &$form_state) {
if ($form_state['values']['op'] == t('Delete')) {
$title = $form_state['values']['title'];
- // Unset the title:
+ // Unset the title.
unset($form_state['values']['title']);
}
aggregator_save_feed($form_state['values']);
@@ -227,25 +237,25 @@ function aggregator_admin_settings() {
$form['aggregator_allowed_html_tags'] = array(
'#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('A space-separated list of HTML tags allowed in the content of feed items. (Tags in this list are not removed by Drupal.)')
+ '#description' => t('A space-separated list of HTML tags allowed in the content of feed items. (Tags in this list are not removed by Drupal.)'),
);
$form['aggregator_summary_items'] = array(
'#type' => 'select', '#title' => t('Items shown in sources and categories pages') ,
'#default_value' => variable_get('aggregator_summary_items', 3), '#options' => $items,
- '#description' => t('Number of feed items displayed in feed and category summary pages.')
+ '#description' => t('Number of feed items displayed in feed and category summary pages.'),
);
$form['aggregator_clear'] = array(
'#type' => 'select', '#title' => t('Discard items older than'),
'#default_value' => variable_get('aggregator_clear', 9676800), '#options' => $period,
- '#description' => t('The length of time to retain feed items before discarding. (Requires a correctly configured <a href="@cron">cron maintenance task</a>.)', array('@cron' => url('admin/reports/status')))
+ '#description' => t('The length of time to retain feed items before discarding. (Requires a correctly configured <a href="@cron">cron maintenance task</a>.)', array('@cron' => url('admin/reports/status'))),
);
$form['aggregator_category_selector'] = array(
'#type' => 'radios', '#title' => t('Category selection type'), '#default_value' => variable_get('aggregator_category_selector', 'checkboxes'),
'#options' => array('checkboxes' => t('checkboxes'), 'select' => t('multiple selector')),
- '#description' => t('The type of category selection widget displayed on categorization pages. (For a small number of categories, checkboxes are easier to use, while a multiple selector work well with large numbers of categories.)')
+ '#description' => t('The type of category selection widget displayed on categorization pages. (For a small number of categories, checkboxes are easier to use, while a multiple selector work well with large numbers of categories.)'),
);
return system_settings_form($form);
@@ -305,7 +315,7 @@ function aggregator_form_category_validate($form, &$form_state) {
function aggregator_form_category_submit($form, &$form_state) {
if ($form_state['values']['op'] == t('Delete')) {
$title = $form_state['values']['title'];
- // Unset the title:
+ // Unset the title.
unset($form_state['values']['title']);
}
aggregator_save_category($form_state['values']);
diff --git a/modules/aggregator/aggregator.info b/modules/aggregator/aggregator.info
index ae6d3e767..dad36ff24 100644
--- a/modules/aggregator/aggregator.info
+++ b/modules/aggregator/aggregator.info
@@ -1,4 +1,5 @@
; $Id$
+
name = Aggregator
description = "Aggregates syndicated content (RSS, RDF, and Atom feeds)."
package = Core - optional
diff --git a/modules/aggregator/aggregator.install b/modules/aggregator/aggregator.install
index cacb16a7a..3b9c181b4 100644
--- a/modules/aggregator/aggregator.install
+++ b/modules/aggregator/aggregator.install
@@ -230,7 +230,7 @@ function aggregator_schema() {
'timestamp' => array(
'type' => 'int',
'not null' => FALSE,
- 'description' => t('Post date of feed item, as a Unix timestamp.'),
+ 'description' => t('Posted date of the feed item, as a Unix timestamp.'),
),
'guid' => array(
'type' => 'varchar',
diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module
index 565a3617c..33796a5a9 100644
--- a/modules/aggregator/aggregator.module
+++ b/modules/aggregator/aggregator.module
@@ -28,7 +28,7 @@ function aggregator_help($path, $arg) {
}
/**
- * Implementation of hook_theme()
+ * Implementation of hook_theme().
*/
function aggregator_theme() {
return array(
@@ -294,7 +294,7 @@ function aggregator_block($op = 'list', $delta = '', $edit = array()) {
$block['feed-' . $feed->fid]['info'] = t('!title feed latest items', array('!title' => $feed->title));
}
}
- else if ($op == 'configure') {
+ elseif ($op == 'configure') {
list($type, $id) = explode('-', $delta);
if ($type == 'category') {
$value = db_result(db_query('SELECT block FROM {aggregator_category} WHERE cid = %d', $id));
@@ -305,7 +305,7 @@ function aggregator_block($op = 'list', $delta = '', $edit = array()) {
$form['block'] = array('#type' => 'select', '#title' => t('Number of news items in block'), '#default_value' => $value, '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)));
return $form;
}
- else if ($op == 'save') {
+ elseif ($op == 'save') {
list($type, $id) = explode('-', $delta);
if ($type == 'category') {
$value = db_query('UPDATE {aggregator_category} SET block = %d WHERE cid = %d', $edit['block'], $id);
@@ -314,7 +314,7 @@ function aggregator_block($op = 'list', $delta = '', $edit = array()) {
$value = db_query('UPDATE {aggregator_feed} SET block = %d WHERE fid = %d', $edit['block'], $id);
}
}
- else if ($op == 'view') {
+ elseif ($op == 'view') {
list($type, $id) = explode('-', $delta);
switch ($type) {
case 'feed':
@@ -369,8 +369,8 @@ function aggregator_save_category($edit) {
$op = 'delete';
}
}
- else if (!empty($edit['title'])) {
- // A single unique id for bundles and feeds, to use in blocks
+ elseif (!empty($edit['title'])) {
+ // A single unique id for bundles and feeds, to use in blocks.
db_query("INSERT INTO {aggregator_category} (title, description, block) VALUES ('%s', '%s', 5)", $edit['title'], $edit['description']);
$link_path .= db_last_insert_id('aggregator', 'cid');
$op = 'insert';
@@ -394,7 +394,7 @@ function aggregator_save_feed($edit) {
if (!empty($edit['fid']) && !empty($edit['title'])) {
db_query("UPDATE {aggregator_feed} SET title = '%s', url = '%s', refresh = %d WHERE fid = %d", $edit['title'], $edit['url'], $edit['refresh'], $edit['fid']);
}
- else if (!empty($edit['fid'])) {
+ elseif (!empty($edit['fid'])) {
$items = array();
$result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = %d', $edit['fid']);
while ($item = db_fetch_object($result)) {
@@ -406,9 +406,9 @@ function aggregator_save_feed($edit) {
db_query('DELETE FROM {aggregator_feed} WHERE fid = %d', $edit['fid']);
db_query('DELETE FROM {aggregator_item} WHERE fid = %d', $edit['fid']);
}
- else if (!empty($edit['title'])) {
+ elseif (!empty($edit['title'])) {
db_query("INSERT INTO {aggregator_feed} (title, url, refresh, block, description, image) VALUES ('%s', '%s', %d, 5, '', '')", $edit['title'], $edit['url'], $edit['refresh']);
- // A single unique id for bundles and feeds, to use in blocks.
+ // A single unique ID for bundles and feeds, to use in blocks.
$edit['fid'] = db_last_insert_id('aggregator_feed', 'fid');
}
if (!empty($edit['title'])) {
@@ -443,7 +443,7 @@ function aggregator_remove($feed) {
}
/**
- * Call-back function used by the XML parser.
+ * Callback function used by the XML parser.
*/
function aggregator_element_start($parser, $name, $attributes) {
global $item, $element, $tag, $items, $channel;
@@ -509,7 +509,7 @@ function aggregator_element_end($parser, $name) {
}
/**
- * Call-back function used by the XML parser.
+ * Callback function used by the XML parser.
*/
function aggregator_element_data($parser, $data) {
global $channel, $element, $items, $item, $image, $tag;
@@ -585,11 +585,11 @@ function aggregator_refresh($feed) {
case 301:
$feed['url'] = $result->redirect_url;
watchdog('aggregator', 'Updated URL for feed %title to %url.', array('%title' => $feed['title'], '%url' => $feed['url']));
- // Deliberate no break.
+ // Do not break here.
case 200:
case 302:
case 307:
- // Filter the input data:
+ // Filter the input data.
if (aggregator_parse_feed($result->data, $feed)) {
$modified = empty($result->headers['Last-Modified']) ? 0 : strtotime($result->headers['Last-Modified']);
@@ -604,7 +604,8 @@ function aggregator_refresh($feed) {
}
if (!empty($image['LINK']) && !empty($image['URL']) && !empty($image['TITLE'])) {
- // Note, we should really use theme_image() here but that only works with local images it won't work with images fetched with a URL unless PHP version > 5
+ // TODO: we should really use theme_image() here, but that only works with
+ // local images. It won't work with images fetched with a URL unless PHP version > 5.
$image = '<a href="' . check_url($image['LINK']) . '" class="feed-image"><img src="' . check_url($image['URL']) . '" alt="' . check_plain($image['TITLE']) . '" /></a>';
}
else {
@@ -623,7 +624,7 @@ function aggregator_refresh($feed) {
break;
}
$result->error = t('feed not parseable');
- // Deliberate no break.
+ // Do not break here..
default:
watchdog('aggregator', 'The feed from %site seems to be broken, due to "%error".', array('%site' => $feed['title'], '%error' => $result->code . ' ' . $result->error), WATCHDOG_WARNING);
drupal_set_message(t('The feed from %site seems to be broken, because of error "%error".', array('%site' => $feed['title'], '%error' => $result->code . ' ' . $result->error)));
@@ -632,8 +633,9 @@ function aggregator_refresh($feed) {
}
/**
- * Parse the W3C date/time format, a subset of ISO 8601. PHP date parsing
- * functions do not handle this format.
+ * 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.
* Originally from MagpieRSS (http://magpierss.sourceforge.net/).
*
@@ -645,11 +647,11 @@ function aggregator_refresh($feed) {
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
+ // Calculate the 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
+ // Zero out the variables.
if (!$tz_hour) {
$tz_hour = 0;
}
@@ -657,7 +659,7 @@ function aggregator_parse_w3cdtf($date_str) {
$tz_min = 0;
}
$offset_secs = (($tz_hour * 60) + $tz_min) * 60;
- // is timezone ahead of GMT? then subtract offset
+ // Is timezone ahead of GMT? If yes, subtract offset.
if ($tz_mod == '+') {
$offset_secs *= -1;
}
@@ -683,13 +685,13 @@ function aggregator_parse_w3cdtf($date_str) {
function aggregator_parse_feed(&$data, $feed) {
global $items, $image, $channel;
- // Unset the global variables before we use them:
+ // Unset the global variables before we use them.
unset($GLOBALS['element'], $GLOBALS['item'], $GLOBALS['tag']);
$items = array();
$image = array();
$channel = array();
- // parse the data:
+ // Parse the data.
$xml_parser = drupal_xml_parser_create($data);
xml_set_element_handler($xml_parser, 'aggregator_element_start', 'aggregator_element_end');
xml_set_character_data_handler($xml_parser, 'aggregator_element_data');
@@ -716,7 +718,7 @@ function aggregator_parse_feed(&$data, $feed) {
}
// 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
+ // characters of the description ending at a word boundary, but not
// splitting potential entities.
if (!empty($item['TITLE'])) {
$title = $item['TITLE'];
@@ -741,15 +743,15 @@ function aggregator_parse_feed(&$data, $feed) {
if (!empty($item['CONTENT:ENCODED'])) {
$item['DESCRIPTION'] = $item['CONTENT:ENCODED'];
}
- else if (!empty($item['SUMMARY'])) {
+ elseif (!empty($item['SUMMARY'])) {
$item['DESCRIPTION'] = $item['SUMMARY'];
}
- else if (!empty($item['CONTENT'])) {
+ elseif (!empty($item['CONTENT'])) {
$item['DESCRIPTION'] = $item['CONTENT'];
}
// Try to resolve and parse the item's publication date. If no date is
- // found, we use the current date instead.
+ // found, use the current date instead.
$date = 'now';
foreach (array('PUBDATE', 'DC:DATE', 'DCTERMS:ISSUED', 'DCTERMS:CREATED', 'DCTERMS:MODIFIED', 'ISSUED', 'CREATED', 'MODIFIED', 'PUBLISHED', 'UPDATED') as $key) {
if (!empty($item[$key])) {
@@ -759,10 +761,12 @@ function aggregator_parse_feed(&$data, $feed) {
}
$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
+ $timestamp = aggregator_parse_w3cdtf($date); // Aggregator_parse_w3cdtf() returns FALSE on failure.
if (!$timestamp) {
- $timestamp = time(); // better than nothing
+ // Better than nothing.
+ $timestamp = time();
}
}
@@ -810,11 +814,11 @@ function aggregator_save_item($edit) {
if ($edit['iid'] && $edit['title']) {
db_query("UPDATE {aggregator_item} SET title = '%s', link = '%s', author = '%s', description = '%s', guid = '%s', timestamp = %d WHERE iid = %d", $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['guid'], $edit['timestamp'], $edit['iid']);
}
- else if ($edit['iid']) {
+ elseif ($edit['iid']) {
db_query('DELETE FROM {aggregator_item} WHERE iid = %d', $edit['iid']);
db_query('DELETE FROM {aggregator_category_item} WHERE iid = %d', $edit['iid']);
}
- else if ($edit['title'] && $edit['link']) {
+ elseif ($edit['title'] && $edit['link']) {
db_query("INSERT INTO {aggregator_item} (fid, title, link, author, description, timestamp, guid) VALUES (%d, '%s', '%s', '%s', '%s', %d, '%s')", $edit['fid'], $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['timestamp'], $edit['guid']);
$edit['iid'] = db_last_insert_id('aggregator_item', 'iid');
// file the items in the categories indicated by the feed
@@ -838,6 +842,7 @@ function aggregator_feed_load($fid) {
if (!isset($feeds[$fid])) {
$feeds[$fid] = db_fetch_array(db_query('SELECT * FROM {aggregator_feed} WHERE fid = %d', $fid));
}
+
return $feeds[$fid];
}
@@ -854,6 +859,7 @@ function aggregator_category_load($cid) {
if (!isset($categories[$cid])) {
$categories[$cid] = db_fetch_array(db_query('SELECT * FROM {aggregator_category} WHERE cid = %d', $cid));
}
+
return $categories[$cid];
}
diff --git a/modules/aggregator/aggregator.pages.inc b/modules/aggregator/aggregator.pages.inc
index e2e708a4b..b899e6b0a 100644
--- a/modules/aggregator/aggregator.pages.inc
+++ b/modules/aggregator/aggregator.pages.inc
@@ -30,7 +30,7 @@ function aggregator_page_last() {
* @param $arg2
* If there are two arguments then $arg2 is feed.
* @return
- * The items HTML.
+ * The item's HTML.
*/
function aggregator_page_source($arg1, $arg2 = NULL) {
// If there are two arguments then this function is the categorize form, and
@@ -95,6 +95,7 @@ function aggregator_feed_items_load($sql) {
$items[$item->iid] = $item;
}
}
+
return $items;
}
@@ -125,6 +126,7 @@ function _aggregator_page_list($items, $op, $feed_source = '') {
}
$output = theme('aggregator_wrapper', $output);
}
+
return $output;
}
@@ -145,11 +147,15 @@ function aggregator_categorize_items($items, $feed_source = '') {
$form['#submit'][] = 'aggregator_categorize_items_submit';
$form['#validate'][] = 'aggregator_categorize_items_validate';
$form['#theme'] = 'aggregator_categorize_items';
- $form['feed_source'] = array('#value' => $feed_source);
+ $form['feed_source'] = array(
+ '#value' => $feed_source,
+ );
$categories = array();
$done = FALSE;
$form['items'] = array();
- $form['categories'] = array('#tree' => TRUE);
+ $form['categories'] = array(
+ '#tree' => TRUE,
+ );
foreach ($items as $item) {
$form['items'][$item->iid] = array('#value' => theme('aggregator_item', $item));
$form['categories'][$item->iid] = array();
@@ -178,7 +184,7 @@ function aggregator_categorize_items($items, $feed_source = '') {
}
/**
- * Validate aggregator_categorize_items form submissions.
+ * Validate aggregator_categorize_items() form submissions.
*/
function aggregator_categorize_items_validate($form, &$form_state) {
if (!user_access('administer news feeds')) {
@@ -187,7 +193,7 @@ function aggregator_categorize_items_validate($form, &$form_state) {
}
/**
- * Process aggregator_categorize_items form submissions.
+ * Process aggregator_categorize_items() form submissions.
*/
function aggregator_categorize_items_submit($form, &$form_state) {
if (!empty($form_state['values']['categories'])) {
@@ -228,6 +234,7 @@ function theme_aggregator_categorize_items($form) {
$output .= theme('table', array('', t('Categorize')), $rows);
$output .= drupal_render($form['submit']);
$output .= drupal_render($form);
+
return theme('aggregator_wrapper', $output);
}
@@ -322,13 +329,13 @@ function aggregator_page_categories() {
*/
function aggregator_page_rss() {
$result = NULL;
- // arg(2) is the passed cid, only select for that category
+ // arg(2) is the passed cid, only select for that category.
if (arg(2)) {
$category = db_fetch_object(db_query('SELECT cid, title FROM {aggregator_category} WHERE cid = %d', arg(2)));
$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, i.iid DESC';
$result = db_query_range($sql, $category->cid, 0, variable_get('feed_default_items', 10));
}
- // or, get the default aggregator items
+ // Or, get the default aggregator items.
else {
$category = NULL;
$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';
@@ -339,6 +346,7 @@ function aggregator_page_rss() {
while ($item = db_fetch_object($result)) {
$feeds[] = $item;
}
+
return theme('aggregator_page_rss', $feeds, $category);
}
@@ -376,7 +384,7 @@ function theme_aggregator_page_rss($feeds, $category = NULL) {
$url = url((isset($category) ? 'aggregator/categories/' . $category->cid : 'aggregator'), array('absolute' => TRUE));
$description = isset($category) ? t('@site_name - aggregated feeds in category @title', array('@site_name' => $site_name, '@title' => $category->title)) : t('@site_name - aggregated feeds', array('@site_name' => $site_name));
- $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
+ $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
$output .= "<rss version=\"2.0\">\n";
$output .= format_rss_channel(t('@site_name aggregator', array('@site_name' => $site_name)), $url, $description, $items);
$output .= "</rss>\n";
@@ -416,10 +424,9 @@ function aggregator_page_opml($cid = NULL) {
* @ingroup themeable
*/
function theme_aggregator_page_opml($feeds) {
-
drupal_set_header('Content-Type: text/xml; charset=utf-8');
- $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
+ $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
$output .= "<opml version=\"1.1\">\n";
$output .= "<head>\n";
$output .= '<title>' . check_plain(variable_get('site_name', 'Drupal')) . "</title>\n";
diff --git a/modules/aggregator/aggregator.test b/modules/aggregator/aggregator.test
index e94c23af3..f504cde48 100644
--- a/modules/aggregator/aggregator.test
+++ b/modules/aggregator/aggregator.test
@@ -60,18 +60,18 @@ class AggregatorTestCase extends DrupalWebTestCase {
* @param object $feed Feed object representing the feed.
*/
function updateFeedItems(&$feed) {
- // First, let's ensure we could get to the rss xml
+ // First, let's ensure we can get to the rss xml.
$this->drupalGet('rss.xml');
$this->assertResponse(200, t('rss.xml is reachable.'));
- // our tests are based off of rss.xml, so let's find out how many elements should be related
+ // Our tests are based off of rss.xml, so let's find out how many elements should be related.
$feed_count = db_result(db_query_range(db_rewrite_sql('SELECT COUNT(*) FROM {node} n WHERE n.promote = 1 AND n.status = 1'), 0, variable_get('feed_default_items', 10)));
$feed_count = $feed_count > 10 ? 10 : $feed_count;
- // refresh the feed (simulated link click)
+ // Refresh the feed (simulated link click).
$this->drupalGet('admin/content/aggregator/update/'. $feed->fid);
- // ensure we have the right number of items
+ // Ensure we have the right number of items.
$result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = %d', $feed->fid);
$items = array();
$feed->items = array();