You are here

function filefield_widget_settings_form in FileField 6.3

Implementation of CCK's hook_widget_settings($op == 'form').

1 call to filefield_widget_settings_form()
filefield_widget_settings in ./filefield.module
Implementation of CCK's hook_widget_settings().

File

./filefield_widget.inc, line 14
This file contains CCK widget related functionality.

Code

function filefield_widget_settings_form($widget) {
  $form = array();

  // Convert the extensions list to be a human-friendly comma-separated list.
  $extensions = is_string($widget['file_extensions']) ? $widget['file_extensions'] : 'txt';
  $form['file_extensions'] = array(
    '#type' => 'textfield',
    '#title' => t('Permitted upload file extensions'),
    '#default_value' => $extensions,
    '#size' => 64,
    '#maxlength' => 512,
    '#description' => t('Extensions a user can upload to this field. Separate extensions with a space and do not include the leading dot. Leaving this blank will allow users to upload a file with any extension.'),
    '#element_validate' => array(
      '_filefield_widget_settings_extensions_validate',
    ),
    '#pre_render' => array(
      '_filefield_widget_settings_extensions_value',
    ),
    '#weight' => 1,
  );
  $form['progress_indicator'] = array(
    '#type' => 'radios',
    '#title' => t('Progress indicator'),
    '#options' => array(
      'bar' => t('Bar with progress meter'),
      'throbber' => t('Throbber'),
    ),
    '#default_value' => empty($widget['progress_indicator']) ? 'bar' : $widget['progress_indicator'],
    '#description' => t('Your server supports upload progress capabilities. The "throbber" display does not indicate progress but takes up less room on the form, you may want to use it if you\'ll only be uploading small files or if experiencing problems with the progress bar.'),
    '#weight' => 5,
    '#access' => filefield_progress_implementation(),
  );
  $form['path_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Path settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#weight' => 6,
  );
  $form['path_settings']['file_path'] = array(
    '#type' => 'textfield',
    '#title' => t('File path'),
    '#default_value' => is_string($widget['file_path']) ? $widget['file_path'] : '',
    '#description' => t('Optional subdirectory within the "%directory" directory where files will be stored. Do not include preceding or trailing slashes.', array(
      '%directory' => variable_get('file_directory_path', 'files') . '/',
    )),
    '#element_validate' => array(
      '_filefield_widget_settings_file_path_validate',
    ),
    '#suffix' => theme('token_help', 'user'),
  );
  $form['max_filesize'] = array(
    '#type' => 'fieldset',
    '#title' => t('File size restrictions'),
    '#description' => t('Limits for the size of files that a user can upload. Note that these settings only apply to newly uploaded files, whereas existing files are not affected.'),
    '#weight' => 6,
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['max_filesize']['max_filesize_per_file'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum upload size per file'),
    '#default_value' => is_string($widget['max_filesize_per_file']) ? $widget['max_filesize_per_file'] : '',
    '#description' => t('Specify the size limit that applies to each file separately. Enter a value like "512" (bytes), "80K" (kilobytes) or "50M" (megabytes) in order to restrict the allowed file size. If you leave this empty the file sizes will be limited only by PHP\'s maximum post and file upload sizes (current limit <strong>%limit</strong>).', array(
      '%limit' => format_size(file_upload_max_size()),
    )),
    '#element_validate' => array(
      '_filefield_widget_settings_max_filesize_per_file_validate',
    ),
  );
  $form['max_filesize']['max_filesize_per_node'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum upload size per node'),
    '#default_value' => is_string($widget['max_filesize_per_node']) ? $widget['max_filesize_per_node'] : '',
    '#description' => t('Specify the total size limit for all files in field on a given node. Enter a value like "512" (bytes), "80K" (kilobytes) or "50M" (megabytes) in order to restrict the total size of a node. Leave this empty if there should be no size restriction.'),
    '#element_validate' => array(
      '_filefield_widget_settings_max_filesize_per_node_validate',
    ),
  );
  return $form;
}