public function doAction() { if (empty($this->id_segment)) { $this->result['error'][] = array("code" => -1, "message" => "missing id_segment"); } if (empty($this->id_job)) { $this->result['error'][] = array("code" => -2, "message" => "missing id_job"); } if (empty($this->id_first_file)) { $this->result['error'][] = array("code" => -2, "message" => "missing id_job"); } if (empty($this->time_to_edit)) { $this->time_to_edit = 0; } if (empty($this->status)) { $this->status = 'DRAFT'; } if (empty($this->translation)) { log::doLog("empty"); return 0; // won's save empty translation but there is no need to return an error } //ONE OR MORE ERRORS OCCURRED : EXITING if (!empty($this->result['error'])) { log::doLog("Generic Error in SetTranslationController"); return -1; } $this->translation = CatUtils::view2rawxliff($this->translation); $res = CatUtils::addSegmentTranslation($this->id_segment, $this->id_job, $this->status, $this->time_to_edit, $this->translation); if (!empty($res['error'])) { $this->result['error'] = $res['error']; return -1; } $job_stats = CatUtils::getStatsForJob($this->id_job); $file_stats = CatUtils::getStatsForFile($this->id_first_file); $this->result['stats'] = $job_stats; $this->result['file_stats'] = $file_stats; $this->result['code'] = 1; $this->result['data'] = "OK"; }
public function doAction() { $lang_handler = languages::getInstance("en"); // log::doLog('REF SEGMENT: '.$this->ref_segment); if ($this->ref_segment == '') { $this->ref_segment = 0; } // CASMACAT extension start if ($this->casIsReplaying) { $data = getMoreSegmentsWithoutTranslation($this->jid, $this->password, $this->step, $this->ref_segment, $this->where); } else { $data = getMoreSegments($this->jid, $this->password, $this->step, $this->ref_segment, $this->where); } // CASMACAT extension end $first_not_translated_found = false; //log::doLog('REF SEGMENT: '.$this->ref_segment); // print_r($data); exit; foreach ($data as $i => $seg) { if ($this->where == 'before') { if ((double) $seg['sid'] >= (double) $this->ref_segment) { break; } } // remove this when tag management enabled // $seg['segment'] = $this->stripTagsFromSource($seg['segment']); if (empty($this->pname)) { $this->pname = $seg['pname']; } if (empty($this->last_opened_segment)) { $this->last_opened_segment = $seg['last_opened_segment']; } if (empty($this->cid)) { $this->cid = $seg['cid']; } if (empty($this->pid)) { $this->pid = $seg['pid']; } if (empty($this->tid)) { $this->tid = $seg['tid']; } if (empty($this->create_date)) { $this->create_date = $seg['create_date']; } if (empty($this->source_code)) { $this->source_code = $seg['source']; } if (empty($this->target_code)) { $this->target_code = $seg['target']; } if (empty($this->source)) { $s = explode("-", $seg['source']); $source = strtoupper($s[0]); $this->source = $source; } if (empty($this->target)) { $t = explode("-", $seg['target']); $target = strtoupper($t[0]); $this->target = $target; } $id_file = $seg['id_file']; $file_stats = CatUtils::getStatsForFile($id_file); if (!isset($this->data["{$id_file}"])) { $this->data["{$id_file}"]['jid'] = $seg['jid']; $this->data["{$id_file}"]["filename"] = $seg['filename']; $this->data["{$id_file}"]["mime_type"] = $seg['mime_type']; $this->data["{$id_file}"]['id_segment_start'] = $seg['id_segment_start']; $this->data["{$id_file}"]['id_segment_end'] = $seg['id_segment_end']; $this->data["{$id_file}"]['source'] = $lang_handler->iso2Language($seg['source']); $this->data["{$id_file}"]['target'] = $lang_handler->iso2Language($seg['target']); $this->data["{$id_file}"]['source_code'] = $seg['source']; $this->data["{$id_file}"]['target_code'] = $seg['target']; $this->data["{$id_file}"]['file_stats'] = $file_stats; $this->data["{$id_file}"]['segments'] = array(); } //if (count($this->data["$id_file"]['segments'])>100){continue;} $this->filetype_handler = new filetype($seg['mime_type']); unset($seg['id_file']); unset($seg['source']); unset($seg['target']); unset($seg['source_code']); unset($seg['target_code']); unset($seg['mime_type']); unset($seg['filename']); unset($seg['jid']); unset($seg['pid']); unset($seg['cid']); unset($seg['tid']); unset($seg['pname']); unset($seg['create_date']); unset($seg['id_segment_end']); unset($seg['id_segment_start']); // log::doLog('A'); $seg['segment'] = $this->filetype_handler->parse($seg['segment']); // ASKED. MARCO CONFIRMED: in the web interface do not show xliff_ext_prec_tags and xliff_ext_succ_tags // $seg['segment'] = $seg['xliff_ext_prec_tags'] . $seg['segment'].$seg['xliff_ext_succ_tags'] ; $seg['segment'] = CatUtils::rawxliff2view($seg['segment']); $seg['translation'] = CatUtils::rawxliff2view($seg['translation']); $seg['parsed_time_to_edit'] = $this->parse_time_to_edit($seg['time_to_edit']); $this->data["{$id_file}"]['segments'][] = $seg; } //log::doLog ($this->data); $this->result['data']['files'] = $this->data; $this->result['data']['where'] = $this->where; }
public function doAction() { $files_found = array(); $lang_handler = languages::getInstance("en"); // CASMACAT extension start // if ($this->casIsReplaying) { // $data = getSegmentsInfoWithoutTranslation($this->jid, $this->password, $this->start_from, $this->step); // } // else { $data = getSegmentsInfo($this->jid, $this->password); // } // CASMACAT extension end if (empty($data) or $data < 0) { $this->job_not_found = true; } // echo "<pre>"; // print_r ($data); // exit; $first_not_translated_found = false; foreach ($data as $i => $seg) { if (empty($this->pname)) { $this->pname = $seg['pname']; $this->downloadFileName = $seg['pname'] . ".zip"; // will be overwritten below in case of one file job } if (empty($this->last_opened_segment)) { $this->last_opened_segment = $seg['last_opened_segment']; } if (empty($this->cid)) { $this->cid = $seg['cid']; } if (empty($this->pid)) { $this->pid = $seg['pid']; } if (empty($this->tid)) { $this->tid = $seg['tid']; } if (empty($this->create_date)) { $this->create_date = $seg['create_date']; } if (empty($this->source_code)) { $this->source_code = $seg['source']; } if (empty($this->target_code)) { $this->target_code = $seg['target']; } if (empty($this->source)) { $s = explode("-", $seg['source']); $source = strtoupper($s[0]); $this->source = $source; } if (empty($this->target)) { $t = explode("-", $seg['target']); $target = strtoupper($t[0]); $this->target = $target; } $id_file = $seg['id_file']; $this->fid = $id_file; if (!isset($this->data["{$id_file}"])) { $files_found[] = $seg['filename']; $file_stats = CatUtils::getStatsForFile($id_file); $this->data["{$id_file}"]['jid'] = $seg['jid']; $this->data["{$id_file}"]["filename"] = $seg['filename']; $this->data["{$id_file}"]["mime_type"] = $seg['mime_type']; $this->data["{$id_file}"]['id_segment_start'] = $seg['id_segment_start']; $this->data["{$id_file}"]['id_segment_end'] = $seg['id_segment_end']; $this->data["{$id_file}"]['source'] = $lang_handler->iso2Language($seg['source']); $this->data["{$id_file}"]['target'] = $lang_handler->iso2Language($seg['target']); $this->data["{$id_file}"]['source_code'] = $seg['source']; $this->data["{$id_file}"]['target_code'] = $seg['target']; $this->data["{$id_file}"]['last_opened_segment'] = $seg['last_opened_segment']; $this->data["{$id_file}"]['file_stats'] = $file_stats; //$this->data["$id_file"]['segments'] = array(); } //if (count($this->data["$id_file"]['segments'])>100){continue;} $this->filetype_handler = new filetype($seg['mime_type']); unset($seg['id_file']); unset($seg['source']); unset($seg['target']); unset($seg['source_code']); unset($seg['target_code']); unset($seg['mime_type']); unset($seg['filename']); unset($seg['jid']); unset($seg['pid']); unset($seg['cid']); unset($seg['tid']); unset($seg['pname']); unset($seg['create_date']); unset($seg['id_segment_end']); unset($seg['id_segment_start']); unset($seg['last_opened_segment']); } if (empty($this->last_opened_segment)) { $this->last_opened_segment = getFirstSegmentId($this->jid, $this->password); log::doLog($this->last_opened_segment); } $this->job_stats = CatUtils::getStatsForJob($this->jid, $this->casIsReplaying); if (count($files_found) == 1) { $this->downloadFileName = $files_found[0]; } // CASMACAT start if ($this->casIsReplaying) { $this->initCfg = json_decode(fetchInitialConfig($this->jid, $this->fid)); log::doLog("CASMACAT: Initial config: " . print_r($this->initCfg, true)); } // CASMACAT end // echo "<pre>"; // print_r($this->data); // exit; }