You are here

function _sheetnode_update_index in Sheetnode 7.2

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

Helper function to return an indexable version of the spreadsheet.

1 call to _sheetnode_update_index()
sheetnode_node_update_index in ./sheetnode.module
Implements hook_node_update_index().

File

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

Code

function _sheetnode_update_index($value) {
  module_load_include('inc', 'sheetnode', 'socialcalc');
  $output = '<table>';
  $socialcalc = socialcalc_parse($value);
  $sc = $socialcalc['sheet'];
  $row = -1;
  if (!empty($sc['cells'])) {
    foreach ($sc['cells'] as $c) {
      if ($c['pos'][1] > $row) {

        // New row? - this assumes cells are ordered by col/row.
        if ($row != -1) {
          $output .= '</tr>';
        }
        $row = $c['pos'][1];
        $output .= '<tr>';
      }
      $output .= '<td>' . (isset($c['datavalue']) ? $c['datavalue'] : '&nbsp;') . (isset($c['comment']) ? ' (' . check_plain($c['comment']) . ')' : '') . '</td>';
    }
    if ($row != -1) {
      $output .= '</tr>';
    }
    $output .= '</table>';
    return $output;
  }
}