function tripal_views_data_tripal_entity
3.x tripal.views.inc | tripal_views_data_tripal_entity(&$data) |
Integrates the TripalEntity entities with Drupal Views.
1 call to tripal_views_data_tripal_entity()
- tripal_views_data in tripal/
tripal.views.inc - Describe various Tripal Core systems to Views
File
- tripal/
tripal.views.inc, line 145 - Integrates many of the core database tables with drupal views
Code
function tripal_views_data_tripal_entity(&$data) {
// Get the list of all of the bundles (entity types) and add them
// as "base tables" for views.
$bundles = db_select('tripal_bundle', 'tb')
->fields('tb')
->execute();
// Iterate through the bundles.
while ($bundle = $bundles->fetchObject()) {
// This isn't really the table name, but because our bundle table
// names are unique on every Tripal site we must ust a more generic
// name. Because we're using our own query class this should be fine.
$term = tripal_load_term_entity(array('term_id' => $bundle->term_id));
$table = $term->vocab->vocabulary . '__' . $term->accession;
// Each bundle gets it's own "table".
$data[$table]['table']['group'] = t($bundle->label);
$data[$table]['table']['base'] = array(
'query class' => 'tripal_views_query',
'title' => t($bundle->label),
'help' => t('Tripal ' . $bundle->label . ' pages'),
);
$data[$table]['entity_id'] = array(
'title' => t('Entity ID'),
'help' => t('The unique entity ID for this content type.'),
'field' => array(
'handler' => 'tripal_views_handler_field_entity',
),
'filter' => array(
'handler' => 'tripal_views_handler_filter',
),
'sort' => array(
'handler' => 'tripal_views_handler_sort',
),
);
$data[$table]['link'] = array(
'title' => t('Link'),
'help' => t('Provide a simple link to the content.'),
'field' => array(
'handler' => 'tripal_views_handler_field_entity_link',
),
);
$data[$table]['edit_link'] = array(
'title' => t('Edit Link'),
'help' => t('Provide a simple link to edit the content.'),
'field' => array(
'handler' => 'tripal_views_handler_field_entity_link_edit',
),
);
$data[$table]['delete_link'] = array(
'title' => t('Delete Link'),
'help' => t('Provide a simple link to delete the content.'),
'field' => array(
'handler' => 'tripal_views_handler_field_entity_link_delete',
),
);
$data[$table]['status'] = array(
'title' => t('Published'),
'help' => t('Whether or not the content is published.'),
'field' => array(
'handler' => 'tripal_views_handler_field_boolean',
'click sortable' => TRUE,
'output formats' => array(
'published-notpublished' => array(t('Published'), t('Not published')),
),
),
'filter' => array(
'handler' => 'tripal_views_handler_filter_boolean_operator',
'label' => t('Published'),
'type' => 'yes-no',
'use equal' => TRUE, // Use status = 1 instead of status <> 0 in WHERE statment
),
'sort' => array(
'handler' => 'tripal_views_handler_sort',
),
);
}
}