Tripal v1.0 (6.x-1.0)
tripal_natural_diversity.views.inc File Reference

Go to the source code of this file.

Functions

 tripal_natural_diversity_views_data ()
 tripal_natural_diversity_views_handlers ()
 tripal_natural_diversity_views_default_views ()

Detailed Description

This file contains the basic functions for views integration of chado/tripal_natural_diversity tables.

Documentation on views integration can be found at http://views2.logrus.com/doc/html/index.html.

Definition in file tripal_natural_diversity.views.inc.


Function Documentation

tripal_natural_diversity_views_data ( )

Implements hook_views_data() Purpose: Describe chado/tripal tables & fields to views

Returns:
: a data array which follows the structure outlined in the views2 documentation for this hook. Essentially, it's an array of table definitions keyed by chado/tripal table name. Each table definition includes basic details about the table, fields in that table and relationships between that table and others (joins)

Definition at line 28 of file tripal_natural_diversity.views.inc.

                                                {
  $data = array();

  if (module_exists('tripal_views')) {
    $tables = array(
      'nd_experiment',
      'nd_geolocation',
      'nd_protocol',
      'nd_reagent'
    );
    foreach ($tables as $tablename) {
      $priority = 9;

      // check to see if the table is integrated. If it is then integrate it's
      // corresponding 'chado_[table]' table.
      if (!tripal_views_is_integrated($tablename, $priority)) {
        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE, $priority);

        // Add specialty handlers
        switch ($tablename) {
          case 'nd_geolocation':
            $table_integration_array['fields']['description']['handlers']['filter']['name'] = 'tripal_views_handler_filter_select_string';
            $table_integration_array['fields']['geodetic_datum']['handlers']['filter']['name'] = 'tripal_views_handler_filter_select_string';
            $table_integration_array['fields']['latitude']['handlers']['filter']['name'] = 'chado_views_handler_filter_float';
            $table_integration_array['fields']['longitude']['handlers']['filter']['name'] = 'chado_views_handler_filter_float';
            $table_integration_array['fields']['altitude']['handlers']['filter']['name'] = 'chado_views_handler_filter_float';
            break;
        }

        tripal_views_integration_add_entry($table_integration_array);
      }
    }

    $tables = array(
      'nd_experiment_contact',
      'nd_experiment_dbxref',
      'nd_experiment_genotype',
      'nd_experiment_phenotype',
      'nd_experiment_project',
      'nd_experiment_protocol',
      'nd_experiment_pub',
      'nd_experiment_stock',
      'nd_experiment_stock_dbxref',
      'nd_experiment_stockprop',
      'nd_experimentprop',
      'nd_geolocationprop',
      'nd_protocol_reagent',
      'nd_protocolprop',
      'nd_reagent_relationship',
      'nd_reagentprop'
    );
    foreach ($tables as $tablename) {
      $priority = 9;
      if (!tripal_views_is_integrated($tablename, $priority)) {
        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority);
        tripal_views_integration_add_entry($table_integration_array);
      }
    }
  }

  return $data;
}
tripal_natural_diversity_views_handlers ( )

Implements hook_views_handlers() Purpose: Register all custom handlers with views where a handler describes either "the type of field", "how a field should be filtered", "how a field should be sorted"

Returns:
: An array of handler definitions

Definition at line 99 of file tripal_natural_diversity.views.inc.

                                                   {
  return array(
    'info' => array(
      'path' => drupal_get_path('module', 'tripal_natural_diversity') . '/views/handlers',
    ),
    'handlers' => array(
      'views_handler_field_chado_relationship_all' => array(
        'parent' => 'views_handler_field_prerender_list',
      ),
      'views_handler_field_chado_relationship_by_type' => array(
       'parent' => 'views_handler_field_prerender_list',
      ),
    ),
  );
}
 All Classes Files Functions Variables