You are here

function feeds_excel_token_values in Feeds Excel 6

Implementation of hook_token_values().

File

./feeds_excel.module, line 135

Code

function feeds_excel_token_values($type, $object = NULL) {
  $values = array();
  switch ($type) {
    case 'excel_file':
      $values['excel-filepath'] = check_url($object->filepath);
      $values['excel-fileurl'] = url($object->filepath, array(
        'absolute' => TRUE,
      ));
      break;
    case 'excel_sheet':
      $values['sheet-id'] = check_plain($object->id);
      $values['sheet-name-raw'] = $object->name;
      $values['sheet-name'] = check_plain($object->name);
      if (is_array($object->fixed_cells)) {
        foreach ($object->fixed_cells as $id => $cell) {
          $key = 'sheet-cell-' . $cell['row'] . '-' . $cell['column'];
          $values[$key . '-raw'] = $cell['raw'];
          $values[$key] = $cell['value'];
        }
      }
      break;
    case 'excel_row':
      $values['row'] = $object->row;
      $values['range-id'] = $object->meta['range_id'];
      $values['column-offset'] = $object->meta['range_col_offset'];
      if (is_array($object->cells)) {
        foreach ($object->cells as $cell) {
          $raw = $cell['raw'];
          $formatted = check_plain($cell['value']);
          $values['column-' . $cell['column'] . '-raw'] = $raw;
          $values['column-' . $cell['column']] = $formatted;
          $values['x-' . $cell['x'] . '-raw'] = $raw;
          $values['x-' . $cell['x']] = $formatted;
        }
      }
      break;
    case 'excel_column':
      $values['column'] = $object->column;
      $values['column-alpha'] = ExcelRange::num2alpha($object->column);
      $values['range-id'] = $object->meta['range_id'];
      $values['row-offset'] = $object->meta['range_row_offset'];
      foreach ($object->cells as $cell) {
        $raw = $cell['raw'];
        $formatted = check_plain($cell['value']);
        $values['row-' . $cell['row'] . '-raw'] = $raw;
        $values['row-' . $cell['row']] = $formatted;
        $values['y-' . $cell['y'] . '-raw'] = $raw;
        $values['y-' . $cell['y']] = $formatted;
      }
      break;
  }
  return $values;
}