You are here

function file_entity_settings_form in File Entity (fieldable files) 7.3

Same name and namespace in other branches
  1. 7.2 file_entity.admin.inc \file_entity_settings_form()

Form callback for file_entity settings.

1 string reference to 'file_entity_settings_form'
file_entity_menu in ./file_entity.module
Implements hook_menu().

File

./file_entity.admin.inc, line 1080

Code

function file_entity_settings_form($form, &$form_state) {
  $form['file_entity_max_filesize'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum upload size'),
    '#default_value' => variable_get('file_entity_max_filesize', ''),
    '#description' => t('Enter a value like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes) in order to restrict the allowed file size. If left empty the file sizes will be limited only by PHP\'s maximum post and file upload sizes (current max limit <strong>%limit</strong>).', array(
      '%limit' => format_size(file_upload_max_size()),
    )),
    '#size' => 10,
    '#element_validate' => array(
      '_file_generic_settings_max_filesize',
    ),
  );
  $form['file_entity_default_file_directory'] = array(
    '#type' => 'textfield',
    '#title' => t('Default file directory'),
    '#default_value' => variable_get('file_entity_default_file_directory', ''),
    '#maxlength' => NULL,
  );
  if (module_exists('token')) {
    $form['file_entity_default_file_directory']['#description'] = t('Optional subdirectory within the upload destination where files will be stored if the file is uploaded through the file entity overview page and the directory is not specified otherwise. Do not include preceding or trailing slashes. This field supports tokens.  Suggest using: [current-date:custom:Y]/[current-date:custom:m]/[current-date:custom:d]');
    $form['file_entity_default_file_directory']['tokens'] = array(
      '#theme' => 'token_tree',
      '#dialog' => TRUE,
    );
  }
  else {
    $form['file_entity_default_file_directory']['#description'] = t('Optional subdirectory within the upload destination where files will be stored if the file is uploaded through the file entity overview page and the directory is not specified otherwise. Do not include preceding or trailing slashes.');
  }
  $form['file_entity_default_allowed_extensions'] = array(
    '#type' => 'textfield',
    '#title' => t('Default allowed file extensions'),
    '#default_value' => variable_get('file_entity_default_allowed_extensions', 'jpg jpeg gif png txt doc docx xls xlsx pdf ppt pptx pps ppsx odt ods odp mp3 mov mp4 m4a m4v mpeg avi ogg oga ogv weba webp webm'),
    '#description' => t('Separate extensions with a space and do not include the leading dot.'),
    '#maxlength' => NULL,
  );
  $form['file_entity_max_filesize_extensions'] = array(
    '#type' => 'textarea',
    '#title' => t('Maximum upload size per extension'),
    '#default_value' => variable_get('file_entity_max_filesize_extensions', ''),
    '#description' => t('Set the maximum filesize for specific extensions. Enter one value per line, in the format <strong>extension|filesize</strong>. When an extension does not have a file size limit, the default maximum file size is used.'),
    '#rows' => 10,
    '#element_validate' => array(
      'file_entity_max_filesize_extensions_validate',
    ),
  );
  $form['file_entity_alt'] = array(
    '#type' => 'textfield',
    '#title' => t('Alt attribute'),
    '#description' => t('The text to use as value for the <em>img</em> tag <em>alt</em> attribute.'),
    '#default_value' => variable_get('file_entity_alt', '[file:field_file_image_alt_text]'),
  );
  $form['file_entity_title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title attribute'),
    '#description' => t('The text to use as value for the <em>img</em> tag <em>title</em> attribute.'),
    '#default_value' => variable_get('file_entity_title', '[file:field_file_image_title_text]'),
  );

  // Provide default token values.
  if (module_exists('token')) {
    $form['token_help'] = array(
      '#theme' => 'token_tree',
      '#token_types' => array(
        'file',
      ),
      '#dialog' => TRUE,
    );
    $form['file_entity_alt']['#description'] .= t('This field supports tokens.');
    $form['file_entity_title']['#description'] .= t('This field supports tokens.');
  }
  $form['file_upload_wizard'] = array(
    '#type' => 'fieldset',
    '#title' => t('File upload wizard'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#description' => t('Configure the steps available when uploading a new file.'),
  );
  $form['file_upload_wizard']['file_entity_file_upload_wizard_skip_file_type'] = array(
    '#type' => 'checkbox',
    '#title' => t('Skip filetype selection.'),
    '#default_value' => variable_get('file_entity_file_upload_wizard_skip_file_type', FALSE),
    '#description' => t('The file type selection step is only available if the uploaded file falls into two or more file types. If this step is skipped, files with no available file type or two or more file types will not be assigned a file type.'),
  );
  $form['file_upload_wizard']['file_entity_file_upload_wizard_skip_scheme'] = array(
    '#type' => 'checkbox',
    '#title' => t('Skip scheme selection.'),
    '#default_value' => variable_get('file_entity_file_upload_wizard_skip_scheme', FALSE),
    '#description' => t('The scheme selection step is only available if two or more file destinations, such as public local files served by the webserver and private local files served by Drupal, are available. If this step is skipped, files will automatically be saved using the default download method.'),
  );
  $form['file_upload_wizard']['file_entity_file_upload_wizard_skip_fields'] = array(
    '#type' => 'checkbox',
    '#title' => t('Skip available fields.'),
    '#default_value' => variable_get('file_entity_file_upload_wizard_skip_fields', FALSE),
    '#description' => t('The field selection step is only available if the file type the file belongs to has any available fields. If this step is skipped, any fields on the file will be left blank.'),
  );
  $form['file_replace_options'] = array(
    '#type' => 'fieldset',
    '#title' => t('File replace optons'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#description' => t('Default settings for how to handle file name changes during replace.'),
  );
  $form['file_replace_options']['file_entity_file_replace_options_keep_original_filename'] = array(
    '#type' => 'checkbox',
    '#title' => t('Keep original file name'),
    '#default_value' => variable_get('file_entity_file_replace_options_keep_original_filename', FALSE),
    '#description' => t('Rename the newly uploaded file to the name of the original file. This action cannot be undone.'),
  );
  $form['file_entity_protect_repeated_render'] = array(
    '#type' => 'checkbox',
    '#title' => t('Protect against repeat rendering'),
    '#default_value' => variable_get('file_entity_protect_repeated_render', TRUE),
    '#description' => t('Avoid rendering the same entity more than 20 times. This can be a sign of an image entity getting caught in a recursive render, but it can also be triggered when the same image is rendered more than 20 times, e.g. in an long content list or data feed.'),
  );
  return system_settings_form($form);
}