1 system.admin.inc system_file_system_settings()

Form builder; Configure the site file handling.

Related topics

File

core/modules/system/system.admin.inc, line 1855
Admin page callbacks for the System module.

Code

function system_file_system_settings() {
  $config = config('system.core');

  $form['#config'] = 'system.core';
  $form['file_public_path'] = array(
    '#type' => 'textfield',
    '#title' => t('Public file system path'),
    '#default_value' => $config->get('file_public_path'),
    '#maxlength' => 255,
    '#description' => t('A local file system path where public files will be stored. This directory must exist and be writable by Backdrop. This directory must be relative to the Backdrop installation directory and be accessible over the web.'),
    '#after_build' => array('system_check_directory'),
  );

  $form['file_private_path'] = array(
    '#type' => 'textfield',
    '#title' => t('Private file system path'),
    '#default_value' => $config->get('file_private_path'),
    '#maxlength' => 255,
    '#description' => t('An existing local file system path for storing private files. It should be writable by Backdrop and not accessible over the web. See the online handbook for <a href="@handbook">more information about securing private files</a>.', array('@handbook' => 'https://docs.backdropcms.org/documentation/managing-file-locations-and-access')),
    '#after_build' => array('system_check_directory'),
  );

  $form['file_temporary_path'] = array(
    '#type' => 'textfield',
    '#title' => t('Temporary directory'),
    '#default_value' => file_directory_temp(),
    '#maxlength' => 255,
    '#description' => t('A local file system path where temporary files will be stored. This directory should not be accessible over the web.'),
    '#after_build' => array('system_check_directory'),
  );
  // Any visible, writeable wrapper can potentially be used for the files
  // directory, including a remote file system that integrates with a CDN.
  foreach (file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE) as $scheme => $info) {
    $options[$scheme] = check_plain($info['description']);
  }

  if (!empty($options)) {
    $default_scheme = $config->get('file_default_scheme');
    $default_scheme = isset($options[$default_scheme]) ? $default_scheme : key($options);
    $form['file_default_scheme'] = array(
      '#type' => 'radios',
      '#title' => t('Default download method'),
      '#default_value' => $default_scheme,
      '#options' => $options,
      '#description' => t('This setting is used as the preferred download method. The use of public files is more efficient, but does not provide any access control.'),
    );
  }

  $form['transliteration'] = array(
    '#type' => 'item',
    '#title' => t('Transliteration'),
    '#value' => '',
  );
  $form['transliteration']['file_transliterate_uploads'] = array(
    '#type' => 'checkbox',
    '#title' => t('Transliterate file names during upload'),
    '#description' => t('Enable to convert file names to US-ASCII character set for cross-platform compatibility. If you enable this setting later, you may want to <a href="@transliteration">retroactively transliterate existing file names</a>.', array('@transliteration' => url('admin/config/media/file-system/transliteration'))),
    '#default_value' => $config->get('file_transliterate_uploads'),
  );
  $form['transliteration']['file_transliterate_uploads_display_name'] = array(
    '#type' => 'checkbox',
    '#title' => t('Transliterate the displayed file name'),
    '#description' => t('Enable to also convert the file name that is displayed within the site (for example, in link text).'),
    '#default_value' => $config->get('file_transliterate_uploads_display_name'),
    '#states' => array(
      'invisible' => array(
        'input[name="file_transliterate_uploads"]' => array('checked' => FALSE),
      ),
    ),
  );
  $form['transliteration']['file_transliterate_lowercase'] = array(
    '#type' => 'checkbox',
    '#title' => t('Lowercase transliterated file names'),
    '#default_value' => $config->get('file_transliterate_lowercase'),
    '#description' => t('Enable to convert file names to lowercase. This is recommended to prevent issues with case-insensitive file systems.'),
    '#states' => array(
      'invisible' => array(
        'input[name="file_transliterate_uploads"]' => array('checked' => FALSE),
      ),
    ),
  );

  return system_settings_form($form);
}