function globallink_block_get_translations_for_row_id in GlobalLink Connect for Drupal 7.6
Same name and namespace in other branches
- 7.5 globallink_block/globallink_block_receive.inc \globallink_block_get_translations_for_row_id()
Gets block translations by row ID.
Parameters
string $row_id: The row ID.
Return value
array Array of block translations.
1 call to globallink_block_get_translations_for_row_id()
- globallink_block_preview_translated_block_content in globallink_block/
globallink_block_receive.inc - Previews translated block content in the form of JSON.
File
- globallink_block/
globallink_block_receive.inc, line 722
Code
function globallink_block_get_translations_for_row_id($row_id) {
module_load_include('inc', 'globallink', 'globallink');
module_load_include('inc', 'globallink_block', 'globallink_block');
module_load_include('inc', 'globallink', 'globallink_settings');
module_load_include('inc', 'globallink', 'gl_ws/gl_ws_receive_translations');
$row = globallink_get_other_row($row_id, 'block');
$globallink = new GlobalLink();
$globallink->tptRowId = $row_id;
$globallink->otherObjectId = $row->object_id;
$globallink->type = $row->object_type;
$globallink->title = $row->title;
$globallink->sourceLocale = $row->source;
$globallink->targetLocale = $row->target;
$globallink->documentTicket = $row->document_ticket;
$globallink->submissionTicket = $row->submission_ticket;
$globallink->submission = $row->submission;
$globallink->status = $row->status;
$source_arr = array();
$translation = array();
$error = FALSE;
try {
$pd4 = globallink_get_project_director_details();
$targets = globallink_get_completed_targets_by_doc($pd4, $globallink->documentTicket);
if (!is_array($targets)) {
$targets = array(
$targets,
);
}
foreach ($targets as $target) {
if (str_replace('-', '_', $target->targetLanguage->locale) != $globallink->targetLocale) {
continue;
}
if (is_null($target->ticket) || $target->ticket == '') {
continue;
}
$globallink->targetTicket = $target->ticket;
$globallink->targetXML = globallink_download_target_resource($pd4, $globallink->targetTicket);
if (is_null($globallink->targetXML) || $globallink->targetXML == '') {
continue;
}
$translation = globallink_block_get_arr_items($globallink->targetXML);
$bid = $translation['bid'];
$block = globallink_block_load_data($bid);
if ($block && is_array($block) && !is_null($block)) {
$strings = globallink_block_get_strings(NULL, 'blocks');
$title = isset($strings['blocks:block:' . $bid . ':title']) ? $strings['blocks:block:' . $bid . ':title'] : FALSE;
$body = isset($strings['blocks:block:' . $bid . ':body']) ? $strings['blocks:block:' . $bid . ':body'] : FALSE;
$source_xml = globallink_block_get_xml($bid, $title, $body);
$source_arr = array();
if ($source_xml) {
$source_arr = globallink_block_get_arr_items($source_xml);
}
}
else {
$source_xml = 'Source Deleted';
$globallink->sourceDeleted = TRUE;
}
}
} catch (SoapFault $se) {
$error = $se->faultstring;
} catch (Exception $ex) {
$error = $ex
->getMessage();
}
$arr = array();
$arr['target_ticket'] = $globallink->targetTicket;
if ($globallink->sourceDeleted) {
$arr = array(
'Source Deleted',
);
}
elseif ($error) {
$arr = array(
'error' => $error,
);
}
else {
$arr['source'] = $source_arr;
$arr['target'] = $translation;
}
return $arr;
}