This repository has been archived by the owner on Dec 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tmgmt_oht.ui.inc
97 lines (92 loc) · 3.29 KB
/
tmgmt_oht.ui.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
/**
* @file
* Please supply a file description.
*/
/**
* @file
* Provides myGengo translation plugin controller.
*/
class TMGMTOhtTranslatorUIController extends TMGMTDefaultTranslatorUIController {
/**
* Overrides TMGMTDefaultTranslatorUIController::pluginSettingsForm().
*/
public function pluginSettingsForm($form, &$form_state, TMGMTTranslator $translator, $busy = FALSE) {
$form['api_account_id'] = array(
'#type' => 'textfield',
'#title' => t('OHT API Account ID'),
'#default_value' => $translator->getSetting('api_account_id'),
'#description' => t('Please enter yout Account ID for OneHourTranslation service.'),
);
$form['api_secret_key'] = array(
'#type' => 'textfield',
'#title' => t('OHT API Secret key'),
'#default_value' => $translator->getSetting('api_secret_key'),
'#description' => t('Please enter your secret API key for OneHourTranslation service.'),
);
$form['use_sandbox'] = array(
'#type' => 'checkbox',
'#title' => t('Use the sandbox'),
'#default_value' => $translator->getSetting('use_sandbox'),
'#description' => t('Check to use the testing environment.'),
);
return parent::pluginSettingsForm($form, $form_state, $translator, $busy);
}
/**
* Overrides TMGMTDefaultTranslatorUIController::checkoutSettingsForm().
*/
/* public function checkoutSettingsForm($form, &$form_state, TMGMTJob $job) {
$plugin = tmgmt_translator_plugin_controller($this->pluginType);
$quality = !empty($form_state['values']['settings']['quality']) ? $form_state['values']['settings']['quality'] : 'machine';
$translation_array = $plugin->generateMyGengoTranslationJobArray($job, $quality);
$response = $plugin->requestFromGengo($job->getTranslator(), '/translate/service/quote', 'POST', array(
'jobs' => $translation_array,
'as_group' => 1
));
$sum_credits = 0;
$highest_eta = '';
$sum_unit_count = 0;
foreach ($response->jobs as $mygengo_job) {
$sum_unit_count = $sum_unit_count + $mygengo_job->unit_count;
$sum_credits = $sum_credits + $mygengo_job->credits;
$highest_eta = ($mygengo_job->eta > $highest_eta) ? $mygengo_job->eta : $highest_eta;
}
$settings['word_count'] = array(
'#type' => 'item',
'#title' => t('Word count'),
'#markup' => $sum_unit_count,
);
$settings['quality'] = array(
'#type' => 'select',
'#title' => t('Quality'),
'#options' => array(
'machine' => t('Machine'),
'standard' => t('Standard'),
'pro' => t('Pro'),
'ultra' => t('Ultra'),
),
'#description' => t('With which Quality you want to translate?'),
'#ajax' => array(
'callback' => 'tmgmt_mygengo_quote',
'wrapper' => 'mygengo-quote',
),
);
$settings['quote'] = array(
'#type' => 'fieldset',
'#title' => t('Quote'),
'#prefix' => '<div id="mygengo-quote">',
'#suffix' => '</div>',
);
$settings['quote']['needed_credits'] = array(
'#type' => 'item',
'#title' => t('Needed Credits'),
'#markup' => $sum_credits,
);
$settings['quote']['eta'] = array(
'#type' => 'item',
'#title' => t('ETA'),
'#markup' => format_date(mktime() + $highest_eta, "long"),
);
return $settings;
}*/
}