You are here

function tmgmt_ui_cart_content in Translation Management Tool 7

Form constructor for cart form.

_state

Parameters

array $form:

Return value

array $form

Related topics

1 string reference to 'tmgmt_ui_cart_content'
tmgmt_ui_menu in ui/tmgmt_ui.module
Implements hook_menu().

File

ui/includes/tmgmt_ui.pages.inc, line 869
Provides page callbacks and form functions for the Translation Management Tool User Interface module.

Code

function tmgmt_ui_cart_content($form, &$form_state) {
  $languages = tmgmt_available_languages();
  $options = array();
  foreach (tmgmt_ui_cart_get()
    ->getJobItemsFromCart() as $item) {
    $uri = $item
      ->getSourceUri();
    $options[$item->tjiid] = array(
      $item
        ->getSourceType(),
      !empty($uri['path']) ? l($item
        ->label(), $uri['path']) : $item
        ->label(),
      isset($languages[$item
        ->getSourceLangCode()]) ? $languages[$item
        ->getSourceLangCode()] : t('Unknown'),
    );
  }
  $form['items'] = array(
    '#type' => 'tableselect',
    '#header' => array(
      t('Type'),
      t('Content'),
      t('Language'),
    ),
    '#empty' => t('There are no items in your cart.'),
    '#options' => $options,
  );
  $form['enforced_source_language'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enforce source language'),
    '#description' => t('The source language is by default determined from the items source language. Check to enforce a different language as source.'),
  );
  $form['source_language'] = array(
    '#type' => 'select',
    '#title' => t('Source language'),
    '#description' => t('If the enforced source language does not match the item source language then its translation will be used. This could result in loss of quality.'),
    '#options' => $languages,
    '#states' => array(
      'visible' => array(
        ':input[name="enforced_source_language"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['target_language'] = array(
    '#type' => 'select',
    '#title' => t('Request translation into language/s'),
    '#multiple' => TRUE,
    '#options' => $languages,
    '#description' => t('If the item\'s source language will be the same as the target language the item will be ignored.'),
  );
  $form['request_translation'] = array(
    '#type' => 'submit',
    '#value' => t('Request translation'),
    '#submit' => array(
      'tmgmt_ui_cart_request_translation_form_submit',
    ),
    '#validate' => array(
      'tmgmt_ui_cart_source_overview_validate',
    ),
  );
  $form['remove_selected'] = array(
    '#type' => 'submit',
    '#value' => t('Remove selected'),
    '#submit' => array(
      'tmgmt_ui_cart_remove_selected_form_submit',
    ),
    '#validate' => array(
      'tmgmt_ui_cart_source_overview_validate',
    ),
  );
  $form['empty_cart'] = array(
    '#type' => 'submit',
    '#value' => t('Empty cart'),
    '#submit' => array(
      'tmgmt_ui_cart_empty_cart_form_submit',
    ),
    '#access' => tmgmt_ui_cart_get()
      ->count(),
  );
  return $form;
}