function emfield_emfield_field in Embedded Media Field 5
Same name and namespace in other branches
- 6.3 deprecated/emfield-deprecated.inc \emfield_emfield_field()
- 6 emfield.module \emfield_emfield_field()
- 6.2 emfield.module \emfield_emfield_field()
Implementation of hook_emfield_field *
4 calls to emfield_emfield_field()
- emaudio_field in contrib/
emaudio/ emaudio.module - Implementation of hook_field *
- emfield_operations_reload in ./
emfield.module - This reloads and saves the data for all the nid's in the array.
- image_ncck_field in contrib/
image_ncck/ image_ncck.module - Implementation of hook_field *
- video_cck_field in contrib/
video_cck/ video_cck.module
File
- ./
emfield.module, line 143
Code
function emfield_emfield_field($op, &$node, $field, &$items, $teaser, $page, $module) {
switch ($op) {
// TODO: nothing to validate at the moment. we need to have different provider api's have a chance to validate
case 'validate':
foreach ($items as $delta => $item) {
$error_field = $field['multiple'] ? $field['field_name'] . '][' . $delta . '][embed' : $field['field_name'];
_emfield_field_validate_id($field, $item, $error_field, $module, $delta);
}
break;
case 'submit':
foreach ($items as $delta => $item) {
$list = _emfield_field_submit_id($field, $item, $module);
$items[$delta]['provider'] = $list['provider'];
$items[$delta]['value'] = $list['value'];
$items[$delta]['data'] = $list['data'];
}
break;
case 'load':
// We need to unserialize the 'data' column manually
$field_name = $field['field_name'];
foreach ($items as $delta => $item) {
$data = (array) unserialize($items[$delta]['data']);
$items[$delta]['data'] = $data;
$node->{$field_name}[$delta]['data'] = $data;
}
$return = array();
$return[$field_name] = $items;
break;
case 'delete':
break;
}
// allow modules (such as emthumb) to alter our data.
foreach (module_implements('emfield_field_extra') as $module) {
$args = array(
$op,
&$node,
$field,
&$items,
$teaser,
$page,
$module,
);
$ret = call_user_func_array($module . '_emfield_field_extra', $args);
if (is_array($return) && is_array($ret)) {
$return = array_merge($return, $ret);
}
}
// drupal_set_message($op .' node field: <pre>'. print_r($items, true) .'</pre>');
if (in_array($op, array(
'insert',
'update',
))) {
// we need to manually serialize the 'data' array
foreach ($items as $delta => $item) {
$items[$delta]['data'] = serialize($items[$delta]['data']);
}
}
return $return;
}