summaryrefslogtreecommitdiff
path: root/modules/aggregator
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2004-06-18 15:04:37 +0000
committerDries Buytaert <dries@buytaert.net>2004-06-18 15:04:37 +0000
commit54b77d64354949428bc8bf48d47b587312a535f2 (patch)
tree8e29ff15063129388e14009f0de6fda996beb897 /modules/aggregator
parent5ad73c8eb63c8c8db451e5586860f52be8dd8874 (diff)
downloadbrdo-54b77d64354949428bc8bf48d47b587312a535f2.tar.gz
brdo-54b77d64354949428bc8bf48d47b587312a535f2.tar.bz2
Tabs patch!
CHANGES ------- + Introduced tabs. First, we extended the menu system to support tabs. Next, a tab was added for every link that was (1) an administrative action other than the implicit 'view' (2) relevant to that particular page only. This is illustrated by the fact that all tabs are verbs and that clicking a page's tab leads you to a subpage of that page. + Flattened the administration menu. The tabs helped simplify the navigation menu as I could separate 'actions' from 'navigation'. In addition, I removed the 'administer > configuration'-menu, renamed 'blocks' to 'sidebars' which I hope is a bit more descriptive, and made a couple more changes. Earlier, we already renamed 'taxonomy' to 'categorization' and we move 'statistics' under 'logs'. + Grouped settings. All settings have been grouped under 'administer > settings'. TODO ---- + Update core themes: only Xtemplate default supports tabs and even those look ugly. Need help. + Update contributed modules. The menu() hook changed drastically. Updating your code adhere the new menu() function should be 90% of the work. Moreover, ensure that your modue's admin links are still valid and that URLs to node get updated to the new scheme ('node/view/x' -> 'node/x').
Diffstat (limited to 'modules/aggregator')
-rw-r--r--modules/aggregator/aggregator.module186
1 files changed, 135 insertions, 51 deletions
diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module
index f82f5ea27..a06d5d65a 100644
--- a/modules/aggregator/aggregator.module
+++ b/modules/aggregator/aggregator.module
@@ -17,8 +17,8 @@ function aggregator_help($section) {
<p>To learn much more about RSS, read Mark Pilgrim\'s <a href="http://www.xml.com/pub/a/2002/12/18/dive-into-xml.html">What is RSS</a> and WebReference.com\'s <a href="http://www.webreference.com/authoring/languages/xml/rss/1/">The Evolution of RSS</a>.</p>
<p>NOTE: Enable your site\'s XML syndication button by turning on the Syndicate block in block management.</p>
<h3>Adding news feeds</h3>
- <p>To subscribe to an RSS feed on another site, use the <a href="%admin-news">RSS/RDF</a> administration page.</p>
- <p>Once there, select <a href="%new-feed">new feed</a> from the menu. Drupal will then ask for the following:</p>
+ <p>To subscribe to an RSS feed on another site, use the <a href="%admin-news">aggregation page</a>.</p>
+ <p>Once there, click the <a href="%new-feed">new feed</a> tab. Drupal will then ask for the following:</p>
<ul>
<li><strong>Title</strong> -- The text entered here will be used in your news aggregator, within the administration configuration section, and as title for the news feed block. As a general rule, use the web site name from which the feed originates.</li>
<li><strong>URL</strong> -- Here you\'ll enter the fully-qualified URL for the feed for the site you want to subscribe to.</li>
@@ -26,9 +26,9 @@ function aggregator_help($section) {
<li><strong>Latest items block</strong> -- The number of items selected here will determine how many of the latest items from the feed will appear in a block which may be enabled and placed in the <a href="%block">blocks</a> administration page.</li>
<li><strong>Automatically file items</strong> -- As items are recieved from a feed they will be put in the checked categories.</li>
</ul>
- <p>Once you submit your new feed, check to see if it is working properly. Select <a href="%update-items">update items</a> on the <a href="%admin-news">RSS/RDF</a> page. If you do not see any items listed for that feed, edit the feed and make sure that the URL was entered correctly.</p>
+ <p>Once you submit your new feed, check to see if it is working properly. Select <a href="%update-items">update items</a> on the <a href="%admin-news">aggregation page</a>. If you do not see any items listed for that feed, edit the feed and make sure that the URL was entered correctly.</p>
<h3>Adding categories</h3>
- <p>News items can be filed into categories. To create a category, start at the <a href="%admin-news">RSS/RDF</a> administration page.</p>
+ <p>News items can be filed into categories. To create a category, start at the <a href="%admin-news">aggregation page</a>.</p>
<p>Once there, select <a href="%new-category">new category</a> from the menu. Drupal will then ask for the following:</p>
<ul>
<li><strong>Title</strong> -- The title will be used in the <i>news by topics</i> listing in your news aggregator and with the customized block created for the bundle.</li>
@@ -53,13 +53,13 @@ function aggregator_help($section) {
<h3>Technical details</h3>
<p>Drupal automatically generates an OPML feed file that is available by selecting the XML icon on the News Sources page.</p>
<p>When fetching feeds Drupal supports conditional GETs, this reduces the bandwidth usage for feeds that have not been updated since the last check.</p>
- <p>If a feed is permanently moved to a new location Drupal will automatically update the feed URL to the new address.</p>', array('%block' => url('admin/system/block'), '%admin-news' => url('admin/aggregator'), '%new-feed' => url('admin/aggregator/add/feed'), '%new-category' => url('admin/aggregator/add/category'), '%update-items' => url('admin/aggregator'), '%news-aggregator' => url('aggregator'), '%sources' => url('aggregator/sources'), '%categories' => url('aggregator/categories')));
- case 'admin/system/modules#description':
+ <p>If a feed is permanently moved to a new location Drupal will automatically update the feed URL to the new address.</p>', array('%block' => url('admin/block'), '%admin-news' => url('admin/aggregator'), '%new-feed' => url('admin/aggregator/add/feed'), '%new-category' => url('admin/aggregator/add/category'), '%update-items' => url('admin/aggregator'), '%news-aggregator' => url('aggregator'), '%sources' => url('aggregator/sources'), '%categories' => url('aggregator/categories')));
+ case 'admin/modules#description':
return t('Used to aggregate syndicated content (RSS and RDF).');
- case 'admin/system/modules/aggregator':
+ case 'admin/settings/aggregator':
return t('These settings control the display of aggregated content.');
case 'admin/aggregator':
- return t('Several web sites, especially news related sites, syndicate parts of their site\'s content for other web sites to display. Usually, the syndicated content includes the latest headlines with a direct link to that story on the remote site. Some syndicated content also includes a description of the headline. The standard method of syndication is using the XML based Rich Site Summary (RSS) or Resource Description Framework (RDF). To get a feed to work you <strong>must</strong> have <a href=\"%cron\">cron</a> working. To display the feed or categoty in a block you must decide how many items to show by editing the feed or block and turn on the <a href="%block">feed\'s block</a>.', array('%block' => url('admin/system/block'), '%cron' => url('admin/help', NULL, 'cron')));
+ return t('Several web sites, especially news related sites, syndicate parts of their site\'s content for other web sites to display. Usually, the syndicated content includes the latest headlines with a direct link to that story on the remote site. Some syndicated content also includes a description of the headline. The standard method of syndication is using the XML based Rich Site Summary (RSS) or Resource Description Framework (RDF). To get a feed to work you <strong>must</strong> have <a href=\"%cron\">cron</a> working. To display the feed or categoty in a block you must decide how many items to show by editing the feed or block and turn on the <a href="%block">feed\'s block</a>.', array('%block' => url('admin/block'), '%cron' => url('admin/help', NULL, 'cron')));
case 'admin/aggregator/add/feed':
return t('Add a site that has an RSS/RDF feed. The URL is the full path to the RSS feed file. For the feed to update automatically you must run "cron.php". If you already have a feed with the URL you are planning to use, the system will not accept another feed with the same URL.');
case 'admin/aggregator/add/category':
@@ -74,10 +74,11 @@ function aggregator_help_page() {
print theme('page', aggregator_help('admin/help#aggregator'));
}
-/**
- * Implementation of hook_settings().
- */
-function aggregator_settings() {
+function aggregator_configure() {
+ if ($_POST) {
+ system_settings_save();
+ }
+
$output = '';
$number = drupal_map_assoc(array(5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100));
$items = array(0 => t('none'), 3 => t('3 items'), 5 => t('5 items'), 10 => t('10 items'), 15 => t('15 items'), 20 => t('20 items'), 25 => t('25 items'));
@@ -85,7 +86,7 @@ function aggregator_settings() {
$output .= form_select(t('Items shown in sources and categories pages'), 'aggregator_summary_items', variable_get('aggregator_summary_items', 3), $items, t('The number of items which will be shown with each feed or category in the feed and category summary pages.'));
$output .= form_radios(t('Category selection type'), 'aggregator_category_selector', variable_get('aggregator_category_selector', 'check'), array('check' => t('checkboxes'), 'select' => t('multiple selector')), t('The type of category selection widget which is shown on categorization pages. Checkboxes are easier to use; a multiple selector is good for working with large numbers of categories.'));
- return $output;
+ print theme('page', system_settings_form($output));
}
/**
@@ -102,43 +103,91 @@ function aggregator_link($type) {
if ($type == 'page' && user_access('access news feeds')) {
return array(l(t('news feeds'), 'aggregator', array('title' => t('Read the latest news from syndicated web sites.'))));
}
+}
- if ($type == 'system') {
- $access = user_access('administer news feeds');
- menu('admin/aggregator', t('aggregator'), $access ? 'aggregator_admin_overview' : MENU_DENIED);
- menu('admin/aggregator/add/feed', t('new feed'), $access ? 'aggregator_admin_edit_feed' : MENU_DENIED, 2);
- menu('admin/aggregator/edit/feed', t('edit feed'), $access ? 'aggregator_admin_edit_feed' : MENU_DENIED, 2, MENU_HIDE);
- menu('admin/aggregator/add/category', t('new category'), $access ? 'aggregator_admin_edit_category' : MENU_DENIED, 3);
- menu('admin/aggregator/edit/category', t('edit category'), $access ? 'aggregator_admin_edit_category' : MENU_DENIED, 3, MENU_HIDE);
- menu('admin/aggregator/remove', t('remove items'), $access ? 'aggregator_admin_remove_feed' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/aggregator/update', t('update items'), $access ? 'aggregator_admin_refresh_feed' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
- menu('admin/aggregator/help', t('help'), $access ? 'aggregator_help_page' : MENU_DENIED, 9);
-
- $access = user_access('access news feeds');
- menu('aggregator', t('news aggregator'), $access ? 'aggregator_page_last' : MENU_DENIED, 5);
- menu('aggregator/sources', t('sources'), $access ? 'aggregator_page_sources' : MENU_DENIED, 0);
- menu('aggregator/categories', t('categories'), $access ? 'aggregator_page_categories' : MENU_DENIED, 1, MENU_HIDE_NOCHILD);
-
- // To reduce the number of SQL queries, we don't query the database when
- // not on an aggregator page.
- // If caching of the menu is implemented, this check should be removed
- // so that DHTML menu presentation can be used correctly.
- if (arg(0) == 'aggregator') {
- // Sources:
- $result = db_query('SELECT title, fid FROM {aggregator_feed} ORDER BY title');
- while ($feed = db_fetch_object($result)) {
- menu('aggregator/sources/'. $feed->fid, $feed->title, $access ? 'aggregator_page_source' : MENU_DENIED);
- }
+/**
+ * Implementation of hook_menu().
+ */
+function aggregator_menu() {
+ $items = array();
- // Categories:
- $result = db_query('SELECT title, cid FROM {aggregator_category} ORDER BY title');
- while ($category = db_fetch_object($result)) {
- menu('aggregator/categories/'. $category->cid, $category->title, $access ? 'aggregator_page_category' : MENU_DENIED);
- }
+ $edit = user_access('administer news feeds');
+ $view = user_access('access news feeds');
+
+ $items[] = array('path' => 'admin/aggregator', 'title' => t('aggregator'),
+ 'callback' => 'aggregator_admin_overview', 'access' => $edit);
+ $items[] = array('path' => 'admin/aggregator/edit/feed', 'title' => t('edit feed'),
+ 'callback' => 'aggregator_admin_edit_feed', 'access' => $edit,
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/aggregator/edit/category', 'title' => t('edit category'),
+ 'callback' => 'aggregator_admin_edit_category', 'access' => $edit,
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/aggregator/remove', 'title' => t('remove items'),
+ 'callback' => 'aggregator_admin_remove_feed', 'access' => $edit,
+ 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/aggregator/update', 'title' => t('update items'),
+ 'callback' => 'aggregator_admin_refresh_feed', 'access' => $edit,
+ 'type' => MENU_CALLBACK);
+
+ // Tabs:
+ $items[] = array('path' => 'admin/aggregator/add/feed', 'title' => t('add feed'),
+ 'callback' => 'aggregator_admin_edit_feed', 'access' => $edit,
+ 'type' => MENU_LOCAL_TASK);
+ $items[] = array('path' => 'admin/aggregator/add/category', 'title' => t('add category'),
+ 'callback' => 'aggregator_admin_edit_category', 'access' => $edit,
+ 'type' => MENU_LOCAL_TASK);
+ $items[] = array('path' => 'admin/aggregator/configure', 'title' => t('configure'),
+ 'callback' => 'aggregator_configure', 'access' => $edit,
+ 'type' => MENU_LOCAL_TASK);
+
+ $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);
+
+ // To reduce the number of SQL queries, we don't query the database when
+ // not on an aggregator page.
+ // If caching of the menu is implemented, this check should be removed
+ // so that DHTML menu presentation can be used correctly.
+ if (arg(0) == 'aggregator') {
+ // Sources:
+ $result = db_query('SELECT title, fid FROM {aggregator_feed} ORDER BY title');
+ while ($feed = db_fetch_object($result)) {
+ $items[] = array('path' => 'aggregator/sources/'. $feed->fid, 'title' => $feed->title,
+ 'callback' => 'aggregator_page_source', 'access' => $view);
+ $items[] = array('path' => 'aggregator/sources/'. $feed->fid .'/categorize', 'title' => t('categorize'),
+ 'callback' => 'aggregator_page_source', 'access' => $edit,
+ 'type' => MENU_LOCAL_TASK);
+ $items[] = array('path' => 'aggregator/sources/'. $feed->fid .'/configure', 'title' => t('configure'),
+ 'callback' => 'aggregator_edit', 'access' => $edit,
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 1);
}
- menu('aggregator/opml', t('opml'), $access ? 'aggregator_page_opml' : MENU_DENIED, '', MENU_HIDE);
+ // Categories:
+ $result = db_query('SELECT title, cid FROM {aggregator_category} ORDER BY title');
+ while ($category = db_fetch_object($result)) {
+ $items[] = array('path' => 'aggregator/categories/'. $category->cid, 'title' => $category->title,
+ 'callback' => 'aggregator_page_category', 'access' => $view);
+ $items[] = array('path' => 'aggregator/categories/'. $category->cid .'/categorize', 'title' => t('categorize'),
+ 'callback' => 'aggregator_page_category', 'access' => $edit,
+ 'type' => MENU_LOCAL_TASK);
+ $items[] = array('path' => 'aggregator/categories/'. $category->cid .'/configure', 'title' => t('configure'),
+ 'callback' => 'aggregator_edit', 'access' => $edit,
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 1);
+ }
}
+
+ $items[] = array('path' => 'aggregator/opml', 'title' => t('opml'),
+ 'callback' => 'aggregator_page_opml', 'access' => $view,
+ 'type' => MENU_CALLBACK);
+
+ return $items;
}
/**
@@ -501,7 +550,7 @@ function aggregator_form_category($edit = array()) {
$form = form_textfield(t('Title'), 'title', $edit['title'], 50, 64);
$form .= form_textarea(t('Description'), 'description', $edit['description'], 60, 5);
- $form .= form_select(t('Latest items block'), 'block', $edit['block'], $block_items, t('If enabled, a block containing the latest items in this category will be availiable for placement on the <a href="%url">block configuration</a> page.', array('%url' => url('admin/system/block'))));
+ $form .= form_select(t('Latest items block'), 'block', $edit['block'], $block_items, t('If enabled, a block containing the latest items in this category will be availiable for placement on the <a href="%url">block configuration</a> page.', array('%url' => url('admin/block'))));
$form .= form_submit(t('Submit'));
if ($edit['cid']) {
@@ -537,7 +586,7 @@ function aggregator_form_feed($edit = array()) {
$form .= form_textfield(t('Title'), 'title', $edit['title'], 50, 64, t('The name of the feed; typically the name of the web site you syndicate content from.'));
$form .= form_textfield(t('URL'), 'url', $edit['url'], 50, 128, t('The fully-qualified URL of the feed.'));
$form .= form_select(t('Update interval'), 'refresh', $edit['refresh'], $period, t('The refresh interval indicating how often you want to update this feed. Requires crontab.'));
- $form .= form_select(t('Latest items block'), 'block', $edit['block'], $block_items, t('If enabled, a block containing the latest items from this feed will be availiable for placement on the <a href="%url">block configuration</a> page.', array('%url' => url('admin/system/block'))));
+ $form .= form_select(t('Latest items block'), 'block', $edit['block'], $block_items, t('If enabled, a block containing the latest items from this feed will be availiable for placement on the <a href="%url">block configuration</a> page.', array('%url' => url('admin/block'))));
$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']);
while ($category = db_fetch_object($categories)) {
$checkboxes .= form_checkbox($category->title, "category][$category->cid", 1, $category->fid ? 1 : 0);
@@ -626,6 +675,45 @@ function aggregator_view() {
return $output;
}
+function aggregator_edit() {
+
+ if ($_POST['op'] == t('Submit')) {
+ if (arg(1) == 'categories') {
+ aggregator_save_category($_POST['edit']);
+ drupal_set_message(t('The category has been updated.'));
+ }
+ else {
+ aggregator_save_feed($_POST['edit']);
+ drupal_set_message(t('The feed has been updated.'));
+ }
+ }
+ else if ($_POST['op'] == t('Delete')) {
+ // Unset the title:
+ unset($_POST['edit']['title']);
+
+ if (arg(1) == 'categories') {
+ aggregator_save_category($_POST['edit']);
+ drupal_set_message(t('The category has been deleted.'));
+ }
+ else {
+ aggregator_save_feed($_POST['edit']);
+ drupal_set_message(t('The feed has been deleted.'));
+ }
+
+ drupal_goto('aggregator');
+ }
+
+ if (arg(1) == 'categories') {
+ $output = aggregator_form_category(aggregator_get_category(arg(2)));
+ }
+ else {
+ $output = aggregator_form_feed(aggregator_get_feed(arg(2)));
+ }
+
+ print theme('page', $output);
+}
+
+
/**
* Menu callback; displays the category edit form, or saves changes and
* displays the overview page.
@@ -743,15 +831,11 @@ function _aggregator_page_list($sql, $op, $header = '') {
}
}
}
- $links[] = l(t('categorize news items'), $_GET['q']);
}
else {
$categorize = true;
}
}
- if (user_access('administer news feeds') && $op != 'categorize') {
- $links[] = l(t('categorize news items'), $_GET['q'] .'/categorize');
- }
$output = '<div id="aggregator">';
if ($header) {