Commit 48d139ae authored by Dries's avatar Dries

- Patch #1496462 by acrollet, sun, cosmicdreams, Niklas Fiekas, aspilicious:...

- Patch #1496462 by acrollet, sun, cosmicdreams, Niklas Fiekas, aspilicious: convert RSS publishing settings to configuration system.
parent 9f5ef6d4
......@@ -403,15 +403,16 @@ function aggregator_page_categories() {
*/
function aggregator_page_rss() {
$result = NULL;
$rss_config = config('system.rss');
// arg(2) is the passed cid, only select for that category.
if (arg(2)) {
$category = db_query('SELECT cid, title FROM {aggregator_category} WHERE cid = :cid', array(':cid' => arg(2)))->fetchObject();
$result = db_query_range('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 = :cid ORDER BY timestamp DESC, i.iid DESC', 0, config('system.rss-publishing')->get('feed_default_items'), array(':cid' => $category->cid));
$result = db_query_range('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 = :cid ORDER BY timestamp DESC, i.iid DESC', 0, $rss_config->get('items.limit'), array(':cid' => $category->cid));
}
// Or, get the default aggregator items.
else {
$category = NULL;
$result = db_query_range('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', 0, config('system.rss-publishing')->get('feed_default_items'));
$result = db_query_range('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', 0, $rss_config->get('items.limit'));
}
$feeds = $result->fetchAll();
......@@ -437,7 +438,7 @@ function theme_aggregator_page_rss($variables) {
drupal_add_http_header('Content-Type', 'application/rss+xml; charset=utf-8');
$items = '';
$feed_length = config('system.rss-publishing')->get('feed_item_length');
$feed_length = config('system.rss')->get('items.view_mode');
foreach ($feeds as $feed) {
switch ($feed_length) {
case 'teaser':
......
......@@ -83,8 +83,8 @@ public function testBlockLinks() {
public function testFeedPage() {
// Increase the number of items published in the rss.xml feed so we have
// enough articles to test paging.
$config = config('system.rss-publishing');
$config->set('feed_default_items', 30);
$config = config('system.rss');
$config->set('items.limit', 30);
$config->save();
// Create a feed with 30 items.
......@@ -98,7 +98,7 @@ public function testFeedPage() {
$this->assertTrue(!empty($elements), t('Individual source page contains a pager.'));
// Reset the number of items in rss.xml to the default value.
$config->set('feed_default_items', 10);
$config->set('items.limit', 10);
$config->save();
}
}
......@@ -88,7 +88,7 @@ function getFeedEditArray($feed_url = NULL) {
*/
function getDefaultFeedItemCount() {
// Our tests are based off of rss.xml, so let's find out how many elements should be related.
$feed_count = db_query_range('SELECT COUNT(*) FROM {node} n WHERE n.promote = 1 AND n.status = 1', 0, config('system.rss-publishing')->get('feed_default_items'))->fetchField();
$feed_count = db_query_range('SELECT COUNT(*) FROM {node} n WHERE n.promote = 1 AND n.status = 1', 0, config('system.rss')->get('items.limit'))->fetchField();
return $feed_count > 10 ? 10 : $feed_count;
}
......
......@@ -2446,6 +2446,7 @@ function node_block_list_alter(&$blocks) {
function node_feed($nids = FALSE, $channel = array()) {
global $base_url;
$language_content = drupal_container()->get(LANGUAGE_TYPE_CONTENT);
$rss_config = config('system.rss');
if ($nids === FALSE) {
$nids = db_select('node', 'n')
......@@ -2453,13 +2454,13 @@ function node_feed($nids = FALSE, $channel = array()) {
->condition('n.promote', 1)
->condition('n.status', 1)
->orderBy('n.created', 'DESC')
->range(0, config('system.rss-publishing')->get('feed_default_items'))
->range(0, $rss_config->get('items.limit'))
->addTag('node_access')
->execute()
->fetchCol();
}
$item_length = config('system.rss-publishing')->get('feed_item_length');
$item_length = $rss_config->get('items.view_mode');
$namespaces = array('xmlns:dc' => 'http://purl.org/dc/elements/1.1/');
$teaser = ($item_length == 'teaser');
......@@ -2499,7 +2500,7 @@ function node_feed($nids = FALSE, $channel = array()) {
'version' => '2.0',
'title' => config('system.site')->get('name'),
'link' => $base_url,
'description' => config('system.rss-publishing')->get('feed_description'),
'description' => $rss_config->get('channel.description'),
'language' => $language_content->langcode
);
$channel_extras = array_diff_key($channel, $channel_defaults);
......
feed_description: ''
feed_default_items: '10'
feed_item_length: fulltext
......@@ -1882,47 +1882,48 @@ function system_image_toolkit_settings() {
* Form builder; Configure how the site handles RSS feeds.
*
* @ingroup forms
* @see system_settings_form()
*/
function system_rss_feeds_settings($form, &$form_state) {
$rss_config = config('system.rss');
$form['feed_description'] = array(
'#type' => 'textarea',
'#title' => t('Feed description'),
'#default_value' => config('system.rss-publishing')->get('feed_description'),
'#default_value' => $rss_config->get('channel.description'),
'#description' => t('Description of your site, included in each feed.')
);
$form['feed_default_items'] = array(
'#type' => 'select',
'#title' => t('Number of items in each feed'),
'#default_value' => config('system.rss-publishing')->get('feed_default_items'),
'#default_value' => $rss_config->get('items.limit'),
'#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),
'#description' => t('Default number of items to include in each feed.')
);
$form['feed_item_length'] = array(
'#type' => 'select',
'#title' => t('Feed content'),
'#default_value' => config('system.rss-publishing')->get('feed_item_length'),
'#options' => array('title' => t('Titles only'), 'teaser' => t('Titles plus teaser'), 'fulltext' => t('Full text')),
'#default_value' => $rss_config->get('items.view_mode'),
'#options' => array(
'title' => t('Titles only'),
'teaser' => t('Titles plus teaser'),
'fulltext' => t('Full text'),
),
'#description' => t('Global setting for the default display of content items in each feed.')
);
$form['submit'] = array('#type' => 'submit', '#value' => t('Submit'));
return $form;
return system_config_form($form, $form_state);
}
/**
* Form builder submit handler; Handle submission for RSS feeds settings.
*
* @ingroup forms
* @see system_settings_form()
*/
function system_rss_feeds_settings_submit($form, &$form_state) {
// Set the RSS publishing parameters.
$config = config('system.rss-publishing');
$config->set('feed_description', $form_state['values']['feed_description']);
$config->set('feed_default_items', $form_state['values']['feed_default_items']);
$config->set('feed_item_length', $form_state['values']['feed_item_length']);
$config->save();
config('system.rss')
->set('channel.description', $form_state['values']['feed_description'])
->set('items.limit', $form_state['values']['feed_default_items'])
->set('items.view_mode', $form_state['values']['feed_item_length'])
->save();
}
/**
......
......@@ -1909,10 +1909,10 @@ function system_update_8009() {
* @ingroup config_upgrade
*/
function system_update_8010() {
update_variables_to_config('system.rss-publishing', array(
'feed_description' => 'feed_description',
'feed_default_items' => 'feed_default_items',
'feed_item_length' => 'feed_item_length',
update_variables_to_config('system.rss', array(
'feed_description' => 'channel.description',
'feed_default_items' => 'items.limit',
'feed_item_length' => 'items.view_mode',
));
}
......
......@@ -73,7 +73,7 @@ function taxonomy_term_feed(Term $term) {
// Only display the description if we have a single term, to avoid clutter and confusion.
// HTML will be removed from feed description.
$channel['description'] = check_markup($term->description, $term->format, '', TRUE);
$nids = taxonomy_select_nodes($term->tid, FALSE, config('system.rss-publishing')->get('feed_default_items'));
$nids = taxonomy_select_nodes($term->tid, FALSE, config('system.rss')->get('items.limit'));
node_feed($nids, $channel);
}
......
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