function _feeds_excel_token_values__excel_column in Feeds Excel 7
Helper function for rendering token values for excel column tokens.
Parameters
object $object: the exce column object to build the token value for.
string $token_name: the specific token name, like passed to hook_tokens() as $tokens key.
string $original_token: the original complete token, containing type and name, like passed to hook_tokens() as $tokens value.
Return value
string rendered token value for the given token
1 string reference to '_feeds_excel_token_values__excel_column'
- feeds_excel_tokens in ./
feeds_excel.module - Implements hook_tokens().
File
- ./
feeds_excel.module, line 417
Code
function _feeds_excel_token_values__excel_column($object, $token_name, $original_token, $sanitize) {
// Subpattern for preg_match
$subpattern = array();
if ($token_name == 'column') {
return $sanitize ? check_plain($object->column) : $object->column;
}
elseif ($token_name == 'column-alpha') {
return $sanitize ? check_plain(ExcelRange::num2alpha($object->column)) : ExcelRange::num2alpha($object->column);
}
elseif ($token_name == 'range-id') {
return $sanitize ? check_plain($object->meta['range_id']) : $object->meta['range_id'];
}
elseif ($token_name == 'row-offset') {
return $sanitize ? check_plain($object->meta['range_col_offset']) : $object->meta['range_col_offset'];
}
elseif (is_array($object->cells) && preg_match('&^y-([0-9]+)(-formatted)?$&is', $token_name, $subpattern)) {
$y = $subpattern[1];
$formatted = !empty($subpattern[2]);
foreach ($object->cells as $id => $cell) {
// We found the correct cell.
if ($cell['y'] == $y) {
$key = $formatted ? 'value' : 'raw';
return $sanitize ? check_plain($cell[$key]) : $cell[$key];
}
}
return '';
}
elseif (is_array($object->cells) && preg_match('&^row-([0-9]+)(-formatted)?$&is', $token_name, $subpattern)) {
$row = $subpattern[1];
$formatted = !empty($subpattern[2]);
foreach ($object->cells as $id => $cell) {
// We found the correct cell.
if ($cell['row'] == $row) {
$key = $formatted ? 'value' : 'raw';
return $sanitize ? check_plain($cell[$key]) : $cell[$key];
}
}
return '';
}
}