function page_sync_comment_translations in Lingotek Translation 7.7
Same name and namespace in other branches
- 7.2 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 643 - 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 {
LingotekLog::error('Unable to update local translations for comment @id', array(
'@id' => $comment_id,
));
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 {
LingotekLog::error('Unable to retrieve the status of the lingotek document: @id while updating
comment @comment_id', array(
'@id' => $lingotek_document_id,
'@comment_id' => $comment_id,
), WATCHDOG_ERROR);
drupal_set_message(t('An error occurred. Local translations for the comment were not updated.'), 'error');
}
}
else {
LingotekLog::error('Attempt to refresh local translations for comment @id, but the comment
is not associated with a Lingotek document.', array(
'@id' => $comment_id,
));
}
}
}
else {
LingotekLog::error('Attempt to refresh local translations for comment @id without a valid security token.', array(
'@id' => $comment_id,
));
}
drupal_goto();
}