You are here

function sheetnode_plugin_style::merge_annotation in Sheetnode 7

Same name and namespace in other branches
  1. 7.2 views/sheetnode_plugin_style.inc \sheetnode_plugin_style::merge_annotation()
1 call to sheetnode_plugin_style::merge_annotation()
sheetnode_plugin_style::render_sheet in views/sheetnode_plugin_style.inc

File

views/sheetnode_plugin_style.inc, line 440

Class

sheetnode_plugin_style

Code

function merge_annotation(&$original) {
  $annotation = db_query("SELECT value FROM {sheetnode_view} WHERE view_name = :name AND display_id = :id", array(
    ':name' => $this->view->name,
    ':id' => $this->view->display_handler->display->id,
  ))
    ->fetchField();
  if ($annotation) {
    $merge = socialcalc_parse($annotation);

    // TODO - This is the wrong way to merge, because annotations will wind up
    // on the wrong rows if the view contains new records or is sorted differently.
    // What's needed is to associate each row with a record id to match them up when merging.
    foreach ($merge['sheet']['cells'] as $coord => $cell) {
      if (empty($original['sheet']['cells'][$coord])) {
        $original['sheet']['cells'][$coord] = $cell;

        // TODO - Import annotation styles into original.
      }
    }

    // Adjust lastcol and lastrow.
    $original['sheet']['attribs']['lastcol'] = max($original['sheet']['attribs']['lastcol'], $merge['sheet']['attribs']['lastcol']);
    $original['sheet']['attribs']['lastrow'] = max($original['sheet']['attribs']['lastrow'], $merge['sheet']['attribs']['lastrow']);
  }
}