You are here

function globallink_block_send_blocks_for_translations in GlobalLink Connect for Drupal 7.5

Same name and namespace in other branches
  1. 7.7 globallink_block/globallink_block.inc \globallink_block_send_blocks_for_translations()
  2. 7.6 globallink_block/globallink_block.inc \globallink_block_send_blocks_for_translations()

Sends blocks for translation.

Parameters

array $bids: The array of block IDs.

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_block_send_blocks_for_translations()
globallink_block_dashboard_form_submit in globallink_block/globallink_block_send.inc
Handles block form submission.

File

globallink_block/globallink_block.inc, line 26

Code

function globallink_block_send_blocks_for_translations($bids, $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');
  $strings = globallink_block_get_strings(globallink_get_drupal_locale_code($source_locale), 'blocks');
  $submitter = $submission_details['submitter'];
  $globallink_arr = array();
  foreach ($bids as $bid) {
    $rows = globallink_block_get_sent_tpt_rows_by_bid($bid);
    $target_arr = $target_locale_arr;
    foreach ($rows as $row) {
      if (array_search($row->target, $target_locale_arr)) {
        unset($target_arr[$row->target]);
      }
    }
    if (empty($target_arr)) {
      continue;
    }
    $title_string_arr = isset($strings['blocks:block:' . $bid . ':title']) ? $strings['blocks:block:' . $bid . ':title'] : FALSE;
    $body_string_arr = isset($strings['blocks:block:' . $bid . ':body']) ? $strings['blocks:block:' . $bid . ':body'] : FALSE;
    if (!$body_string_arr) {
      continue;
    }
    $xml = globallink_block_get_xml($bid, $title_string_arr, $body_string_arr);
    $name = 'Block_' . $bid . '.xml';
    watchdog('GlobalLink', 'XML - %xml', array(
      '%xml' => $xml,
    ), WATCHDOG_DEBUG);
    $globallink = new GlobalLink();
    $globallink->type = 'block';
    $globallink->metadata = 'block';
    $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 = $bid;
    $globallink->submissionInstructions = $submission_details['instructions'] . "\nSubmitter: " . $submitter;
    $globallink_arr[] = $globallink;
  }
  if (!empty($globallink_arr)) {
    globallink_send_documents_for_translation_to_pd($globallink_arr, $pd4, $project_code, $submitter);
  }
  return $globallink_arr;
}