You are here

function clients_views_views_data in Web Service Clients 7

Same name and namespace in other branches
  1. 6 clients/clients_views/clients_views.module \clients_views_views_data()

File

clients/clients_views/clients_views.module, line 83
Client for Views

Code

function clients_views_views_data() {

  // Iterate through all resources
  foreach (clients_resources_load() as $rid => $source) {
    $data[$source['name']]['table']['group'] = $source['name'];
    $data[$source['name']]['table']['group'] = t('Clients');

    // N.B. Placeholder UI. This might be better done as a clients radio with select for resources in initial view setup form
    $data[$source['name']]['table']['base'] = array(
      'title' => $source['name'],
      'help' => t('Clients remote content'),
      'query class' => 'clientsQuery',
    );
    $resource = clients_resource_load($rid);
    foreach (clients_fields($resource) as $field_key => $field_val) {

      // only works for string fields
      $data[$source['name']][$field_key] = array(
        'title' => $field_val['name'],
        'help' => $field_val['description'] ? $field_val['description'] : ' ',
        'field' => array(
          'handler' => 'clients_views_handler_field',
        ),
      );
    }
    $connection = clients_connection_load((int) $source['connection']);
    foreach (clients_arguments($connection) as $arg) {
      $data[$source['name']][$arg->name] = array(
        'title' => $arg->title,
        'help' => $arg->help,
        'argument' => array(
          'handler' => 'views_handler_argument',
        ),
      );
    }
  }
  return $data;
}