You are here

public function FeedsExBase::configForm in Feeds extensible parsers 7

Same name and namespace in other branches
  1. 7.2 src/FeedsExBase.inc \FeedsExBase::configForm()
2 calls to FeedsExBase::configForm()
FeedsExBase::sourceForm in src/FeedsExBase.inc
FeedsExXml::configForm in src/FeedsExXml.inc
1 method overrides FeedsExBase::configForm()
FeedsExXml::configForm in src/FeedsExXml.inc

File

src/FeedsExBase.inc, line 427
Contains FeedsExBase.

Class

FeedsExBase
The Feeds extensible parser.

Code

public function configForm(&$form_state) {
  $form = array(
    '#tree' => TRUE,
    '#theme' => 'feeds_ex_configuration_table',
    '#prefix' => '<div id="feeds-ex-configuration-wrapper">',
    '#suffix' => '</div>',
  );
  if ($this
    ->hasConfigurableContext()) {
    $form['context']['name'] = array(
      '#type' => 'markup',
      '#markup' => t('Context'),
    );
    $form['context']['value'] = array(
      '#type' => 'textfield',
      '#title' => t('Context value'),
      '#title_display' => 'invisible',
      '#default_value' => $this->config['context']['value'],
      '#size' => 50,
      '#required' => TRUE,
      // We're hiding the title, so add a little hint.
      '#description' => '<span class="form-required">*</span>',
      '#attributes' => array(
        'class' => array(
          'feeds-ex-context-value',
        ),
      ),
      '#maxlength' => 1024,
    );
  }
  $form['sources'] = array(
    '#id' => 'feeds-ex-source-table',
  );
  $max_weight = 0;
  foreach ($this->config['sources'] as $machine_name => $source) {
    $form['sources'][$machine_name]['name'] = array(
      '#type' => 'textfield',
      '#title' => t('Name'),
      '#title_display' => 'invisible',
      '#default_value' => $source['name'],
      '#size' => 20,
    );
    $form['sources'][$machine_name]['machine_name'] = array(
      '#title' => t('Machine name'),
      '#title_display' => 'invisible',
      '#markup' => $machine_name,
    );
    $form['sources'][$machine_name]['value'] = array(
      '#type' => 'textfield',
      '#title' => t('Value'),
      '#title_display' => 'invisible',
      '#default_value' => $source['value'],
      '#size' => 50,
      '#maxlength' => 1024,
    );
    foreach ($this
      ->configFormTableHeader() as $column => $name) {
      $form['sources'][$machine_name][$column] = $this
        ->configFormTableColumn($form_state, $source, $column, $machine_name);
    }
    $form['sources'][$machine_name]['debug'] = array(
      '#type' => 'checkbox',
      '#title' => t('Debug'),
      '#title_display' => 'invisible',
      '#default_value' => $source['debug'],
    );
    $form['sources'][$machine_name]['remove'] = array(
      '#type' => 'checkbox',
      '#title' => t('Remove'),
      '#title_display' => 'invisible',
    );
    $form['sources'][$machine_name]['weight'] = array(
      '#type' => 'textfield',
      '#default_value' => $source['weight'],
      '#size' => 3,
      '#attributes' => array(
        'class' => array(
          'feeds-ex-source-weight',
        ),
      ),
    );
    $max_weight = $source['weight'];
  }
  $form['add']['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Add new source'),
    '#id' => 'edit-sources-add-name',
    '#description' => t('Name'),
    '#size' => 20,
  );
  $form['add']['machine_name'] = array(
    '#title' => t('Machine name'),
    '#title_display' => 'invisible',
    '#type' => 'machine_name',
    '#machine_name' => array(
      'exists' => 'feeds_ex_source_exists',
      'source' => array(
        'add',
        'name',
      ),
      'standalone' => TRUE,
      'label' => '',
    ),
    '#field_prefix' => '<span dir="ltr">',
    '#field_suffix' => '</span>&lrm;',
    '#feeds_importer' => $this->id,
    '#required' => FALSE,
    '#maxlength' => 32,
    '#size' => 15,
    '#description' => t('A unique machine-readable name containing letters, numbers, and underscores.'),
  );
  $form['add']['value'] = array(
    '#type' => 'textfield',
    '#description' => t('Value'),
    '#title' => '&nbsp;',
    '#size' => 50,
    '#maxlength' => 1024,
  );
  foreach ($this
    ->configFormTableHeader() as $column => $name) {
    $form['add'][$column] = $this
      ->configFormTableColumn($form_state, array(), $column, '');
  }
  $form['add']['debug'] = array(
    '#type' => 'checkbox',
    '#title' => t('Debug'),
    '#title_display' => 'invisible',
  );
  $form['add']['weight'] = array(
    '#type' => 'textfield',
    '#default_value' => ++$max_weight,
    '#size' => 3,
    '#attributes' => array(
      'class' => array(
        'feeds-ex-source-weight',
      ),
    ),
  );
  $form['display_errors'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display errors'),
    '#description' => t('Display all error messages after parsing. Fatal errors will always be displayed.'),
    '#default_value' => $this->config['display_errors'],
  );
  $form['debug_mode'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable debug mode'),
    '#description' => t('Displays the configuration form on the feed source page to ease figuring out the expressions. Any values entered on that page will be saved here.'),
    '#default_value' => $this->config['debug_mode'],
  );
  $form = $this
    ->getEncoder()
    ->configForm($form, $form_state);
  $form['#attached']['drupal_add_tabledrag'][] = array(
    'feeds-ex-source-table',
    'order',
    'sibling',
    'feeds-ex-source-weight',
  );
  $form['#attached']['css'][] = drupal_get_path('module', 'feeds_ex') . '/feeds_ex.css';
  $form['#header'] = $this
    ->getFormHeader();
  return $form;
}