function sheetnode_nodeapi in Sheetnode 6
Same name and namespace in other branches
- 5 sheetnode.module \sheetnode_nodeapi()
Implementation of hook_nodeapi().
File
- ./
sheetnode.module, line 304
Code
function sheetnode_nodeapi($node, $op) {
if ($op == 'update index') {
// Update index for sheetnodes and sheetfields.
$output = '';
if ($node->type == 'sheetnode') {
$output .= _sheetnode_update_index($node->sheetnode['value']);
}
foreach (sheetnode_get_sheetfields($node->type) as $field_name => $field) {
foreach ($node->{$field_name} as $item) {
if (!empty($item['name'])) {
$output .= '<h5>' . $item['name'] . '</h5>';
}
$output .= _sheetnode_update_index($item['value']);
}
}
return $output;
}
else {
if ($op == 'presave' && $node->type == 'sheetnode' && isset($node->devel_generate)) {
// Generate random spreadsheets for sheetnodes.
$node->sheetnode = array(
'template' => NULL,
) + sheetnode_content_generate($node, NULL);
}
else {
if ($op == 'delete revision' && $node->type == 'sheetnode') {
db_query("DELETE FROM {sheetnode} WHERE vid=%d", $node->vid);
}
}
}
}