You are here

itoggle_views.module in iToggle 7

Same filename and directory in other branches
  1. 7.2 modules/views/itoggle_views.module

iToggle Views module.

File

modules/views/itoggle_views.module
View source
<?php

/**
 * @file
 * iToggle Views module.
 */

/**
 * Implements hook_views_data().
 */
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;
}

/**
 * Implements hook_views_api().
 */
function itoggle_views_views_api() {
  list($module, $api) = func_get_args();
  if ($module == "views" && $api == "views_default") {
    return array(
      "version" => "3.0",
    );
  }
}

Functions