You are here

function transliteration_form_system_file_system_settings_alter in Transliteration 7.3

Same name and namespace in other branches
  1. 6.3 transliteration.module \transliteration_form_system_file_system_settings_alter()

Implements hook_form_FORM_ID_alter().

Adds transliteration settings to the file system configuration form.

File

./transliteration.module, line 38
Converts non-latin text to US-ASCII and sanitizes file names.

Code

function transliteration_form_system_file_system_settings_alter(&$form, &$form_state) {
  $form['transliteration'] = array(
    '#type' => 'item',
    '#title' => t('Transliteration'),
    '#value' => '',
  );
  $form['transliteration']['transliteration_file_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.'),
    '#default_value' => variable_get('transliteration_file_uploads', TRUE),
  );
  $form['transliteration']['transliteration_file_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' => variable_get('transliteration_file_uploads_display_name', TRUE),
    '#states' => array(
      'invisible' => array(
        'input[name="transliteration_file_uploads"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  $form['transliteration']['transliteration_file_lowercase'] = array(
    '#type' => 'checkbox',
    '#title' => t('Lowercase transliterated file names.'),
    '#default_value' => variable_get('transliteration_file_lowercase', TRUE),
    '#description' => t('This is a recommended setting to prevent issues with case-insensitive file systems. It has no effect if transliteration has been disabled.'),
    '#states' => array(
      'invisible' => array(
        'input[name="transliteration_file_uploads"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  $form['transliteration']['transliteration_file_underscore_replacement_option'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable Underscore replacement in the file names.'),
    '#default_value' => variable_get('transliteration_file_underscore_replacement_option', TRUE),
    '#description' => t('This is used to enaled replacing underscore in all file names.'),
  );
  $form['transliteration']['transliteration_file_underscore_replacement'] = array(
    '#type' => 'radios',
    '#title' => t('Replace underscore with'),
    '#default_value' => variable_get('transliteration_file_underscore_replacement', '_'),
    '#description' => t('Select what character to use when replacing Underscore in file names. It has no effect if transliteration has been disabled.'),
    '#options' => array(
      '_' => t('Default (_)'),
      '-' => t('Hyphen (-)'),
    ),
    '#states' => array(
      'invisible' => array(
        'input[name="transliteration_file_underscore_replacement_option"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  $form['buttons']['#weight'] = 1;
}