diff --git a/core/modules/aggregator/aggregator.pages.inc b/core/modules/aggregator/aggregator.pages.inc index ebb561b..5a55a44 100644 --- a/core/modules/aggregator/aggregator.pages.inc +++ b/core/modules/aggregator/aggregator.pages.inc @@ -404,12 +404,12 @@ function aggregator_page_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, variable_get('feed_default_items', 10), 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, config('system.rss-publishing')->get('feed_default_items'), 10), 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, variable_get('feed_default_items', 10)); + $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')); } $feeds = $result->fetchAll(); @@ -435,7 +435,7 @@ function theme_aggregator_page_rss($variables) { drupal_add_http_header('Content-Type', 'application/rss+xml; charset=utf-8'); $items = ''; - $feed_length = variable_get('feed_item_length', 'fulltext'); + $feed_length = config('system.rss-publishing')->get('feed_item_length'); foreach ($feeds as $feed) { switch ($feed_length) { case 'teaser': diff --git a/core/modules/aggregator/aggregator.test b/core/modules/aggregator/aggregator.test index 2149bed..d59a6d4 100644 --- a/core/modules/aggregator/aggregator.test +++ b/core/modules/aggregator/aggregator.test @@ -81,7 +81,7 @@ class AggregatorTestCase extends DrupalWebTestCase { */ 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, variable_get('feed_default_items', 10))->fetchField(); + $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(); return $feed_count > 10 ? 10 : $feed_count; } @@ -895,7 +895,9 @@ class AggregatorRenderingTestCase extends AggregatorTestCase { public function testFeedPage() { // Increase the number of items published in the rss.xml feed so we have // enough articles to test paging. - variable_set('feed_default_items', 30); + config('system.rss-publishing') + ->set('feed_default_items', 30) + ->save(); // Create a feed with 30 items. $this->createSampleNodes(30); @@ -908,7 +910,9 @@ class AggregatorRenderingTestCase extends AggregatorTestCase { $this->assertTrue(!empty($elements), t('Individual source page contains a pager.')); // Reset the number of items in rss.xml to the default value. - variable_set('feed_default_items', 10); + config('system.rss-publishing') + ->set('feed_default_items', 10) + ->save(); } } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index be60e48..f56b94c 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -2598,13 +2598,13 @@ function node_feed($nids = FALSE, $channel = array()) { ->condition('n.promote', 1) ->condition('n.status', 1) ->orderBy('n.created', 'DESC') - ->range(0, variable_get('feed_default_items', 10)) + ->range(0, config('system.rss-publishing')->get('feed_default_items')) ->addTag('node_access') ->execute() ->fetchCol(); } - $item_length = variable_get('feed_item_length', 'fulltext'); + $item_length = config('system.rss-publishing')->get('feed_item_length'); $namespaces = array('xmlns:dc' => 'http://purl.org/dc/elements/1.1/'); $teaser = ($item_length == 'teaser'); @@ -2644,7 +2644,7 @@ function node_feed($nids = FALSE, $channel = array()) { 'version' => '2.0', 'title' => variable_get('site_name', 'Drupal'), 'link' => $base_url, - 'description' => variable_get('feed_description', ''), + 'description' => config('system.rss-publishing')->get('feed_description'), 'language' => $language_content->langcode ); $channel_extras = array_diff_key($channel, $channel_defaults); diff --git a/core/modules/system/config/system.rss-publishing.xml b/core/modules/system/config/system.rss-publishing.xml new file mode 100644 index 0000000..f9a78a8 --- /dev/null +++ b/core/modules/system/config/system.rss-publishing.xml @@ -0,0 +1,6 @@ + + + + 10 + fulltext + diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 978b0f4..b95a6a1 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -1866,29 +1866,49 @@ function system_image_toolkit_settings() { * @ingroup forms * @see system_settings_form() */ -function system_rss_feeds_settings() { +function system_rss_feeds_settings($form, &$form_state) { $form['feed_description'] = array( '#type' => 'textarea', '#title' => t('Feed description'), - '#default_value' => variable_get('feed_description', ''), + '#default_value' => config('system.rss-publishing')->get('feed_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' => variable_get('feed_default_items', 10), + '#default_value' => config('system.rss-publishing')->get('feed_default_items'), '#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' => variable_get('feed_item_length', 'fulltext'), + '#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')), '#description' => t('Global setting for the default display of content items in each feed.') ); + $form['submit'] = array('#type' => 'submit', '#value' => t('Submit')); - return system_settings_form($form); + return $form; +} + +/** + * 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('system.rss-publishing') + ->set('feed_description', $form_state['values']['feed_description']) + ->save(); + config('system.rss-publishing') + ->set('feed_default_items', $form_state['values']['feed_default_items']) + ->save(); + config('system.rss-publishing') + ->set('feed_item_length', $form_state['values']['feed_item_length']) + ->save(); } /** diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 905d11d..01a14aa 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -1761,6 +1761,26 @@ function system_update_8005() { db_drop_field('session', 'cache'); } + /** + * Moves system settings from variable to config. + */ +function system_update_8006() { + $var_names = array_keys(config('system.rss-publishing')->get()); + if (!empty($var_names)) { + $query = db_select('variable', 'v') + ->fields('v') + ->condition('name', $var_names, 'IN'); + $del = db_delete('variable')->condition('name', $var_names, 'IN'); + $var_values = $query->execute()->fetchAllKeyed(0); + $del->execute(); + $config = config('system.rss-publishing'); + foreach($var_values as $name => $val) { + $config->set($name, $val); + } + $config->save(); + } +} + /** * @} End of "defgroup updates-7.x-to-8.x" * The next series of updates should start at 9000. diff --git a/core/modules/taxonomy/taxonomy.pages.inc b/core/modules/taxonomy/taxonomy.pages.inc index 6994b6e..acfcbf0 100644 --- a/core/modules/taxonomy/taxonomy.pages.inc +++ b/core/modules/taxonomy/taxonomy.pages.inc @@ -71,7 +71,7 @@ function taxonomy_term_feed($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, variable_get('feed_default_items', 10)); + $nids = taxonomy_select_nodes($term->tid, FALSE, config('system.rss-publishing')->get('feed_default_items')); node_feed($nids, $channel); }