You are here

function feed_import_add_new_feed_form in Feed Import 7.2

Same name and namespace in other branches
  1. 7 feed_import.module \feed_import_add_new_feed_form()

Add a new feed form

1 string reference to 'feed_import_add_new_feed_form'
feed_import_menu in ./feed_import.module
Implements hook_menu().

File

./feed_import.module, line 835
User interface, cron functions for feed_import module

Code

function feed_import_add_new_feed_form($form, &$form_state) {
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Feed name'),
    '#description' => t('This usually is source name.'),
    '#required' => TRUE,
  );
  $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!'),
    '#required' => TRUE,
    '#machine_name' => array(
      'source' => array(
        'name',
      ),
      'exists' => 'feed_import_machine_name_exists',
    ),
  );
  $entities = FeedImport::getEntityInfo();
  $options = array();
  foreach ($entities as &$entity) {
    $options[$entity['name']] = $entity['name'];
  }
  $form['entity'] = array(
    '#type' => 'select',
    '#options' => $options,
    '#default_value' => 'node',
    '#title' => t('Entity name'),
    '#description' => t('Entity where you want to import content. Ex: node, user, ...'),
    '#required' => TRUE,
  );
  $form['url'] = array(
    '#type' => 'textfield',
    '#title' => t('URL to feed'),
    '#description' => t('Please use a valid url that returns valid content!'),
    '#required' => TRUE,
  );
  $options = array();
  $functions = array_keys(FeedImport::processFunctions());
  foreach ($functions as $f) {
    $options[$f] = $f;
  }
  $form['process_function'] = array(
    '#type' => 'select',
    '#options' => $options,
    '#title' => t('Select feed processing function'),
    '#description' => t('Read help for more information about processing functions'),
  );
  $form['time'] = array(
    '#type' => 'textfield',
    '#title' => t('Keep imported items (seconds)'),
    '#description' => t('This is used to delete items after expiration.'),
    '#default_value' => 0,
    '#required' => TRUE,
  );
  $form['enabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Import at cron'),
    '#default_value' => 0,
    '#description' => t('Check this if you want to import feed items when cron runs.'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Add feed'),
  );
  return $form;
}