function comment_upload_upload_form in Comment Upload 6
Build the section of the upload_form that holds the attachments table and upload element.
Parameters
array $files:
Return value
array
2 calls to comment_upload_upload_form()
- comment_upload_alter_comment_form in ./
comment_upload.module - Alter the comment form to support AHAH uploads.
- comment_upload_js in ./
comment_upload.module - React to the Attach button; update file information on AHAH request.
File
- ./
comment_upload.module, line 290 - Provides file attachment functionality for comments.
Code
function comment_upload_upload_form($files = array()) {
$form = array(
'#theme' => 'comment_upload_form_new',
);
if (!empty($files) && is_array($files)) {
$count = count($files);
$form['files']['#theme'] = 'comment_upload_form_current';
$form['files']['#tree'] = TRUE;
foreach ($files as $key => $file) {
$file = (object) $file;
$form['files'][$key] = comment_upload_create_file_element($file, $count);
}
}
$limits = _upload_file_limits($GLOBALS['user']);
$form['new']['upload'] = array(
'#type' => 'file',
'#title' => t('Attach new file'),
'#description' => ($limits['resolution'] ? t('Images are larger than %resolution will be resized. ', array(
'%resolution' => $limits['resolution'],
)) : '') . t('The maximum upload size is %filesize. Only files with the following extensions may be uploaded: %extensions. ', array(
'%extensions' => $limits['extensions'],
'%filesize' => format_size($limits['file_size']),
)),
);
$form['new']['attach'] = array(
'#type' => 'submit',
'#value' => t('Attach'),
'#name' => 'attach',
'#ahah' => array(
'path' => 'comment-upload/js',
'wrapper' => 'attach-wrapper',
'progress' => array(
'type' => 'bar',
'message' => t('Please wait...'),
),
),
'#submit' => array(),
'#validate' => array(
'comment_upload_comment_form_validate',
),
);
return $form;
}