function feed_import_edit_feed_form in Feed Import 7.3
Same name and namespace in other branches
- 7 feed_import.module \feed_import_edit_feed_form()
- 7.2 feed_import.module \feed_import_edit_feed_form()
Edit feed form
1 string reference to 'feed_import_edit_feed_form'
- feed_import_menu in ./
feed_import.module - Implements hook_menu().
File
- ./
feed_import.module, line 1002 - User interface, cron functions for feed_import module
Code
function feed_import_edit_feed_form($form, &$form_state, $feed = FALSE) {
if ($feed) {
drupal_set_title(t('Edit feed - @name', array(
'@name' => $feed->name,
)));
}
else {
drupal_set_title(t('Add new feed'));
}
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Feed name'),
'#maxlength' => 64,
'#description' => t('This usually is source name.'),
'#default_value' => $feed ? $feed->name : NULL,
'#required' => TRUE,
);
if ($feed) {
$form['machine_name'] = array(
'#type' => 'value',
'#value' => $feed->machine_name,
);
}
else {
$form['machine_name'] = array(
'#type' => 'machine_name',
'#title' => t('Feed machine name'),
'#description' => t('This must be unique for each feed and must be not numeric.') . '<br />' . t('Once saved this can not be changed!'),
'#maxlength' => 64,
'#required' => TRUE,
'#machine_name' => array(
'source' => array(
'name',
),
'exists' => 'feed_import_machine_name_exists',
),
);
}
$form['entity'] = array(
'#type' => 'select',
'#options' => FeedImport::getAllEntities(),
'#default_value' => 'node',
'#title' => t('Entity name'),
'#description' => t('Entity where you want to import content. Ex: node, user, ...'),
'#maxlength' => 64,
'#required' => TRUE,
);
if ($feed) {
$form['entity']['#default_value'] = $feed->entity;
$form['entity']['#disabled'] = !empty($feed->settings['fields']);
$form['cron_import'] = array(
'#type' => 'checkbox',
'#title' => t('Import at cron'),
'#default_value' => $feed->cron_import,
'#description' => t('Check this if you want to import feed items when cron runs.'),
);
$form['feed'] = array(
'#type' => 'fieldset',
'#tree' => TRUE,
'#title' => t('Delete protection'),
'#description' => t('Reschedule items if one of the below conditions is met.') . ' ' . t('This is useful for cron imported items.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['feed']['protect_on_invalid_source'] = array(
'#type' => 'checkbox',
'#title' => t('Source file or network is unavailable'),
'#default_value' => $feed->settings['feed']['protect_on_invalid_source'],
);
$form['feed']['protect_on_fewer_items'] = array(
'#type' => 'textfield',
'#title' => t('Total number of items is less than'),
'#default_value' => $feed->settings['feed']['protect_on_fewer_items'],
'#description' => t('You can also use a percentage by appending %. Percentage is reported to items count of last import.') . ' ' . t('Use 0 to ignore this setting.'),
);
$form['preprocess'] = array(
'#type' => 'textfield',
'#title' => t('Pre-process callback'),
'#description' => t('You can use a pre-process function before the feed is imported in order to make some changes to configuration.'),
'#default_value' => isset($feed->settings['preprocess']) ? $feed->settings['preprocess'] : '',
);
}
else {
$form['cron_import'] = array(
'#type' => 'value',
'#value' => FALSE,
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save feed'),
);
return $form;
}