You are here

function theme_sheetnode_range in Sheetnode 6

Same name and namespace in other branches
  1. 5 sheetnode.module \theme_sheetnode_range()
  2. 7.2 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
sheetnode_handler_field_range::render in views/sheetnode_handler_field_range.inc

File

./sheetnode.module, line 587

Code

function theme_sheetnode_range($range, $labels = SHEETNODE_RANGE_LABELS_ROW_COL) {
  if (empty($range)) {
    return '';
  }
  require_once drupal_get_path('module', 'sheetnode') . '/socialcalc.inc';
  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', $labels & SHEETNODE_RANGE_LABELS_COL ? $header : NULL, $rows);
}