function lingotek_download_translations_form in Lingotek Translation 7.5
Same name and namespace in other branches
- 7.7 lingotek.page.inc \lingotek_download_translations_form()
- 7.3 lingotek.page.inc \lingotek_download_translations_form()
- 7.4 lingotek.page.inc \lingotek_download_translations_form()
- 7.6 lingotek.page.inc \lingotek_download_translations_form()
Download Translations Form.
1 string reference to 'lingotek_download_translations_form'
- lingotek_pm in ./
lingotek.page.inc - Page callback for the Lingotek local task on node detail pages.
File
- ./
lingotek.page.inc, line 11 - Lingotek Tab for Nodes
Code
function lingotek_download_translations_form($form, $form_state, $node, $document = NULL) {
module_load_include('lingotek', 'lingotek.bulk_grid', 'inc');
$form = array();
$document = is_null($document) ? LingotekDocument::load($node->lingotek['document_id']) : $document;
$document_progress = $document
->getProgress();
$sum_progress = 0;
if ($document_progress->results == 'success') {
$rows = array();
foreach ($document_progress->translationTargets as $target) {
$current_phase = $document
->currentPhase($target->id);
$marked_complete = FALSE;
$phase_complete_percent = is_object($current_phase) ? $current_phase->percentComplete : 0;
if (empty($phase_complete_percent)) {
$phase_complete_percent = 0;
}
$language_link = l(lingotek_language_field_lookup('native', $target->language), 'lingotek/workbench/node/' . $node->nid . '/' . $target->language, array(
'attributes' => array(
'target' => '_blank',
),
));
$language_link .= ' (' . lingotek_language_field_lookup('name', $target->language) . ')';
$row = array(
'column_1' => array(
'data' => $language_link,
'width' => '40%',
),
'column_2' => array(
'data' => lingotek_grid_create_progress_bar($target->percentComplete),
'width' => '40%',
),
'column_3' => array(
'data' => '',
),
//$target->percentComplete == 100 ? '<i class="fa fa-check-sign ltk-complete-check" title="'.t('Workflow complete').'"></i>' : '<i class="fa fa-check-empty ltk-complete-check"></i>', 'width' => '20%'
'#attributes' => array(
'class' => array(
'bold-row',
),
),
);
LingotekLog::trace("lingotek_pm table row [@locale]", array(
'@locale' => $target->language,
));
$rows[$target->language] = $row;
foreach ($target->phases as $phase) {
$row = array(
'column_1' => $phase->name,
'column_2' => lingotek_grid_create_progress_bar($phase->percentComplete),
'column_3' => $phase->isMarkedComplete ? '<i class="fa fa-check-sign ltk-complete-check" title="' . t('Phase complete') . '"></i>' : '<i class="fa fa-check-empty ltk-complete-check"></i>',
'#attributes' => array(
'class' => array(
'no-checkbox-row',
),
),
);
$rows[$target->language . '_' . $phase->name] = $row;
$marked_complete = $phase->isMarkedComplete;
}
// update progress
$lingotek_locale = $target->language;
$progress_percentage = empty($target->percentComplete) ? 0 : $target->percentComplete;
$sum_progress += $progress_percentage;
$target_status_local = lingotek_keystore('node', $node->nid, 'target_sync_status_' . $lingotek_locale);
if ($target_status_local === LingotekSync::STATUS_PENDING) {
$target_status = $marked_complete ? LingotekSync::STATUS_READY : LingotekSync::STATUS_PENDING;
lingotek_keystore('node', $node->nid, 'target_sync_status_' . $lingotek_locale, $target_status);
}
}
$form['fieldset'] = array(
'#type' => 'fieldset',
'#title' => t('Download Translations'),
'#description' => t('Download the latest translations from Lingotek in the selected languages.'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$header = array(
'column_1' => t('Target Language'),
'column_2' => t('Progress'),
'column_3' => t('Status'),
);
$form['fieldset']['documents'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $rows,
'#empty' => t('No content available.'),
'#after_build' => array(
'lingotek_remove_checkboxes',
),
);
$form['fieldset']['submit'] = array(
'#type' => 'submit',
'#value' => t('Download'),
);
$form['fieldset']['nid'] = array(
'#type' => 'value',
'#value' => $node->nid,
);
}
return $form;
}