25, 'password' => 'YOUR_PASSWORD', 'client' => 'YOUR_COMPANY_LOGIN'); public $customer = array('id' => 1825); // existing customer ID public $tmCustomer = array('id' => 17891); // existing TM customer ID public $termCustomer = array('id' => 17894); // existing Term customer ID public $sourceLanguage = 'en_GB'; // source language public $targetLanguages = array('es_ES'); // list of target languages public $secondFileName = 'https://www.w3schools.com/xml/note.xml'; public $sourceFileName = 'simple.xml'; public $workflowId = 12456; public $tmFile = 'simple.xml.xlf.tmx'; public $termFile = 'simpleTerminology.xls'; public $tippFile = ''; //TIPP response file public $downloadDirectory = 'D:\\tmp\\'; public $proxy; public $proxyTM; public $proxyTerm; public function __construct() { $this->proxy = new SoapClient($this->wsdl); $this->proxyTM = new SoapClient($this->wsdlTM); $this->proxyTerm = new SoapClient($this->wsdlTerm); } } $configuration = new XTMAPIProjectManagerConfiguration(); ///////////////////////////// END poject manager configuration ////////////////////////// SCENARIOS //////////////////////// try { $customFields = obtainCustomFields(); $userDescriptor = createUser($customFields); updateUser($userDescriptor, $customFields); obtainPMConcordanceLink($userDescriptor); findUser($userDescriptor); checkUserLogin($userDescriptor); obtainXTMProjectManagerLink($userDescriptor); $customerDescriptor = createCustomer($userDescriptor, $customFields); findCustomer($customerDescriptor); findAnalysisTemplates($customerDescriptor); obtainLanguageCombinations($customerDescriptor); updateCustomer($customerDescriptor, $customFields); findCustomer($customerDescriptor); $importTM = importTMMTOM($customerDescriptor); checkTMCompletion($importTM); $exportTM = exportTM($customerDescriptor); checkTMCompletion($exportTM); downloadTMMTOM($exportTM); // downloadTMURL($exportTM); findMatches(); deleteTM($customerDescriptor); $exportTerm = exportTerm($customerDescriptor); checkTermCompletion($exportTerm); downloadTermURL($exportTerm); // downloadTermMTOM($exportTerm); $importTerm = importTermMTOM($customerDescriptor); // $importTermURL = importTermURL($customerDescriptor); // Choose one of two methods to create a project // $projectResponse = createProjectForPMURL($customerDescriptor); $projectResponse = createProjectForPMMTOM($customerDescriptor, $customFields); findWorkflow(); updateProjectWorkflow($projectResponse->projectDescriptor); checkProjectAnalysisCompletion($projectResponse->projectDescriptor); updateProject($projectResponse->projectDescriptor); $costBaseDescriptor = generateCost($projectResponse->projectDescriptor); obtainCost($costBaseDescriptor); $jobsDescriptors = jobsDescriptors($projectResponse); updateTranslationFilesMTOM($projectResponse->projectDescriptor); updateJobGroupWorkflow($projectResponse->projectDescriptor); createCustomerPM($customerDescriptor); obtainPMTranslationPropsLink($customerDescriptor); obtainXTMEditorLink($customerDescriptor, $userDescriptor, $jobsDescriptors[0]); obtainXTMTermManagerLink($customerDescriptor, $userDescriptor); obtainXTMTmManagerLink($customerDescriptor, $userDescriptor); // updateUserActivity($userDescriptor); // updateCustomerActivity($customerDescriptor); findTemplate(); $jobFileBaseResponse = generateJobFile($jobsDescriptors); //TIPP updateJobActivity($jobsDescriptors); checkProjectFileCompletion($jobFileBaseResponse->fileDescriptor); downloadProjectFileMTOM($jobFileBaseResponse->fileDescriptor); // downloadProjectFileURL($jobFileBaseResponse->fileDescriptor); // uploadProjectFileMTOM($projectResponse->projectDescriptor); // findConcordance(""); 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 updateTranslationFilesMTOM($projectDescriptor) { global $configuration; methodName('updateTranslationFilesMTOM'); $fileContent = file_get_contents($configuration->secondFilePath); $fileMTOM = ['fileName' => $configuration->secondFileName, 'fileMTOM' => $fileContent, 'externalDescriptors' => []]; $updateTranslationFiles = [ 'projectDescriptor' => $projectDescriptor, 'filesToDelete' => [ 'targetLanguages' => $configuration->targetLanguages, 'translationFiles' => [['fileName' => $configuration->sourceFileName]]] , 'filesToAdd' => [ 'matchType' => 'NO_MATCH', //'matchType' => 'MATCH_NAMES', // if matchType is set to MATCH_NAMES and file names match, treat it as a continuous project 'translationFiles' => [$fileMTOM] ] ]; $input = ['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 = [$projectResponse->jobs]; } foreach ($projectResponse->jobs as $jobResponse) { print('Job ID: ' . $jobResponse->jobDescriptor->id . ', file name: ' . $jobResponse->fileName . '
'); } } } function updateJobActivity($jobsDescriptors) { global $configuration; methodName('updateJobActivity'); $updateJobActivityOptions = ['activity' => 'CANCEL']; $input = ['loginAPI' => $configuration->loginAPI, 'updateJobsActivity' => ['jobs' => $jobsDescriptors], 'options' => $updateJobActivityOptions ]; $res = $configuration->proxy->updateJobActivity($input); print('Success: ' . var_export($res->return->result, true) . '
'); } function findAnalysisTemplates($customerDescriptor){ global $configuration; methodName('findAnalysisTemplates'); $filter = ['customers' => $customerDescriptor]; $input = ['loginAPI' => $configuration->loginAPI, 'filter' => $filter]; $res = $configuration->proxy->findAnalysisTemplates($input); print('Result: ' . var_dump($res->return->analysisTemplates)); } function findWorkflow() { global $configuration; methodName('findWorkflow'); $input = ['loginAPI' => $configuration->loginAPI]; $res = $configuration->proxy->findWorkflow($input); $workflows = $res->return->workflows; foreach ($workflows as $workflow) { print_r($workflow->id . ":" . $workflow->workflowName . '
'); } } function updateProjectWorkflow($projectDescriptor) { global $configuration; methodName('updateProjectWorkflow'); $workflowId = $configuration->workflowId; $workflowDescription = ['id' => $workflowId, 'workflowName' => 'translate']; $workflow = ['workflow' => $workflowDescription]; $updateProjectWorkflow = ['project' => $projectDescriptor, 'workflow' => $workflow]; $input = ['loginAPI' => $configuration->loginAPI, 'updateProjectWorkflow' => $updateProjectWorkflow]; $configuration->proxy->updateProjectWorkflow($input); } function obtainLanguageCombinations($customerDescriptor ) { global $configuration; methodName('obtainLanguageCombinations'); $filter = ['customer'=>$customerDescriptor]; $options=['fetchLanguageDefinitions'=>'YES']; $input = ['loginAPI' => $configuration->loginAPI, 'filter' => $filter, 'options' => $options]; $res = $configuration->proxy->obtainLanguageCombinations($input); print('XTM Language Combination Type : ' . $res->return->languageCombinationSpecification->languageCombinationType . '
'); $languageDefiniotions = $res->return->languageCombinationSpecification->languageDefinitions; $i = 0; foreach ($languageDefiniotions as $languageDefinition){ print_r($languageDefinition->languageCode . ":".$languageDefinition->name . '
'); $i++; if ($i > 20 ){ break; } } } function obtainCustomFields() { //Add custom field in XTM Panel: Settings -> Data -> Custom Fields global $configuration; methodName('obtainCustomFields'); $filter = [ 'activity' => 'ALL', 'module' => 'ALL', 'name' => null ]; $input = [ 'loginAPI' => $configuration->loginAPI, 'filter' => $filter, ]; $res = $configuration->proxy->obtainCustomFields($input); if (empty($res->return->customFields)){ echo "No custom fields"; return []; } foreach ($res->return->customFields as $customField) { echo "id: " . $customField->id . ", "; echo "activity: " . $customField->activity . ", "; echo "module: " . $customField->module . ", "; echo "name: " . $customField->name . ", "; echo "obligatory: " . $customField->obligatory . ", "; // echo "values: " . $customField->values . ", "; // echo "termDetails: " . $customField->termDetails . ", "; echo "type: " . $customField->type . "
"; } return $res->return->customFields; } function createUser($customFields) { global $configuration; methodName('createUser'); $languageCombination = array('sourceLanguage' => 'fr_FR', 'targetLanguage' => 'hu_HU', 'costPerHour' => 25, 'costPerWord' => 0.3); $domainDescriptor = array('domain' => 'ENGINEERING'); // $pmRolesDescriptor = array('id' => '7372'); // Please uncomment the above line to add PM_LIMITED or PM_CREATOR role. IDs for roles can be supplied to you by XTM Support. $termRights = array('termRight' => 'ADD', 'termRight' => 'APPROVE'); $user = array('firstName' => 'Jack', 'lastName' => 'Black', 'username' => 'jack_' . rand(0, 1000000), 'password' => 'secret', 'email' => 'noreply@xtm-intl.com'); $userAddition = array( 'roles' => array('TRANSLATOR', 'REVIEWER', 'PROJECT_MANAGER'), 'languages' => array($languageCombination), 'domains' => array($domainDescriptor), 'user' => $user, 'groupAccount' => false, 'termGlobal' => false, // 'rolesDescriptors' => array($pmRolesDescriptor) // Please uncomment the above line to add a user with PM_LIMITED or PM_CREATOR role. // Only one of the three PM roles (PROJECT_MANAGER counts as well) can be added at the same time, so please delete PROJECT_MANAGER role from roles if // Uncomment the line under this comment to set the projects created by this user as the only visible for him. // 'projectVisibility' => 'CREATOR' ); if (false === empty($customFields)){ $userAddition['customFields'] = createCustomFieldArray($customFields); } $input = array('loginAPI' => $configuration->loginAPI, 'userAddition' => $userAddition); $res = $configuration->proxy->createUser($input); $createUserResponse = $res->return; $userDescriptor = $createUserResponse->user->userDescriptor; print('User ID: ' . $userDescriptor->id . ', '); print('Name: ' . $userDescriptor->name . '
'); return $userDescriptor; } function createCustomFieldArray($customFields) { $userCustomFields = []; foreach ($customFields as $customField) { $userCustomFields[] = [ 'customFieldDescriptor' => ['id' => $customField->id], 'customFieldValue' => [ 'booleanValue' => ($customField->type === "CHECKBOX"), 'dateValue' => date("Y-m-d"), 'ids' => false, 'value' => ($customField->type === "CHECKBOX") ? true : "1234" ] ]; } return $userCustomFields; } function updateCustomer($customerDescriptor, $customFields = null) { global $configuration; methodName('updateCustomer'); $customerBase = ['name' => 'Example Company Updated ' . rand(0, 1000)]; $address = ['city' => 'New York City', 'street' => '7th Avenue', 'country' => 'USA']; $customer = [ 'customerBase' => $customerBase, 'address' => $address, 'customerDescriptor' =>$customerDescriptor ]; if (false === empty($customFields)) { $customer['customFields'] = createCustomFieldArray($customFields); } $input = ['loginAPI' => $configuration->loginAPI, 'customers' => $customer]; $res = $configuration->proxy->updateCustomer($input); $updateCustomerResponse = $res->return; $customers = $updateCustomerResponse->customers; ($customers->result) ? print("Update customer successful
") : print('Update customer failed
'); print('Customer ID: ' . $customers->customerDescriptor->id . ', '); print('Name: ' . $customers->customerDescriptor->name . '
'); } function createCustomer($projectManagerDescriptor, $customFields = null) { global $configuration; methodName('createCustomer'); $customerBase = array('name' => 'Example Company ' . rand(0, 1000)); $address = array('city' => 'New York', 'street' => '5th Avenue', 'country' => 'USA'); $additionalSettings = array('projectManagerDescriptor' => $projectManagerDescriptor); $customer = array('customerBase' => $customerBase, 'address' => $address, 'additionalSettings' => $additionalSettings); if (false === empty($customFields)){ $customer['customFields'] = createCustomFieldArray($customFields); } $input = array('loginAPI' => $configuration->loginAPI, 'customer' => $customer); $res = $configuration->proxy->createCustomer($input); $createCustomerResponse = $res->return; $customerDescriptor = $createCustomerResponse->customer->customerDescriptor; print('Customer ID: ' . $customerDescriptor->id . ', '); print('Name: ' . $customerDescriptor->name . '
'); return $customerDescriptor; } function createCustomerPM($customerDescriptor) { global $configuration; methodName('createCustomerPM'); $user = array('firstName' => 'Sean', 'lastName' => 'Noname', 'username' => 'sean_' . rand(0, 1000), 'password' => 'pwsd', 'email' => 'sean@example.com'); $customerPM = array('user' => $user, 'customer' => $customerDescriptor, 'role' => 'MANAGER', 'tmAccessRights' => ('MODIFY_TM'), 'termAccessRights' => array('ADD', 'APPROVE', 'DELETE')); $input = array('loginAPI' => $configuration->loginAPI, 'customerPM' => $customerPM); $res = $configuration->proxy->createCustomerPM($input); $createCustomerPMResponse = $res->return; $customerPMDescriptor = $createCustomerPMResponse->customerPM->customerPMDescriptor; print('Customer ID: ' . $customerPMDescriptor->id . ', '); print('Name: ' . $customerPMDescriptor->name . '
'); return $customerPMDescriptor; } function obtainPMTranslationPropsLink($customerDescriptor) { global $configuration; methodName('obtainPMTranslationPropsLink'); $pmTranslationPropsOptions = array('showMachineTranslationBox' => false); $pmTranslationPropsLinkOptions = array('configurationLevel' => 'CLIENT', 'customerDescriptor' => $customerDescriptor, 'translationPropsOptions' => $pmTranslationPropsOptions); $input = array('loginAPI' => $configuration->loginAPI, 'options' => $pmTranslationPropsLinkOptions); $res = $configuration->proxy->obtainPMTranslationPropsLink($input); $obtainPMTranslationPropsLinkResponse = $res->return; print('Translation properties link: ' . $obtainPMTranslationPropsLinkResponse->translationProps->translationPropsLink . '
'); } function obtainXTMEditorLink($customerDescriptor, $userDescriptor, $jobDescriptor) { global $configuration; methodName('obtainXTMEditorLink'); // To show or hide specific file generation options from the Editor please use below object and flags. //$previewDTO = array('showExtendedTable' => true, //'showGenerateTarget' => false, //'showHTMLIcon' => false, //'showHTMLSideBySideIcon' => false, //'showPDFIcon' => true, //'showPDFSideBySideIcon' => true); $editorOptions = array('allowShowingSegmentId' => true, 'showUserDescription' => true, //'previewDTO' => $previewDTO, 'editorMode' => 'STANDARD' //To open editor in the Visual mode please uncomment the line below. //Also please note that it will open standard Editor view, even if this option will be set to VISUAL, //when the source file not be an HTML file, or XML without proper configuration. //'editorMode' => 'VISUAL' ); $userOptions = array('role' => 'TRANSLATOR', 'terminologyRights' => array('MODIFY', 'ADD', 'VIEW', 'IMPORT', 'EXPORT', 'APPROVE')); $workflowStepDescriptor = array('workflowStep' => 'TRANSLATE1'); $useLqa = false; //$useLqa = true; //open editor with LQA $workflowOptions = array( 'currentWorkflowStep' => $workflowStepDescriptor, // 'manageType' => 'FINISH', 'useLqa' => $useLqa); $editor = array('customerDescriptor' => $customerDescriptor, 'userDescriptor' => $userDescriptor, 'jobDescriptor' => $jobDescriptor, 'editorOptions' => $editorOptions, 'userOptions' => $userOptions, 'workflowOptions' => $workflowOptions); $input = array('loginAPI' => $configuration->loginAPI, 'editor' => $editor); $res = $configuration->proxy->obtainXTMEditorLink($input); $obtainXTMEditorLinkResponse = $res->return; print('XTM Editor link: ' . $obtainXTMEditorLinkResponse->editor->editorURL . '
'); } function obtainXTMTermManagerLink($customerDescriptor, $userDescriptor) { global $configuration; methodName('obtainXTMTermManagerLink'); $termManagerOptions = array('downloadSimpleFiles' => true); $userOptions = array('termRights' => array('ADD', 'VIEW', 'IMPORT', 'EXPORT', 'APPROVE', 'DELETE')); $termManager = array('customersDescriptors' => array($customerDescriptor), 'userDescriptor' => $userDescriptor, 'termManagerOptions' => $termManagerOptions, 'userOptions' => $userOptions); $input = array('loginAPI' => $configuration->loginAPI, 'termManager' => $termManager); $res = $configuration->proxy->obtainXTMTermManagerLink($input); $obtainXTMTermManagerLinkResponse = $res->return; print('XTM Terminology Manager link: ' . $obtainXTMTermManagerLinkResponse->termManager->termManagerURL . '
'); } function obtainXTMTmManagerLink($customerDescriptor, $userDescriptor) { global $configuration; methodName('obtainXTMTmManagerLink'); $tmManagerOptions = array('downloadSimpleFiles' => true); $userOptions = array('tmRights' => array('IMPORT', 'EXPORT', 'MODIFY', 'VIEW')); $tmManager = array('customersDescriptors' => array($customerDescriptor), 'userDescriptor' => $userDescriptor, 'tmManagerOptions' => $tmManagerOptions, 'userOptions' => $userOptions); $input = array('loginAPI' => $configuration->loginAPI, 'tmManager' => $tmManager); $res = $configuration->proxy->obtainXTMTmManagerLink($input); $obtainXTMTmManagerLinkResponse = $res->return; print('XTM Translation Memory Manager link: ' . $obtainXTMTmManagerLinkResponse->tmManager->tmManagerURL . '
'); } function createProjectForPMURL($customerDescriptor) { global $configuration; methodName('createProjectForPMURL'); //$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, 'externalDescriptors' => array()); $projectURL = array('translationFiles' => array($fileURL), 'sourceLanguage' => $configuration->sourceLanguage, 'targetLanguages' => $configuration->targetLanguages, 'customer' => $configuration->customer, 'name' => 'PHP API PM project_' . rand(0, 1000), //'tmTags' => array($daysTag, $monthTag), //'tmPenaltyProfile' => $penaltyProfile, 'allowNotApproveTerm' => 'DISALLOW', 'useTerminologyDecoration' => 'TRUE', 'tmCustomers' => array($configuration->tmCustomer), //'autoWorkflowFinish' => 'AUTO_FINISH_FULL_MATCHED_STEPS', 'termCustomers' => array($configuration->termCustomer)); $createProjectURLOptions = array('autopopulate' => true); $input = array('loginAPI' => $configuration->loginAPI, 'project' => $projectURL, 'options' => $createProjectURLOptions); $res = $configuration->proxy->createProjectForPMURL($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 createProjectForPMMTOM($customerDescriptor, $customFields = null) { global $configuration; methodName('createProjectForPMMTOM'); //$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'); $fileContent = file_get_contents($configuration->sourcefile); $fileMTOM = array('fileName' => $configuration->sourcefile, 'fileMTOM' => $fileContent, 'externalDescriptors' => array()); // To create project container do not set the translation files $projectMTOM = array( 'translationFiles' => array($fileMTOM), '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", 'domain' => ['domain' => 'TRAVEL', 'Lorem ipsum'], 'sourceLanguage' => $configuration->sourceLanguage, 'targetLanguages' => $configuration->targetLanguages, 'customer' => $configuration->customer, 'name' => 'PHP API MTOM project_' . rand(0, 1000), 'fileProcessType' => 'JOIN', //'tmTags' => array($daysTag, $monthTag), //'tmPenaltyProfile' => $penaltyProfile, 'allowNotApproveTerm' => 'DISALLOW', 'useTerminologyDecoration' => 'TRUE', 'tmCustomers' => array($configuration->tmCustomer), //'autoWorkflowFinish' => 'AUTO_FINISH_FULL_MATCHED_STEPS', 'termCustomers' => array($configuration->termCustomer)); if (false === empty($customFields)){ $projectMTOM['projectCustomFields'] = createCustomFieldArray($customFields); } $createProjectMTOMOptions = array('autopopulate' => true); $input = array('loginAPI' => $configuration->loginAPI, 'project' => $projectMTOM, 'options' => $createProjectMTOMOptions); $res = $configuration->proxy->createProjectForPMMTOM($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 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 checkProjectAnalysisCompletion($projectDescriptor) { global $configuration; methodName('checkProjectAnalysisCompletion'); while (true) { $input = array('loginAPI' => $configuration->loginAPI, 'project' => $projectDescriptor); $res = $configuration->proxy->checkProjectAnalysisCompletion($input); $checkProjectAnalysisCompletionResponse = $res->return; $projectCompletionStatus = $checkProjectAnalysisCompletionResponse->project->status; if ('FINISHED' == $projectCompletionStatus) { print('Project analysis has been finished, ID: ' . $checkProjectAnalysisCompletionResponse->project->projectDescriptor->id . '
'); print('Jobs:
'); $jobs = $checkProjectAnalysisCompletionResponse->project->jobs; if(!is_array($jobs)) { $jobs = array($jobs); } foreach ($jobs as $jobResponse) { print('- Job ID: ' . $jobResponse->jobDescriptor->id . ', status: ' . $jobResponse->status . '
'); } break; } else { print('Checking...
'); } sleep(2); } } function updateUserActivity($userBaseDescriptor) { global $configuration; methodName('updateUserActivity'); $usersDescriptors = array(getUserDescriptor($userBaseDescriptor, 'INTERNALLINGUIST')); $updateUserActivityOptions = array('activity' => 'DELETE'); $input = array('loginAPI' => $configuration->loginAPI, 'users' => $usersDescriptors, 'options' => $updateUserActivityOptions); $res = $configuration->proxy->updateUserActivity($input); $updateUserActivityResponse = $res->return; if (is_object($updateUserActivityResponse) && isset($updateUserActivityResponse->users)) { if(!is_array($updateUserActivityResponse->users)) { $updateUserActivityResponse->users = array($updateUserActivityResponse->users); } foreach ($updateUserActivityResponse->users as $userActivityResponse) { print('User ID: ' . $userActivityResponse->userDescriptor->id . ', '); print('Result: ' . $userActivityResponse->result . '
'); } } } function updateCustomerActivity($customerDescriptor) { global $configuration; methodName('updateCustomerActivity'); $customersDescriptors = array($customerDescriptor); $updateCustomerActivityOptions = array('activity' => 'DELETE'); $input = array('loginAPI' => $configuration->loginAPI, 'customers' => $customersDescriptors, 'options' => $updateCustomerActivityOptions); $res = $configuration->proxy->updateCustomerActivity($input); $updateCustomerActivityResponse = $res->return; if (is_object($updateCustomerActivityResponse) && isset($updateCustomerActivityResponse->customers)) { if(!is_array($updateCustomerActivityResponse->customers)) { $updateCustomerActivityResponse->customers = array($updateCustomerActivityResponse->customers); } foreach ($updateCustomerActivityResponse->customers as $customerActivityResponse) { print('User ID: ' . $customerActivityResponse->customerDescriptor->id . ', '); print('Result: ' . $customerActivityResponse->result . '
'); } } } function importTMMTOM($customerDescriptor) { global $configuration; methodName('importTMMTOM'); $fileContent = file_get_contents($configuration->tmFile); //// Create tags and profile before use them in the example //$daysTag = array('name' => 'day', 'values' => array(array('name' => 'Monday'), array('name' => 'Tuesday'))); //$monthTag = array('name' => 'month', 'values' => array(array('name' => 'February'))); $importTMMTOM = array( 'fileName' => $configuration->tmFile, 'fileMTOM' => $fileContent, 'sourceLanguage' => $configuration->sourceLanguage, 'targetLanguage' => $configuration->targetLanguages[0], //'tmTags' => array($daysTag, $monthTag), //// set imported segment status //'segmentImportStatus' => "APPROVED", 'customer' => $customerDescriptor); $importTMMTOMs = array($importTMMTOM); $input = array('loginAPI' => $configuration->loginAPI, 'tmFiles' => $importTMMTOMs); $res = $configuration->proxy->importTMMTOM($input); $importTMMTOMResponse = $res->return; $filesResponse = $importTMMTOMResponse->files; if(!is_array($filesResponse)) { $filesResponse = array($filesResponse); } foreach ($filesResponse as $file) { print('File ID: ' . $file->id . ', '); print('name: ' . $file->fileName . '
'); } return $filesResponse; } function checkTMCompletion($tmFilesDescriptors) { global $configuration; methodName('checkTMCompletion'); $inProgress = false; $files = array(); do { $input = array('loginAPI' => $configuration->loginAPI, 'files' => $tmFilesDescriptors); $res = $configuration->proxy->checkTMCompletion($input); $checkTMCompletionResponse = $res->return; $files = $checkTMCompletionResponse->files; $inProgress = false; if(!is_array($files)) { $files = array($files); } foreach ($files as $file) { $inProgress |= $file->status == 'IN_PROGRESS'; } if ($inProgress) { print('Checking...
'); sleep(2); } } while ($inProgress); foreach ($files as $file) { print('File ID: ' . $file->file->id . ', status: ' . $file->status); } } function importTermMTOM($customerDescriptor) { global $configuration; methodName('importTermMTOM'); $fileContent = file_get_contents($configuration->termFile); $importTermMTOM = array( 'fileName' => $configuration->termFile, 'fileMTOM' => $fileContent, 'fileType' => 'XLS', 'customer' => $customerDescriptor); $importTermOptions = array( // Uncomment below line to use Purge Terms option. // 'purgeTerms' => true, 'addToExistingTerms' => false); $importTermMTOMs = array($importTermMTOM); $input = array('loginAPI' => $configuration->loginAPI, 'files' => $importTermMTOMs, 'options' => $importTermOptions); $res = $configuration->proxyTerm->importTermMTOM($input); $importTermMTOMResponse = $res->return; $filesResponse = $importTermMTOMResponse->termFiles; if(!is_array($filesResponse)) { $filesResponse = array($filesResponse); } foreach ($filesResponse as $file) { print('File ID: ' . $file->id . ', '); print('name: ' . $file->fileName . '
'); } return $filesResponse; } function importTermURL($customerDescriptor) { global $configuration; methodName('importTermURL'); $importTermURL = array( 'url' => '', //Please provide your own file to import Term 'fileType' => 'XLS', 'customer' => $customerDescriptor); $importTermURLOptions = array( // Uncomment below line to use Purge Terms option. // 'purgeTerms' => true, 'addToExistingTerms' => false); $importTermURLs = array($importTermURL); $input = array('loginAPI' => $configuration->loginAPI, 'files' => $importTermURLs, 'options' => $importTermURLOptions); $res = $configuration->proxyTerm->importTermURL($input); $importTermURLResponse = $res->return; $filesResponse = $importTermURLResponse->files; if(!is_array($filesResponse)) { $filesResponse = array($filesResponse); } foreach ($filesResponse as $file) { print('File ID: ' . $file->id . ', '); print('name: ' . $file->fileName . '
'); } return $filesResponse; } function exportTM($customerDescriptor) { global $configuration; methodName('exportTM'); $exportTM = array( 'sourceLanguage' => $configuration->sourceLanguage, 'targetLanguage' => $configuration->targetLanguages[0], 'customer' => $customerDescriptor); $exportTMs = array($exportTM); $exportTMOptions = null; //Please comment this line and uncomment the line below to include Reverse Memory. //$exportTMOptions = array('includeReverseMemory' => 'true'); $input = array('loginAPI' => $configuration->loginAPI, 'files' => $exportTMs, 'options' => $exportTMOptions); $res = $configuration->proxy->exportTM($input); $exportTMResponse = $res->return; $filesResponse = $exportTMResponse->files; if(!is_array($filesResponse)) { $filesResponse = array($filesResponse); } foreach ($filesResponse as $file) { print('File ID: ' . $file->id . ', '); print('name: ' . $file->fileName . '
'); } return $filesResponse; } function downloadTMMTOM($tmFilesDescriptors) { global $configuration; methodName('downloadTMMTOM'); $input = array('loginAPI' => $configuration->loginAPI, 'tmFiles' => $tmFilesDescriptors); $res = $configuration->proxy->downloadTMMTOM($input); $downloadTMMTOMResponse = $res->return; if (isset($downloadTMMTOMResponse->files)) { if(!is_array($downloadTMMTOMResponse->files)) { $downloadTMMTOMResponse->files = array($downloadTMMTOMResponse->files); } foreach ($downloadTMMTOMResponse->files as $tmMTOMResponse) { print('File name: ' . $tmMTOMResponse->fileName . '
'); downloadMTOM($tmMTOMResponse->fileName, $tmMTOMResponse->fileMTOM, $configuration->downloadDirectory); } } } function downloadTMURL($tmFilesDescriptors) { global $configuration; methodName('downloadTMURL'); $input = array('loginAPI' => $configuration->loginAPI, 'tmFiles' => $tmFilesDescriptors); $res = $configuration->proxy->downloadTMURL($input); $downloadTMMTOMResponse = $res->return; if (isset($downloadTMMTOMResponse->files)) { if(!is_array($downloadTMMTOMResponse->files)) { $downloadTMMTOMResponse->files = array($downloadTMMTOMResponse->files); } foreach ($downloadTMMTOMResponse->files as $tmMTOMResponse) { print('File URL: ' . $tmMTOMResponse->fileURL . '
'); download($tmMTOMResponse->fileURL, $configuration->downloadDirectory); } } } function exportTerm($customerDescriptor) { global $configuration, $sourceLanguage,$targetLanguages; methodName('exportTerm'); $xtmExportTermAPI = array('columnsToExport' => array('STATUS', 'LAST_MOD_BY'), 'customer' => $customerDescriptor, 'fileType' => 'XLSX', 'allLanguages' => 'TRUE'); $exportTermOptions = null; $input = array('loginAPI' => $configuration->loginAPI, 'files' => $xtmExportTermAPI, 'options' => $exportTermOptions); $res = $configuration->proxyTerm->exportTerm($input); $exportTermResponse = $res->return; $filesResponse = $exportTermResponse->files; if(!is_array($filesResponse)) { $filesResponse = array($filesResponse); } foreach ($filesResponse as $file) { print('File ID: ' . $file->id ); } return $filesResponse; } function checkTermCompletion($exportTerm){ global $configuration; methodName('checkTermCompletion'); $inProgress = false; $files = array(); do { $input = array('loginAPI' => $configuration->loginAPI, 'files' => $exportTerm); $res = $configuration->proxyTerm->checkTermCompletion($input); $checkTermCompletionResponse = $res->return; $files = $checkTermCompletionResponse->files; $inProgress = false; if(!is_array($files)) { $files = array($files); } foreach ($files as $file) { $inProgress |= $file->status == 'IN_PROGRESS'; } if ($inProgress) { print('Checking...
'); sleep(2); } } while ($inProgress); foreach ($files as $file) { print('File ID: ' . $file->file->id . ', status: ' . $file->status); } } function downloadTermMTOM($termFilesDescriptors) { global $configuration; methodName('downloadTermMTOM'); $input = array('loginAPI' => $configuration->loginAPI, 'files' => $termFilesDescriptors); $res = $configuration->proxyTerm->downloadTermMTOM($input); $downloadTermMTOMResponse = $res->return; if (isset($downloadTermMTOMResponse->files)) { if(!is_array($downloadTermMTOMResponse->files)) { $downloadTermMTOMResponse->files = array($downloadTermMTOMResponse->files); } foreach ($downloadTermMTOMResponse->files as $termMTOMResponse) { print('File name: ' . $termMTOMResponse->fileName . '
'); downloadMTOM($termMTOMResponse->fileName, $termMTOMResponse->fileMTOM, $configuration->downloadDirectory); } } } function downloadTermURL($tmFilesDescriptors) { global $configuration; methodName('downloadTermURL'); $input = array('loginAPI' => $configuration->loginAPI, 'files' => $tmFilesDescriptors); $res = $configuration->proxyTerm->downloadTermURL($input); $downloadTermURLResponse = $res->return; if (isset($downloadTermURLResponse->files)) { if(!is_array($downloadTermURLResponse->files)) { $downloadTermURLResponse->files = array($downloadTermURLResponse->files); } foreach ($downloadTermURLResponse->files as $termURLResponse) { print('File URL: ' . $termURLResponse->fileURL . '
'); download($termURLResponse->fileURL, $configuration->downloadDirectory); } } } function obtainPMConcordanceLink($userDescriptor) { global $configuration; methodName('obtainPMConcordanceLink'); $customersDescriptors = array ($configuration->customer); $languageCombinations = array (array('sourceLanguage' => 'pl_PL', 'targetLanguage' => 'en_GB')); $concordanceAPI = array ('userDescriptor' => $userDescriptor, 'customersDescriptors' => $customersDescriptors, 'languageCombinations' => $languageCombinations); $input = array('loginAPI' => $configuration->loginAPI, 'concordanceAPI' => $concordanceAPI); $res = $configuration->proxy->obtainPMConcordanceLink($input); $concordance = $res->return->concordance; print('Concordance link: ' . $concordance->concordanceURL); } function updateUser($userDescriptor, $customFields = null) { global $configuration; methodName('updateUser'); $input = [ 'loginAPI' => $configuration->loginAPI, 'users' => [ "userDescriptor" => $userDescriptor, "firstName" => "Mark_" . rand(0, 1000000), "lastName" => "Smith" ] ]; if (false === empty($customFields)) { $input['users']['customFields'] = createCustomFieldArray($customFields); } $res = $configuration->proxy->updateUser($input); $findUserResponse = $res->return; $users = $findUserResponse->users; ($users->result) ? print("Update user successful
") : print('Update user failed
'); print('User ID: ' . $users->userDescriptor->id . ', '); print('First name: ' . $users->userDescriptor->name . '
'); } function findUser($userDescriptor) { global $configuration; methodName('findUser'); $filter = array('users' => array($userDescriptor)); $options =['fetchAddress'=>'YES']; $input = array('loginAPI' => $configuration->loginAPI, 'filter' => $filter, 'options'=>$options); $res = $configuration->proxy->findUser($input); $findUserResponse = $res->return; $users = $findUserResponse->users; if(!is_array($users)) { $users = array($users); } foreach ($users as $user) { print('User ID: ' . $user->user->id . ', '); print('First name: ' . $user->firstName . ', '); print('Last name: ' . $user->lastName . ', '); print('Preferred language: ' . $user->preferredLanguage . '
'); if (!empty($user->customFields)){ foreach ($user->customFields as $customField){ print('Custom field id: ' . $customField->customFieldDescriptor->id . '
'); } } print('Custom fields: ' ); } } function findCustomer($customerDescriptor) { global $configuration; methodName('findCustomer'); $filter = array('customers' => array($customerDescriptor), 'activityFilter' => 'ONLY_ACTIVE'); $options =['fetchAddress'=>'YES']; $input = array('loginAPI' => $configuration->loginAPI, 'filter' => $filter, 'options'=>$options); $res = $configuration->proxy->findCustomer($input); $findCustomerResponse = $res->return; $customers = $findCustomerResponse->customers; if(!is_array($customers)) { $customers = array($customers); } foreach ($customers as $customer) { print('Customer ID: ' . $customer->customer->id . ', '); print('Name: ' . $customer->customer->name . '
'); print('City: '. $customer->address->city. '
'); print('Country: '. $customer->address->country. '
'); print('Street: '. $customer->address->street. '
'); if (property_exists($customer, 'customFields')) { $customFields = $customer->customFields; print('Custom field id: ' . $customFields->customFieldDescriptor->id . '
'); print('Custom field value: ' . $customFields->customFieldValue->value . '
'); } } } function findTemplate() { global $configuration; methodName('findTemplate'); $filter = array('scope' => 'GLOBAL'); $input = array('loginAPI' => $configuration->loginAPI, 'filter' => $filter); $res = $configuration->proxy->findTemplate($input); $findTemplateResponse = $res->return; $templates = $findTemplateResponse->templates; if(!is_array($templates)) { $templates = array($templates); } foreach ($templates as $template) { print('Template ID: ' . $template->template->id . ', '); print('Name: ' . $template->template->name . '
'); } } function generateCost($projectDescriptor) { global $configuration; methodName('generateCost'); $costAPI = array('projectDescriptor' => $projectDescriptor, 'source' => 'INITIAL_METRICS'); $costs = array($costAPI); $options = array( // use below options to generate with overridden all/missing user with specific user //'assignment' => array('user' => array('id' => 5166, 'type' => 'INTERNALLINGUIST'), 'overrideAssignment' => 'OVERRIDE_ALL') // use below options to generate costs with missing rates/time //'missingRatesProvider' => 'ZERO', 'missingTimeProvider' => 'ZERO' ); $input = array('loginAPI' => $configuration->loginAPI, 'costs' => $costs, 'options' => $options); $res = $configuration->proxy->generateCost($input); $generateCostResponse = $res->return; $costDescriptors = $generateCostResponse->costDescriptors; if (isset($costDescriptors)) { if(!is_array($costDescriptors)) { $costDescriptors = array($costDescriptors); } foreach ($costDescriptors as $cost) { print('Cost ID: ' . $cost->costBaseDescriptor->id . '
'); } } return $costDescriptors[0]->costBaseDescriptor; } function obtainCost($costBaseDescriptor) { global $configuration; methodName('obtainCost'); $costDescriptor = array('costBaseDescriptor' => $costBaseDescriptor); $costs = array($costDescriptor); $input = array('loginAPI' => $configuration->loginAPI, 'costs' => $costs); $res = $configuration->proxy->obtainCost($input); $obtainCostResponse = $res->return; $costsResponse = $obtainCostResponse->costs; if (isset($costsResponse)) { if(!is_array($costsResponse)) { $costsResponse = array($costsResponse); } foreach ($costsResponse as $cost) { print('Cost ID: ' . $cost->costDescriptor->costBaseDescriptor->id . ', '); print('Project ID: ' . $cost->costDescriptor->projectDescriptor->id . '
'); } } } function checkUserLogin($userDescriptor) { global $configuration; methodName('checkUserLogin'); //please uncomment code below to check user login credentials on LSP instance //$xtmInstance = array('name' => 'LSP name', 'xtmInstanceTypw' => 'LSP'); $userLogin = array('username' => $userDescriptor->name, 'password' => 'secret' /**, 'xtmInstance' => $xtmInstance **/); $input = array('loginAPI' => $configuration->loginAPI, 'userLogin' => $userLogin); $res = $configuration->proxy->checkUserLogin($input); $checkUserLoginResponse = $res->return; $result = $checkUserLoginResponse->result; if(isset($result)) { print('User id: ' . $userDescriptor->id . ' check login credentials operation ended with result: ' . $result . '
'); } } function updateJobGroupWorkflow($projectDesc) { global $configuration; methodName('updateJobGroupWorkflow'); $jobGroup = array('projectDescriptor' => $projectDesc // uncomment line below to use the update workflow for only specific target language jobs // 'projectTargetLanguages' => array('en_GB') // uncomment line below and comment two lines above to update only specific jobs // 'jobDescriptors' => array('jobDescriptor' => $jobDescriptor) ); // change workflow to only translate step $workflow = array('workflowSteps' => array('stepDescriptor' => array('workflowStep' => 'TRANSLATE1'))); //use option below to overwrite all details in current worklow like assignment etc. //$options = array('matchType' => 'NO_MATCH'); $input = array('loginAPI' => $configuration->loginAPI, 'jobGroup' => $jobGroup, 'workflow' => $workflow); //'options' => $options); $res = $configuration->proxy->updateJobGroupWorkflow($input); } function obtainXTMProjectManagerLink($userDescriptor) { global $configuration; methodName('obtainXTMProjectManagerLink'); $userLogin = array('username' => $userDescriptor->name, 'password' => 'secret'); $interfaceOptions = array('fullWindowMode' => false); $linkRequest = array('userLogin' => $userLogin, 'interfaceOptions' => $interfaceOptions); $input = array('loginAPI' => $configuration->loginAPI, 'projectManager' => $linkRequest); $res = $configuration->proxy->obtainXTMProjectManagerLink($input); $obtainXTMProjectManagerLinkResponse = $res->return; if(isset($obtainXTMProjectManagerLinkResponse) && $obtainXTMProjectManagerLinkResponse->result == 'SUCCESS') { print('XTM Project Manager login link: ' . $obtainXTMProjectManagerLinkResponse->projectManagerURL . '
'); } } function generateJobFile($jobsDescriptors) { global $configuration; methodName('generateJobFile'); $generateJobFileOptions = array('fileType' => 'TIPP'); $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('File ID: ' . $jobFileBaseResponses->fileDescriptor->id . ', '); print('File type: ' . $jobFileBaseResponses->fileType . '
'); } return $generateJobFileResponse->files[0]; } 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 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 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 uploadProjectFileMTOM($projectDescriptor) { global $configuration; methodName('uploadProjectFileMTOM'); $fileContent = file_get_contents($configuration->tippFile); $stepDescriptor = array('workflowStep' => 'TRANSLATE1'); // please change the fileType value in the line below to 'SEGMENT_ID_FILES' to send the segment id files, please note that the step descripton should not be set for such files $projectFile = array('fileName' => $configuration->tippFile, 'fileMTOM' => $fileContent, 'fileType' => 'TIPP', 'projectDescriptor' => $projectDescriptor, 'stepDescriptor' => $stepDescriptor); $input = array('loginAPI' => $configuration->loginAPI, 'projectFile' => $projectFile); $res = $configuration->proxy->uploadProjectFileMTOM($input); $uploadProjectFileResponse = $res->return; if (isset($uploadProjectFileResponse)) { print('Uploaded project file: '. $uploadProjectFileResponse->fileDescriptor->id .' for project: '. $uploadProjectFileResponse->projectDescriptor->id .' target: '. $uploadProjectFileResponse->languageCode .'
'); } } function findConcordance($uuid) { global $configuration; methodName('findConcordance'); $baseProjectDescriptor = array('uuid' => $uuid); $phrase = ''; $filter = array('baseProjectDescriptor' => $baseProjectDescriptor, 'phrase' => $phrase, //'customerSearchType' => 'ALL_CUSTOMERS', //Uncomment if search for concordance is to be set for all customers 'searchType' => 'SOURCE' ); $input = array('loginAPI' => $configuration->loginAPI, 'filter' => $filter); $res = $configuration->proxyTM->findConcordance($input); $findConcordanceResponse = $res->return; if (isset($findConcordanceResponse)) { if (!is_array($findConcordanceResponse->segments)) { $findConcordanceResponse->segments = array($findConcordanceResponse->segments); } print('Found ' . sizeof($findConcordanceResponse->segments) . ' segments'); foreach ($findConcordanceResponse->segments as $segment) { print('Source language: ' . $segment->sourceLanguage . ', '); print('Target language: ' . $segment->targetLanguage . ', '); print('Segment id: ' . $segment->segmentId . ', '); print('Source text: ' . $segment->sourceText . ', '); print('Target text: ' . $segment->targetText . ', '); print('File name: ' . $segment->fileName . '
'); } } } function findMatches() { global $configuration; methodName('findMatches'); $searchAPI = array('sourceSentence' => 'Belgian Waffles'); $languageCombination = array('sourceLanguage' => $configuration->sourceLanguage, 'targetLanguage' => $configuration->targetLanguages[0]); $filter = array('customerDescriptor' => $configuration->tmCustomer, 'languageCombination' => $languageCombination, 'tmSearch' => $searchAPI); $input = array('loginAPI' => $configuration->loginAPI, 'filter' => $filter); $res = $configuration->proxyTM->findMatches($input); $findMatchesResposne = $res->return; if ($findMatchesResposne != null) { if (!is_array($findMatchesResposne->matches)) { $findMatchesResposne->matches = array($findMatchesResposne->matches); } foreach ($findMatchesResposne->matches as $match) { if ($match != null) { print('Found segment = [id: ' . $match->segment->segmentId . ', source: ' . $match->segment->sourceText . ', target: ' . $match->segment->targetText . ']
'); print('Match score: ' . $match->score->type . ' - ' . $match->score->score . '
'); } } } } function deleteTM($customerDescriptor) { global $configuration; methodName('deleteTM'); $customer = $customerDescriptor; $sourceLanguage = $configuration->sourceLanguage; $targetLanguage = $configuration->targetLanguages[0]; $status = 'NOT_APPROVED'; $xliffDocStatuses = array('NEW'); //$projectName = 'TM project name'; //$tag = array('name' => 'day', 'values' => array(array('name' => 'Monday'), array('name' => 'Tuesday'))); $filter = array('customer' => $customer, 'sourceLanguage' => $sourceLanguage, 'targetLanguage' => $targetLanguage, 'status' => $status, //'projectName' => $projectName, //'tag' => $tag, 'xliffDocStatuses' => $xliffDocStatuses ); $input = array('loginAPI' => $configuration->loginAPI, 'filter' => $filter); $res = $configuration->proxyTM->deleteTM($input); $deleteTMResponse = $res->return; print('Success: ' . var_export($deleteTMResponse->success, true) . '
'); } //////////////////////////// BEGIN helper methods ////////////////////////////////// function methodName($method) { print("

$method

"); } function getUserDescriptor($userBaseDescriptor, $actorType) { $userDescriptor = array( 'id' => $userBaseDescriptor->id, 'name' => $userBaseDescriptor->name, 'type' => $actorType); return $userDescriptor; } function jobsDescriptors($projectResponse) { $jobsDescriptors = array(); foreach ($projectResponse->jobs as $jobResponse) { array_push($jobsDescriptors, $jobResponse->jobDescriptor); } return $jobsDescriptors; } function download($url, $directory) { $file = $directory . substr($url, strrpos($url, '/') + 1); $url = str_replace(' ', '%20', $url); 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 ////////////////////////////////// ?>