You are here

function i18nstrings_admin_settings in Internationalization 6

Configure filters for string translation.

This has serious security implications so this form needs the 'administer filters' permission

1 string reference to 'i18nstrings_admin_settings'
i18nstrings_menu in i18nstrings/i18nstrings.module
Implementation of hook_menu().

File

i18nstrings/i18nstrings.admin.inc, line 109
Admin page callbacks for the i18nstrings module.

Code

function i18nstrings_admin_settings() {
  include_once './includes/locale.inc';

  // As the user has administer filters permissions we get a full list here
  foreach (filter_formats() as $fid => $format) {
    $format_list[$fid] = $format->name;
  }
  $form['i18nstrings_allowed_formats'] = array(
    '#title' => t('Translatable input formats'),
    '#options' => $format_list,
    '#type' => 'checkboxes',
    '#default_value' => variable_get('i18nstrings_allowed_formats', array(
      variable_get('filter_default_format', 1),
    )),
    '#description' => t('Only the strings that have the input formats selected will be allowed by the translation system. All the others will be deleted next time the strings are refreshed.'),
  );

  // Whitelist text groups without formatted strings for backwards compatibility
  $textgroups = module_invoke_all('locale', 'groups');
  unset($textgroups['default']);
  foreach (array_keys($textgroups) as $group) {
    $format = i18nstrings_group_info($group, 'format');
    if (isset($format)) {

      // This one already has format information, so remove from list
      unset($textgroups[$group]);
    }
  }

  // If there are 'old' textgroups, display the bypass option
  if ($textgroups) {
    $form['i18nstrings_allowed_textgroups'] = array(
      '#title' => t('Safe text groups'),
      '#options' => $textgroups,
      '#type' => 'checkboxes',
      '#default_value' => variable_get('i18nstrings_allowed_textgroups', array()),
      '#description' => t('Select text groups to bypass filter format checking. . <strong>It is unsafe to check this option unless you are sure all the strings from that text groups are safe for translators</strong>. This option is just for backwards compatibility until all the contributed modules implement the new strings API.'),
    );
  }
  elseif (variable_get('i18nstrings_allowed_textgroups', 0)) {

    // Just in case there's a leftover variable before we updated some of the modules
    variable_del('i18nstrings_allowed_textgroups');
  }
  $form['array_filter'] = array(
    '#type' => 'value',
    '#value' => TRUE,
  );
  return system_settings_form($form);
}