function _content_field_invoke in Content Construction Kit (CCK) 5
Same name and namespace in other branches
- 6.3 content.module \_content_field_invoke()
- 6 content.module \_content_field_invoke()
- 6.2 content.module \_content_field_invoke()
Invoke a field hook.
For each operation, both this function and _content_field_invoke_default() are called so that the default database handling can occur.
7 calls to _content_field_invoke()
- content_delete in ./
content.module - Delete node type fields.
- content_delete_revision in ./
content.module - delete node type fields for a revision.
- content_insert in ./
content.module - Insert node type fields.
- content_load in ./
content.module - Load data for a node type's fields.
- content_submit in ./
content.module - Submit form callback for node type fields.
File
- ./
content.module, line 533 - Allows administrators to associate custom fields to content types.
Code
function _content_field_invoke($op, &$node, $teaser = NULL, $page = NULL) {
$type_name = is_string($node) ? $node : (is_array($node) ? $node['type'] : $node->type);
$type = content_types($type_name);
$field_types = _content_field_types();
$return = array();
if (count($type['fields'])) {
foreach ($type['fields'] as $field) {
$node_field = isset($node->{$field}['field_name']) ? $node->{$field}['field_name'] : array();
$module = $field_types[$field['type']]['module'];
$function = $module . '_field';
if (function_exists($function)) {
$result = $function($op, $node, $field, $node_field, $teaser, $page);
if (is_array($result)) {
$return = array_merge($return, $result);
}
else {
if (isset($result)) {
$return[] = $result;
}
}
}
// test for values in $node_field in case modules added items on insert
if (isset($node->{$field}['field_name']) || count($node_field)) {
$node->{$field}['field_name'] = $node_field;
}
}
}
return $return;
}