function tmgmt_ui_translation_review_form_defaults in Translation Management Tool 7
Form wrapper callback for the job item review form.
See also
1 string reference to 'tmgmt_ui_translation_review_form_defaults'
- tmgmt_ui_forms in ui/
tmgmt_ui.module - Implements hook_forms().
File
- ui/
tmgmt_ui.module, line 565 - Common Translation managment UI.
Code
function tmgmt_ui_translation_review_form_defaults($form, &$form_state, TMGMTJobItem $item) {
// We store the item in the root of the form state so we can easily access it
// in all the form functions.
$form_state['item'] = $item;
$wrapper = entity_metadata_wrapper('tmgmt_job_item', $item);
$form['info'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array(
'tmgmt-ui-job-info',
'clearfix',
),
),
'#weight' => 0,
);
$uri = $item
->getSourceUri();
$form['info']['source'] = array(
'#type' => 'item',
'#title' => t('Source'),
'#markup' => !empty($uri) ? l($item
->getSourceLabel(), $uri['path'], $uri['options']) : $item
->getSourceLabel(),
'#prefix' => '<div class="tmgmt-ui-source tmgmt-ui-info-item">',
'#suffix' => '</div>',
);
$form['info']['sourcetype'] = array(
'#type' => 'item',
'#title' => t('Source type'),
'#markup' => $item
->getSourceType(),
'#prefix' => '<div class="tmgmt-ui-source-type tmgmt-ui-info-item">',
'#suffix' => '</div>',
);
$form['info']['changed'] = array(
'#type' => 'item',
'#title' => t('Last change'),
'#markup' => format_date($wrapper->changed
->value()),
'#prefix' => '<div class="tmgmt-ui-changed tmgmt-ui-info-item">',
'#suffix' => '</div>',
);
$form['info']['state'] = array(
'#type' => 'item',
'#title' => t('State'),
'#markup' => $wrapper->state
->label(),
'#prefix' => '<div class="tmgmt-ui-item-state tmgmt-ui-info-item">',
'#suffix' => '</div>',
);
$job = $item
->getJob();
$uri = $job
->uri();
$form['info']['job'] = array(
'#type' => 'item',
'#title' => t('Job'),
'#markup' => l($job
->label(), $uri['path']),
'#prefix' => '<div class="tmgmt-ui-job tmgmt-ui-info-item">',
'#suffix' => '</div>',
);
// Display selected translator for already submitted jobs.
if (!$item
->getJob()
->isSubmittable()) {
$translators = tmgmt_translator_labels();
$form['info']['translator'] = array(
'#type' => 'item',
'#title' => t('Translator'),
'#markup' => isset($translators[$item
->getJob()->translator]) ? check_plain($translators[$item
->getJob()->translator]) : t('Missing translator'),
'#prefix' => '<div class="tmgmt-ui-translator tmgmt-ui-info-item">',
'#suffix' => '</div>',
);
}
// Actually build the review form elements...
$form['review'] = array(
'#type' => 'container',
);
// Build the review form.
$data = $item
->getData();
// Need to keep the first hierarchy. So flatten must take place inside
// of the foreach loop.
$zebra = 'even';
foreach (element_children($data) as $key) {
$form['review'][$key] = _tmgmt_ui_review_form_element($form_state, tmgmt_flatten_data($data[$key], $key), $item, $zebra, $key);
}
if ($output = tmgmt_ui_embed_view('tmgmt_ui_job_item_messages', 'block', array(
$item->tjiid,
))) {
$form['messages'] = array(
'#type' => 'fieldset',
'#title' => t('Messages'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#weight' => 50,
);
$form['messages']['view'] = array(
'#type' => 'item',
'#markup' => $output,
);
}
// Add the form actions as well.
$form['actions']['#type'] = 'actions';
$form['actions']['accept'] = array(
'#type' => 'submit',
'#value' => t('Save as completed'),
'#access' => $item
->isNeedsReview(),
);
$form['actions']['save'] = array(
'#type' => 'submit',
'#value' => t('Save'),
'#access' => !$item
->isAccepted() && !$item
->isAborted(),
);
$uri = $item
->getJob()
->uri();
$url = isset($_GET['destination']) ? $_GET['destination'] : $uri['path'];
$form['actions']['cancel'] = array(
'#type' => 'link',
'#title' => t('Cancel'),
'#href' => $url,
);
$form['#attached']['css'][] = drupal_get_path('module', 'tmgmt_ui') . '/css/tmgmt_ui.admin.css';
// The reject functionality has to be implement by the translator plugin as
// that process is completely unique and custom for each translation service.
return $form;
}