function lingotek_project_select_form in Lingotek Translation 7.2
Project Select Screen (for Current Users) - Form Layout
1 string reference to 'lingotek_project_select_form'
- lingotek_menu in ./
lingotek.module - Implements hook_menu().
File
- ./
lingotek.setup.inc, line 394 - Lingotek Easy Install Process.
Code
function lingotek_project_select_form() {
$login_id = variable_get('lingotek_login_id', '');
$password = variable_get('lingotek_password', '');
$form = array();
// V3 API Call for Legacy Users
$lingotek_url = variable_get('lingotek_url', LINGOTEK_API_SERVER);
$community_identity = variable_get('lingotek_community_identifier', NULL);
$projects = lingotek_get_projects_v4($login_id, $password, $community_identity, $lingotek_url . '/lingopoint/api/4');
//To-do: $vaults = lingotek_get_vaults_v4( $login_id, $password, $community_identity, $lingotek_url . '/lingopoint/api/4' );
if ($projects === FALSE) {
drupal_set_message(t('Error Retrieving Account Information.'), 'error');
drupal_goto('admin/config/lingotek/account-settings');
// Error geting projects. Go back.
}
else {
$count = count($projects);
if ($count == 1) {
// If there is just 1 Project, Auto-Select it. Then move on to the next step.
$project_id = '';
$workflow_id = '';
$project_keys = array_keys($projects);
$project_string = array_pop($project_keys);
// This can come back as just the ProjectID, OR the ProjectID ||| WorkflowID jammed together, so check the string.
if (strpos($project_string, '|||')) {
// Returns a position or false if not found.
$parts = explode('|||', $project_string);
$project_id = $parts[0];
$workflow_id = $parts[1];
}
else {
$project_id = $project_string;
}
variable_set('lingotek_project', $project_id);
variable_set('lingotek_workflow', $workflow_id);
drupal_goto('admin/config/lingotek/language-settings');
// Default path, if they only have 1 project.
}
else {
// Stay on this page.
}
}
$form['lingotek_user_directions_1'] = array(
'#markup' => '<p>Your account is associated with multiple Lingotek projects.</p><p>Choose the project where you would like your translated content stored.</p>',
);
$form['lingotek_top_spacer'] = array(
'#markup' => '<div> </div>',
);
$form['lingotek_site_project'] = array(
'#title' => t('Project'),
'#type' => 'select',
'#options' => $projects,
//'#default_value' => ,
//'#description' => t( '' ),
'#required' => TRUE,
);
$form['lingotek_button_spacer'] = array(
'#markup' => '<div> </div>',
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Next'),
);
if (is_array($_SESSION['lingotek_setup_path'])) {
if (end($_SESSION['lingotek_setup_path']) == 'admin/config/lingotek/project-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['lingotek_support_footer'] = lingotek_support_footer();
return $form;
}