25, 'password' => 'YOUR_PASSWORD', 'client' => 'YOUR_COMPANY_LOGIN'); public $customer = array('id' => 1260); // existing customer ID public $linguist = array('id' => 25); // existing linguist ID public $sourceLanguage = 'en_GB'; // source language public $targetLanguages = array('es_ES', 'de_DE'); // list of target languages public $downloadDirectory = 'D:\\tmp\\'; public $proxy; public function __construct() { $this->proxy = new SoapClient($this->wsdl); } } $configuration = new XTMAPICustomerConfiguration(); ///////////////////////////// END client configuration //////////////////////// SCENARIOS //////////////////////// try { getXTMInfo(); getSupportedFilesInfo(); $templateResponse = createTemplate(); obtainPMTemplateEditorLink($templateResponse->templateDescriptor); // Choose one of two methods to create a project // $projectResponse = createProjectURL(); $projectResponse = createProjectMTOM(); $projectDescriptor = $projectResponse->projectDescriptor; updateProject($projectDescriptor); $jobsDescriptors = jobsDescriptors($projectResponse); checkProjectAnalysisCompletion($projectDescriptor); $projectResponse2 = createProjectMTOM(); $projectDescriptor2 = $projectResponse2->projectDescriptor; checkProjectAnalysisCompletion($projectDescriptor2); obtainJobMetrics($jobsDescriptors); obtainProjectMetrics($projectDescriptor); updateTranslationFilesMTOM($projectDescriptor); // updateTranslationFilesURL($projectDescriptor); checkProjectAnalysisCompletion($projectDescriptor); updateTargetLanguages($projectDescriptor); $projectStatus = checkProjectAnalysisCompletion($projectDescriptor); $jobsDescriptors = jobsDescriptorsFromProjectStatus($projectStatus); updateProjectWorkflow($projectDescriptor); assignLinguistToJob($jobsDescriptors); assignLinguistToProject($projectDescriptor); startProject($projectDescriptor); checkJobCompletion($jobsDescriptors); checkProjectCompletion($projectDescriptor); moveJobWorkflow($jobsDescriptors); moveProjectWorkflow($projectDescriptor); $jobFileBaseResponse = generateJobFile($jobsDescriptors); $filesDescriptors = array($jobFileBaseResponse->fileDescriptor); checkJobFileCompletion($filesDescriptors); obtainProjectEstimates($projectDescriptor); updateProjectEstimates($projectDescriptor); downloadProjectURL($projectDescriptor); downloadJobURL($jobsDescriptors); downloadProjectMTOM($projectDescriptor); downloadJobMTOM($jobsDescriptors); // downloadJobFileURL($filesDescriptors); downloadJobFileMTOM($filesDescriptors); $fileDescriptor = generateProjectFile($projectDescriptor); $filesDescriptors = array($fileDescriptor); checkProjectFileCompletion($filesDescriptors); // downloadProjectFileURL($filesDescriptors); downloadProjectFileMTOM($filesDescriptors); updateJobStepProperty($jobsDescriptors); updateProjectStepProperty($projectDescriptor); obtainPMProjectEditorLink($projectDescriptor); obtainProjectStatistics($projectDescriptor); obtainProjectAllStatistics($projectDescriptor); findProject($projectDescriptor); updateReferenceFilesMTOM($projectDescriptor, $configuration->customer); //adds reference files to the project // updateReferenceFilesMTOM(null, $configuration->customer); //adds reference files to the customer updateReferenceFilesURL($projectDescriptor, $configuration->customer); // updateReferenceFilesURL(null, $configuration->customer); obtainJobExtraInfo($jobsDescriptors); obtainProjectExtraInfo($projectDescriptor); updateJobWorkflowActivity($jobsDescriptors); updateProjectWorkflowActivity($projectDescriptor); obtainProjectEstimates($projectDescriptor); //updateProjectEstimates($projectDescriptor); $similarityDescriptor = generateProjectsSimilarity($projectDescriptor, $projectDescriptor2); obtainProjectsSimilarity($similarityDescriptor); updateProjectActivity($projectDescriptor); print('

Done!'); exit(); } catch (Exception $e) { printf("Error: %s\n
", $e->getMessage()); if (isset($e->Reason)) { printf("Reason: %s\n
", $e->Reason); } var_dump($e); } function getXTMInfo() { global $configuration; methodName('getXTMInfo'); $input = array('loginAPI' => $configuration->loginAPI); $res = $configuration->proxy->getXTMInfo($input); $infoResponse = $res->return; $xtmInfo = $infoResponse->xtmInfo; if(isset($xtmInfo)) { print('Company name: ' . $xtmInfo->companyName . '
'); print('Version: ' . $xtmInfo->version . '
'); print('Website: ' . $xtmInfo->website . '
'); print('Logo: ' . $xtmInfo->logo . '
'); } } function getSupportedFilesInfo() { global $configuration; methodName('getSupportedFilesInfo'); $input = array('loginAPI' => $configuration->loginAPI); $res = $configuration->proxy->getSupportedFilesInfo($input); $supportedFilesInfoResponse = $res->return; $supportedFilesInfo = $supportedFilesInfoResponse->supportedFilesInfo; $supported = array(); foreach ($supportedFilesInfo->supportedFiles as $supportedFile) { $supported[] = $supportedFile->extension; } print('Supported files: ' . join(', ', $supported) . '
'); $unsupported = array(); foreach ($supportedFilesInfo->notSupportedFiles as $notSupportedFile) { $extension = $notSupportedFile->extension; $supported = array(); if(isset($notSupportedFile->supportedFiles) && count($notSupportedFile->supportedFiles) > 0) { foreach ($notSupportedFile->supportedFiles as $supportedFile) { if(is_object($supportedFile)) { $supported[] = $supportedFile->extension; } } $extension .= ' -> (' . join(', ', $supported) . ')'; } $unsupported[] = $extension; } print('Not supported files: ' . join(', ', $unsupported) . '
'); } function createProjectURL() { global $configuration; methodName('createProjectURL'); // $daysTag = array('name' => 'day', 'values' => array(array('name' => 'Monday'), array('name' => 'Tuesday'))); // $monthTag = array('name' => 'month', 'values' => array(array('name' => 'February'))); // $penaltyProfile = array('name' => 'time'); $fileURL = array('fileURL' => $configuration->sourceFile, 'fileName' => $configuration->sourceFileName, 'externalDescriptors' => array()); // $projectCallback = array('jobFinishedCallback' => "http://localhost", //This url will be invoked when job is completed. // 'projectFinishedCallback' => "http://localhost", //This url will be invoked when project is completed. // 'analysisFinishedCallback' => "http://localhost", //This url will be invoked when analysis is completed. // 'workflowTransitionCallback' => "http://localhost"); //This url will be invoked when workflow transitions. // $fuzzySearch = 'ALWAYS'; //Options for fuzzySearch include: ALWAYS, EVEN_ICE_FOUND, EVEN_LEVERAGED_FOUND, NEVER; // $matchingOptions = array('fuzzyC1Visbility' => 'YES', //Other options for fuzzyCVisbility: 'ONLY_IF_ITS_APPROVAL_AND_XLIFFDOC_STATUS_ARE_HIGHER_THAN_THE_ICE_OR_LEVERAGED_MATCH', 'NO' // 'fuzzyC2Visbility' => 'ONLY_IF_ITS_APPROVAL_STATUS_IS_HIGHER_THAN_THE_ICE_OR_LEVERAGED_MATCH', // 'fuzzyC3Visbility' => 'ONLY_IF_ITS_XLIFFDOC_STATUS_IS_HIGHER_THAN_THE_ICE_OR_LEVERAGED_MATCH', // 'fuzzySearch' => $fuzzySearch); // To create project container do not set the translation files $projectURL = array('translationFiles' => array($fileURL), 'sourceLanguage' => $configuration->sourceLanguage, 'targetLanguages' => $configuration->targetLanguages, 'customer' => $configuration->customer, 'workflow' => array('workflow' => 'TRANSLATE_P_CORRECT_F_REVIEW'), // 'workflowForNonAnalyzableFiles' => array('workflow' => 'TRANSLATE_P_CORRECT_F_REVIEW'), 'fileProcessType' => 'JOIN', // 'tmTags' => array($daysTag, $monthTag), // 'tmPenaltyProfile' => $penaltyProfile, // 'projectCallback' => $projectCallback, // 'matchingOptions' => $matchingOptions, 'allowNotApproveTerm' => 'DISALLOW', 'useTerminologyDecoration' => 'TRUE', 'name' => 'PHP API project_' . rand(0, 1000) ); $createProjectURLOptions = array('autopopulate' => true); $input = array('loginAPI' => $configuration->loginAPI, 'project' => $projectURL, 'options' => $createProjectURLOptions); $res = $configuration->proxy->createProjectURL($input); $createProjectURLResponse = $res->return; $projectResponse = $createProjectURLResponse->project; print('Project name: ' . $projectResponse->name . '
'); print('Project ID: ' . $projectResponse->projectDescriptor->id . '

