You are here

public function FeedsExcelParser::getSourceElement in Feeds Excel 7

Same name and namespace in other branches
  1. 6 ExcelParser.inc \FeedsExcelParser::getSourceElement()

Return the token replaced value for the given element.

File

./ExcelParser.inc, line 320

Class

FeedsExcelParser
Parses a given file as a Excel file.

Code

public function getSourceElement(FeedsSource $source, FeedsParserResult $result, $element_key) {

  // excel file
  $types['excel-file'] = (object) array(
    'filepath' => $this->filepath,
  );

  // excel sheet
  $item = (object) $result
    ->currentItem();
  $data['excel-sheet'] = (object) $this
    ->getSheet($item->meta['sheet_id']);

  // excel row or column
  switch ($this->config['mapping_mode']) {
    case 'rows':
      $data['excel-row'] = $item;
      break;
    case 'columns':
      $data['excel-column'] = $item;
      break;
  }

  // global
  $data['site'] = '';

  // parent node
  if ($source->feed_nid) {
    $node = node_load($source->feed_nid);
    $data['node'] = $node;
  }
  $value = token_replace($element_key, $data, array(
    'clear' => FALSE,
  ));

  // For debug clear is set to FALSE;
  return $value;
}