You are here

function theme_sheetnode_range in Sheetnode 7.2

Same name and namespace in other branches
  1. 5 sheetnode.module \theme_sheetnode_range()
  2. 6 sheetnode.module \theme_sheetnode_range()
  3. 7 sheetnode.module \theme_sheetnode_range()

Theme function for sheetnode_range.

2 theme calls to theme_sheetnode_range()
sheetnode_handler_field_named_range::render in views/sheetnode_handler_field_named_range.inc
Render views field.
sheetnode_handler_field_range::render in views/sheetnode_handler_field_range.inc
Render views field.

File

./sheetnode.module, line 612
Module file for the sheetnode module.

Code

function theme_sheetnode_range($variables) {
  $range = $variables['range'];
  $labels = $variables['labels'];
  if (empty($range)) {
    return '';
  }
  module_load_include('inc', 'sheetnode', 'socialcalc');
  list($c, $r) = socialcalc_coord_to_cr(key($range));
  $row = array();
  if ($labels & SHEETNODE_RANGE_LABELS_ROW) {
    $row[] = array(
      'data' => $r,
      'header' => TRUE,
    );
  }
  $header = array();
  if ($labels & SHEETNODE_RANGE_LABELS_ROW) {
    $header[] = array();
  }
  $rows = array();
  foreach ($range as $coord => $value) {
    $pos = socialcalc_coord_to_cr($coord);
    if ($pos[1] > $r) {
      $rows[] = $row;
      $r = $pos[1];
      $row = array();
      if ($labels & SHEETNODE_RANGE_LABELS_ROW) {
        $row[] = array(
          'data' => $r,
          'header' => TRUE,
        );
      }
    }
    $row[] = $value;
    if (empty($rows)) {
      $coord = socialcalc_cr_to_coord($pos[0], $pos[1], TRUE);
      $header[] = $coord[0];
    }
  }
  $rows[] = $row;
  return theme('table', array(
    'header' => $labels & SHEETNODE_RANGE_LABELS_COL ? $header : NULL,
    'rows' => $rows,
  ));
}