- Patch #43245 by mustafau, Dries, agentrickard, markus_petrux, et al: add an option to not generate blocks for RSS feeds.
parent
72d13bc3f8
commit
64764bf961
|
@ -21,6 +21,7 @@ Drupal 7.0, xxxx-xx-xx (development version)
|
|||
the includes directory.
|
||||
- News aggregator:
|
||||
* Added OPML import functionality for RSS feeds.
|
||||
* Add an option not to generate blocks for RSS feeds.
|
||||
- Search:
|
||||
* Added support for language-aware searches.
|
||||
- Testing:
|
||||
|
|
|
@ -52,7 +52,7 @@ function aggregator_view() {
|
|||
* @see aggregator_form_feed_validate()
|
||||
* @see aggregator_form_feed_submit()
|
||||
*/
|
||||
function aggregator_form_feed(&$form_state, $edit = array('refresh' => 900, 'title' => '', 'url' => '', 'fid' => NULL)) {
|
||||
function aggregator_form_feed(&$form_state, $edit = array('refresh' => 900, 'block' => 5, 'title' => '', 'url' => '', 'fid' => NULL)) {
|
||||
$period = drupal_map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
|
||||
|
||||
if ($edit['refresh'] == '') {
|
||||
|
@ -77,7 +77,13 @@ function aggregator_form_feed(&$form_state, $edit = array('refresh' => 900, 'tit
|
|||
'#title' => t('Update interval'),
|
||||
'#default_value' => $edit['refresh'],
|
||||
'#options' => $period,
|
||||
'#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'))),
|
||||
'#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'))),
|
||||
);
|
||||
$form['block'] = array('#type' => 'select',
|
||||
'#title' => t('News items in block'),
|
||||
'#default_value' => $edit['block'],
|
||||
'#options' => drupal_map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)),
|
||||
'#description' => t("Drupal can make a block with the most recent news items of this feed. You can <a href=\"@block-admin\">configure blocks</a> to be displayed in the sidebar of your page. This setting lets you configure the number of news items to show in this feed's block. If you choose '0' this feed's block will be disabled.", array('@block-admin' => url('admin/build/block'))),
|
||||
);
|
||||
|
||||
// Handling of categories.
|
||||
|
@ -240,7 +246,13 @@ function aggregator_form_opml(&$form_state) {
|
|||
'#title' => t('Update interval'),
|
||||
'#default_value' => 3600,
|
||||
'#options' => $period,
|
||||
'#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'))),
|
||||
'#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'))),
|
||||
);
|
||||
$form['block'] = array('#type' => 'select',
|
||||
'#title' => t('News items in block'),
|
||||
'#default_value' => 5,
|
||||
'#options' => drupal_map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)),
|
||||
'#description' => t("Drupal can make a block with the most recent news items of a feed. You can <a href=\"@block-admin\">configure blocks</a> to be displayed in the sidebar of your page. This setting lets you configure the number of news items to show in a feed's block. If you choose '0' these feeds' blocks will be disabled.", array('@block-admin' => url('admin/build/block'))),
|
||||
);
|
||||
|
||||
// Handling of categories.
|
||||
|
|
|
@ -299,7 +299,7 @@ function aggregator_block($op = 'list', $delta = '', $edit = array()) {
|
|||
while ($category = db_fetch_object($result)) {
|
||||
$block['category-' . $category->cid]['info'] = t('!title category latest items', array('!title' => $category->title));
|
||||
}
|
||||
$result = db_query('SELECT fid, title FROM {aggregator_feed} ORDER BY fid');
|
||||
$result = db_query('SELECT fid, title FROM {aggregator_feed} WHERE block <> 0 ORDER BY fid');
|
||||
while ($feed = db_fetch_object($result)) {
|
||||
$block['feed-' . $feed->fid]['info'] = t('!title feed latest items', array('!title' => $feed->title));
|
||||
}
|
||||
|
@ -308,27 +308,26 @@ function aggregator_block($op = 'list', $delta = '', $edit = array()) {
|
|||
list($type, $id) = explode('-', $delta);
|
||||
if ($type == 'category') {
|
||||
$value = db_result(db_query('SELECT block FROM {aggregator_category} WHERE cid = %d', $id));
|
||||
$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 {
|
||||
$value = db_result(db_query('SELECT block FROM {aggregator_feed} WHERE fid = %d', $id));
|
||||
}
|
||||
$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;
|
||||
}
|
||||
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);
|
||||
}
|
||||
else {
|
||||
$value = db_query('UPDATE {aggregator_feed} SET block = %d WHERE fid = %d', $edit['block'], $id);
|
||||
}
|
||||
}
|
||||
elseif ($op == 'view') {
|
||||
list($type, $id) = explode('-', $delta);
|
||||
switch ($type) {
|
||||
case 'feed':
|
||||
if ($feed = db_fetch_object(db_query('SELECT fid, title, block FROM {aggregator_feed} WHERE fid = %d', $id))) {
|
||||
if ($feed = db_fetch_object(db_query('SELECT fid, title, block FROM {aggregator_feed} WHERE block <> 0 AND fid = %d', $id))) {
|
||||
$block['subject'] = check_plain($feed->title);
|
||||
$result = db_query_range('SELECT * FROM {aggregator_item} WHERE fid = %d ORDER BY timestamp DESC, iid DESC', $feed->fid, 0, $feed->block);
|
||||
$read_more = theme('more_link', url('aggregator/sources/' . $feed->fid), t("View this feed's recent news."));
|
||||
|
@ -404,7 +403,7 @@ function aggregator_save_feed($edit) {
|
|||
db_query('DELETE FROM {aggregator_category_feed} WHERE fid = %d', $edit['fid']);
|
||||
}
|
||||
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']);
|
||||
db_query("UPDATE {aggregator_feed} SET title = '%s', url = '%s', refresh = %d, block = %d WHERE fid = %d", $edit['title'], $edit['url'], $edit['refresh'], $edit['block'], $edit['fid']);
|
||||
}
|
||||
elseif (!empty($edit['fid'])) {
|
||||
$items = array();
|
||||
|
@ -421,7 +420,7 @@ function aggregator_save_feed($edit) {
|
|||
db_query("DELETE FROM {blocks} WHERE module = '%s' AND delta = '%s'", 'aggregator', 'feed-' . $edit['fid']);
|
||||
}
|
||||
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']);
|
||||
db_query("INSERT INTO {aggregator_feed} (title, url, refresh, block, description, image) VALUES ('%s', '%s', %d, %d, '', '')", $edit['title'], $edit['url'], $edit['refresh'], $edit['block']);
|
||||
// A single unique ID for bundles and feeds, to use in blocks.
|
||||
$edit['fid'] = db_last_insert_id('aggregator_feed', 'fid');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue