function tmgmt_color_legend

Provides color legends for source statuses.

Return value

array Color legend render array.

1 call to tmgmt_color_legend()

File

./tmgmt.module, line 945
Main module file for the Translation Management module.

Code

function tmgmt_color_legend() {
  $items = [
    [
      'icon' => \Drupal::service('file_url_generator')
        ->generateAbsoluteString('core/misc/icons/bebebe/house.svg'),
      'legend' => t('Original language'),
    ],
    [
      'icon' => \Drupal::service('file_url_generator')
        ->generateAbsoluteString('core/misc/icons/bebebe/ex.svg'),
      'legend' => t('Not translated'),
    ],
    [
      'icon' => \Drupal::service('file_url_generator')
        ->generateAbsoluteString('core/misc/icons/73b355/check.svg'),
      'legend' => t('Translated'),
    ],
    [
      'icon' => \Drupal::service('file_url_generator')
        ->generateAbsoluteString(\Drupal::service('extension.list.module')
        ->getPath('tmgmt') . '/icons/outdated.svg'),
      'legend' => t('Translation Outdated'),
    ],
  ];
  $output[] = [
    '#attached' => array(
      'library' => [
        'tmgmt/admin.seven',
        'tmgmt/admin',
      ],
    ),
    '#theme' => 'tmgmt_legend',
    '#title' => t('Source status:'),
    '#items' => $items,
  ];
  $items = [];
  foreach (JobItem::getStateDefinitions() as $state_definition) {
    if (!empty($state_definition['icon'])) {
      $items[] = [
        'icon' => \Drupal::service('file_url_generator')
          ->transformRelative(\Drupal::service('file_url_generator')
          ->generateAbsoluteString($state_definition['icon'])),
        'legend' => $state_definition['label'],
      ];
    }
  }
  $output[] = [
    '#attached' => array(
      'library' => [
        'tmgmt/admin.seven',
        'tmgmt/admin',
      ],
    ),
    '#theme' => 'tmgmt_legend',
    '#title' => t('Item status:'),
    '#items' => $items,
    '#prefix' => '<div class="clear"></div>',
  ];
  $output['#prefix'] = '<div class="tmgmt-color-legend clearfix">';
  $output['#suffix'] = '</div>';
  return $output;
}