audiofield_js

Versions
5
audiofield_js()

Menu callback for JavaScript-based uploads.

Code

contributions/mediafield/audiofield.module, line 477

<?php
function audiofield_js() {
  // Parse fieldname from submit button.
  $matches = array();
  foreach(array_keys($_POST) as $key) {
    if (preg_match('/cck_audiofield_(.*)_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.
  audiofield_field('load', $node, $field, $node_field, FALSE, FALSE);

  // Handle uploads and validation.
  _audiofield_widget_prepare_form_values($node, $field, $node_field);
  _audiofield_widget_validate($node, $field, $node_field);

  // Get our new form baby, yeah tiger, get em!
  $form = _audiofield_widget_form($node, $field, $node_field);

  foreach (module_implements('form_alter') as $module) {
    $function = $module .'_form_alter';
    $function('audiofield_js', $form);
  }
  $form = form_builder('audiofield_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();
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters (without spaces) shown in the image.