You are here

function itoggle_views_views_data in iToggle 7

Implements hook_views_data().

File

modules/views/itoggle_views.module, line 11
iToggle Views module.

Code

function itoggle_views_views_data() {
  $return = array();
  $info = itoggle_get_entity_info();
  foreach ($info as $type => $entity) {
    $table_name = $entity['base table'];
    $id = $entity['entity keys']['id'];
    $return["itoggle_{$type}"] = array(
      'table' => array(
        'group' => t('iToggle'),
        'join' => array(
          $table_name => array(
            'left_field' => $id,
            'field' => $id,
          ),
        ),
      ),
    );
    $uctype = ucwords($type);
    foreach ($entity['properties'] as $name) {
      $ucname = ucwords($name);
      $return["itoggle_{$type}"]["itoggle_{$type}_{$name}"] = array(
        'title' => "{$uctype} {$ucname}",
        'help' => t('iToggle Widget for %type %name property.', array(
          '%type' => $uctype,
          '%name' => $ucname,
        )),
        'field' => array(
          'handler' => 'itoggle_views_handler_field',
          'click sortable' => TRUE,
        ),
      );
    }
  }
  return $return;
}