You are here

function _content_field_invoke in Content Construction Kit (CCK) 6.2

Same name and namespace in other branches
  1. 5 content.module \_content_field_invoke()
  2. 6.3 content.module \_content_field_invoke()
  3. 6 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.

9 calls to _content_field_invoke()
content_delete in ./content.module
Implementation of hook_nodeapi 'delete' op.
content_delete_revision in ./content.module
Implementation of hook_nodeapi 'delete_revision' op.
content_insert in ./content.module
Implementation of hook_nodeapi 'insert' op.
content_load in ./content.module
Load data for a node type's fields. Implementation of hook_nodeapi 'load' op.
content_prepare_translation in ./content.module
Implementation of hook_nodeapi 'prepare translation' op.

... See full list

File

./content.module, line 1240
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();
  foreach ($type['fields'] as $field) {
    $items = isset($node->{$field}['field_name']) ? $node->{$field}['field_name'] : array();

    // Make sure AHAH 'add more' button isn't sent to the fields for processing.
    unset($items[$field['field_name'] . '_add_more']);
    $module = $field_types[$field['type']]['module'];
    $function = $module . '_field';
    if (function_exists($function)) {
      $result = $function($op, $node, $field, $items, $teaser, $page);
      if (is_array($result)) {
        $return = array_merge($return, $result);
      }
      else {
        if (isset($result)) {
          $return[] = $result;
        }
      }
    }

    // test for values in $items in case modules added items on insert
    if (isset($node->{$field}['field_name']) || count($items)) {
      $node->{$field}['field_name'] = $items;
    }
  }
  return $return;
}