From be951cdcd0fcb26a263bf4190d836f3623be50a4 Mon Sep 17 00:00:00 2001 From: Alex Barth <alex_b@53995.no-reply.drupal.org> Date: Wed, 16 Sep 2009 21:41:30 +0000 Subject: [PATCH] Remove unused code from feeds.module, add delete functionality. --- feeds.module | 79 ++----------------------------------- feeds_ui/feeds_ui.admin.inc | 31 +++++++++++++-- feeds_ui/feeds_ui.module | 8 ++++ 3 files changed, 39 insertions(+), 79 deletions(-) diff --git a/feeds.module b/feeds.module index 1e8169ec..caef6344 100644 --- a/feeds.module +++ b/feeds.module @@ -124,83 +124,10 @@ function feeds_get_feed($id) { } /** - * Create a configuration object. + * Delete a feed. */ -function feeds_create_configuration($id) { - feeds_include('configuration'); -} - -/** - * Get a configuration object for a given id. - */ -function feeds_get_configuration($id) { - feeds_include('configuration'); -} - -/** - * Delete a configuration object. - */ -function feeds_delete_configuration($id) { - -} - -/** - * Attach a configuration to a content type. - */ -function feeds_attach_configuration($id, $content_type) { - -} - -/** - * Detach a configuration from a content type. - */ -function feeds_detach_configuration($content_type) { - -} - -/** - * Create a feed. - */ -function feeds_create_feed($configuration) { - feeds_include('configuration'); - feeds_include('feed'); - $feed = new Feed($configuration); - return $feed; -} - -/** - * Retrieve a feed object that is attached to a feed node. - * @todo. - */ -function feeds_get_feed_node($nid) { - $node = node_load($nid); - $configuration = feeds_get_configuration($node->type, TRUE); -} - -/** - * Fetches, parses and processes a feed. - * - * @return - * TRUE if the feed could be imported completely, - * FALSE if a timeout occurred. - */ -function feeds_import($id, FeedsResource $source, $timeout = NULL) { - $importer = new FeedImporter($id, $source, $timeout); - return $importer->import(); -} - -/** - * Determines whether execution time is up. - */ -function feeds_timeout($timeout = NULL) { - $timeout_time = 0; - if ($timeout) { - $timeout_time = time() + $timeout; - } - if (time() > $timeout_time) { - return FALSE; - } - return TRUE; +function feeds_delete($id) { + db_query('DELETE FROM {feeds_configuration} WHERE id = "%s"', $id); } /** diff --git a/feeds_ui/feeds_ui.admin.inc b/feeds_ui/feeds_ui.admin.inc index 30e7c8c3..bc52632c 100644 --- a/feeds_ui/feeds_ui.admin.inc +++ b/feeds_ui/feeds_ui.admin.inc @@ -85,16 +85,19 @@ function feeds_ui_build_create_form(&$form_state) { function feeds_ui_build_create_form_validate($form, &$form_state) { ctools_include('export'); if (isset($form_state['values']['id'])) { + $feed = feeds_get_feed($form_state['values']['id']); if (ctools_export_load_object('feeds_configuration', 'conditions', array('id' => $form_state['values']['id'], 'class' => 'Feed'))) { form_set_error('id', t('Id is taken.')); } } elseif (isset($form_state['storage']['id'])) { + $feed = feeds_get_feed($form_state['storage']['id']); if (ctools_export_load_object('feeds_configuration', 'conditions', array('id' => $form_state['storage']['id'], 'class' => 'Feed'))) { form_set_error('id', t('Id is taken.')); drupal_goto('admin/build/feeds/create'); } } + $feed->configFormValidate($form, &$form_state); } /** @@ -107,8 +110,7 @@ function feeds_ui_build_create_form_submit($form, &$form_state) { else { // Save feed. $feed = feeds_get_feed($form_state['storage']['id']); - $feed->addConfig($form_state['values']); - $feed->save(); + $feed->configFormSubmit($form, &$form_state); drupal_set_message(t('Created configuration')); // Unset storage to enable redirect. @@ -150,7 +152,7 @@ function feeds_ui_build_edit_form_submit($form, &$form_state) { } /** - * Edit an existing configuration. + * Edit mapping. */ function feeds_ui_build_mapping_form(&$form_state, $feed) { $form = array(); @@ -163,6 +165,8 @@ function feeds_ui_build_mapping_form(&$form_state, $feed) { /** * Edit plugin configuration. + * + * @todo: move plugin form generation into feed class. */ function feeds_ui_build_plugin_form(&$form_state, $feed) { $form = array(); @@ -206,3 +210,24 @@ function feeds_ui_build_plugin_form(&$form_state, $feed) { ); return $form; } + +/** + * Delete form. + */ +function feeds_ui_build_delete_form(&$form_state, $feed) { + $form['#redirect'] = 'admin/build/feeds'; + $form['#feed'] = $feed; + return confirm_form($form, + t('Would you really like to delete the configuration !id?', array('!id' => $feed->getId())), + $form['#redirect'], + t('This action cannot be undone.'), + t('Delete') + ); +} + +/** + * Submit handler for feeds_ui_build_delete_form(). + */ +function feeds_ui_build_delete_form_submit($form, &$form_state) { + feeds_delete($form['#feed']->getId()); +} \ No newline at end of file diff --git a/feeds_ui/feeds_ui.module b/feeds_ui/feeds_ui.module index e3fee1c8..b9bc0072 100644 --- a/feeds_ui/feeds_ui.module +++ b/feeds_ui/feeds_ui.module @@ -80,6 +80,14 @@ function feeds_ui_menu() { 'type' => MENU_LOCAL_TASK, 'weight' => 2, ); + $items['admin/build/feeds/delete/%feeds'] = array( + 'title' => t('Create preset'), + 'page callback' => 'drupal_get_form', + 'page arguments' => array('feeds_ui_build_delete_form', 4), + 'access arguments' => array('administer feeds'), + 'file' => 'feeds_ui.admin.inc', + 'type' => MENU_CALLBACK, + ); return $items; } -- GitLab