You are here

function _content_field_invoke_default in Content Construction Kit (CCK) 6

Same name and namespace in other branches
  1. 5 content.module \_content_field_invoke_default()
  2. 6.3 content.module \_content_field_invoke_default()
  3. 6.2 content.module \_content_field_invoke_default()

Invoke content.module's version of a field hook.

10 calls to _content_field_invoke_default()
content_alter in ./content.module
Nodeapi 'alter' op.
content_delete in ./content.module
Nodeapi 'delete' op.
content_delete_revision in ./content.module
Nodeapi 'delete_revision' op.
content_insert in ./content.module
Nodeapi 'insert' op.
content_load in ./content.module
Load data for a node type's fields.

... See full list

File

./content.module, line 1123
Allows administrators to associate custom fields to content types.

Code

function _content_field_invoke_default($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();

  // The operations involving database queries are better off handled by table
  // rather than by field.
  if (in_array($op, array(
    'load',
    'insert',
    'update',
    'delete',
    'delete revision',
  ))) {
    return content_storage($op, $node);
  }
  else {
    foreach ($type['fields'] as $field) {
      $items = isset($node->{$field}['field_name']) ? $node->{$field}['field_name'] : array();
      $result = content_field($op, $node, $field, $items, $teaser, $page);
      if (is_array($result)) {
        $return = array_merge($return, $result);
      }
      else {
        if (isset($result)) {
          $return[] = $result;
        }
      }
      if (isset($node->{$field}['field_name'])) {
        $node->{$field}['field_name'] = $items;
      }
    }
  }
  return $return;
}