You are here

public function FeedsExcelParser::configForm in Feeds Excel 6

Same name and namespace in other branches
  1. 7.2 FeedsExcelParser.inc \FeedsExcelParser::configForm()
  2. 7 ExcelParser.inc \FeedsExcelParser::configForm()

Build configuration form.

Overrides FeedsConfigurable::configForm

File

./ExcelParser.inc, line 282

Class

FeedsExcelParser
Parses a given file as a Excel file.

Code

public function configForm(&$form_state) {
  $form = array();
  $form['mapping_mode'] = array(
    '#type' => 'select',
    '#title' => t('Mapping mode'),
    '#description' => t('Whether to map rows or columns.'),
    '#options' => array(
      'rows' => t('Rows'),
      'columns' => t('Columns'),
    ),
    '#default_value' => $this->config['mapping_mode'],
  );
  $form['sheets'] = array(
    '#type' => 'textfield',
    '#title' => t('Sheets'),
    '#default_value' => $this->config['sheets'],
    '#description' => t('Enter the sheet names or IDs that shall be imported. Leaving empty means that all sheets are processed. Use <code>,</code> to separate different sheets. Use <code>:</code> to mark a range of IDs (e.g. <code>0:15</code>).'),
  );

  // Format string for range format.
  $format_single_1 = '<code>' . EXCELRANGE_ROW . '1' . EXCELRANGE_COL . '2</code>';
  $format_single_2 = '<code>B1</code>';
  $format_range_1 = '<code>' . EXCELRANGE_ROW . '1' . EXCELRANGE_COL . '2:' . EXCELRANGE_ROW . '5' . EXCELRANGE_COL . '4</code>';
  $format_range_2 = '<code>B1:D5</code>';
  $format_columns = '<code>B:D</code>';
  $format_rows = '<code>1:5</code>';
  $format = t('You can use different range formats: !formats <br/> Use !sep to separate multiple range entries.', array(
    '!sep' => '<code>' . EXCELRANGE_SEP . '</code>',
    '!formats' => "{$format_single_1}, {$format_single_2}, {$format_range_1}, {$format_range_2}, {$format_columns}, {$format_rows}",
  ));
  $form['fixed'] = array(
    '#type' => 'textfield',
    '#title' => t('Fixed Range'),
    '#description' => t('Range of the sheet, that can be referenced from any item.<br/>!format', array(
      '!format' => $format,
    )),
    '#default_value' => $this->config['fixed'],
  );
  $form['iterative'] = array(
    '#type' => 'textfield',
    '#title' => t('Iterative range'),
    '#description' => t('Enter a range that feeds should run through for iterative mapping to process items.<br/>!format', array(
      '!format' => $format,
    )),
    '#required' => TRUE,
    '#default_value' => $this->config['iterative'],
  );
  $form['header'] = array(
    '#type' => 'textfield',
    '#title' => t('Header range'),
    '#description' => t('Enter the range that can be used as row or column aliases for a given iterative range.<br/>!format', array(
      '!format' => $format,
    )),
    '#default_value' => $this->config['header'],
    '#disabled' => TRUE,
    '#prefix' => '<span class="error">Currently disabled option:</span>',
  );
  return $form;
}