Commit 6b88e617 authored by Dries's avatar Dries

- Patch #256793 by Senpai and flobruit: code clean up.

parent 7cd8427f
......@@ -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:
......
......@@ -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.
*
......
......@@ -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; ?>
......@@ -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.
......
......@@ -2,7 +2,7 @@
// $Id$
/**
* @file comment-wrapper.tpl.php
* @file
* Default theme implementation to wrap aggregator content.
*
* Available variables:
......
......@@ -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']);
......
; $Id$
name = Aggregator
description = "Aggregates syndicated content (RSS, RDF, and Atom feeds)."
package = Core - optional
......
......@@ -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',
......
This diff is collapsed.
......@@ -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";
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment