function block_upload_plupload_form in Block Upload 7
Returns plupload form for the form builder.
See also
block_upload_plupload_form_submit()
1 string reference to 'block_upload_plupload_form'
- block_upload_block_view in ./
block_upload.module - Implements hook_block_view().
File
- ./
block_upload.module, line 410 - Block Upload module.
Code
function block_upload_plupload_form($form, &$form_state, $node, $buid) {
$field_name = variable_get('block_upload_' . $buid . '_field', '');
$field = field_info_instance('node', $field_name, $node->type);
$validators = block_upload_get_validators($field_name, $field);
$submit = FALSE;
$field_limit = field_info_field($field_name);
if (isset($node->{$field_name}[LANGUAGE_NONE])) {
$field_files_exists = count($node->{$field_name}[LANGUAGE_NONE]);
}
else {
$field_files_exists = 0;
}
if (user_access('block remove') && $field_files_exists > 0) {
$title_remove_form = t('Remove files');
$form['remove_files_title'] = array(
'#markup' => '<h3>' . $title_remove_form . '</h3>',
);
$form['remove_files'] = block_upload_remove_form($field_limit, $node, $field_name);
$submit = TRUE;
}
if ($field_limit['cardinality'] > $field_files_exists || $field_limit['cardinality'] == FIELD_CARDINALITY_UNLIMITED) {
if ($field_limit['cardinality'] != FIELD_CARDINALITY_UNLIMITED) {
$avaliable = $field_limit['cardinality'] - $field_files_exists;
$attention = t('Attention: Thit field is limited to uploading files. Availability %num%', array(
'%num%' => $avaliable,
));
$form[] = array(
'#type' => 'item',
'#title' => check_plain($attention),
);
}
$submit = TRUE;
unset($validators['file_validate_is_image']);
$title_upload_form = t('Upload files');
$form['upload_files_title'] = array(
'#markup' => '<h3>' . $title_upload_form . '</h3>',
);
$form['block_upload_file'] = array(
'#type' => 'plupload',
'#upload_validators' => $validators,
);
}
else {
$form[] = array(
'#type' => 'item',
'#description' => t('Exceeded limit of files'),
);
}
$form_state['node'] = $node;
$form_state['field'] = $field;
$form_state['buid'] = $buid;
if ($submit) {
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
}
return $form;
}