Commit 545ef5b0 authored by Dries's avatar Dries

- Patch #748742 by mr.baileys, catch: aggregator categorize feature is broken.

parent ca435ae9
......@@ -209,7 +209,7 @@ function aggregator_menu() {
$items['aggregator/categories/%aggregator_category/categorize'] = array(
'title' => 'Categorize',
'page callback' => 'drupal_get_form',
'page arguments' => array('aggregator_page_category', 2),
'page arguments' => array('aggregator_page_category_form', 2),
'access arguments' => array('administer news feeds'),
'type' => MENU_LOCAL_TASK,
'file' => 'aggregator.pages.inc',
......@@ -238,7 +238,7 @@ function aggregator_menu() {
$items['aggregator/sources/%aggregator_feed/categorize'] = array(
'title' => 'Categorize',
'page callback' => 'drupal_get_form',
'page arguments' => array('aggregator_page_source', 2),
'page arguments' => array('aggregator_page_source_form', 2),
'access arguments' => array('administer news feeds'),
'type' => MENU_LOCAL_TASK,
'file' => 'aggregator.pages.inc',
......
......@@ -23,19 +23,13 @@ function aggregator_page_last() {
/**
* Menu callback; displays all the items captured from a particular feed.
*
* If there are two arguments then this function is the categorize form.
* @param $feed
* The feed for which to display all items.
*
* @param $arg1
* If there are two arguments then $arg1 is $form_state. Otherwise, $arg1 is $feed.
* @param $arg2
* If there are two arguments then $arg2 is feed.
* @return
* The item's HTML.
* The rendered list of items for a feed.
*/
function aggregator_page_source($arg1, $arg2 = NULL) {
// If there are two arguments then this function is the categorize form, and
// $arg1 is $form_state and $arg2 is $feed. Otherwise, $arg1 is $feed.
$feed = is_object($arg2) ? $arg2 : $arg1;
function aggregator_page_source($feed) {
drupal_set_title($feed->title);
$feed_source = theme('aggregator_feed_source', array('feed' => $feed));
......@@ -47,22 +41,30 @@ function aggregator_page_source($arg1, $arg2 = NULL) {
}
/**
* Menu callback; displays all the items aggregated in a particular category.
* Menu callback; displays a form with all items captured from a feed.
*
* If there are two arguments then this function is called as a form.
* @param $feed
* The feed for which to list all the aggregated items.
*
* @param $arg1
* If there are two arguments then $arg1 is $form_state. Otherwise, $arg1 is $category.
* @param $arg2
* If there are two arguments then $arg2 is $category.
* @return
* The items HTML.
* The rendered list of items for a feed.
*
* @see aggregator_page_source()
*/
function aggregator_page_category($arg1, $arg2 = NULL) {
// If there are two arguments then we are called as a form, $arg1 is
// $form_state and $arg2 is $category. Otherwise, $arg1 is $category.
$category = is_array($arg2) ? $arg2 : $arg1;
function aggregator_page_source_form($form, $form_state, $feed) {
return aggregator_page_source($feed);
}
/**
* Menu callback; displays all the items aggregated in a particular category.
*
* @param $category
* The category for which to list all the aggregated items.
*
* @return
* The rendered list of items for a category.
*/
function aggregator_page_category($category) {
drupal_add_feed(url('aggregator/rss/' . $category['cid']), variable_get('site_name', 'Drupal') . ' ' . t('aggregator - @title', array('@title' => $category['title'])));
// It is safe to include the cid in the query because it's loaded from the
......@@ -72,6 +74,21 @@ function aggregator_page_category($arg1, $arg2 = NULL) {
return _aggregator_page_list($items, arg(3));
}
/**
* Menu callback; displays a form containing items aggregated in a category.
*
* @param $category
* The category for which to list all the aggregated items.
*
* @return
* The rendered list of items for a category.
*
* @see aggregator_page_category()
*/
function aggregator_page_category_form($form, $form_state, $category) {
return aggregator_page_category($category);
}
/**
* Load feed items
*
......
......@@ -283,6 +283,8 @@ class AddFeedTestCase extends AggregatorTestCase {
$this->drupalGet('aggregator/sources/' . $feed->fid);
$this->assertResponse(200, t('Feed source exists.'));
$this->assertText($feed->title, t('Page title'));
$this->drupalGet('aggregator/sources/' . $feed->fid . '/categorize');
$this->assertResponse(200, t('Feed categorization page exists.'));
// Delete feed.
$this->deleteFeed($feed);
......
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