upload_js
modules/upload/upload.module, строка 879
- Версии
- 5 – 6
upload_js()
Коллбэк меню для JavaScript загрузок файлов.
Код
<?php
function upload_js() {
if (isset($_POST['vid']) && is_numeric($_POST['vid'])) {
// Load the node and check the user is allowed to post attachments to it.
$node = node_load(array('vid' => $_POST['vid']));
if (!$node || !node_access('update', $node) || !variable_get('upload_'. $node->type, TRUE)) {
// Setting this error will cause the form to fail validation.
form_set_error('form_token', t('Validation error, please try again. If this error persists, please contact the site administrator.'));
$output = theme('status_messages');
print drupal_to_js(array('status' => TRUE, 'data' => $output));
exit();
}
}
else {
// This is a new node.
$node = new stdClass();
}
// Load existing node files.
$node->files = upload_load($node);
// Handle new uploads, and merge tmp files into node-files.
_upload_prepare($node);
_upload_validate($node);
$form = _upload_form($node);
foreach (module_implements('form_alter') as $module) {
$function = $module .'_form_alter';
$function('upload_js', $form);
}
$form = form_builder('upload_js', $form);
$output = theme('status_messages') . drupal_render($form);
// We send the updated file attachments form.
print drupal_to_js(array('status' => TRUE, 'data' => $output));
exit;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии