function globallink_webform_send_for_translations in GlobalLink Connect for Drupal 7.7
Same name and namespace in other branches
- 7.5 globallink_webform/globallink_webform.inc \globallink_webform_send_for_translations()
- 7.6 globallink_webform/globallink_webform.inc \globallink_webform_send_for_translations()
Sends webforms for translation.
Parameters
array $lids: The array of webform LIDs.
string $pd4: The project director details.
string $submission_name: The name of the submission.
string $due_date: When the translation is due.
string $project_code: The project's registered code.
string $source_locale: The locale of the content being translated.
array $target_locale_arr: Array of desired locales to translate into.
array $submission_details: Associative array of details about the submission.
Return value
object GlobalLink object that represents active translation.
1 call to globallink_webform_send_for_translations()
File
- globallink_webform/
globallink_webform.inc, line 26
Code
function globallink_webform_send_for_translations($lids, $pd4, $submission_name, $due_date, $project_code, $source_locale, $target_locale_arr, $submission_details, $submission_priority, $parents) {
$globallink_arr = array();
$submitter = $submission_details['submitter'];
// For each target locale code, we check if the lid is in Sent or Error
// We group lids per target locale code
$final_tgt_arr = array();
foreach ($target_locale_arr as $target_locale) {
foreach ($parents as $pid => $p) {
foreach ($p as $lid) {
$active_row = globallink_webform_get_sent_tpt_rows_by_lid_and_target($pid, $lid, $target_locale);
if ($active_row != NULL) {
continue;
}
if (isset($final_tgt_arr[$target_locale][$pid])) {
array_push($final_tgt_arr[$target_locale][$pid], $lid);
}
else {
$final_tgt_arr[$target_locale][$pid] = array();
array_push($final_tgt_arr[$target_locale][$pid], $lid);
}
}
}
}
foreach ($final_tgt_arr as $target_locale_code => $final_parent_arr) {
$xmls = globallink_webform_get_xml($final_parent_arr);
foreach ($xmls as $parent => $xml) {
$tgt_arr = array();
$tgt_arr[] = $target_locale_code;
$title = array();
$name = 'Webform_' . $parent . '.xml';
foreach ($final_parent_arr[$parent] as $key => $value) {
$t1 = db_select('locales_source', 'ls')
->fields('ls')
->condition('lid', $value, '=')
->execute()
->fetchAll();
$title[$value] = $t1[0]->source;
}
$globallink = new GlobalLink();
$globallink->type = GLOBALLINK_ENTITY_TYPE_WEBFORM;
$globallink->metadata = GLOBALLINK_ENTITY_TYPE_WEBFORM;
$globallink->title = $title;
$globallink->sourceLocale = $source_locale;
$globallink->targetLocale = $tgt_arr;
$globallink->sourceXML = $xml;
$globallink->sourceFileName = $name;
$globallink->submissionName = $submission_name;
$globallink->submissionPriority = $submission_priority;
$globallink->dueDate = $due_date;
$globallink->otherObjectId = $parent;
$globallink->submissionInstructions = $submission_details['instructions'] . "\nSubmitter: " . $submitter;
$globallink->lids = $final_parent_arr[$parent];
$globallink_arr[GLOBALLINK_ENTITY_TYPE_WEBFORM][] = $globallink;
}
}
return $globallink_arr;
}