Same name and namespace in other branches
  1. 4.6.x modules/aggregator.module \aggregator_form_feed()
  2. 5.x modules/aggregator/aggregator.module \aggregator_form_feed()
  3. 6.x modules/aggregator/aggregator.admin.inc \aggregator_form_feed()
  4. 7.x modules/aggregator/aggregator.admin.inc \aggregator_form_feed()

Generate a form to add/edit feed sources.

1 string reference to 'aggregator_form_feed'
aggregator_menu in modules/aggregator.module
Implementation of hook_menu().

File

modules/aggregator.module, line 415
Used to aggregate syndicated content (RSS, RDF, and Atom).

Code

function aggregator_form_feed($edit = array()) {
  $period = drupal_map_assoc(array(
    900,
    1800,
    3600,
    7200,
    10800,
    21600,
    32400,
    43200,
    64800,
    86400,
    172800,
    259200,
    604800,
    1209600,
    2419200,
  ), 'format_interval');
  if ($edit['refresh'] == '') {
    $edit['refresh'] = 3600;
  }
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#default_value' => $edit['title'],
    '#maxlength' => 64,
    '#description' => t('The name of the feed; typically the name of the web site you syndicate content from.'),
    '#required' => TRUE,
  );
  $form['url'] = array(
    '#type' => 'textfield',
    '#title' => t('URL'),
    '#default_value' => $edit['url'],
    '#maxlength' => 255,
    '#description' => t('The fully-qualified URL of the feed.'),
    '#required' => TRUE,
  );
  $form['refresh'] = array(
    '#type' => 'select',
    '#title' => t('Update interval'),
    '#default_value' => $edit['refresh'],
    '#options' => $period,
    '#description' => t('The refresh interval indicating how often you want to update this feed. Requires crontab.'),
  );

  // Handling of categories:
  $options = array();
  $values = array();
  $categories = db_query('SELECT c.cid, c.title, f.fid FROM {aggregator_category} c LEFT JOIN {aggregator_category_feed} f ON c.cid = f.cid AND f.fid = %d ORDER BY title', $edit['fid']);
  while ($category = db_fetch_object($categories)) {
    $options[$category->cid] = check_plain($category->title);
    if ($category->fid) {
      $values[] = $category->cid;
    }
  }
  if ($options) {
    $form['category'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Categorize news items'),
      '#default_value' => $values,
      '#options' => $options,
      '#description' => t('New items in this feed will be automatically filed in the checked categories as they are received.'),
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  if ($edit['fid']) {
    $form['delete'] = array(
      '#type' => 'submit',
      '#value' => t('Delete'),
    );
    $form['fid'] = array(
      '#type' => 'hidden',
      '#value' => $edit['fid'],
    );
  }
  return drupal_get_form('aggregator_form_feed', $form);
}