function globallink_get_ready_translations_details_from_pd in GlobalLink Connect for Drupal 7.6
Same name and namespace in other branches
- 7.5 gl_ws/gl_ws_receive_translations.inc \globallink_get_ready_translations_details_from_pd()
9 calls to globallink_get_ready_translations_details_from_pd()
- globallink_beans_receive_form_submit in globallink_beans/
globallink_beans_receive.inc - Handles beans form submission.
- globallink_block_receive_form_submit in globallink_block/
globallink_block_receive.inc - Handles block form submission.
- globallink_dashboard_receive_submit in ./
globallink_receive_translations.inc - Handles GlobalLink form submission.
- globallink_entity_receive_form_submit in globallink_entity/
globallink_entity_receive.inc - Handles entity form submission.
- globallink_fieldable_panels_receive_form_submit in globallink_fieldable_panels/
globallink_fieldable_panels_receive.inc - Handles fieldable panels form submission.
File
- gl_ws/
gl_ws_receive_translations.inc, line 13
Code
function globallink_get_ready_translations_details_from_pd($pd_obj, $type = 'node', $submission_tickets = NULL) {
$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) {
if ($submission_tickets != NULL) {
$targets = globallink_get_completed_targets_by_submissions($target_service, $submission_tickets, $token, $pd_obj);
}
else {
$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;
}
switch ($type) {
case 'entity':
if ($source_type != 'entity') {
continue;
}
break;
case 'menu':
if ($source_type != 'menu') {
continue;
}
break;
case 'block':
if ($source_type != 'block') {
continue;
}
break;
case 'taxonomy':
if ($source_type != 'taxonomy') {
continue;
}
break;
case 'interface':
if ($source_type != 'interface') {
continue;
}
break;
case 'webform':
if ($source_type != 'webform') {
continue;
}
break;
case 'fieldable_panels_panes':
if ($source_type != 'fieldable_panels_panes') {
continue;
}
break;
default:
if ($source_type == 'entity' || $source_type == 'menu' || $source_type == 'block' || $source_type == 'taxonomy' || $source_type == 'interface' || $source_type == 'webform' || $source_type == 'fieldable_panels_panes') {
continue;
}
}
$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' && $source_type != 'entity') {
$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;
}
switch ($type) {
case 'entity':
if ($source_type != 'entity') {
return $globallink_arr;
}
break;
case 'menu':
if ($source_type != 'menu') {
return $globallink_arr;
}
break;
case 'block':
if ($source_type != 'block') {
return $globallink_arr;
}
break;
case 'taxonomy':
if ($source_type != 'taxonomy') {
return $globallink_arr;
}
break;
case 'interface':
if ($source_type != 'interface') {
return $globallink_arr;
}
break;
case 'webform':
if ($source_type != 'webform') {
return $globallink_arr;
}
break;
case 'fieldable_panels':
if ($source_type != 'fieldable_panels_panes') {
return $globallink_arr;
}
break;
default:
if ($source_type == 'entity' || $source_type == 'menu' || $source_type == 'block' || $source_type == 'taxonomy' || $source_type == 'interface' || $source_type == 'webform' || $source_type == 'fieldable_panels_panes') {
return $globallink_arr;
}
}
$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' && $source_type != 'entity') {
$globallink->otherObjectId = $type_id;
}
else {
$globallink->nid = $type_id;
}
$globallink_arr[$count] = $globallink;
}
}
}
return $globallink_arr;
}