/** * Send a request for download * * First basic implementation * TODO in the future we would send a mail with link for direct prepared download */ public function downloadTMX() { /** * @var $result Engines_Results_MyMemory_ExportResponse */ $result = $this->mymemory_engine->createExport($this->tm_key); if ($result->responseDetails == 'QUEUED' && $result->responseStatus == 202) { do { /** * @var $result Engines_Results_MyMemory_ExportResponse */ $result = $this->mymemory_engine->checkExport($this->tm_key); usleep(1500000); // 1.5 seconds } while ($result->responseDetails != 'READY' && $result->responseDetails != 'NO SEGMENTS'); if (!isset($result->responseDetails)) { throw new Exception("Status check failed. Export broken.", -16); } if ($result->responseDetails == 'NO SEGMENTS') { throw new DomainException("No translation memories found to download.", -17); } $_download_url = parse_url($result->resourceLink); parse_str($_download_url['query'], $secrets); list($_key, $pass) = array_values($secrets); } else { throw new Exception("Critical. Export Creation Failed.", -18); } $resource_pointer = $this->mymemory_engine->downloadExport($this->tm_key, $pass); return $resource_pointer; }
protected function _delete($config) { $tm_keys = $this->job_info['tm_keys']; if (self::isRevision()) { $this->userRole = TmKeyManagement_Filter::ROLE_REVISOR; } //get TM keys with read grants $tm_keys = TmKeyManagement_TmKeyManagement::getJobTmKeys($tm_keys, 'w', 'glos', $this->uid, $this->userRole); $config['segment'] = CatUtils::view2rawxliff($config['segment']); $config['translation'] = CatUtils::view2rawxliff($config['translation']); //prepare the error report $set_code = array(); //set the glossary entry for each key with write grants if (count($tm_keys)) { /** * @var $tm_key TmKeyManagement_TmKeyStruct */ foreach ($tm_keys as $tm_key) { $config['id_user'] = $tm_key->key; $TMS_RESULT = $this->_TMS->delete($config); $set_code[] = $TMS_RESULT; } } $set_successful = true; if (array_search(false, $set_code, true)) { $set_successful = false; } $this->result['code'] = $set_successful; $this->result['data'] = $set_successful ? 'OK' : null; }