1 | <?php |
||
19 | class Order |
||
20 | { |
||
21 | /** |
||
22 | * The order name. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | private $orderName; |
||
27 | |||
28 | /** |
||
29 | * The source language. |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | private $sourceLanguage; |
||
34 | |||
35 | /** |
||
36 | * The target languages. |
||
37 | * |
||
38 | * @var array |
||
39 | */ |
||
40 | private $targetLanguages = array(); |
||
41 | |||
42 | /** |
||
43 | * The order instruction. |
||
44 | * |
||
45 | * @var array |
||
46 | */ |
||
47 | private $instructions = array(); |
||
48 | |||
49 | /** |
||
50 | * The client reference. |
||
51 | * |
||
52 | * @var string |
||
53 | */ |
||
54 | private $reference; |
||
55 | |||
56 | /** |
||
57 | * The configuration. |
||
58 | * |
||
59 | * @var array |
||
60 | */ |
||
61 | private $config = array( |
||
62 | 'clientId' => '', |
||
63 | 'orderNamePrefix' => '', |
||
64 | 'templateId' => '', |
||
65 | 'dueDate' => 0, |
||
66 | 'issuedBy' => '', |
||
67 | 'isConfidential' => false, |
||
68 | 'needsConfirmation' => true, |
||
69 | 'needsQuotation' => false, |
||
70 | ); |
||
71 | |||
72 | /** |
||
73 | * Array of files that are part of the order. |
||
74 | * |
||
75 | * @var array |
||
76 | */ |
||
77 | private $files = array(); |
||
78 | |||
79 | |||
80 | /** |
||
81 | * Create a new order. |
||
82 | * |
||
83 | * @param string $source_language |
||
84 | * The source language for the translation order. |
||
85 | * @param array $config |
||
86 | * The configuration elements for the order: |
||
87 | * - clientId : The client ID to order the translations for. |
||
88 | * - orderNamePrefix : The order gets by default the following name: |
||
89 | * translation_order_<date as YmdHis><microseconds as 3 digits>. |
||
90 | * You can override the "translation_order_" with your own prefix. |
||
91 | * (optional). |
||
92 | * - templateId : The translation template ID. (optional). |
||
93 | * - dueDate : What is the deadline for the file(s) to be translated. |
||
94 | * The deadline should be set in days from the moment the translation |
||
95 | * is ordered. (optional, default 0). |
||
96 | * - issuedBy : The email address of the, by the translation known, issuer |
||
97 | * of the translation. |
||
98 | * - isConfidential : Is the content for the translation confidential? |
||
99 | * (optional, default false). |
||
100 | * - needsConfirmation : Should there be a conformation send when the |
||
101 | * translation is ready? (optional, default true). |
||
102 | * - needsQuotation : Should a quotation be created and send before the |
||
103 | * translation is performed? (optional, default false). |
||
104 | */ |
||
105 | 60 | public function __construct($source_language, $config = array()) |
|
112 | |||
113 | /** |
||
114 | * Get the source language. |
||
115 | * |
||
116 | * @return string |
||
117 | * The source language of the translation. |
||
118 | */ |
||
119 | 6 | public function getSourceLanguage() |
|
123 | |||
124 | /** |
||
125 | * Helper function to generate the order name when the object is created. |
||
126 | * |
||
127 | * @return string |
||
128 | */ |
||
129 | 60 | protected function createOrderName() |
|
149 | |||
150 | /** |
||
151 | * Fill in the configuration based on the given config array. |
||
152 | * |
||
153 | * @param array $config |
||
154 | * The config array to store. |
||
155 | */ |
||
156 | 60 | protected function setConfig($config) |
|
165 | |||
166 | /** |
||
167 | * Get the order name. |
||
168 | * |
||
169 | * @return string |
||
170 | * The order name. |
||
171 | */ |
||
172 | 3 | public function getOrderName() |
|
176 | |||
177 | /** |
||
178 | * Get the client id. |
||
179 | * |
||
180 | * @return string |
||
181 | * The client ID. |
||
182 | */ |
||
183 | 6 | public function getClientId() |
|
187 | |||
188 | /** |
||
189 | * Get the template id. |
||
190 | * |
||
191 | * @return string |
||
192 | * The template ID. |
||
193 | */ |
||
194 | 3 | public function getTemplateId() |
|
198 | |||
199 | /** |
||
200 | * Get the request date. |
||
201 | * |
||
202 | * @return DateTime |
||
203 | * The date time presentation of the request date. |
||
204 | */ |
||
205 | 3 | public function getRequestDate() |
|
210 | |||
211 | /** |
||
212 | * Get the request due date. |
||
213 | * |
||
214 | * The date is calculated based on the dueDate value in the settings. |
||
215 | * |
||
216 | * @return DateTime |
||
217 | * The date time presentation of the due date. |
||
218 | */ |
||
219 | 3 | public function getDueDate() |
|
235 | |||
236 | /** |
||
237 | * Get the issuer identifier. |
||
238 | * |
||
239 | * @return string |
||
240 | * The email address. |
||
241 | */ |
||
242 | 3 | public function getIssuedBy() |
|
246 | |||
247 | /** |
||
248 | * Get if the translation content is confidential. |
||
249 | * |
||
250 | * @return bool |
||
251 | * Translation vcontent is confidential true/false. |
||
252 | */ |
||
253 | 3 | public function isConfidential() |
|
257 | |||
258 | /** |
||
259 | * Add a target language. |
||
260 | * |
||
261 | * @param string $language |
||
262 | * The target language to add to the order. |
||
263 | */ |
||
264 | 6 | public function addTargetLanguage($language) |
|
270 | |||
271 | /** |
||
272 | * Get the target languages. |
||
273 | * |
||
274 | * @return array |
||
275 | * The target language codes. |
||
276 | */ |
||
277 | 6 | public function getTargetLanguages() |
|
281 | |||
282 | /** |
||
283 | * Add instruction to the order. |
||
284 | * |
||
285 | * @param string $instruction |
||
286 | * The instruction. |
||
287 | */ |
||
288 | 6 | public function addInstruction($instruction) |
|
292 | |||
293 | /** |
||
294 | * Get the client instruction. |
||
295 | * |
||
296 | * @return string |
||
297 | * The client instruction regarding the translation. |
||
298 | */ |
||
299 | 6 | public function getInstructions() |
|
303 | |||
304 | /** |
||
305 | * Set the client reference. |
||
306 | * |
||
307 | * @param string $reference |
||
308 | * The reference to use in the order. |
||
309 | */ |
||
310 | 6 | public function setReference($reference) |
|
314 | |||
315 | /** |
||
316 | * Get the client reference. |
||
317 | * |
||
318 | * @return string |
||
319 | * The client reference. |
||
320 | */ |
||
321 | 6 | public function getReference() |
|
325 | |||
326 | /** |
||
327 | * Is there a confirmation needed before the translation may be processed. |
||
328 | * |
||
329 | * @return bool |
||
330 | * Needs confirmation true/false. |
||
331 | */ |
||
332 | 3 | public function needsConfirmation() |
|
336 | |||
337 | /** |
||
338 | * Get if an quotation is required before translation is processed. |
||
339 | * |
||
340 | * @return bool |
||
341 | * Needs quotation true/false. |
||
342 | */ |
||
343 | 3 | public function needsQuotation() |
|
347 | |||
348 | /** |
||
349 | * Add an input file to the order. |
||
350 | * |
||
351 | * @param string $file_name |
||
352 | * The file name of the file to add to the order. |
||
353 | */ |
||
354 | 9 | public function addFile($file_name) |
|
360 | |||
361 | /** |
||
362 | * Get the input files. |
||
363 | * |
||
364 | * @return array |
||
365 | * The input file names part of the translation order. |
||
366 | */ |
||
367 | 9 | public function getFiles() |
|
371 | } |
||
372 |