function lingotek_mark_phases_complete in Lingotek Translation 7.5
Same name and namespace in other branches
- 7.7 lingotek.page.inc \lingotek_mark_phases_complete()
- 7.2 lingotek.page.inc \lingotek_mark_phases_complete()
- 7.3 lingotek.page.inc \lingotek_mark_phases_complete()
- 7.4 lingotek.page.inc \lingotek_mark_phases_complete()
- 7.6 lingotek.page.inc \lingotek_mark_phases_complete()
Form constructor for the lingotek_mark_phases_complete form.
Parameters
array $form: A FAPI form array.
array $form_state: A FAPI form state array.
object $node: The Drupal node whose complete-eligible phases should be displayed.
Return value
array A FAPI form data array.
1 string reference to 'lingotek_mark_phases_complete'
- lingotek_pm in ./
lingotek.page.inc - Page callback for the Lingotek local task on node detail pages.
File
- ./
lingotek.page.inc, line 508 - Lingotek Tab for Nodes
Code
function lingotek_mark_phases_complete($form, $form_state, $node, $document = NULL) {
$form = array();
$document = is_null($document) ? LingotekDocument::load($node->lingotek['document_id']) : $document;
$document_id = $document->document_id;
if (class_exists('LingotekPhase') && $document_id) {
$api = LingotekApi::instance();
$progress = $document
->getProgress();
if ($progress) {
$targets = $progress->translationTargets;
foreach ($targets as $target) {
$language = Lingotek::convertLingotek2Drupal($target->language);
$current_phase = $document
->currentPhase($target->id);
$phase_complete_percent = empty($current_phase->percentComplete) ? 0 : $current_phase->percentComplete;
if ($current_phase && $current_phase
->canBeMarkedComplete()) {
$phase_link = l($current_phase->name, '', array(
'attributes' => array(
'onclick' => 'window.open(\'' . $api
->getWorkbenchLink($document_id, $current_phase->id) . '\'); return false;',
),
));
$row = array(
lingotek_language_native($language) . ' (' . lingotek_language_name($language) . ')',
$phase_link,
$phase_complete_percent . '%',
);
$options[$current_phase->id] = $row;
}
}
$form['mark_complete'] = array(
'#type' => 'fieldset',
'#title' => t('Mark Workflow Phases complete'),
'#description' => t('The following Translation Targets have Phases that can be marked as complete.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['mark_complete']['phases'] = array(
'#type' => 'tableselect',
'#header' => array(
t('Language'),
t('Phase'),
t('Phase Progress'),
),
'#options' => $options,
);
$form['mark_complete']['submit'] = array(
'#type' => 'submit',
'#value' => t('Mark Selected Phases as Complete'),
);
}
else {
LingotekLog::error('Unable to build mark as complete form: could not get progress data from API.');
}
}
return $form;
}