function filefield_js in FileField 5.2
Same name and namespace in other branches
- 6.3 filefield.module \filefield_js()
- 6.2 filefield.widget.inc \filefield_js()
Menu callback for JavaScript-based uploads.
1 string reference to 'filefield_js'
File
- ./
filefield.module, line 869 - Defines a file field type.
Code
function filefield_js() {
// Parse fieldname from submit button.
$matches = array();
foreach (array_keys($_POST) as $key) {
if (preg_match('/cck_filefield_(.*)_op/', $key, $matches)) {
$fieldname = $matches[1];
break;
}
}
$node = (object) $_POST;
$field = content_fields($fieldname, $node->type);
// load field data
// Load fids stored by content.module.
$items = array();
$values = content_field('load', $node, $field, $items, FALSE, FALSE);
$items = $values[$fieldname];
// Load additional field data.
filefield_field('load', $node, $field, $items, FALSE, FALSE);
// Handle uploads and validation.
_filefield_widget_prepare_form_values($node, $field, $items);
_filefield_widget_validate($node, $field, $items);
// Get our new form baby, yeah tiger, get em!
$form = _filefield_widget_form($node, $field, $items);
foreach (module_implements('form_alter') as $module) {
$function = $module . '_form_alter';
$function('filefield_js', $form);
}
$form = form_builder('filefield_js', $form);
$output = theme('status_messages') . drupal_render($form);
// Send the updated file attachments form.
$GLOBALS['devel_shutdown'] = false;
print drupal_to_js(array(
'status' => TRUE,
'data' => $output,
));
exit;
}