function l10n_client_settings_form_validate in Localization client 7
Same name and namespace in other branches
- 6.2 l10n_client.admin.inc \l10n_client_settings_form_validate()
- 6 l10n_client.module \l10n_client_settings_form_validate()
Validation to make sure the provided server can handle our submissions.
Make sure it supports the exact version of the API we will try to use.
File
- ./
l10n_client.admin.inc, line 40 - Administrative page callbacks for the Localization client module.
Code
function l10n_client_settings_form_validate($form, &$form_state) {
if ($form_state['values']['l10n_client_use_server']) {
if (!empty($form_state['values']['l10n_client_server'])) {
// Try to invoke the remote string submission with a test request.
$response = xmlrpc($form_state['values']['l10n_client_server'] . '/xmlrpc.php', array(
'l10n.server.test' => array(
'2.0',
),
));
if ($response && !empty($response['name']) && !empty($response['version'])) {
if (empty($response['supported']) || !$response['supported']) {
form_set_error('l10n_client_server', t('The given server could not handle the v2.0 remote submission API.'));
}
else {
drupal_set_message(t('Verified that the specified server can handle remote string submissions. Supported languages: %languages.', array(
'%languages' => $response['languages'],
)));
}
}
else {
form_set_error('l10n_client_server', t('Invalid localization server address specified. Make sure you specified the right server address.'));
}
}
else {
form_set_error('l10n_client_server', t('You should provide a server address, such as https://localize.drupal.org/'));
}
}
}