'); print('Jobs:
'); if(!is_array($projectResponse->jobs)) { $projectResponse->jobs = array($projectResponse->jobs); } foreach ($projectResponse->jobs as $jobResponse) { print('- Job ID: ' . $jobResponse->jobDescriptor->id . ', '); print('File name: ' . $jobResponse->fileName . ', '); print('Target language: ' . $jobResponse->targetLanguage . '
'); } return $projectResponse; } function createProjectMTOM() { global $configuration; methodName('createProjectMTOM'); // $daysTag = array('name' => 'day', 'values' => array(array('name' => 'Monday'), array('name' => 'Tuesday'))); // $monthTag = array('name' => 'month', 'values' => array(array('name' => 'February'))); // $penaltyProfile = array('name' => 'time'); $externalDescriptors = array(); // $externalDescriptors = array( // 'pl_PL' => array('integrationId' => (rand(0, 1000)) ), // 'en_GB' => array('integrationId' => (rand(0, 1000)) ) // ); $fileContent = file_get_contents($configuration->sourceFile); // set languages for file // $targetLanguages = array('sv_SE'); $targetLanguages = array(); $fileMTOM = array('fileName' => $configuration->sourceFileName, 'fileMTOM' => $fileContent, 'externalDescriptors' => $externalDescriptors, 'targetLanguages' => $targetLanguages); // $projectCallback = array('jobFinishedCallback' => "http://localhost", //This url will be invoked when job is completed. // 'projectFinishedCallback' => "http://localhost", //This url will be invoked when project is completed. // 'analysisFinishedCallback' => "http://localhost", //This url will be invoked when analysis is completed. // 'workflowTransitionCallback' => "http://localhost"); //This url will be invoked when workflow transitions. // $fuzzySearch = 'ALWAYS'; //Options for fuzzySearch include: ALWAYS, EVEN_ICE_FOUND, EVEN_LEVERAGED_FOUND, NEVER; // $matchingOptions = array('fuzzyC1Visbility' => 'YES', //Other options for fuzzyCVisbility: 'ONLY_IF_ITS_APPROVAL_AND_XLIFFDOC_STATUS_ARE_HIGHER_THAN_THE_ICE_OR_LEVERAGED_MATCH', 'NO' // 'fuzzyC2Visbility' => 'ONLY_IF_ITS_APPROVAL_STATUS_IS_HIGHER_THAN_THE_ICE_OR_LEVERAGED_MATCH', // 'fuzzyC3Visbility' => 'ONLY_IF_ITS_XLIFFDOC_STATUS_IS_HIGHER_THAN_THE_ICE_OR_LEVERAGED_MATCH', // 'fuzzySearch' => $fuzzySearch); // To create project container do not set the translation files $projectMTOM = array('translationFiles' => array($fileMTOM), 'sourceLanguage' => $configuration->sourceLanguage, 'targetLanguages' => $configuration->targetLanguages, 'customer' => $configuration->customer, 'workflow' => array('workflow' => 'TRANSLATE_P_CORRECT_F_REVIEW'), // 'workflowForNonAnalyzableFiles' => array('workflow' => 'TRANSLATE_P_CORRECT_F_REVIEW'), 'fileProcessType' => 'JOIN', // 'tmTags' => array($daysTag, $monthTag), // 'tmPenaltyProfile' => $penaltyProfile, // 'externalDescriptor' => array('integrationId' => rand(0, 1000)), 'name' => 'PHP MTOM project_' . rand(0, 1000), // 'projectCallback' => $projectCallback, // 'matchingOptions' => $matchingOptions, 'allowNotApproveTerm' => 'DISALLOW', 'useTerminologyDecoration' => 'TRUE', 'projectManagerType' => 'FROM_CUSTOMER' //Project Manager for the created project will be taken from Customer's settings. ); $createProjectMTOMOptions = array('autopopulate' => true); $input = array('loginAPI' => $configuration->loginAPI, 'project' => $projectMTOM, 'options' => $createProjectMTOMOptions); $res = $configuration->proxy->createProjectMTOM($input); $createProjectMTOMResponse = $res->return; $projectResponse = $createProjectMTOMResponse->project; print('Project name: ' . $projectResponse->name . '
'); print('Project ID: ' . $projectResponse->projectDescriptor->id . '

'); print('Jobs:
'); if(!is_array($projectResponse->jobs)) { $projectResponse->jobs = array($projectResponse->jobs); } foreach ($projectResponse->jobs as $jobResponse) { print('- Job ID: ' . $jobResponse->jobDescriptor->id . ', '); print('File name: ' . $jobResponse->fileName . ', '); print('Target language: ' . $jobResponse->targetLanguage . '
'); } return $projectResponse; } function checkProjectAnalysisCompletion($projectDescriptor) { global $configuration; methodName('checkProjectAnalysisCompletion'); while (true) { $input = array('loginAPI' => $configuration->loginAPI, 'project' => $projectDescriptor); $res = $configuration->proxy->checkProjectAnalysisCompletion($input); $checkProjectAnalysisCompletionResponse = $res->return; $projectStatus = $checkProjectAnalysisCompletionResponse->project; $projectCompletionStatus = $projectStatus->status; if ('FINISHED' == $projectCompletionStatus) { print('Project analysis has been finished, ID: ' . $checkProjectAnalysisCompletionResponse->project->projectDescriptor->id . '
'); print('Jobs:
'); foreach ($checkProjectAnalysisCompletionResponse->project->jobs as $jobResponse) { print('- Job ID: ' . $jobResponse->jobDescriptor->id . ', status: ' . $jobResponse->status . '
'); } break; } else { print('Checking...
'); } sleep(2); } return $projectStatus; } function obtainJobMetrics($jobsDescriptors) { global $configuration; methodName('obtainJobMetrics'); $input = array('loginAPI' => $configuration->loginAPI, 'jobs' => $jobsDescriptors); $res = $configuration->proxy->obtainJobMetrics($input); $obtainJobMetricsResponse = $res->return; if(!is_array($obtainJobMetricsResponse->jobsMetrics)) { $obtainJobMetricsResponse->jobsMetrics = array($obtainJobMetricsResponse->jobsMetrics); } foreach ($obtainJobMetricsResponse->jobsMetrics as $jobMetricsResponse) { print('Job ID: ' . $jobMetricsResponse->jobDescriptor->id . ', '); print('Total characters: ' . $jobMetricsResponse->coreMetrics->totalCharacters . '
'); print('No-matched characters: ' . getNoMatchedCharacters($jobMetricsResponse->coreMetrics) . '
'); print('Non-translatables: ' . getNonTranslatables($jobMetricsResponse->coreMetrics) . '
'); foreach ($jobMetricsResponse->metricsProgressMap->entry as $step) { $metricsProgress = $step->value; print('Step name: ' . $step->key . ', '); print('Words to be done: ' . $metricsProgress->wordsToBeDone . ', '); print('Words done: ' . $metricsProgress->wordsDone . ', '); print('Characters to be done: ' . $metricsProgress->charactersToBeDone . ', '); print('Characters done: ' . $metricsProgress->charactersToBeDone . ', '); print('Units to be done: ' . $metricsProgress->unitsToBeDone . ', '); print('Units done: ' . $metricsProgress->unitsDone . ', '); print('Total units count: ' . $metricsProgress->totalUnitsCount . ', '); print('Total word count: ' . $metricsProgress->totalWordCount . ', '); print('Total characters count: ' . $metricsProgress->totalCharactersCount . '
'); } } } function obtainJobExtraInfo($jobsDescriptors) { global $configuration; methodName('obtainJobExtraInfo'); $input = array('loginAPI' => $configuration->loginAPI, 'jobs' => $jobsDescriptors); $res = $configuration->proxy->obtainJobExtraInfo($input); $obtainJobExtraInfoResponse = $res->return; if(isset($obtainJobExtraInfoResponse->jobs)) { if(!is_array($obtainJobExtraInfoResponse->jobs)) { $obtainJobExtraInfoResponse->jobs = array($obtainJobExtraInfoResponse->jobs); } foreach ($obtainJobExtraInfoResponse->jobs as $jobExtraInfoResponse) { print('Job ID: ' . $jobExtraInfoResponse->jobDescriptor->id . ', '); print('Project ID: ' . $jobExtraInfoResponse->projectDescriptor->id . '
'); print('Original file name: ' . $jobExtraInfoResponse->originalFileName . '
'); } } } function obtainProjectMetrics($projectDescriptor) { global $configuration; methodName('obtainProjectMetrics'); $obtainProjectMetricsOptions = array('targetLanguage' => $configuration->targetLanguages[0]); $input = array('loginAPI' => $configuration->loginAPI, 'project' => $projectDescriptor, 'options' => $obtainProjectMetricsOptions); $res = $configuration->proxy->obtainProjectMetrics($input); $obtainProjectMetricsResponse = $res->return; if(!is_array($obtainProjectMetricsResponse->projectMetrics)) { $obtainProjectMetricsResponse->projectMetrics = array($obtainProjectMetricsResponse->projectMetrics); } foreach ($obtainProjectMetricsResponse->projectMetrics as $projectMetricsResponse) { print('Project ID: ' . $projectMetricsResponse->projectDescriptor->id . ', '); print('Total words: ' . $projectMetricsResponse->coreMetrics->totalWords . '
'); print('No-matched characters: ' . getNoMatchedCharacters($projectMetricsResponse->coreMetrics) . '
'); print('Non-translatables: ' . getNonTranslatables($projectMetricsResponse->coreMetrics) . '
'); foreach ($projectMetricsResponse->metricsProgressMap->entry as $step) { $metricsProgress = $step->value; print('Step name: ' . $step->key . ', '); print('Words to be done: ' . $metricsProgress->wordsToBeDone . ', '); print('Words done: ' . $metricsProgress->wordsDone . ', '); print('Characters to be done: ' . $metricsProgress->charactersToBeDone . ', '); print('Characters done: ' . $metricsProgress->charactersToBeDone . ', '); print('Units to be done: ' . $metricsProgress->unitsToBeDone . ', '); print('Units done: ' . $metricsProgress->unitsDone . ', '); print('Total units count: ' . $metricsProgress->totalUnitsCount . ', '); print('Total word count: ' . $metricsProgress->totalWordCount . ', '); print('Total characters count: ' . $metricsProgress->totalCharactersCount . '
'); } } } function obtainProjectExtraInfo($projectDescriptor) { global $configuration; methodName('obtainProjectExtraInfo'); $input = array('loginAPI' => $configuration->loginAPI, 'project' => $projectDescriptor); $res = $configuration->proxy->obtainProjectExtraInfo($input); $obtainProjectExtraInfoResponse = $res->return; $projectExtraInfoResponse = $obtainProjectExtraInfoResponse->project; print('Project ID: ' . $projectExtraInfoResponse->projectDescriptor->id . '
'); if(isset($projectExtraInfoResponse->jobs)) { if(!is_array($projectExtraInfoResponse->jobs)) { $projectExtraInfoResponse->jobs = array($projectExtraInfoResponse->jobs); } foreach ($projectExtraInfoResponse->jobs as $jobExtraInfoResponse) { print('Job ID: ' . $jobExtraInfoResponse->jobDescriptor->id . ', '); print('Original file name: ' . $jobExtraInfoResponse->originalFileName . '
'); } } } function findProject($projectDescriptor) { global $configuration; methodName('findProject'); $projectsDescriptors = array($projectDescriptor); $filterProject = array( 'projects' => $projectsDescriptors, 'status' => 'NOT_STARTED'); //status options: NOT_STARTED, STARTED, FINISHED $options = array('projectCreator' => 'LOGIN_API_USER'); $input = array('loginAPI' => $configuration->loginAPI, 'filter' => $filterProject, 'options' => $options); $res = $configuration->proxy->findProject($input); $findProjectResponse = $res->return; if (is_object($findProjectResponse) && isset($findProjectResponse->projects)) { $dateFormat = 'd-m-Y H:i'; if(!is_array($findProjectResponse->projects)) { $findProjectResponse->projects = array($findProjectResponse->projects); } foreach ($findProjectResponse->projects as $projectDetailsResponse) { print('Project ID: ' . $projectDetailsResponse->projectDescriptor->id . '
'); print('Name: ' . $projectDetailsResponse->name . '
'); print('Status: ' . $projectDetailsResponse->status . '
'); if(isset($projectDetailsResponse->description)) { print('Description: ' . $projectDetailsResponse->description . '
'); } if(isset($projectDetailsResponse->reference)) { print('Reference: ' . $projectDetailsResponse->reference . '
'); } if(isset($projectDetailsResponse->domain) && isset($projectDetailsResponse->domain->domainName)) { print('Domain: ' . $projectDetailsResponse->domain->domainName . '
'); } print('Source language: ' . $projectDetailsResponse->sourceLanguage . '
'); print('Target languages: ' . join(', ', $projectDetailsResponse->targetLanguages) . '
'); print('Creator: ' . $projectDetailsResponse->creator->name . '
'); print('Create date: ' . date($dateFormat, strtotime($projectDetailsResponse->createDate)) . '
'); if (isset($findProjectResponse->status)){ print('Status: ' . $findProjectResponse->status . '
'); } if(isset($projectDetailsResponse->newSourceLanguage)){ print('newSourceLanguage: ' . $projectDetailsResponse->newSourceLanguage . '
'); } if(isset($projectDetailsResponse->dueDate)) { print('Create date: ' . date($dateFormat, strtotime($projectDetailsResponse->createDate)) . '
'); } print('Customer: ' . $projectDetailsResponse->customer->name . '
'); print('Project manager: ' . $projectDetailsResponse->projectManager->name . '
'); print('Use google machine translation: ' . $projectDetailsResponse->useGoogleMachineTranslation . '
'); print('Use not approved translation memory: ' . $projectDetailsResponse->useNotApprovedTranslationMemory . '
'); print('Allow editing of ICE matches: ' . $projectDetailsResponse->allowEditingOfICEMatches . '
'); if (isset($projectDetailsResponse->tmCustomers)) { print('TM customers: '); if(!is_array($projectDetailsResponse->tmCustomers)) { $projectDetailsResponse->tmCustomers = array($projectDetailsResponse->tmCustomers); } foreach ($projectDetailsResponse->tmCustomers as $tmCustomer) { print($tmCustomer->name . ', '); } print('
'); } if (isset($projectDetailsResponse->termCustomers)) { print('Term customers: '); if(!is_array($projectDetailsResponse->termCustomers)) { $projectDetailsResponse->termCustomers = array($projectDetailsResponse->termCustomers); } foreach ($projectDetailsResponse->termCustomers as $termCustomers) { print($termCustomers->name . ', '); } print('
'); } if (isset($projectDetailsResponse->paymentStatus)) { print('Project payment state: ' . $projectDetailsResponse->paymentStatus->projectPaymentState); if (isset($projectDetailsResponse->paymentStatus->details)) { if (!is_array($projectDetailsResponse->paymentStatus->details)) { $projectDetailsResponse->paymentStatus->details = array($projectDetailsResponse->paymentStatus->details); } print('Payment details: '); foreach ($projectDetailsResponse->paymentStatus->details as $detail) { print('State: ' . $detail->paymentState . ', date: ' . $detail->date); } print('
'); } } } } } function assignLinguistToJob($jobsDescriptors) { global $configuration; methodName('assignLinguistToJob'); $workflowStepDescriptor = array('workflowStep' => 'TRANSLATE1'); $stepLinguistAssignment = array('user' => $configuration->linguist, 'step' => $workflowStepDescriptor); $jobLinguistAssignments = array(); foreach ($jobsDescriptors as $jobDescriptor) { $jobLinguistAssignment = array('stepLinguistAssignments' => array($stepLinguistAssignment), 'jobDescriptor' => $jobDescriptor); array_push($jobLinguistAssignments, $jobLinguistAssignment); } $input = array('loginAPI' => $configuration->loginAPI, 'jobLinguistAssignments' => $jobLinguistAssignments); $res = $configuration->proxy->assignLinguistToJob($input); $assignLinguistToJobResponse = $res->return; if(!is_array($assignLinguistToJobResponse->jobsAssignments)) { $assignLinguistToJobResponse->jobsAssignments = array($assignLinguistToJobResponse->jobsAssignments); } foreach ($assignLinguistToJobResponse->jobsAssignments as $jobLinguistAssignment) { print('Job ID: ' . $jobLinguistAssignment->jobDescriptor->id . ', '); print('Result: ' . $jobLinguistAssignment->result . '
'); } } function assignLinguistToProject($projectDescriptor) { global $configuration; methodName('assignLinguistToProject'); $workflowStepDescriptor = array('workflowStep' => 'TRANSLATE1'); $stepLinguistAssignment = array('user' => $configuration->linguist, 'step' => $workflowStepDescriptor); $input = array('loginAPI' => $configuration->loginAPI, 'project' => $projectDescriptor, 'stepLinguistAssignments' => array($stepLinguistAssignment)); $res = $configuration->proxy->assignLinguistToProject($input); $assignLinguistToProjectResponse = $res->return; $projectLinguistAssignment = $assignLinguistToProjectResponse->projectAssignment; print('Project ID: ' . $projectLinguistAssignment->projectDescriptor->id . ', '); print('Result: ' . $projectLinguistAssignment->result . '
'); } function startProject($projectDescriptor) { global $configuration; methodName('startProject'); $projectsDescriptors = array($projectDescriptor); $input = array('loginAPI' => $configuration->loginAPI, 'projects' => $projectsDescriptors); $res = $configuration->proxy->startProject($input); $startProjectResponse = $res->return; if(!is_array($startProjectResponse->projects)) { $startProjectResponse->projects = array($startProjectResponse->projects); } foreach ($startProjectResponse->projects as $projectStartResponse) { print('Project ID: ' . $projectStartResponse->projectDescriptor->id . ', '); print('Result: ' . $projectStartResponse->result . '
'); } } function checkJobCompletion($jobsDescriptors) { global $configuration; methodName('checkJobCompletion'); $input = array('loginAPI' => $configuration->loginAPI, 'jobs' => $jobsDescriptors); $res = $configuration->proxy->checkJobCompletion($input); $checkJobCompletionResponse = $res->return; if (is_object($checkJobCompletionResponse)) { if(!is_array($checkJobCompletionResponse->jobs)) { $checkJobCompletionResponse->jobs = array($checkJobCompletionResponse->jobs); } foreach ($checkJobCompletionResponse->jobs as $jobCompletionResponse) { print('Job ID: ' . $jobCompletionResponse->jobDescriptor->id . ', '); print('Status: ' . $jobCompletionResponse->status . '
'); // print('Locking status: ' . $checkJobCompletionResponse->lockingStatus); } } } function checkProjectCompletion($projectDescriptor) { global $configuration; methodName('checkProjectCompletion'); $input = array('loginAPI' => $configuration->loginAPI, 'project' => $projectDescriptor); $res = $configuration->proxy->checkProjectCompletion($input); $checkProjectCompletionResponse = $res->return; $projectStatusResponse = $checkProjectCompletionResponse->project; print('Project ID: ' . $projectStatusResponse->projectDescriptor->id . ', '); print('Activity: ' . $projectStatusResponse->activity . ', '); print('Status: ' . $projectStatusResponse->status . '
'); } function downloadJobURL($jobsDescriptors) { global $configuration; methodName('downloadJobURL'); $options = null; //With this option method returns URL to latest uploaded target file. //$options = array('fileSource' => 'UPLOADED') $input = array('loginAPI' => $configuration->loginAPI, 'jobs' => $jobsDescriptors, 'options' >= $options); $res = $configuration->proxy->downloadJobURL($input); $downloadJobURLResponse = $res->return; if (is_object($downloadJobURLResponse) && isset($downloadJobURLResponse->jobs)) { if(!is_array($downloadJobURLResponse->jobs)) { $downloadJobURLResponse->jobs = array($downloadJobURLResponse->jobs); } foreach ($downloadJobURLResponse->jobs as $jobFileURLResponse) { print('Job ID: ' . $jobFileURLResponse->jobDescriptor->id . ', '); print('Original file: ' . $jobFileURLResponse->originalFileName . ', '); print('File URL: ' . $jobFileURLResponse->fileURL . '
'); download($jobFileURLResponse->fileURL, $configuration->downloadDirectory); } } } function downloadProjectURL($projectDescriptor) { global $configuration; methodName('downloadProjectURL'); $options = null; //With this option method returns URL to latest uploaded target file. $options = array('fileSource' => 'UPLOADED'); $input = array('loginAPI' => $configuration->loginAPI, 'project' => $projectDescriptor, 'options' => $options); $res = $configuration->proxy->downloadProjectURL($input); $downloadProjectURLResponse = $res->return; if (is_object($downloadProjectURLResponse)) { print('Project ID: ' . $downloadProjectURLResponse->project->projectDescriptor->id . '
'); if (isset($downloadProjectURLResponse->jobs)) { if(!is_array($downloadProjectURLResponse->jobs)) { $downloadProjectURLResponse->jobs = array($downloadProjectURLResponse->jobs); } foreach ($downloadProjectURLResponse->jobs as $jobFileURLResponse) { print('Job ID: ' . $jobFileURLResponse->jobDescriptor->id . ', '); print('Original file: ' . $jobFileURLResponse->originalFileName . ', '); print('File URL: ' . $jobFileURLResponse->fileURL . '
'); download($jobFileURLResponse->fileURL, $configuration->downloadDirectory); } } } } function downloadProjectMTOM($projectDescriptor) { global $configuration; methodName('downloadProjectMTOM'); $options = null; //With this option method returns URL to latest uploaded target file. $options = array('fileSource' => 'UPLOADED'); $input = array('loginAPI' => $configuration->loginAPI, 'project' => $projectDescriptor, 'options' => $options); $res = $configuration->proxy->downloadProjectMTOM($input); $downloadProjectMTOMResponse = $res->return; if (is_object($downloadProjectMTOMResponse)) { print('Project ID: ' . $downloadProjectMTOMResponse->project->projectDescriptor->id . '
'); if (isset($downloadProjectMTOMResponse->jobs)) { if(!is_array($downloadProjectMTOMResponse->jobs)) { $downloadProjectMTOMResponse->jobs = array($downloadProjectMTOMResponse->jobs); } foreach ($downloadProjectMTOMResponse->jobs as $jobFileMTOMResponse) { print('Job ID: ' . $jobFileMTOMResponse->jobDescriptor->id . ', '); print('Original file: ' . $jobFileMTOMResponse->originalFileName . ', '); print('File name: ' . $jobFileMTOMResponse->fileName . '
'); downloadMTOM($jobFileMTOMResponse->fileName, $jobFileMTOMResponse->fileMTOM, $configuration->downloadDirectory); } } } } function downloadJobMTOM($jobsDescriptors) { global $configuration; methodName('downloadJobMTOM'); $options = null; //With this option method returns URL to latest uploaded target file. //$options = array('fileSource' => 'UPLOADED') $input = array('loginAPI' => $configuration->loginAPI, 'jobs' => $jobsDescriptors, 'options' => $options); $res = $configuration->proxy->downloadJobMTOM($input); $downloadJobMTOMResponse = $res->return; if (isset($downloadJobMTOMResponse->jobs)) { if(!is_array($downloadJobMTOMResponse->jobs)) { $downloadJobMTOMResponse->jobs = array($downloadJobMTOMResponse->jobs); } foreach ($downloadJobMTOMResponse->jobs as $jobFileMTOMResponse) { print('Job ID: ' . $jobFileMTOMResponse->jobDescriptor->id . ', '); print('Original file: ' . $jobFileMTOMResponse->originalFileName . ', '); print('File name: ' . $jobFileMTOMResponse->fileName . '
'); downloadMTOM($jobFileMTOMResponse->fileName, $jobFileMTOMResponse->fileMTOM, $configuration->downloadDirectory); } } } function downloadJobFileURL($filesDescriptors) { global $configuration; methodName('downloadJobFileURL'); $input = array('loginAPI' => $configuration->loginAPI, 'files' => $filesDescriptors); $res = $configuration->proxy->downloadJobFileURL($input); $downloadJobFileURLResponse = $res->return; if (isset($downloadJobFileURLResponse->files)) { if(!is_array($downloadJobFileURLResponse->files)) { $downloadJobFileURLResponse->files = array($downloadJobFileURLResponse->files); } foreach ($downloadJobFileURLResponse->files as $jobFileURLResponse) { print('Job ID: ' . $jobFileURLResponse->jobDescriptor->id . ', '); print('Original file: ' . $jobFileURLResponse->originalFileName . ', '); print('File URL: ' . $jobFileURLResponse->fileURL . '
'); download($jobFileURLResponse->fileURL, $configuration->downloadDirectory); } } } function downloadProjectFileURL($filesDescriptors) { global $configuration; methodName('downloadProjectFileURL'); $input = array('loginAPI' => $configuration->loginAPI, 'files' => $filesDescriptors); $res = $configuration->proxy->downloadProjectFileURL($input); $downloadProjectFileURLResponse = $res->return; if (isset($downloadProjectFileURLResponse->files)) { if (!is_array($downloadProjectFileURLResponse->files)) { $downloadProjectFileURLResponse->files = array($downloadProjectFileURLResponse->files); } foreach ($downloadProjectFileURLResponse->files as $projectFileURLResponse) { print('Project ID: ' . $projectFileURLResponse->projectDescriptor->id . ', '); print('Filename: ' . $projectFileURLResponse->fileName . ', '); print('File URL: ' . $projectFileURLResponse->fileURL . '
'); download($projectFileURLResponse->fileURL, $configuration->downloadDirectory); } } } function downloadJobFileMTOM($filesDescriptors) { global $configuration; methodName('downloadJobFileMTOM'); $input = array('loginAPI' => $configuration->loginAPI, 'files' => $filesDescriptors); $res = $configuration->proxy->downloadJobFileMTOM($input); $downloadJobFileMTOMResponse = $res->return; if (isset($downloadJobFileMTOMResponse->files)) { if(!is_array($downloadJobFileMTOMResponse->files)) { $downloadJobFileMTOMResponse->files = array($downloadJobFileMTOMResponse->files); } foreach ($downloadJobFileMTOMResponse->files as $jobFileMTOMResponse) { print('Job ID: ' . $jobFileMTOMResponse->jobDescriptor->id . ', '); print('Original file: ' . $jobFileMTOMResponse->originalFileName . ', '); print('File name: ' . $jobFileMTOMResponse->fileName . '
'); downloadMTOM($jobFileMTOMResponse->fileName, $jobFileMTOMResponse->fileMTOM, $configuration->downloadDirectory); } } } function downloadProjectFileMTOM($filesDescriptors) { global $configuration; methodName('downloadProjectFileMTOM'); $input = array('loginAPI' => $configuration->loginAPI, 'files' => $filesDescriptors); $res = $configuration->proxy->downloadProjectFileMTOM($input); $downloadProjectFileMTOMResponse = $res->return; if (isset($downloadProjectFileMTOMResponse->files)) { if (!is_array($downloadProjectFileMTOMResponse->files)) { $downloadProjectFileMTOMResponse->files = array($downloadProjectFileMTOMResponse->files); } foreach ($downloadProjectFileMTOMResponse->files as $projectFileMTOMResponse) { print('Project ID: ' . $projectFileMTOMResponse->projectDescriptor->id . ', '); print('Filename: ' . $projectFileMTOMResponse->fileName . '
'); downloadMTOM($projectFileMTOMResponse->fileName, $projectFileMTOMResponse->fileMTOM, $configuration->downloadDirectory); } } } function generateJobFile($jobsDescriptors) { global $configuration; methodName('generateJobFile'); $generateJobFileOptions = array('fileType' => 'TARGET'); //$generateJobFileOptions = array('fileType' => 'XLIFF_DOC'); // If psuedo target is wanted to be generated, please uncomment the line below and comment other line with FileType. //$generateJobFileOptions = array('fileType' => 'TARGET_PSEUDO'); // The following two lines allow to generate coloured PDFs by Match Rate or Xliff:Doc status. //$generateJobFileOptions = array('fileType' => 'PDF_COLOURED_BY_MATCH_RATE'); //$generateJobFileOptions = array('fileType' => 'PDF_COLOURED_BY_XLIFF_DOC_STATUS'); //Xliff no target population //$xliffOptions = array('populateTargetWithSource' => false); //$generateJobFileOptions = array('fileType' => 'XLIFF', 'xliffOptions' => $xliffOptions); $input = array('loginAPI' => $configuration->loginAPI, 'jobs' => $jobsDescriptors, 'options' => $generateJobFileOptions); $res = $configuration->proxy->generateJobFile($input); $generateJobFileResponse = $res->return; if (!is_array($generateJobFileResponse->files)) { $generateJobFileResponse->files = array($generateJobFileResponse->files); } foreach ($generateJobFileResponse->files as $jobFileBaseResponses) { print('Job ID: ' . $jobFileBaseResponses->jobDescriptor->id . ', '); print('File ID: ' . $jobFileBaseResponses->fileDescriptor->id . ', '); print('File type: ' . $jobFileBaseResponses->fileType . '
'); } return $generateJobFileResponse->files[0]; } function generateProjectFile($projectDescriptor) { global $configuration; methodName('generateProjectFile'); $generateProjectFileOptions = array('fileType' => 'TIPP'); //With this option method generates LQA report. //$generateProjectFileOptions = array('fileType' => 'LQA_REPORT'); //With this option method generates MULTI_EXCEL report. //$generateProjectFileOptions = array('fileType' => 'MULTI_EXCEL'); //With this option method generates PDF - source files formats only: idml and indb files //$generateProjectFileOptions = array('fileType' => 'PDF'); //With this option method generates PDF coloured by match rate // $generateProjectFileOptions = array('fileType' => 'PDF_COLOURED_BY_MATCH_RATE'); //With this option method generates PDF coloured by xliff:doc status // $generateProjectFileOptions = array('fileType' => 'PDF_COLOURED_BY_XLIFF_DOC_STATUS'); $input = array('loginAPI' => $configuration->loginAPI, 'project' => $projectDescriptor, 'options' => $generateProjectFileOptions); $res = $configuration->proxy->generateProjectFile($input); $generateProjectFileResponse = $res->return; if (isset($generateProjectFileResponse->fileDescriptor)) { print('File ID: ' . $generateProjectFileResponse->fileDescriptor->id . '
'); } return $generateProjectFileResponse->fileDescriptor; } function checkJobFileCompletion($filesDescriptors) { global $configuration; methodName('checkJobFileCompletion'); $i = 0; while (true) { $input = array('loginAPI' => $configuration->loginAPI, 'files' => $filesDescriptors); $res = $configuration->proxy->checkJobFileCompletion($input); $checkJobFileCompletionResponse = $res->return; $jobFileCompletionStatus = null; if(is_array($checkJobFileCompletionResponse->jobs)) { $jobFileCompletionStatus = $checkJobFileCompletionResponse->jobs[0]->status; } else { $jobFileCompletionStatus = $checkJobFileCompletionResponse->jobs->status; } $i++; if ('FINISHED' == $jobFileCompletionStatus) { print('Job file generation finished successfully'); break; } elseif ('ERROR' == $jobFileCompletionStatus) { print('Job file generation failed'); break; } elseif ($i > 5) { print('Job file generation did not finished in 10 seconds'); break; } else { print('Checking...
'); sleep(2); } } } function checkProjectFileCompletion($filesDescriptors) { global $configuration; methodName('checkProjectFileCompletion'); $i = 0; while(true) { $input = array('loginAPI' => $configuration->loginAPI, 'files' => $filesDescriptors); $res = $configuration->proxy->checkProjectFileCompletion($input); $checkProjectFileCompletionResponse = $res->return; $projectFileCompletionStatus = null; if (is_array($checkProjectFileCompletionResponse->statuses)) { $projectFileCompletionStatus = $checkProjectFileCompletionResponse->statuses[0]->status; } else { $projectFileCompletionStatus = $checkProjectFileCompletionResponse->statuses->status; } $i++; if ('FINISHED' == $projectFileCompletionStatus) { print('Project file generation finished successfully'); break; } elseif ('ERROR' == $projectFileCompletionStatus) { print('Project file generation failed'); break; } elseif ($i > 5) { print ('Project file generation did not finished in 10 seconds'); break; } else { print('Checking...
'); sleep(2); } } } function obtainPMProjectEditorLink($projectDescriptor) { global $configuration; methodName('obtainPMProjectEditorLink'); $projectEditorOptions = array('defaultTab' => 'WORKFLOW', 'showEstimates' => false); $obtainPMProjectEditorLinkOptions = array('projectEditorOptions' => $projectEditorOptions); $input = array('loginAPI' => $configuration->loginAPI, 'project' => $projectDescriptor, 'options' => $obtainPMProjectEditorLinkOptions); $res = $configuration->proxy->obtainPMProjectEditorLink($input); $PMProjectEditorLinkResponse = $res->return; print('Project editor link: ' . $PMProjectEditorLinkResponse->projectEditor->projectEditorLink); } function obtainProjectStatistics($projectDescriptor) { global $configuration; methodName('obtainProjectStatistics'); $obtainProjectStatisticsOptions = array('targetLanguage' => $configuration->targetLanguages[0]); $input = array('loginAPI' => $configuration->loginAPI, 'project' => $projectDescriptor, 'options' => $obtainProjectStatisticsOptions); $res = $configuration->proxy->obtainProjectStatistics($input); if(is_object($res) && is_object($res->return)) { $obtainProjectStatisticsResponse = $res->return; if (isset($obtainProjectStatisticsResponse->projectStatistics)) { if(!is_array($obtainProjectStatisticsResponse->projectStatistics)) { $obtainProjectStatisticsResponse->projectStatistics = array($obtainProjectStatisticsResponse->projectStatistics); } if(!is_array($obtainProjectStatisticsResponse->projectStatistics)) { $obtainProjectStatisticsResponse->projectStatistics = array($obtainProjectStatisticsResponse->projectStatistics); } foreach ($obtainProjectStatisticsResponse->projectStatistics as $projectStatisticsResponse) { print('Project ID: ' . $projectStatisticsResponse->projectDescriptor->id . '
'); if(!is_array($projectStatisticsResponse->userStatisticsAPI)) { $projectStatisticsResponse->userStatisticsAPI = array($projectStatisticsResponse->userStatisticsAPI); } foreach ($projectStatisticsResponse->userStatisticsAPI as $userStatistics) { $userDescriptor = $userStatistics->userDescriptor; if (isset($userDescriptor->id)) { print('User ID: ' . $userDescriptor->id . ', user name: ' . $userDescriptor->name . '
'); if(!is_array($userStatistics->stepStatistics)) { $userStatistics->stepStatistics = array($userStatistics->stepStatistics); } foreach ($userStatistics->stepStatistics as $workflowStepStatistics) { print('Workflow step: ' . $workflowStepStatistics->stepDescriptor->workflowStepName . '
'); if(!is_array($workflowStepStatistics->jobsStatistics)) { $workflowStepStatistics->jobsStatistics = array($workflowStepStatistics->jobsStatistics); } foreach ($workflowStepStatistics->jobsStatistics as $jobStatistics) { $metrics = $jobStatistics->statistics; print('Job ID: ' . $jobStatistics->jobDescriptor->id . ', '); print('Total units: ' . $metrics->textUnitCount . ', '); print('Total characters: ' . $metrics->totalCharacterCount . '
'); print('No-matched characters: ' . getNoMatchedCharactersStatistics($metrics) . '
'); print('Non-translatables: ' . getNonTranslatablesStatistics($metrics) . '
'); } } } } } } else { print('No text has been translated, corrected or reviewed in this language yet therefore no statistics are available. '); // Code for processing when there is no statistics. } } } function obtainProjectAllStatistics($projectDescriptor) { global $configuration; methodName('obtainProjectAllStatistics'); $obtainProjectAllStatisticsOptions = array('targetLanguages' => $configuration->targetLanguages); $input = array('loginAPI' => $configuration->loginAPI, 'project' => $projectDescriptor, 'options' => $obtainProjectAllStatisticsOptions); $res = $configuration->proxy->obtainProjectAllStatistics($input); if(!is_null($res) && !is_null($res->return)) { $obtainProjectAllStatisticsResponse = $res->return; if (isset($obtainProjectAllStatisticsResponse->stepStatistics)) { if(!is_array($obtainProjectAllStatisticsResponse->stepStatistics)) { $obtainProjectAllStatisticsResponse->stepStatistics = array($obtainProjectAllStatisticsResponse->stepStatistics); } foreach ($obtainProjectAllStatisticsResponse->stepStatistics as $statisticsResponse) { print('Workflow step: ' . $statisticsResponse->stepDescriptor->workflowStep . '
'); $sourceStatistics = $statisticsResponse->sourceStatistics; print('Source. Total word count: ' . $sourceStatistics->totalWordCount . '
'); print('Source. Repetition matched character count: ' . $sourceStatistics->repetitionMatchedCharacterCount . '
'); $targetStatistics = $statisticsResponse->targetStatistics; print('Source. Total word count: ' . $targetStatistics->totalWordCount . '
'); print('Source. Repetition matched character count: ' . $targetStatistics->repetitionMatchedCharacterCount . '
'); } } else { print('No text has been translated, corrected or reviewed in this language yet therefore no statistics are available. '); // Code for processing when there is no statistics. } if (isset($obtainProjectAllStatisticsResponse->languageStatistics)) { if(!is_array($obtainProjectAllStatisticsResponse->languageStatistics)) { $obtainProjectAllStatisticsResponse->languageStatistics = array($obtainProjectAllStatisticsResponse->languageStatistics); } foreach ($obtainProjectAllStatisticsResponse->languageStatistics as $languageStatistics) { print('Project ID: ' . $languageStatistics->projectDescriptor->id . ', target: ' . $languageStatistics->targetLanguage . '
'); if(!is_array($languageStatistics->stepStatistics)) { $languageStatistics->stepStatistics = array($languageStatistics->stepStatistics); } foreach ($languageStatistics->stepStatistics as $workflowStep) { print("Summarized workflow for step: " . $workflowStep->stepDescriptor->workflowStepName . '
'); print("Source statistics, words done: " . $workflowStep->sourceStatistics->wordsDone . '
'); print("Target statistics, words done: " . $workflowStep->targetStatistics->wordsDone . '
'); } if(!is_array($languageStatistics->userAllStatisticsAPI)) { $languageStatistics->userAllStatisticsAPI = array($languageStatistics->userAllStatisticsAPI); } foreach ($languageStatistics->userAllStatisticsAPI as $userStatistics) { $userDescriptor = $userStatistics->userDescriptor; print('User ID: ' . $userDescriptor->id . ', name: ' . $userDescriptor->name . '
'); if(!is_array($userStatistics->stepStatistics)) { $userStatistics->stepStatistics = array($userStatistics->stepStatistics); } foreach ($userStatistics->stepStatistics as $workflowStep) { print("Workflow step: " . $workflowStep->stepDescriptor->workflowStepName . '
'); print("Source statistics, words done: " . $workflowStep->sourceStatistics->wordsDone . '
'); print("Target statistics, words done: " . $workflowStep->targetStatistics->wordsDone . '
'); } } } } else { print('No text has been translated, corrected or reviewed in this language yet therefore no statistics are available. '); // Code for processing when there is no statistics. } } } function updateJobStepProperty($jobsDescriptors) { global $configuration; methodName('updateJobStepProperty'); $dateFormat = 'Y-m-d'; $stepDescriptor = array('workflowStep' => 'TRANSLATE1'); $steps = array('dueDate' => date($dateFormat), 'stepDescriptor' => $stepDescriptor); $jobs = array('jobDescriptor' => $jobsDescriptors[0], 'steps' => $steps); $updates = array('jobs' => $jobs); $input = array('loginAPI' => $configuration->loginAPI, 'updates' => $updates); $res = $configuration->proxy->updateJobStepProperty($input); $updateJobStepPropertyResponse = $res->return; if (is_object($updateJobStepPropertyResponse) && isset($updateJobStepPropertyResponse->result)) { print('Jobs step dueDate updated'); } } function updateProjectStepProperty($projectDescriptor) { global $configuration; methodName('updateProjectStepProperty'); $dateFormat = 'Y-m-d'; $stepDescriptor = array('workflowStep' => 'TRANSLATE1'); $steps = array('dueDate' => date($dateFormat), 'stepDescriptor' => $stepDescriptor); $projectProperties = array('projectDescriptor' => $projectDescriptor, 'projectDueDate' => date($dateFormat), 'steps' => $steps); $input = array('loginAPI' => $configuration->loginAPI, 'stepProperty' => $projectProperties); $res = $configuration->proxy->updateProjectStepProperty($input); $updateProjectStepPropertyResponse = $res->return; if (is_object($updateProjectStepPropertyResponse) && isset($updateProjectStepPropertyResponse->result)) { print('Project and projects step dueDate updated'); } } function updateTranslationFilesMTOM($projectDescriptor) { global $configuration; methodName('updateTranslationFilesMTOM'); $fileContent = file_get_contents($configuration->secondFilePath . $configuration->secondFileName); $fileMTOM = array('fileName' => $configuration->secondFileName, 'fileMTOM' => $fileContent, 'externalDescriptors' => array()); $updateTranslationFiles = array('projectDescriptor' => $projectDescriptor, 'filesToDelete' => array('translationFiles' => array(array('fileName' => $configuration->sourceFileName))), 'filesToAdd' => array('matchType' => 'NO_MATCH', //'matchType' => 'MATCH_NAMES', // if matchType is set to MATCH_NAMES and file names match, treat it as a continuous project 'translationFiles' => array($fileMTOM))); $input = array('loginAPI' => $configuration->loginAPI, 'files' => $updateTranslationFiles); $res = $configuration->proxy->updateTranslationFilesMTOM($input); $updateTranslationFilesResponse = $res->return; if (is_object($updateTranslationFilesResponse) && isset($updateTranslationFilesResponse->project)) { $projectResponse = $updateTranslationFilesResponse->project; print('Project ID: ' . $projectResponse->projectDescriptor->id . '
'); if(!is_array($projectResponse->jobs)) { $projectResponse->jobs = array($projectResponse->jobs); } foreach ($projectResponse->jobs as $jobResponse) { print('Job ID: ' . $jobResponse->jobDescriptor->id . ', file name: ' . $jobResponse->fileName . '
'); } } } function updateTranslationFilesURL($projectDescriptor) { global $configuration; methodName('updateTranslationFilesURL'); $fileMTOM = array('fileName' => $configuration->secondFileName, 'fileURL' => $configuration->secondFilePath . $configuration->secondFileName, 'externalDescriptors' => array()); $updateTranslationFiles = array('projectDescriptor' => $projectDescriptor, 'filesToDelete' => array('translationFiles' => array(array('fileName' => $configuration->sourceFileName))), 'filesToAdd' => array('matchType' => 'NO_MATCH', //'matchType' => 'MATCH_NAMES', // if matchType is set to MATCH_NAMES and file names match, treat it as a continuous project 'translationFiles' => array($fileMTOM))); $input = array('loginAPI' => $configuration->loginAPI, 'files' => $updateTranslationFiles); $res = $configuration->proxy->updateTranslationFilesURL($input); $updateTranslationFilesResponse = $res->return; if (is_object($updateTranslationFilesResponse) && isset($updateTranslationFilesResponse->project)) { $projectResponse = $updateTranslationFilesResponse->project; print('Project ID: ' . $projectResponse->projectDescriptor->id . '
'); if(!is_array($projectResponse->jobs)) { $projectResponse->jobs = array($projectResponse->jobs); } foreach ($projectResponse->jobs as $jobResponse) { print('Job ID: ' . $jobResponse->jobDescriptor->id . ', file name: ' . $jobResponse->fileName . '
'); } } } function updateTargetLanguages($projectDescriptor) { global $configuration; methodName('updateTargetLanguages'); $updateTargetLanguages = array('projectDescriptor' => $projectDescriptor, 'languagesToAdd' => array('targetLanguages' => array('es_AR')), 'languagesToDelete' => array('targetLanguages' => array('de_DE'))); $input = array('loginAPI' => $configuration->loginAPI, 'languages' => $updateTargetLanguages); $res = $configuration->proxy->updateTargetLanguages($input); $updateTargetLanguagesResponse = $res->return; if (is_object($updateTargetLanguagesResponse) && isset($updateTargetLanguagesResponse->project)) { $projectResponse = $updateTargetLanguagesResponse->project; print('Project ID: ' . $projectResponse->projectDescriptor->id . '
'); if(!is_array($projectResponse->jobs)) { $projectResponse->jobs = array($projectResponse->jobs); } foreach ($projectResponse->jobs as $jobResponse) { print('Job ID: ' . $jobResponse->jobDescriptor->id . ', file name: ' . $jobResponse->fileName . '
'); } } } function updateProjectActivity($projectDescriptor) { global $configuration; methodName('updateProjectActivity'); $projectsDescriptors = array($projectDescriptor); $updateProjectActivityOptions = array('activity' => 'ARCHIVE', 'projectCreator' => 'LOGIN_API_USER'); //possible options //$updateProjectActivityOptions = array('activity' => 'ACTIVATE', 'projectCreator' => 'LOGIN_API_USER'); //$updateProjectActivityOptions = array('activity' => 'DELETE_LEAVING_TM', 'projectCreator' => 'LOGIN_API_USER'); //$updateProjectActivityOptions = array('activity' => 'DELETE_WITH_TM', 'projectCreator' => 'LOGIN_API_USER'); //$updateProjectActivityOptions = array('activity' => 'REANALYSE', 'projectCreator' => 'LOGIN_API_USER'); $input = array('loginAPI' => $configuration->loginAPI, 'projects' => $projectsDescriptors, 'options' => $updateProjectActivityOptions); $res = $configuration->proxy->updateProjectActivity($input); $updateProjectActivityResponse = $res->return; if (is_object($updateProjectActivityResponse) && isset($updateProjectActivityResponse->projects)) { if(!is_array($updateProjectActivityResponse->projects)) { $updateProjectActivityResponse->projects = array($updateProjectActivityResponse->projects); } foreach ($updateProjectActivityResponse->projects as $projectActivityResponse) { print('Project ID: ' . $projectActivityResponse->projectDescriptor->id . ', '); print('Result: ' . $projectActivityResponse->result . '
'); } } } function updateProject($projectDescriptor) { global $configuration; methodName('updateProject'); $newNameOfProject = 'New name of project ' . $projectDescriptor->id; $translationProperties = []; //$translationProperties = array('allowEditingICEMatches' => false); $updateProject = [ 'projectDescriptor' => $projectDescriptor, 'name' => $newNameOfProject, 'translationProperties' => $translationProperties, 'description' => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum", 'domain' => ['domain' => 'LAW', 'Lorem ipsum dolor sit amet'] ]; $updateProjects = [$updateProject]; $input = ['loginAPI' => $configuration->loginAPI, 'projects' => $updateProjects]; $res = $configuration->proxy->updateProject($input); $updateProjectResponse = $res->return; if (is_object($updateProjectResponse) && isset($updateProjectResponse->projects)) { if (!is_array($updateProjectResponse->projects)) { $updateProjectResponse->projects = [$updateProjectResponse->projects]; } foreach ($updateProjectResponse->projects as $projectUpdateResponse) { print('Project ID: ' . $projectUpdateResponse->projectDescriptor->id . ', '); print('Result: ' . $projectUpdateResponse->result . '
'); } } } function updateProjectWorkflow($projectDescriptor) { global $configuration; methodName('updateProjectWorkflow'); $step1 = array('role' => 'TRANSLATE', 'forwardBlockingType' => 'PART_BLOCKING', 'approving' => true, 'stepDescriptor' => array('workflowStep' => 'TRANSLATE1')); $step2 = array('role' => 'CORRECT', 'forwardBlockingType' => 'PART_BLOCKING', 'approving' => true, 'stepDescriptor' => array('workflowStep' => 'CORRECT1')); $updateWorkflow = array('workflowSteps' => array($step1, $step2)); $updateProjectWorkflowOptions = array('matchType' => 'MATCH_NAMES'); $input = array('loginAPI' => $configuration->loginAPI, 'project' => $projectDescriptor, 'workflow' => $updateWorkflow, 'options' => $updateProjectWorkflowOptions); $res = $configuration->proxy->updateProjectWorkflow($input); $updateProjectWorkflowResponse = $res->return; if (is_object($updateProjectWorkflowResponse) && isset($updateProjectWorkflowResponse->project)) { $projectWorkflowResponse = $updateProjectWorkflowResponse->project; print('Project ID: ' . $projectWorkflowResponse->projectDescriptor->id . ', '); print('Result: ' . $projectWorkflowResponse->result . '
'); } } function updateJobWorkflowActivity($jobsDescriptors) { global $configuration; methodName('updateJobWorkflowActivity'); $updateJobWorkflowActivityOptions = array('activity' => 'FINISH'); //possible options //$updateJobWorkflowActivityOptions = array('activity' => 'RESET'); //$updateJobWorkflowActivityOptions = array('activity' => 'REOPEN'); $input = array('loginAPI' => $configuration->loginAPI, 'jobs' => $jobsDescriptors, 'options' => $updateJobWorkflowActivityOptions); $res = $configuration->proxy->updateJobWorkflowActivity($input); $updateJobWorkflowActivityResponse = $res->return; if (is_object($updateJobWorkflowActivityResponse) && isset($updateJobWorkflowActivityResponse->jobs)) { if(!is_array($updateJobWorkflowActivityResponse->jobs)) { $updateJobWorkflowActivityResponse->jobs = array($updateJobWorkflowActivityResponse->jobs); } foreach ($updateJobWorkflowActivityResponse->jobs as $jobWorkflowActivityResponse) { print('Job ID: ' . $jobWorkflowActivityResponse->jobDescriptor->id . ', '); print('Result: ' . $jobWorkflowActivityResponse->result . '
'); } } } function updateProjectWorkflowActivity($projectDescriptor) { global $configuration; methodName('updateProjectWorkflowActivity'); $projectsDescriptors = array($projectDescriptor); $updateProjectWorkflowActivityOptions = array('activity' => 'FINISH'); //possible options //$updateProjectWorkflowActivityOptions = array('activity' => 'REOPEN'); //$updateProjectWorkflowActivityOptions = array('activity' => 'RESET'); $input = array('loginAPI' => $configuration->loginAPI, 'projects' => $projectsDescriptors, 'options' => $updateProjectWorkflowActivityOptions); $res = $configuration->proxy->updateProjectWorkflowActivity($input); $updateProjectWorkflowActivityResponse = $res->return; if (is_object($updateProjectWorkflowActivityResponse) && isset($updateProjectWorkflowActivityResponse->projects)) { if(!is_array($updateProjectWorkflowActivityResponse->projects)) { $updateProjectWorkflowActivityResponse->projects = array($updateProjectWorkflowActivityResponse->projects); } foreach ($updateProjectWorkflowActivityResponse->projects as $projectWorkflowActivityResponse) { print('Project ID: ' . $projectWorkflowActivityResponse->projectDescriptor->id . ', '); print('Result: ' . $projectWorkflowActivityResponse->result . '
'); if(!is_array($projectWorkflowActivityResponse->jobs)) { $projectWorkflowActivityResponse->jobs = array($projectWorkflowActivityResponse->jobs); } foreach ($projectWorkflowActivityResponse->jobs as $jobWorkflowActivityResponse) { print('Job ID: ' . $jobWorkflowActivityResponse->jobDescriptor->id . ', '); print('Result: ' . $jobWorkflowActivityResponse->result . '
'); } } } } function createTemplate() { global $configuration; methodName('createTemplate'); $template = array('name' => 'Example Template ' . rand(0, 1000000), 'description' => 'Description', 'externalDescriptor' => array('externalId' => 'id' . rand(0, 1000000))); $input = array('loginAPI' => $configuration->loginAPI, 'template' => $template); $res = $configuration->proxy->createTemplate($input); $createTemplateResponse = $res->return; $templateResponse = $createTemplateResponse->template; print('Template ID: ' . $templateResponse->templateDescriptor->id . ', ' . $templateResponse->name . '

'); return $templateResponse; } function obtainPMTemplateEditorLink($templateDescriptor) { global $configuration; methodName('obtainPMTemplateEditorLink'); $obtainPMTemplateEditorLinkOptions = array( 'templateEditorOptions' => array( 'showCustomersSettings' => true, 'showProjectSettings' => true, 'showMachineTranslationSettings' => true, 'showTranslationSettings' => true )); $input = array('loginAPI' => $configuration->loginAPI, 'template' => $templateDescriptor, 'options' => $obtainPMTemplateEditorLinkOptions); $res = $configuration->proxy->obtainPMTemplateEditorLink($input); $obtainPMTemplateEditorLinkResponse = $res->return; $templateEditorResponse = $obtainPMTemplateEditorLinkResponse->templateEditor; print('Template editor link: ' . $templateEditorResponse->templateEditorLink . '

'); } function moveJobWorkflow($jobsDescriptors) { global $configuration; methodName('moveJobWorkflow'); $jobMove = array('jobDescriptor' => $jobsDescriptors[0], 'move' => 'FORWARD'); //// restart automatic step // $jobMove = array('jobDescriptor' => $jobsDescriptors[0], 'move' => 'RESTART'); $workflowMove = array('workflowMoves' => $jobMove); $options = array('concurrentStepsAsOne' => false, 'mailing'=>'ENABLED'); $input = array('loginAPI' => $configuration->loginAPI, 'workflowJobMove' => $workflowMove, 'options' => $options); $res = $configuration->proxy->moveJobWorkflow($input); $moveJobWorkflowResponse = $res->return; if (is_object($moveJobWorkflowResponse) && isset($moveJobWorkflowResponse->jobsResult)) { if (!is_array($moveJobWorkflowResponse->jobsResult)) { $moveJobWorkflowResponse->jobsResult = array($moveJobWorkflowResponse->jobsResult); } foreach($moveJobWorkflowResponse->jobsResult as $jobResult) { print('Job: ' . $jobResult->jobDescriptor->id . ' moved forward with result: ' . ($jobResult->result ? 'success
' : 'fail
')); } } } function moveProjectWorkflow($projectDescriptor) { global $configuration; methodName('moveProjectWorkflow'); $workflowMove = array('projectDescriptor' => $projectDescriptor, 'move' => 'FORWARD'); $options = array('concurrentStepsAsOne' => false, 'mailing' => 'DISABLED'); $input = array('loginAPI' => $configuration->loginAPI, 'workflowMove' => $workflowMove, 'options' => $options); $res = $configuration->proxy->moveProjectWorkflow($input); $moveProjectWorkflowResponse = $res->return; if (is_object($moveProjectWorkflowResponse) && isset($moveProjectWorkflowResponse->jobsResult)) { if (!is_array($moveProjectWorkflowResponse->jobsResult)) { $moveProjectWorkflowResponse->jobsResult = array($moveProjectWorkflowResponse->jobsResult); } foreach($moveProjectWorkflowResponse->jobsResult as $jobResult) { print('Job: ' . $jobResult->jobDescriptor->id . ' move forward with result: ' . ($jobResult->result ? 'success
' : 'fail
')); } } } function updateReferenceFilesMTOM($projectDescriptor, $customerDescriptor) { global $configuration; methodName('updateReferenceFilesMTOM'); $fileContent = file_get_contents($configuration->sourceFile); $fileMTOM = array('fileName' => $configuration->sourceFileName, 'fileMTOM' => $fileContent, 'externalDescriptors' => array()); $request = array('projectDescriptor' => $projectDescriptor, 'customerDescriptor' => $customerDescriptor, 'files' => array($fileMTOM)); $input = array('loginAPI' => $configuration->loginAPI, 'referenceFiles' => $request); $res = $configuration->proxy->updateReferenceFilesMTOM($input); $updateReferenceFilesMTOMResponse = $res->return; if (is_object($updateReferenceFilesMTOMResponse)) { print('Reference materials updated with result: ' . ($updateReferenceFilesMTOMResponse->result ? 'success
' : 'fail
')); } } function updateReferenceFilesURL($projectDescriptor, $customerDescriptor) { global $configuration; methodName('updateReferenceFilesURL'); $fileURL = array('fileName' => $configuration->sourceFileName, 'fileURL' => $configuration->sourceFile, 'externalDescriptors' => array()); $request = array('projectDescriptor' => $projectDescriptor, 'customerDescriptor' => $customerDescriptor, 'files' => array($fileURL)); $input = array('loginAPI' => $configuration->loginAPI, 'referenceFiles' => $request); $res = $configuration->proxy->updateReferenceFilesURL($input); $updateReferenceFilesURLResponse = $res->return; if (is_object($updateReferenceFilesURLResponse)) { print('Reference materials updated with result: ' . ($updateReferenceFilesURLResponse->result ? 'successs
' : 'fail
')); } } function obtainProjectEstimates($projectDescriptor) { global $configuration; methodName('obtainProjectEstimates'); $dateFormat = 'd-m-Y H:i'; $deliveryServiceDescriptor = array('id' => 3654); $estimatesWorkflow = array('id' => null, 'workflowName' => null, 'workflow' => 'TRANSLATE_P_CORRECT_F_REVIEW'); //$estimatesWorkflow = array('id' => 2821, 'workflowName' => 'translate'); $estimatesUpdate = array( 'estimatesWorkflow' => $estimatesWorkflow, 'deliveryType' => 'NORMAL', 'deliveryServiceDescriptor' => $deliveryServiceDescriptor, 'numberOfCopies' => 1, 'buyerCountry' => 'GBR', 'buyerEUCitizenship' => 'EU', 'numberOfPages' => 1 ); $options = array('estimatesUpdate' => $estimatesUpdate); // $options = array('estimatesUpdate' => null); $input = array('loginAPI' => $configuration->loginAPI, 'options' => $options, 'projectDescriptor' => $projectDescriptor); $res = $configuration->proxy->obtainProjectEstimates($input); $projectEstimates = $res->return; if (is_object($projectEstimates)) { print('Price: ' . $projectEstimates->projectEstimates->price . ', TaxPrice: ' . $projectEstimates->projectEstimates->taxPrice . ', DeliveryDate: ' . date($dateFormat, strtotime($projectEstimates->projectEstimates->deliveryDate))); } } function updateProjectEstimates($projectDescriptor) { global $configuration; methodName('updateProjectEstimates'); $options = array(); $deliveryServiceDescriptor = array('id' => 3654); $estimatesWorkflow = array('id' => null, 'workflowName' => null, 'workflow' => 'TRANSLATE_P_CORRECT_F_REVIEW'); $estimatesUpdate = array('estimatesWorkflow' => $estimatesWorkflow, 'deliveryType' => 'FASTER_LEVEL_3', 'deliveryServiceDescriptor' => $deliveryServiceDescriptor, 'numberOfCopies' => 12, 'buyerCountry' => 'GBR', 'buyerEUCitizenship' => 'EU', 'numberOfPages' => 2); $estimatesUpdateAPI = array('projectDescriptor' => $projectDescriptor, 'estimatesUpdate' => $estimatesUpdate); $input = array('loginAPI' => $configuration->loginAPI, 'estimatesUpdate' => $estimatesUpdateAPI, 'options' => $options); $res = $configuration->proxy->updateProjectEstimates($input); $result = $res->return; print('Result: ' . $result->result); } function generateProjectsSimilarity($projectDescriptor, $projectDescriptor2) { global $configuration; methodName('generateProjectsSimilarity'); $options = array(); $projectSimilarityPair = array('baseProject' => $projectDescriptor, 'projectToCompare' => $projectDescriptor2); $projectsPairs = array($projectSimilarityPair); $projectsSimilarity = array('projectsPairs' => $projectsPairs); $input = array('loginAPI' => $configuration->loginAPI, 'option' => $options, 'projectsSimilarity' => $projectsSimilarity); $res = $configuration->proxy->generateProjectsSimilarity($input); $response = $res->return; if(!is_array($response->similarityDescriptors)) { $response->similarityDescriptors = array($response->similarityDescriptors); } foreach($response->similarityDescriptors as $similarityDescriptor) { print('Id: ' . $similarityDescriptor->similarityDescriptor->id . ', Base project: ' . $similarityDescriptor->projectsPair->baseProject->id . ', Project to compare: ' . $similarityDescriptor->projectsPair->projectToCompare->id); } return $response; } function obtainProjectsSimilarity($generateResponse) { global $configuration; methodName('obtainProjectsSimilarity'); foreach($generateResponse->similarityDescriptors as $similarityDescriptor) { $similarityDescriptors = array($similarityDescriptor->similarityDescriptor); $options = array(); $input = array('loginAPI' => $configuration->loginAPI, 'option' => $options, 'similarityDescriptors' => $similarityDescriptors); $obtainLimit = 10; while(--$obtainLimit > 0) { usleep(500000); $res = $configuration->proxy->obtainProjectsSimilarity($input); $response = $res->return; if(isset($response->projectsSimilarities->metrics)) { print('Similarity descriptor id: ' . $response->projectsSimilarities->similarityDescriptor->id . ', Base project: ' . $response->projectsSimilarities->projectsPair->baseProject->id . ', Project to compare ' . $response->projectsSimilarities->projectsPair->projectToCompare->id . '
'); print('Metrics: repetitions: ' . $response->projectsSimilarities->metrics->repetitions . ', iceMatches: ' . $response->projectsSimilarities->metrics->iceMatches . ', leveraged ' . $response->projectsSimilarities->metrics->leveraged . ', Total: ' . $response->projectsSimilarities->metrics->total); break; } } } } function getNonTranslatables($coreMetrics) { $result = getNonTranslatablesC($coreMetrics) + getNonTranslatablesWS($coreMetrics); return $result; } function getNoMatchedCharacters($coreMetrics) { $result = $coreMetrics->totalCharacters - getNonTranslatablesC($coreMetrics) - $coreMetrics->fuzzyMatchC1Characters - $coreMetrics->fuzzyMatchC2Characters - $coreMetrics->fuzzyMatchC3Characters - $coreMetrics->leveragedTmCharacters - $coreMetrics->exactMatchCharacters - $coreMetrics->leveragedInheritedCharacters - $coreMetrics->fuzzyForwardC1Characters - $coreMetrics->fuzzyForwardC2Characters - $coreMetrics->fuzzyForwardC3Characters - $coreMetrics->machineTranslationCharacters + getNonMatchedSpaces($coreMetrics); return $result; } function getNonTranslatablesC($coreMetrics) { $result = $coreMetrics->alphanumCharacters + $coreMetrics->measureCharacters + $coreMetrics->numericCharacters + $coreMetrics->punctuationCharacters; return $result; } function getNonMatchedSpaces($coreMetrics) { $result = $coreMetrics->totalWhiteSpaces - getNonTranslatablesWS($coreMetrics) - $coreMetrics->fuzzyMatchC1WhiteSpaces - $coreMetrics->fuzzyMatchC2WhiteSpaces - $coreMetrics->fuzzyMatchC3WhiteSpaces - $coreMetrics->leveragedTmWhiteSpaces - $coreMetrics->exactMatchWhiteSpaces - $coreMetrics->leveragedInheritedWhiteSpaces - $coreMetrics->fuzzyForwardC1WhiteSpaces - $coreMetrics->fuzzyForwardC2WhiteSpaces - $coreMetrics->fuzzyForwardC3WhiteSpaces - $coreMetrics->machineTranslationWhitespaces; return $result; } function getNonTranslatablesWS($coreMetrics) { $result = $coreMetrics->alphanumWhiteSpaces + $coreMetrics->measureWhiteSpaces + $coreMetrics->numericWhiteSpaces + $coreMetrics->punctuationWhiteSpaces; return $result; } function getNoMatchedCharactersStatistics($metrics) { $result = $metrics->totalCharacterCount - getNonTranslatablesCCStatistics($metrics) - $metrics->exactMatchedCharacterCount - $metrics->leveragedCharacterCount - $metrics->fuzzyMatchedCharacterCountC1 - $metrics->fuzzyMatchedCharacterCountC2 - $metrics->fuzzyMatchedCharacterCountC3 - $metrics->repetitionMatchedCharacterCount - $metrics->repetitionMatchedCharacterCountC1 - $metrics->repetitionMatchedCharacterCountC2 - $metrics->repetitionMatchedCharacterCountC3 - $metrics->machineTranslationCharacters + getNotMatchedSpacesStatistics($metrics); return $result; } function getNonTranslatablesStatistics($metrics) { $result = getNonTranslatablesCCStatistics($metrics) + getNonTranslatablesWSStatistics($metrics); return $result; } function getNonTranslatablesCCStatistics($metrics) { $result = $metrics->alphaNumericOnlyCharacterCount + $metrics->measurementOnlyCharacterCount + $metrics->numericOnlyCharacterCount + $metrics->punctuationOnlyCharacterCount + $metrics->otherNonTranslatableCharacterCount; return $result; } function getNotMatchedSpacesStatistics($metrics) { $result = $metrics->totalSpaceCharacterCount - getNonTranslatablesWSStatistics($metrics) - $metrics->exactMatchedSpacesCharacterCount - $metrics->leveragedSpacesCharacterCount - $metrics->fuzzyMatchedSpacesCharacterCountC1 - $metrics->fuzzyMatchedSpacesCharacterCountC2 - $metrics->fuzzyMatchedSpacesCharacterCountC3 - $metrics->repetitionMatchedSpacesCharacterCount - $metrics->repetitionMatchedSpacesCharacterCountC1 - $metrics->repetitionMatchedSpacesCharacterCountC2 - $metrics->repetitionMatchedSpacesCharacterCountC3 - $metrics->machineTranslationWhitespaces; return $result; } function getNonTranslatablesWSStatistics($metrics) { $result = $metrics->alphaNumericOnlySpacesCharacterCount + $metrics->measurementOnlySpacesCharacterCount + $metrics->numericOnlySpacesCharacterCount + $metrics->punctuationOnlySpacesCharacterCount + $metrics->otherNonTranslatableSpacesCharacterCount; return $result; } //////////////////////////// BEGIN helper methods ////////////////////////////////// function methodName($method) { print("

$method

"); } function jobsDescriptors($projectResponse) { $jobsDescriptors = array(); if(!is_array($projectResponse->jobs)) { $projectResponse->jobs = array($projectResponse->jobs); } foreach ($projectResponse->jobs as $jobResponse) { array_push($jobsDescriptors, $jobResponse->jobDescriptor); } return $jobsDescriptors; } function jobsDescriptorsFromProjectStatus($projectStatus) { $jobsDescriptors = array(); if (!is_array($projectStatus->jobs)) { $projectStatus->jobs = array($projectStatus->jobs); } foreach ($projectStatus->jobs as $jobStatus) { array_push($jobsDescriptors, $jobStatus->jobDescriptor); } return $jobsDescriptors; } function download($url, $directory) { $file = $directory . substr($url, strrpos($url, '/') + 1); print("Downloading file from $url to $file
"); copy($url, $file); } function downloadMTOM($fileName, $resource, $directory) { $file = $directory . $fileName; print("Downloading MTOM file $fileName to $file
"); file_put_contents($file, $resource); } //////////////////////////// END helper methods ////////////////////////////////// ?>