Skip to content
Snippets Groups Projects
Commit edb23846 authored by Chris Leppanen's avatar Chris Leppanen
Browse files

Issue #2305919 by twistor: Fixed Return 404 when trying to edit a non-existent feed.

parent 7600c42d
No related branches found
No related tags found
No related merge requests found
......@@ -281,7 +281,7 @@ function feeds_menu() {
'access callback' => 'feeds_page_access',
'file' => 'feeds.pages.inc',
);
$items['import/%'] = array(
$items['import/%feeds_importer'] = array(
'title callback' => 'feeds_importer_title',
'title arguments' => array(1),
'page callback' => 'drupal_get_form',
......@@ -290,12 +290,12 @@ function feeds_menu() {
'access arguments' => array('import', 1),
'file' => 'feeds.pages.inc',
);
$items['import/%/import'] = array(
$items['import/%feeds_importer/import'] = array(
'title' => 'Import',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
$items['import/%/delete-items'] = array(
$items['import/%feeds_importer/delete-items'] = array(
'title' => 'Delete items',
'page callback' => 'drupal_get_form',
'page arguments' => array('feeds_delete_tab_form', 1),
......@@ -304,7 +304,7 @@ function feeds_menu() {
'file' => 'feeds.pages.inc',
'type' => MENU_LOCAL_TASK,
);
$items['import/%/unlock'] = array(
$items['import/%feeds_importer/unlock'] = array(
'title' => 'Unlock',
'page callback' => 'drupal_get_form',
'page arguments' => array('feeds_unlock_tab_form', 1),
......@@ -313,7 +313,7 @@ function feeds_menu() {
'file' => 'feeds.pages.inc',
'type' => MENU_LOCAL_TASK,
);
$items['import/%/template'] = array(
$items['import/%feeds_importer/template'] = array(
'page callback' => 'feeds_importer_template',
'page arguments' => array(1),
'access callback' => 'feeds_access',
......@@ -377,14 +377,18 @@ function feeds_admin_paths() {
* Menu loader callback.
*/
function feeds_importer_load($id) {
return feeds_importer($id);
try {
return feeds_importer($id)->existing();
}
catch (FeedsNotExistingException $e) {
return FALSE;
}
}
/**
* Title callback.
*/
function feeds_importer_title($id) {
$importer = feeds_importer($id);
function feeds_importer_title(FeedsImporter $importer) {
return $importer->config['name'];
}
......@@ -426,9 +430,13 @@ function feeds_access($action, $param) {
return FALSE;
}
$importer_id = FALSE;
if (is_string($param)) {
$importer_id = $param;
}
elseif ($param instanceof FeedsImporter) {
$importer_id = $param->id;
}
elseif ($param->type) {
$importer_id = feeds_get_importer_id($param->type);
}
......
......@@ -63,11 +63,10 @@ function feeds_page() {
/**
* Render a feeds import form on import/[config] pages.
*/
function feeds_import_form($form, &$form_state, $importer_id) {
$source = feeds_source($importer_id, empty($form['nid']['#value']) ? 0 : $form['nid']['#value']);
function feeds_import_form(array $form, array &$form_state, FeedsImporter $importer) {
$source = feeds_source($importer->id);
$form = array();
$form['#importer_id'] = $importer_id;
$form['#importer_id'] = $importer->id;
// @todo Move this into fetcher?
$form['#attributes']['enctype'] = 'multipart/form-data';
$form['source_status'] = array(
......@@ -169,9 +168,9 @@ function feeds_import_tab_form_submit($form, &$form_state) {
* Used on both node pages and configuration pages.
* Therefore $node may be missing.
*/
function feeds_delete_tab_form($form, &$form_state, $importer_id, $node = NULL) {
function feeds_delete_tab_form(array $form, array &$form_state, FeedsImporter $importer = NULL, $node = NULL) {
if (empty($node)) {
$source = feeds_source($importer_id);
$source = feeds_source($importer->id);
$form['#redirect'] = 'import/' . $source->id;
}
else {
......@@ -213,9 +212,9 @@ function feeds_delete_tab_form_submit($form, &$form_state) {
* Used on both node pages and configuration pages.
* Therefore $node may be missing.
*/
function feeds_unlock_tab_form($form, &$form_state, $importer_id, $node = NULL) {
function feeds_unlock_tab_form($form, &$form_state, FeedsImporter $importer = NULL, $node = NULL) {
if (empty($node)) {
$source = feeds_source($importer_id);
$source = feeds_source($importer->id);
$form['#redirect'] = 'import/' . $source->id;
}
else {
......@@ -284,8 +283,7 @@ function feeds_fetcher_callback($importer, $feed_nid = 0) {
/**
* Template generation
*/
function feeds_importer_template($importer_id) {
$importer = feeds_importer($importer_id);
function feeds_importer_template(FeedsImporter $importer) {
if ($importer->parser instanceof FeedsCSVParser) {
return $importer->parser->getTemplate();
}
......
......@@ -273,10 +273,10 @@ function feeds_ui_export_form($form, &$form_state, $importer) {
/**
* Edit feed configuration.
*/
function feeds_ui_edit_page($importer, $active = 'help', $plugin_key = '') {
function feeds_ui_edit_page(FeedsImporter $importer, $active = 'help', $plugin_key = '') {
// Get plugins and configuration.
$plugins = FeedsPlugin::all();
$config = $importer->config;
// Base path for changing the active container.
$path = 'admin/structure/feeds/' . $importer->id;
......@@ -291,12 +291,14 @@ function feeds_ui_edit_page($importer, $active = 'help', $plugin_key = '') {
$active_container['body'] = '<div class="help feeds-admin-ui">' . feeds_ui_edit_help() . '</div>';
unset($active_container['actions']);
break;
case 'fetcher':
case 'parser':
case 'processor':
$active_container['title'] = t('Select a !plugin_type', array('!plugin_type' => $active));
$active_container['body'] = drupal_get_form('feeds_ui_plugin_form', $importer, $active);
break;
case 'settings':
drupal_add_js(drupal_get_path('module', 'ctools') . '/js/dependent.js');
ctools_include('dependent');
......@@ -311,6 +313,7 @@ function feeds_ui_edit_page($importer, $active = 'help', $plugin_key = '') {
$active_container['body'] = feeds_get_form($plugin, 'configForm');
}
break;
case 'mapping':
$active_container['title'] = t('Mapping for !processor', array('!processor' => $plugins[$config['processor']['plugin_key']]['name']));
$active_container['body'] = drupal_get_form('feeds_ui_mapping_form', $importer);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment