You are here

function lingotek_admin_profiles_form in Lingotek Translation 7.4

Same name and namespace in other branches
  1. 7.7 lingotek.admin.inc \lingotek_admin_profiles_form()
  2. 7.5 lingotek.admin.inc \lingotek_admin_profiles_form()
  3. 7.6 lingotek.admin.inc \lingotek_admin_profiles_form()
1 string reference to 'lingotek_admin_profiles_form'
lingotek_admin_configuration_view in ./lingotek.admin.inc

File

./lingotek.admin.inc, line 1293

Code

function lingotek_admin_profiles_form($form, &$form_state, $show_fieldset = FALSE) {
  $profiles = lingotek_get_profiles();
  $form['header'] = array(
    '#type' => 'item',
    '#title' => 'Translation Profiles',
    '#description' => 'Translation management defaults used when creating new nodes. At the node level, these settings can be adjusted.',
  );
  $headers = array(
    'Profile Name',
    'Usage',
    'Actions',
  );
  $total_count_with_profiles = 0;
  $rows = array();
  foreach ($profiles as $key => $profile) {
    $edit_link = l(t('Edit'), LINGOTEK_MENU_MAIN_BASE_URL . '/settings/profile/' . $key, array(
      'attributes' => array(
        'class' => array(
          'ctools-use-modal',
        ),
      ),
    ));
    $count = lingotek_admin_profile_usage($key);
    $count_types = lingotek_admin_profile_usage_by_types($key);
    $total_count_with_profiles += $count;
    $rows[] = array(
      $profile['name'],
      $count . ' ' . format_plural($count, 'node', 'nodes') . ' ⋅  ' . $count_types . ' ' . format_plural($count_types, 'content type', 'content types') . '',
      $edit_link,
    );
  }
  $custom_count = lingotek_admin_profile_usage(LingotekSync::PROFILE_CUSTOM);
  $custom_count_types = lingotek_admin_profile_usage_by_types(LingotekSync::PROFILE_CUSTOM);
  $rows[] = array(
    t('Custom'),
    $custom_count . ' ' . format_plural($custom_count, 'node', 'nodes') . ' ⋅ ' . $custom_count_types . ' ' . format_plural($count_types, 'content type', 'content types'),
    '',
  );
  $total_node_count = current(db_query("SELECT COUNT(DISTINCT(n.nid)) FROM {node} n WHERE n.status=1")
    ->fetchCol());
  $disabled_count = $total_node_count - ($total_count_with_profiles + $custom_count);

  // lingotek_admin_profile_usage(LingotekSync::PROFILE_DISABLED);
  $disabled_count_types = lingotek_admin_profile_usage_by_types(LingotekSync::PROFILE_DISABLED);
  $rows[] = array(
    t('Disabled'),
    $disabled_count . ' ' . format_plural($disabled_count, 'node', 'nodes') . ' ⋅ ' . $disabled_count_types . ' ' . format_plural($disabled_count_types, 'content type', 'content types'),
    '',
  );
  $variables = array(
    'header' => $headers,
    'rows' => $rows,
    'attributes' => array(
      'id' => 'lingotek-profiles',
    ),
  );
  $form['profiles'] = array(
    '#markup' => theme('table', $variables),
  );
  $form['add'] = array(
    '#markup' => '<p>' . l(t('Add new profile'), LINGOTEK_MENU_MAIN_BASE_URL . '/settings/profile/add', array(
      'attributes' => array(
        'class' => 'ctools-use-modal',
      ),
    )) . '</p>',
  );
  return $form;
}