You are here

function _sheetnode_devel_generate in Sheetnode 7

Same name and namespace in other branches
  1. 7.2 sheetnode.module \_sheetnode_devel_generate()

Helper to generate random spreadsheet.

2 calls to _sheetnode_devel_generate()
sheetnode_devel_generate in ./sheetnode.module
Implements hook_devel_generate().
sheetnode_node_presave in ./sheetnode.module
Implements hook_node_presave().
1 string reference to '_sheetnode_devel_generate'
sheetnode_devel_generate in ./sheetnode.module
Implements hook_devel_generate().

File

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

Code

function _sheetnode_devel_generate($object, $field, $instance, $bundle) {
  module_load_include('inc', 'sheetnode', 'socialcalc');
  $sc = array(
    'edit' => array(),
    'audit' => array(),
    'sheet' => array(),
  );
  for ($row = 1; $row < mt_rand(10, 50); $row++) {
    $sc['sheet']['cells'][] = array(
      'pos' => array(
        1,
        $row,
      ),
      'datavalue' => devel_generate_word(mt_rand(6, 12)),
      'datatype' => 't',
      'valuetype' => 't',
    );
    $sc['sheet']['cells'][] = array(
      'pos' => array(
        2,
        $row,
      ),
      'datavalue' => _sheetnode_lcg_randf(-100, 100),
      'datatype' => 'v',
      'valuetype' => 'n',
    );
  }
  $sc['edit']['ecell']['coord'] = 'A1';
  return array(
    'value' => socialcalc_save($sc),
  );
}