public function FeedsExcelParser::sourceForm in Feeds XLS 7
Source form.
Show mapping configuration as a guidance for import form users.
File
- ./
FeedsExcelParser.inc, line 271
Class
- FeedsExcelParser
- Parses a given file as a Excel file. This is heavily inspired by Feeds very own CSV parser.
Code
public function sourceForm($source_config) {
$form = $sources = $uniques = array();
$form['#weight'] = -10;
$mappings = feeds_importer($this->id)->processor->config['mappings'];
foreach ($mappings as $mapping) {
$sources[] = check_plain($mapping['source']);
if (!empty($mapping['unique'])) {
$uniques[] = check_plain($mapping['source']);
}
}
if (substr($this->id, 0, 5) == 'file_') {
$empty_template_text = '';
}
else {
$empty_template_text = t('<a href="!url" target="_blank" class="overlay-exclude">Excel template file</a> for this import. Your template file should contain the following column headers:', array(
'!url' => url('import/' . $this->id . '/xlstemplate'),
)) . '<br/><span style="font-size:80%">' . implode(", ", $sources) . '</span>';
}
$form['help'] = array(
'#type' => 'fieldset',
'#title' => t('Template'),
'text' => array(
'#markup' => '<div class="help"><p>' . $empty_template_text . '</p><p>' . t('<a href="!popurl" target="_blank" class="overlay-exclude">Excel template file</a> for updating data already present on your site. <span class="error">Please ensure all data from your site is present in your downloaded file.</span></p>', array(
'!popurl' => url('import/' . $this->id . '/populated-template'),
)) . '</div>',
),
);
$form['all_worksheets'] = array(
'#prefix' => '<div style="display:none">',
'#suffix' => '</div>',
'#type' => 'checkbox',
'#title' => t('All worksheets'),
'#description' => t('Check this box if you would like to import data from all worksheets, and not just the first sheet.'),
'#default_value' => $this->config['all_worksheets'],
);
$form['chunk_size'] = array(
'#type' => 'hidden',
'#value' => $this->config['chunk_size'],
);
$form['use_chunk_reader'] = array(
'#type' => 'hidden',
'#value' => $this->config['use_chunk_reader'],
);
$form['max_rows'] = array(
'#type' => 'select',
'#title' => t('Maximum number of rows'),
'#description' => t('Select the maximum number of rows your Excel file contains. This number MUST be greater than the total number of rows in your file. Selecting this value will improve the progress bar feedback.'),
'#default_value' => 65535,
'#options' => array(
100 => 100,
1000 => 1000,
5000 => 5000,
10000 => 10000,
20000 => 20000,
30000 => 30000,
40000 => 40000,
50000 => 50000,
65535 => t('65535 XLS Maximum'),
1000000000000 => t('Unlimited. NO PROGRESS FEEDBACK'),
),
);
return $form;
}