function lingotek_admin_connection_form in Lingotek Translation 7.4
Same name and namespace in other branches
- 7.7 lingotek.admin.inc \lingotek_admin_connection_form()
- 7.3 lingotek.admin.inc \lingotek_admin_connection_form()
- 7.5 lingotek.admin.inc \lingotek_admin_connection_form()
- 7.6 lingotek.admin.inc \lingotek_admin_connection_form()
Lingotek Connection Settings Form
1 string reference to 'lingotek_admin_connection_form'
File
- ./
lingotek.admin.inc, line 1186
Code
function lingotek_admin_connection_form($form, &$form_state, $show_fieldset = FALSE) {
$account = LingotekAccount::instance();
$api = LingotekApi::instance();
$force = isset($_GET['test_connection']) ? TRUE : FALSE;
$connected = $api
->testAuthentication($force);
$is_enterprise = $account
->isEnterprise();
$connection_error = t('Connect this site to your Lingotek account by filling in the fields below. If you do not yet have a Lingotek account, you can <a href="@signup_url">sign up</a> to create an ID and collect OAuth credentials. If all fields are complete, there is a problem with one or more of the values.', array(
'@signup_url' => url(LINGOTEK_API_SERVER . '/lingopoint/portal/communitySignup.action'),
));
if (!$connected) {
drupal_set_message($connection_error, 'error');
}
else {
// clear the prior error message
$errors = drupal_get_messages('error');
if (isset($errors['error'])) {
foreach ($errors['error'] as $error) {
if ($error != $connection_error) {
drupal_set_message(check_plain($error), 'error');
}
}
}
}
$edit_connection = isset($_GET['edit_connection']) || !$connected;
$status_message = $connected ? '<span style="color: green;">' . t('Connected') . '</span>' : '<span style="color: red;">' . t('Not Connected') . '</span>';
$form['connection']['connection_summary'] = array(
'#type' => 'hidden',
'#value' => $status_message,
'#attributes' => array(
'id' => array(
'connection_summary',
),
),
);
/* $form['connection'][] = array(
'#type' => 'item',
'#description' => filter_xss($connection_group_description),
); */
if ($is_enterprise || $edit_connection) {
$form['connection']['lingotek_login_id'] = array(
'#type' => 'textfield',
'#title' => t('Lingotek ID'),
'#description' => t('Enter the Lingotek ID you use to access the Lingotek Dashboard and Workbench.'),
'#default_value' => variable_get('lingotek_login_id', ''),
);
$form['connection']['lingotek_oauth_consumer_id'] = array(
'#type' => 'textfield',
'#title' => t('OAuth Key'),
'#description' => t('The OAuth Key used to connect with the Lingotek server.'),
'#default_value' => variable_get('lingotek_oauth_consumer_id', ''),
);
$form['connection']['lingotek_oauth_consumer_secret'] = array(
'#type' => 'textfield',
'#title' => t('OAuth Secret'),
'#description' => t('The OAuth Secret used to connect with the Lingotek server.'),
'#default_value' => variable_get('lingotek_oauth_consumer_secret', ''),
);
// Note: The Lingotek servers may easily be set in code or by setting a 'lingotek_use_stage_servers' drupal variable
$form['connection']['lingotek_use_stage_servers'] = array(
'#type' => 'select',
'#title' => t('Lingotek Environment'),
'#options' => array(
0 => t('Production'),
1 => t('Staging'),
),
'#description' => LINGOTEK_DEV ? t('Note: The above Environment setting above will be overriden by your local configuration (i.e., settings.php).') : '',
'#default_value' => variable_get('lingotek_use_stage_servers', 0),
);
$form['connection']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
}
else {
$form['connection'][] = array(
'#type' => 'item',
'#title' => t('Lingotek Servers'),
'#markup' => theme('table', array(
'header' => array(),
'rows' => array(
array(
'TMS:',
LINGOTEK_API_SERVER,
),
array(
'GMC:',
LINGOTEK_GMC_SERVER,
),
),
)),
);
}
//$form = system_settings_form($form);
if (!($is_enterprise || $edit_connection)) {
unset($form['connection']['actions']);
}
return $form;
}