本文整理汇总了PHP中getJobData函数的典型用法代码示例。如果您正苦于以下问题:PHP getJobData函数的具体用法?PHP getJobData怎么用?PHP getJobData使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getJobData函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doAction
/**
* When Called it perform the controller action to retrieve/manipulate data
*
* @return mixed
*/
function doAction()
{
if (!empty($this->result['errors'])) {
return;
}
$job_data = getJobData($this->id_job, $this->pass);
if (empty($job_data)) {
$errorCode = -3;
$this->addError($errorCode);
return;
}
$first_seg = $job_data['job_first_segment'];
$last_seg = $job_data['job_last_segment'];
try {
$segments = $this->getNewSegments($first_seg, $last_seg);
Log::doLog("SEGS: " . implode(",", $segments));
$affected_rows = $this->copySegmentInTranslation($first_seg, $last_seg);
} catch (Exception $e) {
$errorCode = -4;
self::$errorMap[$errorCode]['internalMessage'] .= $e->getMessage();
$this->addError($errorCode);
return;
}
$this->result['data'] = array('code' => 1, 'segments_modified' => $affected_rows);
Log::doLog($this->result['data']);
}
示例2: doAction
public function doAction()
{
$this->generateAuthURL();
//pay a little query to avoid to fetch 5000 rows
$this->data = $jobData = getJobData($this->jid, $this->password);
$wStruct = new WordCount_Struct();
$wStruct->setIdJob($this->jid);
$wStruct->setJobPassword($this->password);
$wStruct->setNewWords($jobData['new_words']);
$wStruct->setDraftWords($jobData['draft_words']);
$wStruct->setTranslatedWords($jobData['translated_words']);
$wStruct->setApprovedWords($jobData['approved_words']);
$wStruct->setRejectedWords($jobData['rejected_words']);
if ($jobData['status'] == Constants_JobStatus::STATUS_ARCHIVED || $jobData['status'] == Constants_JobStatus::STATUS_CANCELLED) {
//this job has been archived
$this->job_archived = true;
$this->job_owner_email = $jobData['job_owner'];
}
$this->job_stats = CatUtils::getFastStatsForJob($wStruct);
$proj = getProject($jobData['id_project']);
$this->project_status = $proj[0];
/**
* Retrieve information about job errors
* ( Note: these information are fed by the revision process )
* @see setRevisionController
*/
$jobQA = new Revise_JobQA($this->jid, $this->password, $wStruct->getTotal());
$jobQA->retrieveJobErrorTotals();
$jobVote = $jobQA->evalJobVote();
$this->totalJobWords = $wStruct->getTotal();
$this->qa_data = $jobQA->getQaData();
$this->qa_overall_text = $jobVote['minText'];
$this->qa_overall_avg = $jobVote['avg'];
$this->qa_equivalent_class = $jobVote['equivalent_class'];
}
示例3: doAction
public function doAction()
{
$this->generateAuthURL();
//pay a little query to avoid to fetch 5000 rows
$this->jobData = $jobData = getJobData($this->jid, $this->password);
$wStruct = new WordCount_Struct();
$wStruct->setIdJob($this->jid);
$wStruct->setJobPassword($this->password);
$wStruct->setNewWords($jobData['new_words']);
$wStruct->setDraftWords($jobData['draft_words']);
$wStruct->setTranslatedWords($jobData['translated_words']);
$wStruct->setApprovedWords($jobData['approved_words']);
$wStruct->setRejectedWords($jobData['rejected_words']);
if ($jobData['status'] == Constants_JobStatus::STATUS_ARCHIVED || $jobData['status'] == Constants_JobStatus::STATUS_CANCELLED) {
//this job has been archived
$this->job_archived = true;
$this->job_owner_email = $jobData['job_owner'];
}
$tmp = CatUtils::getEditingLogData($this->jid, $this->password);
$this->data = $tmp[0];
$this->stats = $tmp[1];
$this->job_stats = CatUtils::getFastStatsForJob($wStruct);
$proj = getProject($jobData['id_project']);
$this->project_status = $proj[0];
}
示例4: doAction
public function doAction()
{
$this->result['token'] = $this->token;
if (empty($this->job)) {
$this->result['errors'][] = array("code" => -2, "message" => "missing id job");
return;
}
//get Job Info
$this->job_data = getJobData((int) $this->job, $this->password);
$pCheck = new AjaxPasswordCheck();
//check for Password correctness
if (!$pCheck->grantJobAccessByJobData($this->job_data, $this->password)) {
$this->result['errors'][] = array("code" => -10, "message" => "wrong password");
return;
}
switch ($this->function) {
case 'find':
$this->doSearch();
break;
case 'replaceAll':
$this->doReplaceAll();
break;
default:
$this->result['errors'][] = array("code" => -11, "message" => "unknown function. Use find or replace");
return;
}
}
示例5: doAction
/**
* When Called it perform the controller action to retrieve/manipulate data
*
* @return mixed
*/
function doAction()
{
if (count($this->errors) > 0) {
return null;
}
//get job language and data
//Fixed Bug: need a specific job, because we need The target Language
//Removed from within the foreach cycle, the job is always the same...
$jobData = $this->jobInfo = getJobData($this->jobID, $this->jobPass);
$pCheck = new AjaxPasswordCheck();
//check for Password correctness
if (empty($jobData) || !$pCheck->grantJobAccessByJobData($jobData, $this->jobPass)) {
$msg = "Error : wrong password provided for download \n\n " . var_export($_POST, true) . "\n";
Log::doLog($msg);
Utils::sendErrMailReport($msg);
return null;
}
$projectData = getProject($jobData['id_project']);
$source = $jobData['source'];
$target = $jobData['target'];
$tmsService = new TMSService();
/**
* @var $tmx SplTempFileObject
*/
$this->tmx = $tmsService->exportJobAsTMX($this->jobID, $this->jobPass, $source, $target);
$this->fileName = $projectData[0]['name'] . "-" . $this->jobID . ".tmx";
}
示例6: _checkData
protected function _checkData($logName = 'log.txt')
{
//change Log file
Log::$fileName = $logName;
$this->parseIDSegment();
if (empty($this->id_segment)) {
$this->result['errors'][] = array("code" => -1, "message" => "missing id_segment");
}
// $this->result[ 'errors' ][ ] = array( "code" => -1, "message" => "prova" );
// throw new Exception( "prova", -1 );
//strtoupper transforms null to "" so check for the first element to be an empty string
if (!empty($this->split_statuses[0]) && !empty($this->split_num)) {
if (count(array_unique($this->split_statuses)) == 1) {
//IF ALL translation chunks are in the same status, we take the status for the entire segment
$this->status = $this->split_statuses[0];
} else {
$this->status = Constants_TranslationStatus::STATUS_DRAFT;
}
foreach ($this->split_statuses as $pos => $value) {
$this->_checkForStatus($value);
}
} else {
$this->_checkForStatus($this->status);
}
if (empty($this->id_job)) {
$this->result['errors'][] = array("code" => -2, "message" => "missing id_job");
} else {
// $this->result[ 'error' ][ ] = array( "code" => -1000, "message" => "test 1" );
// throw new Exception( 'prova', -1 );
//get Job Info, we need only a row of jobs ( split )
$this->jobData = $job_data = getJobData((int) $this->id_job, $this->password);
if (empty($job_data)) {
$msg = "Error : empty job data \n\n " . var_export($_POST, true) . "\n";
Log::doLog($msg);
Utils::sendErrMailReport($msg);
}
//add check for job status archived.
if (strtolower($job_data['status']) == Constants_JobStatus::STATUS_ARCHIVED) {
$this->result['errors'][] = array("code" => -3, "message" => "job archived");
}
//check for Password correctness ( remove segment split )
$pCheck = new AjaxPasswordCheck();
if (empty($job_data) || !$pCheck->grantJobAccessByJobData($job_data, $this->password, $this->id_segment)) {
$this->result['errors'][] = array("code" => -10, "message" => "wrong password");
}
}
//ONE OR MORE ERRORS OCCURRED : EXITING
if (!empty($this->result['errors'])) {
$msg = "Error \n\n " . var_export(array_merge($this->result, $_POST), true);
throw new Exception($msg, -1);
}
if (is_null($this->translation) || $this->translation === '') {
Log::doLog("Empty Translation \n\n" . var_export($_POST, true));
// won't save empty translation but there is no need to return an errors
throw new Exception("Empty Translation \n\n" . var_export($_POST, true), 0);
}
}
示例7: doAction
public function doAction()
{
if (empty($this->segment)) {
$this->result['errors'][] = array("code" => -1, "message" => "missing source segment");
}
if (empty($this->translation)) {
$this->result['errors'][] = array("code" => -2, "message" => "missing target translation");
}
if (empty($this->source_lang)) {
$this->result['errors'][] = array("code" => -3, "message" => "missing source lang");
}
if (empty($this->target_lang)) {
$this->result['errors'][] = array("code" => -4, "message" => "missing target lang");
}
if (empty($this->time_to_edit)) {
$this->result['errors'][] = array("code" => -5, "message" => "missing time to edit");
}
if (empty($this->id_segment)) {
$this->result['errors'][] = array("code" => -6, "message" => "missing segment id");
}
//get Job Infos, we need only a row of jobs ( split )
$job_data = getJobData((int) $this->id_job, $this->password);
$pCheck = new AjaxPasswordCheck();
//check for Password correctness
if (empty($job_data) || !$pCheck->grantJobAccessByJobData($job_data, $this->password)) {
$this->result['errors'][] = array("code" => -10, "message" => "wrong password");
$msg = "\n\n Error \n\n " . var_export(array_merge($this->result, $_POST), true);
Log::doLog($msg);
Utils::sendErrMailReport($msg);
return;
}
//mt engine to contribute to
if ($job_data['id_mt_engine'] <= 1) {
return false;
}
$this->mt = Engine::getInstance($job_data['id_mt_engine']);
//array of storicised suggestions for current segment
$this->suggestion_json_array = json_decode(getArrayOfSuggestionsJSON($this->id_segment), true);
//extra parameters
$extra = json_encode(array('id_segment' => $this->id_segment, 'suggestion_json_array' => $this->suggestion_json_array, 'chosen_suggestion_index' => $this->chosen_suggestion_index, 'time_to_edit' => $this->time_to_edit));
//send stuff
$config = $this->mt->getConfigStruct();
$config['segment'] = CatUtils::view2rawxliff($this->segment);
$config['translation'] = CatUtils::view2rawxliff($this->translation);
$config['source'] = $this->source_lang;
$config['target'] = $this->target_lang;
$config['email'] = INIT::$MYMEMORY_API_KEY;
$config['segid'] = $this->id_segment;
$config['extra'] = $extra;
$config['id_user'] = array("TESTKEY");
$outcome = $this->mt->set($config);
if ($outcome->error->code < 0) {
$this->result['errors'] = $outcome->error->get_as_array();
}
}
示例8: getData
public function getData($job_id, $password, $options = array())
{
$data = getJobData($job_id, $password);
$wCounter = new WordCount_Counter();
$wStruct = $wCounter->initializeJobWordCount($job_id, $password);
$jobQA = new Revise_JobQA($job_id, $password, $wStruct->getTotal());
$jobQA->retrieveJobErrorTotals();
$jobQA->evalJobVote();
$jobVote = $jobQA->getJobVote();
return array('job_id' => $job_id, 'quality_details' => $jobQA->getQaData(), 'quality_overall' => $jobVote['minText']);
}
示例9: doAction
public function doAction()
{
$this->job_info = getJobData($this->id_job, $this->password);
/**
* For future reminder
*
* MyMemory (id=1) should not be the only Glossary provider
*
*/
$this->_TMS = Engine::getInstance(1);
$this->checkLogin();
try {
$config = $this->_TMS->getConfigStruct();
$config['segment'] = $this->segment;
$config['translation'] = $this->translation;
$config['tnote'] = $this->comment;
$config['source'] = $this->job_info['source'];
$config['target'] = $this->job_info['target'];
$config['email'] = INIT::$MYMEMORY_API_KEY;
$config['id_user'] = $this->job_info['id_translator'];
$config['isGlossary'] = true;
$config['get_mt'] = null;
$config['num_result'] = 100;
//do not want limit the results from glossary: set as a big number
switch ($this->exec) {
case 'get':
$this->_get($config);
break;
case 'set':
/**
* For future reminder
*
* MyMemory should not be the only Glossary provider
*
*/
if ($this->job_info['id_tms'] == 0) {
throw new Exception("Glossary is not available when the TM feature is disabled", -11);
}
$this->_set($config);
break;
case 'update':
$this->_update($config);
break;
case 'delete':
$this->_delete($config);
break;
}
} catch (Exception $e) {
$this->result['errors'][] = array("code" => $e->getCode(), "message" => $e->getMessage());
}
}
示例10: doAction
public function doAction()
{
$this->job = getJobData($this->__postInput['id_job'], $this->__postInput['password']);
$this->checkLogin();
if ($this->userIsLogged) {
$this->loadUser();
}
$pCheck = new AjaxPasswordCheck();
if (!$pCheck->grantJobAccessByJobData($this->job, $this->__postInput['password'])) {
$this->result['errors'][] = array("code" => -10, "message" => "wrong password");
return;
}
$this->route();
}
示例11: __construct
public function __construct()
{
parent::__construct();
//Session Enabled
//define input filters
$filterArgs = array('job_id' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'job_pass' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH));
//filter input
$_postInput = filter_input_array(INPUT_POST, $filterArgs);
//assign variables
$this->job_id = $_postInput['job_id'];
$this->job_pass = $_postInput['job_pass'];
$this->tm_keys = $_POST['data'];
// this will be filtered inside the TmKeyManagement class
//check for eventual errors on the input passed
$this->result['errors'] = array();
if (empty($this->job_id)) {
$this->result['errors'][] = array('code' => -1, 'message' => "Job id missing");
}
if (empty($this->job_pass)) {
$this->result['errors'][] = array('code' => -2, 'message' => "Job pass missing");
}
//get job data
$this->jobData = getJobData($this->job_id, $this->job_pass);
//Check if user can access the job
$pCheck = new AjaxPasswordCheck();
//check for Password correctness
if (empty($this->jobData) || !$pCheck->grantJobAccessByJobData($this->jobData, $this->job_pass)) {
$this->result['errors'][] = array("code" => -10, "message" => "Wrong password");
}
$this->checkLogin();
if (self::isRevision()) {
$this->userRole = TmKeyManagement_Filter::ROLE_REVISOR;
} elseif ($this->userMail == $this->jobData['owner']) {
$this->userRole = TmKeyManagement_Filter::OWNER;
}
}
示例12: performQuote
/**
* Perform a quote on the remote Provider server
*
* @see OutsourceTo_AbstractProvider::performQuote
*
* @param array|null $volAnalysis
*/
public function performQuote($volAnalysis = null)
{
/**
* cache this job info for 20 minutes ( session duration )
*/
$cache_cart = Shop_Cart::getInstance('outsource_to_external_cache');
if ($volAnalysis == null) {
//call matecat API for Project status and information
$project_url_api = INIT::$HTTPHOST . INIT::$BASEURL . "api/status?id_project=" . $this->pid . "&project_pass=" . $this->ppassword;
if (!$cache_cart->itemExists($project_url_api)) {
//trick/hack for shop cart
//Use the shop cart to add Projects info
//to the cache cart because of taking advantage of the cart cache invalidation on project split/merge
Log::doLog("Project Not Found in Cache. Call API url for STATUS: " . $project_url_api);
$options = array(CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => 0, CURLOPT_USERAGENT => INIT::MATECAT_USER_AGENT . INIT::$BUILD_NUMBER, CURLOPT_CONNECTTIMEOUT => 5, CURLOPT_SSL_VERIFYPEER => true, CURLOPT_SSL_VERIFYHOST => 2);
//prepare handlers for curl to quote service
$mh = new MultiCurlHandler();
$resourceHash = $mh->createResource($project_url_api, $options);
$mh->multiExec();
if ($mh->hasError($resourceHash)) {
Log::doLog($mh->getError($resourceHash));
}
$raw_volAnalysis = $mh->getSingleContent($resourceHash);
$mh->multiCurlCloseAll();
//retrieve the project subject: pick the project's first job and get the subject
$jobData = getJobData($this->jobList[0]['jid'], $this->jobList[0]['jpassword']);
$subject = $jobData['subject'];
$itemCart = new Shop_ItemHTSQuoteJob();
$itemCart['id'] = $project_url_api;
$itemCart['show_info'] = $raw_volAnalysis;
$itemCart['subject'] = $subject;
$cache_cart->addItem($itemCart);
} else {
$tmp_project_cache = $cache_cart->getItem($project_url_api);
$raw_volAnalysis = $tmp_project_cache['show_info'];
$subject = $tmp_project_cache['subject'];
}
// Log::doLog( $raw_volAnalysis );
$volAnalysis = json_decode($raw_volAnalysis, true);
}
// Log::doLog( $volAnalysis );
$_jobLangs = array();
$options = array(CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => 0, CURLOPT_USERAGENT => INIT::MATECAT_USER_AGENT . INIT::$BUILD_NUMBER, CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_SSL_VERIFYPEER => true, CURLOPT_SSL_VERIFYHOST => 2);
//prepare handlers for curl to quote service
$mh = new MultiCurlHandler();
foreach ($this->jobList as $job) {
//trim decimals to int
$job_payableWords = (int) $volAnalysis['data']['jobs'][$job['jid']]['totals'][$job['jpassword']]['TOTAL_PAYABLE'][0];
/*
* //languages are in the form:
*
* "langpairs":{
* "5888-e94bd2f79afd":"en-GB|fr-FR",
* "5889-c853a841dafd":"en-GB|de-DE",
* "5890-e852ca45c66e":"en-GB|it-IT",
* "5891-b43f2f067319":"en-GB|es-ES"
* },
*
*/
$langPairs = $volAnalysis['jobs']['langpairs'][$job['jid'] . "-" . $job['jpassword']];
$_langPairs_array = explode("|", $langPairs);
$source = $_langPairs_array[0];
$target = $_langPairs_array[1];
//save langpairs of the jobs
$_jobLangs[$job['jid'] . "-" . $job['jpassword']]['source'] = $source;
$_jobLangs[$job['jid'] . "-" . $job['jpassword']]['target'] = $target;
$url = "https://www.translated.net/hts/?f=quote&cid=htsdemo&p=htsdemo5&s={$source}&t={$target}&pn=MATECAT_{$job['jid']}-{$job['jpassword']}&w={$job_payableWords}&df=matecat&matecat_pid=" . $this->pid . "&matecat_ppass=" . $this->ppassword . "&matecat_pname=" . $volAnalysis['data']['summary']['NAME'] . "&subject=" . $subject;
if (!$cache_cart->itemExists($job['jid'] . "-" . $job['jpassword'])) {
Log::doLog("Not Found in Cache. Call url for Quote: " . $url);
$tokenHash = $mh->createResource($url, $options, $job['jid'] . "-" . $job['jpassword']);
} else {
$cartElem = $cache_cart->getItem($job['jid'] . "-" . $job['jpassword']);
$cartElem["currency"] = $this->currency;
$cartElem["timezone"] = $this->timezone;
$cache_cart->delItem($job['jid'] . "-" . $job['jpassword']);
$cache_cart->addItem($cartElem);
}
}
$mh->multiExec();
$res = $mh->getAllContents();
$failures = array();
//fetch contents and store in cache if there are
foreach ($res as $jpid => $quote) {
if ($mh->hasError($jpid)) {
Log::doLog($mh->getError($jpid));
}
/*
* Quotes are plain text line feed separated fields in the form:
* 1
* OK
* 2014-04-16T09:30:00Z
* 488
* 46.36
//.........这里部分代码省略.........
示例13: doAction
public function doAction()
{
if (empty($this->source_lang)) {
$this->result['errors'][] = array("code" => -1, "message" => "missing source_lang");
}
if (empty($this->target_lang)) {
$this->result['errors'][] = array("code" => -2, "message" => "missing target_lang");
}
if (empty($this->source)) {
$this->result['errors'][] = array("code" => -3, "message" => "missing source");
}
if (empty($this->target)) {
$this->result['errors'][] = array("code" => -4, "message" => "missing target");
}
//get Job Infos
$job_data = getJobData((int) $this->id_job, $this->password);
$pCheck = new AjaxPasswordCheck();
//check for Password correctness
if (empty($job_data) || !$pCheck->grantJobAccessByJobData($job_data, $this->password)) {
$this->result['errors'][] = array("code" => -10, "message" => "wrong password");
return;
}
$this->tm_keys = $job_data['tm_keys'];
$this->checkLogin();
$tms = Engine::getInstance($job_data['id_tms']);
$config = $tms->getConfigStruct();
// $config = TMS::getConfigStruct();
$config['segment'] = CatUtils::view2rawxliff($this->source);
$config['translation'] = CatUtils::view2rawxliff($this->target);
$config['source'] = $this->source_lang;
$config['target'] = $this->target_lang;
$config['email'] = "demo@matecat.com";
$config['id_user'] = array();
//get job's TM keys
try {
$tm_keys = $this->tm_keys;
if (self::isRevision()) {
$this->userRole = TmKeyManagement_Filter::ROLE_REVISOR;
} elseif ($this->userMail == $job_data['owner']) {
$tm_keys = TmKeyManagement_TmKeyManagement::getOwnerKeys(array($tm_keys), 'r', 'tm');
$tm_keys = json_encode($tm_keys);
}
//get TM keys with read grants
$tm_keys = TmKeyManagement_TmKeyManagement::getJobTmKeys($tm_keys, 'r', 'tm', $this->uid, $this->userRole);
if (is_array($tm_keys) && !empty($tm_keys)) {
foreach ($tm_keys as $tm_key) {
$config['id_user'][] = $tm_key->key;
}
}
} catch (Exception $e) {
$this->result['errors'][] = array("code" => -11, "message" => "Cannot retrieve TM keys info.");
return;
}
//prepare the errors report
$set_code = array();
/**
* @var $tm_key TmKeyManagement_TmKeyStruct
*/
//if there's no key
if (empty($tm_keys)) {
//try deleting anyway, it may be a public segment and it may work
$TMS_RESULT = $tms->delete($config);
$set_code[] = $TMS_RESULT;
} else {
//loop over the list of keys
foreach ($tm_keys as $tm_key) {
//issue a separate call for each key
$config['id_user'] = $tm_key->key;
$TMS_RESULT = $tms->delete($config);
$set_code[] = $TMS_RESULT;
}
}
$set_successful = true;
if (array_search(false, $set_code, true)) {
//There's an errors
$set_successful = false;
}
$this->result['data'] = $set_successful ? "OK" : null;
$this->result['code'] = $set_successful;
}
示例14: doAction
public function doAction()
{
$this->parseIDSegment();
//get Job Infos
$job_data = getJobData((int) $this->id_job);
$pCheck = new AjaxPasswordCheck();
if (!$pCheck->grantJobAccessByJobData($job_data, $this->password)) {
$this->result['errors'][] = array("code" => -10, "message" => "wrong password");
}
if (empty($this->id_segment)) {
$this->result['errors'][] = array("code" => -1, "message" => "missing segment id");
}
if (empty($this->id_job)) {
$this->result['errors'][] = array("code" => -2, "message" => "missing Job id");
}
if (!empty($this->result['errors'])) {
//no action on errors
return;
}
$segmentStruct = TranslationsSplit_SplitStruct::getStruct();
$segmentStruct->id_segment = $this->id_segment;
$segmentStruct->id_job = $this->id_job;
$translationDao = new TranslationsSplit_SplitDAO(Database::obtain());
$currSegmentInfo = $translationDao->read($segmentStruct);
/**
* Split check control
*/
$isASplittedSegment = false;
$isLastSegmentChunk = true;
if (count($currSegmentInfo) > 0) {
$isASplittedSegment = true;
$currSegmentInfo = array_shift($currSegmentInfo);
//get the chunk number and check whether it is the last one or not
$isLastSegmentChunk = $this->split_num == count($currSegmentInfo->source_chunk_lengths) - 1;
if (!$isLastSegmentChunk) {
$nextSegmentId = $this->id_segment . "-" . ($this->split_num + 1);
}
}
/**
* End Split check control
*/
if (!$isASplittedSegment || $isLastSegmentChunk) {
$segmentList = getNextSegment($this->id_segment, $this->id_job, $this->password, !self::isRevision() ? false : true);
if (!self::isRevision()) {
$nextSegmentId = fetchStatus($this->id_segment, $segmentList);
} else {
$nextSegmentId = fetchStatus($this->id_segment, $segmentList, Constants_TranslationStatus::STATUS_TRANSLATED);
if (!$nextSegmentId) {
$nextSegmentId = fetchStatus($this->id_segment, $segmentList, Constants_TranslationStatus::STATUS_APPROVED);
}
}
}
$insertRes = setCurrentSegmentInsert($this->id_segment, $this->id_job, $this->password);
$this->result['code'] = 1;
$this->result['data'] = array();
//get segment revision informations
$reviseDao = new Revise_ReviseDAO(Database::obtain());
$searchReviseStruct = Revise_ReviseStruct::getStruct();
$searchReviseStruct->id_job = $this->id_job;
$searchReviseStruct->id_segment = $this->id_segment;
$_dbReviseStruct = $reviseDao->read($searchReviseStruct);
if (count($_dbReviseStruct) > 0) {
$_dbReviseStruct = $_dbReviseStruct[0];
} else {
$_dbReviseStruct = Revise_ReviseStruct::getStruct();
}
$_dbReviseStruct = Revise_ReviseStruct::setDefaultValues($_dbReviseStruct);
$dbReviseStruct = self::prepareReviseStructReturnValues($_dbReviseStruct);
$this->result['nextSegmentId'] = $nextSegmentId;
$this->result['error_data'] = $dbReviseStruct;
$this->result['original'] = CatUtils::rawxliff2view($_dbReviseStruct->original_translation);
}
示例15: doAction
public function doAction()
{
//get Job Infos
$job_data = getJobData($this->jid);
$pCheck = new AjaxPasswordCheck();
//check for Password correctness
if (!$pCheck->grantJobAccessByJobData($job_data, $this->password)) {
$this->result['errors'][] = array("code" => -10, "message" => "wrong password");
return;
}
$lang_handler = Langs_Languages::getInstance();
if ($this->ref_segment == '') {
$this->ref_segment = 0;
}
$data = getMoreSegments($this->jid, $this->password, $this->step, $this->ref_segment, $this->where);
$this->prepareNotes($data);
foreach ($data as $i => $seg) {
if ($this->where == 'before') {
if ((double) $seg['sid'] >= (double) $this->ref_segment) {
break;
}
}
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;
}
if (empty($this->err)) {
$this->err = $seg['serialized_errors_list'];
}
$id_file = $seg['id_file'];
if (!isset($this->data["{$id_file}"])) {
$this->data["{$id_file}"]['jid'] = $seg['jid'];
$this->data["{$id_file}"]["filename"] = ZipArchiveExtended::getFileName($seg['filename']);
$this->data["{$id_file}"]["mime_type"] = $seg['mime_type'];
$this->data["{$id_file}"]['source'] = $lang_handler->getLocalizedName($seg['source']);
$this->data["{$id_file}"]['target'] = $lang_handler->getLocalizedName($seg['target']);
$this->data["{$id_file}"]['source_code'] = $seg['source'];
$this->data["{$id_file}"]['target_code'] = $seg['target'];
$this->data["{$id_file}"]['segments'] = array();
}
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['serialized_errors_list']);
$seg['parsed_time_to_edit'] = CatUtils::parse_time_to_edit($seg['time_to_edit']);
$seg['source_chunk_lengths'] === null ? $seg['source_chunk_lengths'] = '[]' : null;
$seg['target_chunk_lengths'] === null ? $seg['target_chunk_lengths'] = '{"len":[0],"statuses":["DRAFT"]}' : null;
$seg['source_chunk_lengths'] = json_decode($seg['source_chunk_lengths'], true);
$seg['target_chunk_lengths'] = json_decode($seg['target_chunk_lengths'], true);
$seg['segment'] = CatUtils::rawxliff2view(CatUtils::reApplySegmentSplit($seg['segment'], $seg['source_chunk_lengths']));
$seg['translation'] = CatUtils::rawxliff2view(CatUtils::reApplySegmentSplit($seg['translation'], $seg['target_chunk_lengths']['len']));
$this->attachNotes($seg);
$this->data["{$id_file}"]['segments'][] = $seg;
}
$this->result['data']['files'] = $this->data;
$this->result['data']['where'] = $this->where;
}