You are here

function clients_connections_list in Web Service Clients 6.2

Same name and namespace in other branches
  1. 6 clients.module \clients_connections_list()
  2. 7 clients.connection.admin.inc \clients_connections_list()
  3. 7.2 clients.connection.admin.inc \clients_connections_list()

Page callback: list connections.

1 string reference to 'clients_connections_list'
clients_menu in ./clients.module
Implementation of hook_menu().

File

./clients.connection.admin.inc, line 10
clients.connection.admin.inc Page callbacks relating to client connection admin.

Code

function clients_connections_list() {
  $output = '';
  $connection_types = clients_get_connection_types();
  $connections = clients_connection_load_all();
  $rows = array();
  foreach ($connections as $name => $connection) {
    $delete_label = $connection->export_type & EXPORT_IN_CODE ? t('revert') : t('delete');
    $delete_link = $connection->export_type & EXPORT_IN_DATABASE ? l($delete_label, "admin/build/clients/connections/{$name}/delete") : '';
    $type = $connection->type;
    if (isset($connection->broken_message)) {

      // Not sure where best to shove this, will take suggestions.
      $type .= ' ' . t('(broken)');
    }
    $rows[] = array(
      'name' => l($connection->name, "admin/build/clients/connections/{$name}/view"),
      'type' => $type,
      'endpoint' => $connection
        ->formatEndpoint($connection->endpoint),
      'storage' => $connection->export_type_label,
      'edit' => l(t('edit'), "admin/build/clients/connections/{$name}/edit"),
      'test' => l(t('test'), "admin/build/clients/connections/{$name}/test"),
      'delete' => $delete_link,
    );
  }

  // Ensure the table has a row if there are no connections at all.
  if (!count($rows)) {
    $rows[] = array(
      array(
        'data' => t('No connections defined yet.'),
        'colspan' => '5',
      ),
    );
  }
  $headers = array(
    t('Name'),
    t('Type'),
    t('Endpoint'),
    t('Storage'),
    array(
      'data' => t('Operations'),
      'colspan' => 3,
    ),
  );
  $output .= theme_table($headers, $rows);

  // Add a list of connection types that can be created.
  foreach ($connection_types as $type => $type_data) {

    //dsm($type_data);
    $items[] = l(t('Add @type connection', array(
      '@type' => $type_data['label'],
    )), 'admin/build/clients/connections/add/' . $type);
  }
  $output .= theme('item_list', $items);
  return $output;
}