You are here

function feeds_crawler_admin_form in Feeds Crawler 6.2

Same name and namespace in other branches
  1. 6 feeds_crawler.admin.inc \feeds_crawler_admin_form()
1 string reference to 'feeds_crawler_admin_form'
feeds_crawler_menu in ./feeds_crawler.module
Implementation of hook_menu().

File

./feeds_crawler.admin.inc, line 3

Code

function feeds_crawler_admin_form($form_state) {
  if (variable_get('feeds_source_class', NULL) == 'FeedsSourceCrawler') {
    variable_del('feeds_source_class');
  }
  $form = array();
  $feeds = feeds_enabled_importers();
  $options = array();
  foreach ($feeds as $feed_id) {
    $feed = feeds_importer($feed_id);
    if ($feed->config['content_type'] != '') {
      $query = db_query("SELECT nid, title FROM {node} WHERE type='%s'", $feed->config['content_type']);
      while ($result = db_fetch_object($query)) {
        $options += array(
          $feed_id . '$$$' . $result->nid => $result->title,
        );
      }
    }
    else {
      $options += array(
        $feed_id => $feed_id,
      );
    }
  }
  $form['importer'] = array(
    '#type' => 'select',
    '#title' => t('Importer'),
    '#options' => $options,
    '#default_value' => variable_get('feeds_crawler_importer', 0),
  );
  $form['offest_url'] = array(
    '#type' => 'textfield',
    '#title' => t('Offset URL'),
    '#description' => t('Enter a URL here if you want to start at a page other than the first one.'),
    '#default_value' => variable_get('feeds_crawler_offset_url', ''),
  );
  $form['autodetect'] = array(
    '#type' => 'checkbox',
    '#title' => t('Autodetect'),
    '#description' => t('Feeds Crawler can attempt to autodetect the next link for RSS and ATOM feeds.'),
    '#default_value' => variable_get('feeds_crawler_autodetect', FALSE),
  );
  $form['html'] = array(
    '#type' => 'radios',
    '#title' => t('HTML or XML'),
    '#description' => t('Select whether the content is HTML or XML.'),
    '#options' => array(
      'xml' => 'XML',
      'html' => 'HTML',
    ),
    '#default_value' => variable_get('feeds_crawler_html', 'xml'),
  );
  $form['xpath'] = array(
    '#type' => 'textfield',
    '#title' => t('XPath'),
    '#description' => t('This is the XPath query that points to the \'Next\' button on the pager.'),
    '#default_value' => variable_get('feeds_crawler_xpath', ''),
  );
  $form['count'] = array(
    '#type' => 'textfield',
    '#title' => t('Number of pages'),
    '#required' => TRUE,
    '#description' => t('This is how many pages you would like to crawl.  0 means crawl all of them.'),
    '#default_value' => variable_get('feeds_crawler_count', 10),
  );
  $form['next'] = array(
    '#type' => 'submit',
    '#value' => t('Crawl'),
  );
  return $form;
}