You are here

function feed_import_add_new_feed_form in Feed Import 7

Same name and namespace in other branches
  1. 7.2 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 620
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,
  );
  $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"'),
    '#required' => TRUE,
  );
  $form['url'] = array(
    '#type' => 'textfield',
    '#title' => t('URL to XML feed'),
    '#description' => t('Please use a valid url that returns a valid xml file!'),
    '#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('Feed is active'),
    '#default_value' => 0,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Add feeed'),
  );
  return $form;
}