You are here

function _content_widget_invoke in Asset 6

Invoke a widget hook.

1 call to _content_widget_invoke()
asset_nodeapi in inc/asset.node.inc
Implementation of hook_nodeapi() This is where we build the asset_node records.

File

inc/asset.node.inc, line 119

Code

function _content_widget_invoke($op, &$node) {
  $type_name = is_string($node) ? $node : (is_array($node) ? $node['type'] : $node->type);
  $type = content_types($type_name);
  $widget_types = _content_widget_types();
  $return = array();
  if (count($type['fields'])) {
    foreach ($type['fields'] as $field) {
      if ($field['type'] == 'asset') {

        //Saving asset info to node
        $node->{$field}['field_name'] = $_POST[$field['field_name']];
        $node->{$field['field_name']}[0]['options'] = $node->{$field['field_name']}[0]['value'];
      }

      //

      /* $node_field = isset($node->$field['field_name']) ? $node->$field['field_name'] : array();

            $module = $widget_types[$field['widget']['type']]['module'];
            $function = $module .'_widget';
            if (function_exists($function)) {
              // If we're building a node creation form, pre-fill with default values
             // if ($op == 'prepare form values' && empty($node->nid)) {
              //  $node_field = array_merge($node_field, content_default_value($node, $field, $node_field));
              //}

              $result = $function($op, $node, $field, $node_field);
              if (is_array($result) && $op == 'form') {
                $result[$field['field_name']]['#weight'] = $field['widget']['weight'];
              }
              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
            if (is_object($node) && (isset($node->$field['field_name']) || count($node_field))) {
              $node->$field['field_name'] = $node_field;
            }*/
    }
  }
  return $return;
}