summaryrefslogtreecommitdiff
path: root/modules/aggregator/aggregator.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2007-01-24 14:48:36 +0000
committerDries Buytaert <dries@buytaert.net>2007-01-24 14:48:36 +0000
commit03752e35a41992c3d61f2591980020c87af257e7 (patch)
treedd8d9f51a47716785083591d82ca873c201c1057 /modules/aggregator/aggregator.module
parentd407de4cec606623a5946805d2d42b580ccb116b (diff)
downloadbrdo-03752e35a41992c3d61f2591980020c87af257e7.tar.gz
brdo-03752e35a41992c3d61f2591980020c87af257e7.tar.bz2
- Patch #34755 by chx et al: faster menu system. HEAD is temporary broken and there is no upgrade path yet.
Diffstat (limited to 'modules/aggregator/aggregator.module')
-rw-r--r--modules/aggregator/aggregator.module310
1 files changed, 152 insertions, 158 deletions
diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module
index 15cba51ac..9f2712990 100644
--- a/modules/aggregator/aggregator.module
+++ b/modules/aggregator/aggregator.module
@@ -28,169 +28,162 @@ function aggregator_help($section) {
/**
* Implementation of hook_menu().
*/
-function aggregator_menu($may_cache) {
- $items = array();
- $edit = user_access('administer news feeds');
- $view = user_access('access news feeds');
-
- if ($may_cache) {
- $items[] = array('path' => 'admin/content/aggregator',
- 'title' => t('News aggregator'),
- 'description' => t("Configure which content your site aggregates from other sites, how often it polls them, and how they're categorized."),
- 'callback' => 'aggregator_admin_overview',
- 'access' => $edit);
- $items[] = array('path' => 'admin/content/aggregator/add/feed',
- 'title' => t('Add feed'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('aggregator_form_feed'),
- 'access' => $edit,
- 'type' => MENU_LOCAL_TASK);
- $items[] = array('path' => 'admin/content/aggregator/add/category',
- 'title' => t('Add category'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('aggregator_form_category'),
- 'access' => $edit,
- 'type' => MENU_LOCAL_TASK);
- $items[] = array('path' => 'admin/content/aggregator/remove',
- 'title' => t('Remove items'),
- 'callback' => 'aggregator_admin_remove_feed',
- 'access' => $edit,
- 'type' => MENU_CALLBACK);
- $items[] = array('path' => 'admin/content/aggregator/update',
- 'title' => t('Update items'),
- 'callback' => 'aggregator_admin_refresh_feed',
- 'access' => $edit,
- 'type' => MENU_CALLBACK);
- $items[] = array('path' => 'admin/content/aggregator/list',
- 'title' => t('List'),
+function aggregator_menu() {
+ $items['admin/content/aggregator'] = array(
+ 'title' => t('News aggregator'),
+ 'description' => t("Configure which content your site aggregates from other sites, how often it polls them, and how they're categorized."),
+ 'page callback' => 'aggregator_admin_overview',
+ 'access arguments' => array('administer news feeds'),
+ );
+ $items['admin/content/aggregator/add/feed'] = array(
+ 'title' => t('Add feed'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_form_feed'),
+ 'access arguments' => array('administer news feeds'),
+ 'type' => MENU_LOCAL_TASK,
+ );
+ $items['admin/content/aggregator/add/category'] = array(
+ 'title' => t('Add category'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_form_category'),
+ 'access arguments' => array('administer news feeds'),
+ 'type' => MENU_LOCAL_TASK,
+ );
+ $items['admin/content/aggregator/remove/%'] = array(
+ 'title' => t('Remove items'),
+ 'page callback' => 'aggregator_admin_remove_feed',
+ 'page arguments' => array(4),
+ 'map arguments' => array('aggregator_get_feed', 4),
+ 'access arguments' => array('administer news feeds'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/content/aggregator/update/%'] = array(
+ 'title' => t('Update items'),
+ 'page callback' => 'aggregator_admin_refresh_feed',
+ 'page arguments' => array(4),
+ 'map arguments' => array('aggregator_get_feed', 4),
+ 'access arguments' => array('administer news feeds'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/content/aggregator/list'] = array(
+ 'title' => t('List'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+ $items['admin/content/aggregator/settings'] = array(
+ 'title' => t('Settings'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_admin_settings'),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 10,
+ 'access arguments' => array('administer news feeds'),
+ );
+ $items['aggregator'] = array(
+ 'title' => t('News aggregator'),
+ 'page callback' => 'aggregator_page_last',
+ 'access arguments' => array('access news feeds'),
+ 'weight' => 5,
+ );
+ $items['aggregator/sources'] = array(
+ 'title' => t('Sources'),
+ 'page callback' => 'aggregator_page_sources',
+ 'access arguments' => array('access news feeds'));
+ $items['aggregator/categories'] = array(
+ 'title' => t('Categories'),
+ 'page callback' => 'aggregator_page_categories',
+ 'access arguments' => array('access news feeds'),
+ 'type' => MENU_ITEM_GROUPING,
+ );
+ $items['aggregator/rss'] = array(
+ 'title' => t('RSS feed'),
+ 'page callback' => 'aggregator_page_rss',
+ 'access arguments' => array('access news feeds'),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['aggregator/opml'] = array(
+ 'title' => t('OPML feed'),
+ 'page callback' => 'aggregator_page_opml',
+ 'access arguments' => array('access news feeds'),
+ 'type' => MENU_CALLBACK,
+ );
+ $result = db_query('SELECT title, cid FROM {aggregator_category} ORDER BY title');
+ while ($category = db_fetch_array($result)) {
+ $path = 'aggregator/categories/'. $category['cid'];
+ $items[$path] = array(
+ 'title' => $category['title'],
+ 'page callback' => 'aggregator_page_category',
+ 'access arguments' => array('access news feeds'),
+ );
+ $items[$path .'/view'] = array(
+ 'title' => t('View'),
'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => -10);
- $items[] = array('path' => 'admin/content/aggregator/settings',
- 'title' => t('Settings'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('aggregator_admin_settings'),
+ 'weight' => -10,
+ );
+ $items[$path .'/categorize'] = array(
+ 'title' => t('Categorize'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_page_category'),
+ 'access arguments' => array('administer news feeds', 2),
'type' => MENU_LOCAL_TASK,
- 'weight' => 10,
- 'access' => $edit);
-
- $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);
- $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'),
- 'callback' => 'aggregator_page_opml',
- 'access' => $view,
- 'type' => MENU_CALLBACK);
-
- $result = db_query('SELECT title, cid FROM {aggregator_category} ORDER BY title');
- while ($category = db_fetch_array($result)) {
- $items[] = array('path' => 'aggregator/categories/'. $category['cid'],
- 'title' => $category['title'],
- 'callback' => 'aggregator_page_category',
- 'access' => $view);
- }
- }
- else {
- // Add the CSS for this module
- // We put this in !$may_cache so it's only added once per request
- drupal_add_css(drupal_get_path('module', 'aggregator') .'/aggregator.css');
-
- if (arg(0) == 'aggregator' && is_numeric(arg(2))) {
- if (arg(1) == 'sources') {
- $feed = aggregator_get_feed(arg(2));
- if ($feed) {
- $items[] = array('path' => 'aggregator/sources/'. $feed['fid'],
- 'title' => $feed['title'],
- 'callback' => 'aggregator_page_source',
- 'access' => $view,
- 'type' => MENU_CALLBACK);
- $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' => 'drupal_get_form',
- 'callback arguments' => array('aggregator_page_source'),
- 'access' => $edit,
- 'type' => MENU_LOCAL_TASK);
- $items[] = array('path' => 'aggregator/sources/'. $feed['fid'] .'/configure',
- 'title' => t('Configure'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('aggregator_form_feed', $feed),
- 'access' => $edit,
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 1);
- }
- }
- else if (arg(1) == 'categories') {
- $category = aggregator_get_category(arg(2));
- if ($category) {
- $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' => 'drupal_get_form',
- 'callback arguments' => array('aggregator_page_category'),
- 'access' => $edit,
- 'type' => MENU_LOCAL_TASK);
- $items[] = array('path' => 'aggregator/categories/'. $category['cid'] .'/configure',
- 'title' => t('Configure'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('aggregator_form_category', $category),
- 'access' => $edit,
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 1);
- }
- }
- }
- else if (arg(2) == 'aggregator' && is_numeric(arg(5))) {
- if (arg(4) == 'feed') {
- $feed = aggregator_get_feed(arg(5));
- if ($feed) {
- $items[] = array('path' => 'admin/content/aggregator/edit/feed/'. $feed['fid'],
- 'title' => t('Edit feed'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('aggregator_form_feed', $feed),
- 'access' => $edit,
- 'type' => MENU_CALLBACK);
- }
- }
- else {
- $category = aggregator_get_category(arg(5));
- if ($category) {
- $items[] = array('path' => 'admin/content/aggregator/edit/category/'. $category['cid'],
- 'title' => t('Edit category'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('aggregator_form_category', $category),
- 'access' => $edit,
- 'type' => MENU_CALLBACK);
- }
- }
- }
+ );
+ $items[$path .'/configure'] = array(
+ 'title' => t('Configure'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_form_category', 2),
+ 'access arguments' => array('administer news feeds', 2),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 1,
+ );
}
+ $items['aggregator/sources/%'] = array(
+ 'page callback' => 'aggregator_page_source',
+ 'map arguments' => array('aggregator_get_feed', 2),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['aggregator/sources/%/view'] = array(
+ 'title' => t('View'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+ $items['aggregator/sources/%/categorize'] = array(
+ 'title' => t('Categorize'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_page_source'),
+ 'access arguments' => array('administer news feeds'),
+ 'type' => MENU_LOCAL_TASK,
+ );
+ $items['aggregator/sources/%/configure'] = array(
+ 'title' => t('Configure'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_form_feed', 2),
+ 'access arguments' => array('administer news feeds'),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 1,
+ );
+ $items['admin/content/aggregator/edit/feed/%'] = array(
+ 'title' => t('Edit feed'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_form_feed', 5),
+ 'access arguments' => array('administer news feeds'),
+ 'map arguments' => array('aggregator_get_feed', 5),
+ 'type' => MENU_CALLBACK,
+ );
+ $items['admin/content/aggregator/edit/category/%'] = array(
+ 'title' => t('Edit category'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_form_category', 5),
+ 'access arguments' => array('administer news feeds'),
+ 'map arguments' => array('aggregator_get_category', 5),
+ 'type' => MENU_CALLBACK,
+ );
return $items;
}
+function aggregator_init() {
+ drupal_add_css(drupal_get_path('module', 'aggregator') .'/aggregator.css');
+}
+
function aggregator_admin_settings() {
$items = array(0 => t('none')) + drupal_map_assoc(array(3, 5, 10, 15, 20, 25), '_aggregator_items');
$period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval');
@@ -1005,7 +998,7 @@ function aggregator_view() {
* Menu callback; removes all items from a feed, then redirects to the overview page.
*/
function aggregator_admin_remove_feed($feed) {
- aggregator_remove(aggregator_get_feed($feed));
+ aggregator_remove($feed);
drupal_goto('admin/content/aggregator');
}
@@ -1013,7 +1006,7 @@ function aggregator_admin_remove_feed($feed) {
* Menu callback; refreshes a feed, then redirects to the overview page.
*/
function aggregator_admin_refresh_feed($feed) {
- aggregator_refresh(aggregator_get_feed($feed));
+ aggregator_refresh($feed);
drupal_goto('admin/content/aggregator');
}
@@ -1038,6 +1031,7 @@ function aggregator_page_last() {
*/
function aggregator_page_source() {
$feed = db_fetch_object(db_query('SELECT * FROM {aggregator_feed} WHERE fid = %d', arg(2)));
+ drupal_set_title($feed->title);
$info = theme('aggregator_feed', $feed);
return _aggregator_page_list('SELECT * FROM {aggregator_item} WHERE fid = '. $feed->fid .' ORDER BY timestamp DESC, iid DESC', arg(3), $info);