You are here

function key_configs_list in Key 7.3

Same name and namespace in other branches
  1. 7.2 includes/key.admin.inc \key_configs_list()

Menu callback; displays the list of key configurations.

Return value

array The table of key configurations.

1 string reference to 'key_configs_list'
key_menu in ./key.module
Implements hook_menu().

File

includes/key.admin.inc, line 14
Administrative functionality for managing key configurations.

Code

function key_configs_list() {
  $configs = key_get_keys();
  $header = array(
    t('Key'),
    t('Type'),
    t('Provider'),
    array(
      'data' => t('Operations'),
      'colspan' => '2',
    ),
  );
  $rows = array();
  foreach ($configs as $id => $config) {
    $label = $config['label'];
    $id = $config['id'];
    $description = $config['description'];
    $key_type = key_get_plugin('key_type', $config['key_type']);
    $key_provider = key_get_plugin('key_provider', $config['key_provider']);
    $config_url_string = str_replace('_', '-', $id);
    $variables = array(
      'label' => $label,
      'id' => $id,
      'description' => $description,
    );

    // Set the name column.
    $row = array(
      theme('key_configs_list_description', $variables),
    );

    // Set the key type column.
    $row[] = array(
      'data' => $key_type['label'],
    );

    // Set the key provider column.
    $row[] = array(
      'data' => $key_provider['label'],
    );

    // Set the edit column.
    $row[] = array(
      'data' => l(t('edit'), KEY_MENU_PATH . '/manage/' . $config_url_string),
    );

    // Set the delete column.
    $row[] = array(
      'data' => l(t('delete'), KEY_MENU_PATH . '/manage/' . $config_url_string . '/delete'),
    );
    $rows[] = $row;
  }
  $build['key_configs_list_table'] = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => t('No keys are available. <a href="@link">Add a key</a>.', array(
      '@link' => url(KEY_MENU_PATH . '/add'),
    )),
  );
  return $build;
}