videofield_js()Menu callback for JavaScript-based uploads.
contributions/mediafield/videofield.module, line 506
<?php
function videofield_js() {
// Parse fieldname from submit button.
$matches = array();
foreach(array_keys($_POST) as $key) {
if (preg_match('/cck_videofield_(.*)_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.
$node_field = array();
$values = content_field('load', $node, $field, $node_field, FALSE, FALSE);
$node_field = $values[$fieldname];
// Load additional field data.
videofield_field('load', $node, $field, $node_field, FALSE, FALSE);
// Handle uploads and validation.
_videofield_widget_prepare_form_values($node, $field, $node_field);
_videofield_widget_validate($node, $field, $node_field);
// Get our new form baby, yeah tiger, get em!
$form = _videofield_widget_form($node, $field, $node_field);
foreach (module_implements('form_alter') as $module) {
$function = $module .'_form_alter';
$function('videofield_js', $form);
}
$form = form_builder('videofield_js', $form);
$output = theme('status_messages') . drupal_render($form);
// Send the updated file attachments form.
print drupal_to_js(array('status' => TRUE, 'data' => $output));
exit();
}
?>