function page_sync_comment_translations in Lingotek Translation 7.2
Same name and namespace in other branches
- 7.7 lingotek.page.inc \page_sync_comment_translations()
- 7.3 lingotek.page.inc \page_sync_comment_translations()
- 7.4 lingotek.page.inc \page_sync_comment_translations()
- 7.5 lingotek.page.inc \page_sync_comment_translations()
- 7.6 lingotek.page.inc \page_sync_comment_translations()
Page handler for manually refreshing the local translations of a Lingotek-assciated comment.
Parameters
int $comment_id: The ID of a Drupal comment.
1 string reference to 'page_sync_comment_translations'
- lingotek_menu in ./
lingotek.module - Implements hook_menu().
File
- ./
lingotek.page.inc, line 494 - Lingotek Tab for Nodes
Code
function page_sync_comment_translations($comment_id) {
if (!empty($_GET['token']) && drupal_valid_token($_GET['token'])) {
if (class_exists('LingotekComment') && class_exists('LingotekApi')) {
$comment = LingotekComment::loadById($comment_id);
if ($lingotek_document_id = $comment
->getMetadataValue('document_id')) {
if ($document = LingotekApi::instance()
->getDocument($lingotek_document_id)) {
if ($document->percentComplete == 100) {
if ($comment
->updateLocalContent()) {
drupal_set_message(t('Local translations for the comment have been updated.'));
}
else {
watchdog('lingotek', 'Unable to update local translations for comment @id', array(
'@id' => $comment_id,
), WATCHDOG_ERROR);
drupal_set_message(t('An error occurred. Local translations for the comment were not updated.'), 'error');
}
}
else {
drupal_set_message(t('The translation of this comment is not yet complete. Please try again later.'), 'warning');
}
}
else {
watchdog('lingotek', 'Unable to retrieve the status of the lingotek document: @id while updating
comment @comment_id', array(
'@id' => $lingotek_document_id,
'@comment_id' => $commment_id,
), WATCHDOG_ERROR);
drupal_set_message(t('An error occurred. Local translations for the comment were not updated.'), 'error');
}
}
else {
watchdog('lingotek', 'Attempt to refresh local translations for comment @id, but the comment
is not associated with a Lingotek document.', array(
'@id' => $comment_id,
), WATCHDOG_ERROR);
}
}
}
else {
watchdog('lingotek', 'Attempt to refresh local translations for comment @id without a valid security token.', array(
'@id' => $comment_id,
), WATCHDOG_ERROR);
}
drupal_goto();
}