You are here

function i18n_admin_variables_form in Internationalization 6

Variables overview form

1 string reference to 'i18n_admin_variables_form'
i18n_menu in ./i18n.module
Implementation of hook_menu().

File

./i18n.admin.inc, line 66
Extended multilanguage administration and module settings UI.

Code

function i18n_admin_variables_form() {
  $i18n_variables = i18n_variable();
  $i18n_current = array();
  $result = db_query("SELECT DISTINCT(name) FROM {i18n_variable}");
  while ($variable = db_fetch_object($result)) {
    $i18n_current[] = $variable->name;
  }
  $i18n_list = array_unique(array_merge($i18n_variables, $i18n_current));
  foreach ($i18n_list as $name) {
    $is_multilingual = in_array($name, $i18n_variables);
    $has_value = in_array($name, $i18n_current);
    if ($is_multilingual) {
      $class = $has_value ? 'ok' : 'info';
    }
    elseif ($has_value) {
      $class = 'error';
    }
    $rows[] = array(
      'class' => $class,
      'data' => array(
        array(
          'data' => $name,
          'colspan' => 2,
          'header' => TRUE,
        ),
        $is_multilingual ? t('Yes') : t('No'),
        $has_value ? t('Yes') : t('No'),
      ),
    );
  }
  if ($i18n_list) {
    $header = array(
      '',
      t('Variable name'),
      t('Is multilingual'),
      t('Has translations'),
    );
    $form['variables']['#value'] = theme('table', $header, $rows, array(
      'class' => 'system-status-report',
    ));
  }
  else {
    $form['variables']['#value'] = t('There are no multilingual variables.');
  }
  if (count($i18n_list) > count($i18n_variables)) {
    $form['clean'] = array(
      '#type' => 'fieldset',
      '#description' => t('Delete all existing translations for variables that are not marked as multilingual.'),
    );
    $form['clean']['cleanup'] = array(
      '#type' => 'submit',
      '#value' => t('Clean up variables'),
    );
  }
  if ($i18n_current) {
    $form['delete'] = array(
      '#type' => 'fieldset',
      '#description' => t('Delete all existing translations for variables.'),
    );
    $form['delete']['deleteall'] = array(
      '#type' => 'submit',
      '#value' => t('Delete all translations'),
    );
  }
  return $form;
}