function sheetnode_handler_field_range::render in Sheetnode 7.2
Same name and namespace in other branches
- 6 views/sheetnode_handler_field_range.inc \sheetnode_handler_field_range::render()
- 7 views/sheetnode_handler_field_range.inc \sheetnode_handler_field_range::render()
Render views field.
Overrides views_handler_field::render
File
- views/
sheetnode_handler_field_range.inc, line 58 - Views handler for sheetnode ranges.
Class
- sheetnode_handler_field_range
- Provides a custom sheetnode ranges handler.
Code
function render($values) {
module_load_include('inc', 'sheetnode', 'socialcalc');
$sheet = $values->{$this->field_alias};
if (empty($sheet)) {
return NULL;
}
$sc = socialcalc_parse_sheet($sheet);
// Parse the range reference.
$range = preg_split('/:/', $this->options['reference'], 2);
$start = socialcalc_coord_to_cr($range[0]);
$end = socialcalc_coord_to_cr(isset($range[1]) ? $range[1] : $range[0]);
if (empty($end[0])) {
$end[0] = $sc['attribs']['lastcol'];
}
if (empty($end[1])) {
$end[1] = $sc['attribs']['lastrow'];
}
// Build the range of values.
$range = array();
for ($r = $start[1]; $r <= $end[1]; $r++) {
for ($c = $start[0]; $c <= $end[0]; $c++) {
$coord = socialcalc_cr_to_coord($c, $r);
$range[$coord] = !empty($sc['cells'][$coord]['datavalue']) ? $sc['cells'][$coord]['datavalue'] : NULL;
}
}
// Return themed or raw values.
return $this->options['raw'] ? $range : theme('sheetnode_range', array(
'range' => $range,
'labels' => $this->options['labels'],
));
}