function filefield_source_elfinder_process in elFinder file manager 8.2
Same name and namespace in other branches
- 6.2 modules/elfinder_ffsel/elfinder_ffsel.module \filefield_source_elfinder_process()
- 6 modules/elfinder_ffsel/elfinder_ffsel.module \filefield_source_elfinder_process()
- 7.3 modules/elfinder_ffsel/elfinder_ffsel.module \filefield_source_elfinder_process()
- 7 modules/elfinder_ffsel/elfinder_ffsel.module \filefield_source_elfinder_process()
- 7.2 modules/elfinder_ffsel/elfinder_ffsel.module \filefield_source_elfinder_process()
A #process callback to extend the filefield_widget element type.
1 string reference to 'filefield_source_elfinder_process'
- filefield_source_elfinder_info in modules/
elfinder_ffsel/ elfinder_ffsel.module - Implementation of hook_filefield_source_info().
File
- modules/
elfinder_ffsel/ elfinder_ffsel.module, line 91
Code
function filefield_source_elfinder_process($element, &$form_state, $form) {
$instance = field_widget_instance($element, $form_state);
$element['filefield_elfinder'] = array(
'#weight' => 100.5,
'#theme' => 'filefield_source_elfinder_element',
'#filefield_source' => TRUE,
// Required for proper theming.
'#description' => filefield_sources_element_validation_help($element['#upload_validators']),
);
$filepath_id = $element['#id'] . '-elfinder-path';
$display_id = $element['#id'] . '-elfinder-display';
$select_id = $element['#id'] . '-elfinder-select';
$element['filefield_elfinder']['file_path'] = array(
'#type' => 'hidden',
'#value' => '',
'#attributes' => array(
'id' => $filepath_id,
'onchange' => "if (!jQuery('#{$select_id}').attr('disabled')) { jQuery('#{$select_id}').mousedown().disable(); jQuery('#{$display_id}').html(this.value); }",
),
);
$elfinder_function = 'window.open(\'' . url('elfinder', array(
'query' => array(
'app' => 'ffs',
'field_name' => $element['#field_name'],
'filepath_id' => $filepath_id,
'select_id' => $select_id,
),
)) . '\', \'\', \'width=760,height=560,resizable=1\'); return false;';
$element['filefield_elfinder']['display_path'] = array(
'#type' => 'markup',
'#markup' => '<span id="' . $display_id . '" class="filefield-sources-elfinder-display">' . t('No file selected') . '</span> (<a class="filefield-sources-elfinder-browse" href="#" onclick="' . $elfinder_function . '">' . t('browse') . '</a>)',
);
$element['filefield_elfinder']['select'] = array(
'#name' => implode('_', $element['#array_parents']) . '_elfinder_select',
'#type' => 'submit',
'#value' => t('Select'),
'#validate' => array(),
'#submit' => array(
'filefield_sources_field_submit',
),
'#limit_validation_errors' => array(
$element['#parents'],
),
'#name' => $element['#name'] . '[filefield_elfinder][button]',
'#id' => $select_id,
'#attributes' => array(
'style' => 'display: none;',
),
'#ajax' => array(
'path' => 'file/ajax/' . implode('/', $element['#array_parents']) . '/' . $form['form_build_id']['#value'],
'wrapper' => $element['#id'] . '-ajax-wrapper',
'method' => 'replace',
'effect' => 'fade',
),
);
return $element;
}