You are here

function globallink_interface_send_for_translations in GlobalLink Connect for Drupal 7.7

Same name and namespace in other branches
  1. 7.6 globallink_interface/globallink_interface.inc \globallink_interface_send_for_translations()

Sends interfaces for translation.

Parameters

array $lids: The array of interface 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_interface_send_for_translations()
globallink_background_send in ./globallink_background_jobs.inc

File

globallink_interface/globallink_interface.inc, line 26

Code

function globallink_interface_send_for_translations($lids, $pd4, $submission_name, $due_date, $project_code, $source_locale, $target_locale_arr, $submission_details, $submission_priority) {
  module_load_include('inc', 'globallink', 'gl_ws/gl_ws_send_translations');
  module_load_include('inc', 'globallink', 'globallink');
  $submitter = $submission_details['submitter'];
  $globallink_arr = array();
  foreach ($lids as $lid) {
    $rows = globallink_interface_get_sent_rows_by_lid($lid);
    $target_arr = $target_locale_arr;
    $interface_info = globallink_load_source_data($lid);
    $title = $interface_info[0]->source;
    foreach ($rows as $row) {
      if (array_search($row->target_lang_code, $target_locale_arr)) {
        unset($target_arr[$row->target_lang_code]);
        watchdog(GLOBALLINK_MODULE, 'Skipping Interface Id - %id for locales %locale', array(
          '%id' => $lid,
          '%locale' => $row->target_lang_code,
        ), WATCHDOG_DEBUG);
      }
    }
    if (empty($target_arr)) {
      continue;
    }
    $source_arr = globallink_get_source($lid);
    $xml = globallink_interface_get_xml($lid, $source_arr[$lid]);
    $name = 'Interface_' . $lid . '.xml';
    $globallink = new GlobalLink();
    $globallink->type = GLOBALLINK_ENTITY_TYPE_INTERFACE;
    $globallink->metadata = GLOBALLINK_ENTITY_TYPE_INTERFACE;
    $globallink->title = $title;
    $globallink->sourceLocale = $source_locale;
    $globallink->targetLocale = $target_arr;
    $globallink->sourceXML = $xml;
    $globallink->sourceFileName = $name;
    $globallink->submissionName = $submission_name;
    $globallink->submissionPriority = $submission_priority;
    $globallink->dueDate = $due_date;
    $globallink->otherObjectId = $lid;
    $globallink->submissionInstructions = $submission_details['instructions'] . "\nSubmitter: " . $submitter;
    $globallink_arr[GLOBALLINK_ENTITY_TYPE_INTERFACE][] = $globallink;
  }
  return $globallink_arr;
}