You are here

function _tmgmt_ui_translation_suggestions in Translation Management Tool 7

Fills the tableselect with all translation suggestions.

Calls hook_tmgmt_source_suggestions(TMGMTJob) and creates the resulting list based on the results from all modules.

Parameters

array $suggestions_table: Tableselect part for a $form array where the #options should be inserted.

array $form_state: The main form_state.

1 call to _tmgmt_ui_translation_suggestions()
tmgmt_job_form in ui/includes/tmgmt_ui.pages.inc
Entity API form the job entity.

File

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

Code

function _tmgmt_ui_translation_suggestions(array &$suggestions_table, array &$form_state) {
  $options = array();
  $job = $form_state['tmgmt_job'];
  if ($job instanceof TMGMTJob) {

    // Get all suggestions from all modules which implements
    // 'hook_tmgmt_source_suggestions' and cache them in $form_state.
    if (!isset($form_state['tmgmt_suggestions'])) {
      $form_state['tmgmt_suggestions'] = $job
        ->getSuggestions();
    }

    // Remove suggestions which are already processed, translated, ...
    $job
      ->cleanSuggestionsList($form_state['tmgmt_suggestions']);

    // Process all valid entries.
    foreach ($form_state['tmgmt_suggestions'] as $k => $result) {
      if (is_array($result) && isset($result['job_item']) && $result['job_item'] instanceof TMGMTJobItem) {
        $options[$k + 1] = _tmgmt_ui_add_suggestion_item($result);
      }
    }
    $suggestions_table['#options'] = $options;
    $suggestions_table['#empty'] = t('No related suggestions available.');
    $suggestions_table['#header'] = array(
      'title' => t('Label'),
      'plugin' => t('Type'),
      'reason' => t('Reason'),
      'words' => t('Word count'),
    );
  }
}