You are here

function i18n_path_admin_form in Internationalization 7

Path add/edit form

1 string reference to 'i18n_path_admin_form'
i18n_path_menu in i18n_path/i18n_path.module
Implements hook_menu()

File

i18n_path/i18n_path.admin.inc, line 18
Administration pages for path translation.

Code

function i18n_path_admin_form($form, $form_state, $translation_set = NULL) {
  $form['translation_set'] = array(
    '#type' => 'value',
    '#value' => $translation_set,
  );
  if ($translation_set) {
    $paths = $translation_set
      ->get_translations();
  }
  else {
    $paths = array();
  }
  $form['title'] = array(
    '#title' => t('Title'),
    '#type' => 'textfield',
    '#default_value' => $translation_set ? $translation_set->title : '',
    '#description' => t('Optional descriptive name for this set.'),
  );
  $form['translations'] = array(
    '#type' => 'fieldset',
    '#title' => t('Translations'),
    '#tree' => TRUE,
    '#description' => t('The path for this menu link. This can be an internal Drupal path such as %add-node or an external URL such as %drupal. Enter %front to link to the front page.', array(
      '%front' => '<front>',
      '%add-node' => 'node/add',
      '%drupal' => 'http://drupal.org',
    )),
  );
  foreach (i18n_language_list() as $langcode => $name) {
    $form['translations'][$langcode] = array(
      '#type' => 'textfield',
      '#title' => check_plain($name),
      '#default_value' => !empty($paths[$langcode]) ? $paths[$langcode]->path : '',
    );
  }
  $form['controls']['update'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#name' => 'save',
  );
  if ($translation_set) {
    $form['controls']['delete'] = array(
      '#type' => 'submit',
      '#value' => t('Delete'),
      '#name' => 'delete',
    );
  }
  return $form;
}