public function FeedsExcelParser::getSourceElement in Feeds Excel 6
Same name and namespace in other branches
- 7 ExcelParser.inc \FeedsExcelParser::getSourceElement()
Return the token replaced value for the given element.
Overrides FeedsParser::getSourceElement
File
- ./
ExcelParser.inc, line 230
Class
- FeedsExcelParser
- Parses a given file as a Excel file.
Code
public function getSourceElement(FeedsImportBatch $batch, $element_key) {
// excel file
$types['excel_file'] = (object) array(
'filepath' => $batch
->getFilePath(),
);
// excel sheet
$item = (object) $batch
->currentItem();
$types['excel_sheet'] = $batch->sheets[$item->meta['sheet_id']];
// excel row or column
switch ($this->config['mapping_mode']) {
case 'rows':
$types['excel_row'] = $item;
break;
case 'columns':
$types['excel_column'] = $item;
break;
}
// global
$types['global'] = '';
$value = token_replace_multiple($element_key, $types);
// parent node
if ($node = $batch
->feedNode()) {
$value = token_replace($value, 'node', $node, '[parent:', ']');
}
// Cleanup tokens of empty cells
$patterns = array(
'@\\[sheet-cell-[0-9]+-[0-9]+(-raw)?\\]@is',
'@\\[(column|row|x|y)-[0-9]+(-raw)?\\]@is',
);
$value = preg_replace($patterns, '', $value);
return $value;
}