You are here

function lingotek_project_vault_select_form in Lingotek Translation 7.4

Same name and namespace in other branches
  1. 7.7 lingotek.setup.inc \lingotek_project_vault_select_form()
  2. 7.5 lingotek.setup.inc \lingotek_project_vault_select_form()
  3. 7.6 lingotek.setup.inc \lingotek_project_vault_select_form()

Project Select Screen (for Current Users) - Form Layout

1 string reference to 'lingotek_project_vault_select_form'
lingotek_menu in ./lingotek.module
Implements hook_menu().

File

./lingotek.setup.inc, line 408

Code

function lingotek_project_vault_select_form() {
  $form = array();
  $community_identity = variable_get('lingotek_community_identifier', NULL);
  list($community_settings, $full_community_data) = lingotek_get_community_settings($community_identity, TRUE);
  if ($community_settings === FALSE) {
    drupal_set_message(t('Error Retrieving Account Information.'), 'error');
    drupal_goto('admin/config/lingotek/account-settings');

    // Error geting projects.  Go back.
  }
  elseif ($community_settings['project'] === FALSE || $community_settings['workflow'] === FALSE || $community_settings['vault'] === FALSE) {
    drupal_set_message(t('Error Retrieving Account Information.'), 'error');
    drupal_goto('admin/config/lingotek/account-settings');

    // Error geting projects.  Go back.
  }
  $form['lingotek_user_directions'] = array(
    '#markup' => '<p>Select or create the default project and vault that you would like to use.</p>',
  );
  $form['lingotek_community_data'] = array(
    '#type' => 'hidden',
    '#value' => json_encode($full_community_data),
  );

  // Project
  asort($community_settings['project']);
  $project_already_set = !is_null(variable_get('lingotek_project', NULL));
  $projects_count = count($community_settings['project']);
  $project_options = array(
    1 => t('New') . (!$project_already_set ? ' <i>(' . t('recommended') . ')</i>' : ''),
    0 => t('Existing') . ($project_already_set ? ' <i>(' . t('recommended') . ')</i>' : ''),
  );
  if ($projects_count == 0) {
    unset($project_options[0]);
  }
  $form['project_new_or_existing'] = array(
    '#type' => 'radios',
    '#title' => t('Project'),
    '#default_value' => $project_already_set ? 0 : 1,
    '#options' => $project_options,
    //'#description' => t('The Lingotek Project that you would like to use for this site.'),
    '#required' => TRUE,
  );
  $form['project_new'] = array(
    '#type' => 'textfield',
    //'#title' => t('Project Name'),
    '#default_value' => lingotek_get_site_name(),
    '#description' => t('The name of the project where content will be uploaded'),
    '#size' => 20,
    '#states' => array(
      'invisible' => array(
        ':input[name="project_new_or_existing"]' => array(
          'value' => 0,
        ),
      ),
    ),
  );
  $form['project_existing'] = array(
    '#type' => 'select',
    //'#title' => t('Project Selection'),
    '#options' => $community_settings['project'],
    '#default_value' => variable_get('lingotek_project', NULL),
    '#description' => t('Note: ALL documents uploaded to the project, including documents not from this site, will be affected by actions taken on this site (e.g., adding languages)'),
    '#states' => array(
      'invisible' => array(
        ':input[name="project_new_or_existing"]' => array(
          'value' => 1,
        ),
      ),
    ),
  );

  // Workflow (assume project default for workflow)

  /*
  if ($workflow_count > 1) {

    $form['lingotek_site_workflow'] = array(
      '#title' => t('Workflow'),
      '#type' => 'select',
      '#options' => $community_settings['workflow'],
      //'#default_value' => ,
      '#description' => t('The Workflow to use when translating content.'),
      '#required' => TRUE,
    );
  }
  */

  // Vault
  $form['vault_existing_or_new'] = array(
    '#type' => 'radios',
    '#title' => t('Vault'),
    '#default_value' => 0,
    '#options' => array(
      0 => t('Existing') . ' <i>(' . t('recommended') . ')</i>',
      1 => t('New'),
    ),
    //'#description' => t('The Translation Memory (TM) vault where translations are saved.'),
    '#required' => TRUE,
  );
  $form['vault_existing_or_new'][1]['#states'] = array(
    'invisible' => array(
      ':input[name="project_new_or_existing"]' => array(
        'value' => 0,
      ),
    ),
  );
  $form['vault_existing'] = array(
    '#type' => 'select',
    '#options' => $community_settings['vault'],
    '#default_value' => variable_get('lingotek_vault', NULL),
    '#description' => t('Using a shared TM vault allows translations to be re-used.'),
    '#states' => array(
      'invisible' => array(
        ':input[name="vault_existing_or_new"]' => array(
          'value' => 1,
        ),
      ),
    ),
  );
  $form['vault_new'] = array(
    '#type' => 'textfield',
    //'#title' => t('Vault'),
    '#default_value' => lingotek_get_site_name(),
    '#description' => t('The name of the vault where translation memory will be stored'),
    '#size' => 20,
    '#states' => array(
      'invisible' => array(
        ':input[name="vault_existing_or_new"]' => array(
          'value' => 0,
        ),
      ),
    ),
  );

  // submit, etc.
  if (is_array($_SESSION['lingotek_setup_path'])) {
    if (end($_SESSION['lingotek_setup_path']) == 'admin/config/lingotek/project-vault-select') {
      $null = array_pop($_SESSION['lingotek_setup_path']);
    }

    // if the user went back, remove the last element, which is this page.
    $form['lingotek_back_button'] = lingotek_setup_link(end($_SESSION['lingotek_setup_path']), t('Previous Step'));
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Next'),
  );

  //$form['#submit'] = 'lingotek_project_vault_select_form_submit';
  $form['lingotek_support_footer'] = lingotek_support_footer();
  return $form;
}