function globallink_get_all_ready_translations_details_from_pd in GlobalLink Connect for Drupal 7.5
Same name and namespace in other branches
- 7.6 gl_ws/gl_ws_receive_translations.inc \globallink_get_all_ready_translations_details_from_pd()
1 call to globallink_get_all_ready_translations_details_from_pd()
- globallink_auto_receive in ./
globallink.module - Automatically receives translated contents.
File
- gl_ws/
gl_ws_receive_translations.inc, line 256
Code
function globallink_get_all_ready_translations_details_from_pd($pd_obj) {
$username = $pd_obj->username;
$password = $pd_obj->password;
$url = $pd_obj->url;
$project_short_code = $pd_obj->projectShortCode;
$proj_arr = array();
if ($project_short_code != '') {
$arr = explode(',', $project_short_code);
foreach ($arr as $value) {
$proj_arr[$value] = $value;
}
}
$session_service = new SessionService2(GL_WSDL_PATH . 'SessionService2.wsdl', array(
'location' => $url . '/services/SessionService2',
));
$project_service = new ProjectService2(GL_WSDL_PATH . 'ProjectService2.wsdl', array(
'location' => $url . '/services/ProjectService2',
));
$target_service = new TargetService2(GL_WSDL_PATH . 'TargetService2.wsdl', array(
'location' => $url . '/services/TargetService2',
));
$globallink_arr = array();
$token = globallink_login($session_service, $username, $password);
$projects = globallink_get_user_projects($project_service, $token);
$proj_ticket_arr = array();
foreach ($projects as $project) {
$short_code = $project->projectInfo->shortCode;
foreach ($proj_arr as $conf_proj) {
if ($conf_proj == $short_code) {
$proj_ticket_arr[] = $project->ticket;
}
}
}
if (count($proj_ticket_arr) > 0) {
$targets = globallink_get_completed_targets_by_projects($target_service, $proj_ticket_arr, $token, $pd_obj);
$count = 1;
if (is_array($targets)) {
foreach ($targets as $target) {
if (!is_null($target->ticket) && $target->ticket != '') {
$source_file = $target->document->documentInfo->name;
$m_arr = $target->document->documentInfo->metadata;
$source_type = '';
$type_id = '';
if (is_array($m_arr)) {
foreach ($m_arr as $m) {
if ($m->key == 'type') {
$source_type = $m->value;
}
else {
$type_id = $m->value;
}
}
}
else {
$source_type = $target->document->documentInfo->metadata->value;
}
$globallink = new GlobalLink();
$globallink->submissionTicket = $target->document->documentGroup->submission->ticket;
$globallink->submissionName = $target->document->documentGroup->submission->submissionInfo->name;
$globallink->documentTicket = $target->document->ticket;
$globallink->sourceFileName = $source_file;
$globallink->targetTicket = $target->ticket;
$globallink->sourceLocale = str_replace('-', '_', $target->sourceLanguage->locale);
$globallink->targetLocale = str_replace('-', '_', $target->targetLanguage->locale);
$globallink->type = $source_type;
if ($source_type != 'node') {
$globallink->otherObjectId = $type_id;
}
else {
$globallink->nid = $type_id;
}
$globallink_arr[$count] = $globallink;
$count++;
}
}
}
elseif (!is_null($targets)) {
$target = $targets;
if (!is_null($target->ticket) && $target->ticket != '') {
$source_file = $target->document->documentInfo->name;
$m_arr = $target->document->documentInfo->metadata;
$source_type = '';
$type_id = '';
if (is_array($m_arr)) {
foreach ($m_arr as $m) {
if ($m->key == 'type') {
$source_type = $m->value;
}
else {
$type_id = $m->value;
}
}
}
else {
$source_type = $target->document->documentInfo->metadata->value;
}
$globallink = new GlobalLink();
$globallink->submissionTicket = $target->document->documentGroup->submission->ticket;
$globallink->submissionName = $target->document->documentGroup->submission->submissionInfo->name;
$globallink->documentTicket = $target->document->ticket;
$globallink->sourceFileName = $source_file;
$globallink->targetTicket = $target->ticket;
$globallink->sourceLocale = str_replace('-', '_', $target->sourceLanguage->locale);
$globallink->targetLocale = str_replace('-', '_', $target->targetLanguage->locale);
$globallink->type = $source_type;
if ($source_type != 'node') {
$globallink->otherObjectId = $type_id;
}
else {
$globallink->nid = $type_id;
}
$globallink_arr[$count] = $globallink;
}
}
}
return $globallink_arr;
}