Tripal
|
Provides API functions that support direct integration of Chado tables with Drupal Views. This is different from the entity and field integration that Tripal v3 provides. Here Chado tables are directly integrated. Tripal provides a web interface that allows site developers to customize how a Chado table is integrate with Views. However, these functions provide programmatic access to the same functionality.
tripal_add_field_to_views_integration | ( | $table_name, | |
$priority, | |||
$field | |||
) |
Adds the given field to an existing or cloned integration. In the case of a cloned integration, the lightest integration is used as the template for the clone.
NOTE: If that field already exists in the specified integration then it will first be deleted and the new one added.
$table_name | The name of the table the integration is for |
$priority | The priority of the integration to use; pass NULL to use the lightest integration |
$field | An array describing the field ot add; uses the same format as the $defn_array |
tripal_add_join_to_views_integration | ( | $table_name, | |
$priority, | |||
$join | |||
) |
Adds the given field to an existing or cloned integration. In the case of a cloned integration, the lightest integration is used as the template for the clone.
NOTE: If that field already exists in the specified integration then it will first be deleted and the new one added.
$table_name | The name of the table the integration is for |
$priority | The priority of the integration to use; pass NULL to use the lightest integration |
$field | An array describing the join to add. it should contain the following keys: base_table, base_field, left_table, left_field, handler, relationship_handler, relationship_only |
tripal_add_views_integration | ( | $defn_array, | |
$setup_id = FALSE |
|||
) |
Add views integration records into the tripal_views* tables.
This is the programatic way to add your own integrations to the tripal views integrations list. Keep in mind that the priority set in your $defn_array needs to be lighter than any existing integrations to be used by views and that it should still be below 0 in order to allow site administrators to override it should they need to.
$defn_array | An array describing the structure and fields of the table. |
Example usage (in hook_install()):
tripal_clone_views_integration | ( | $table_name, | |
$new_priority = NULL , |
|||
$template_priority = NULL |
|||
) |
Clone an integration. This is often a great way to create your own module-specific integration while still benifiting from an existing (or even the lightest priority) integration.
$table_name | The table for which you'd like to clone an integration |
$new_priority | The priority of the clone; this is the integration which will be created. If no priority is supplied then one lighter then the $template_priority will be used. |
$template_priority | The priority of the template to be used for the clone; this is an existing integration. If no priority is supplied then the lightest priority will be used. |
tripal_disable_view | ( | $view_name, | |
$redirect_link = FALSE |
|||
) |
Programatically disable view.
This should be used in a hook_menu definition as the callback to provide a link to disable the view (first example). It can also be called directly if needed (second example).
$view_name | The machine-name of the view to be enabled |
$redirect_link | The path to redirect to. FALSE if no redirect needed |
tripal_enable_view | ( | $view_name, | |
$redirect_link = FALSE |
|||
) |
Programatically enable view
This should be used in a hook_menu definition as the callback to provide a link to enable the view (first example). It can also be called directly if needed (second example).
$view_name | The machine-name of the view to be enabled |
$redirect_link | The path to redirect to. FALSE if no redirect needed |
tripal_export_views_integration | ( | $setup_id | ) |
Export Views integration records.
This is a great way to create your own integration since it returns an already defined integration in array form that you can modify. After modifications simply set the priority to something lighter (but still below 0) than any existing integrations and use tripal_add_views_integration() to add it to the list of integrations.
$setup_id | The unique setup id of the tripal views integration |
tripal_get_lightest_views_integration_priority | ( | $table_name | ) |
Retrieve the priority of the lightest priority for a given table.
NOTE: Uses lightest priority (drupal-style) where the range is from -10 to 10 and -10 is of highest priority.
$table_name | The name of the table to retrieve the setup ID for. This can be either a materialized view or a chado table |
tripal_get_lightest_views_integration_setup | ( | $table_name | ) |
Retrieve the views integration setup_id with the lightest priority for a given table
NOTE: Uses lightest priority (drupal-style) where the range is from -10 to 10 and -10 is of highest priority.
$table_name | The name of the table to retrieve the setup ID for. This can be either a materialized view or a chado table |
tripal_get_views_integration_setup_id | ( | $table_name, | |
$priority | |||
) |
Retrieve the views integration setup_id with the given priority/table combination.
$table_name | The name of the table to retrieve the setup ID for. This can be either a materialized view or a chado table |
$priority | The priority of the integration to retrieve the setup_id for |
tripal_is_lightest_priority_setup | ( | $setup_id, | |
$table_name | |||
) |
Checks if you are dealing with the lightest priority setup for a given table. This is a good way to determine whether your modules integration is being used by views.
$setup_id | The ID of the setup to check (is this setup the lightest one?) |
$table_name | The name of the table associated with this setup |
tripal_is_table_integrated | ( | $table_name, | |
$priority = NULL |
|||
) |
Check to see if this table already has an integration record with the given priority.
$table_name | The name of the table to check for integration |
$priority | (optional) The priority of record to check for |
tripal_make_view_compatible_with_external | ( | $view | ) |
Remove any drupal fields from a chado-based default view definition if chado is external. This ensures compatibility with an external chado database.
You should be calling this function in your hook_views_default_views(). This function will only remove drupal tables if chado is external; thus you do not need to worry about checking yourself. For example, the following is a good hook_views_default_views():
Notice that the actual views export code is in a separate function. This makes your hook_views_default_views() more readable.
NOTE: Currently assumes all tables not in the tripal views integration tables are Drupal tables.
$view | The default view definition object |
tripal_rebuild_views_integrations | ( | $delete_first = FALSE | ) |
Rebuilds all the default integrations.
This essentially clears the cache in case you mess up the integrations in your site. This should not be used during module development since it really only rebuilds the integrations described by all enabled modules in the site and if $delete_first is TRUE it can delete custom integrations created by site administrators which will not make your module popular.
$delete_first | If TRUE then all integrations are first deleted. |
tripal_remove_join_from_views_integration | ( | $setup_id, | |
$base_table, | |||
$base_field, | |||
$left_table, | |||
$left_field | |||
) |
Remove a join from an integration. This is usually done after cloning an existing integration using tripal_clone_views_integration().
$setup_id | The setup_id of the integration to delete the join from. |
$base_table | The name of the base table involved the join. |
$base_field | The field from the base table involved in the join. |
$left_table | The name of the other table involved in the join |
$left_field | The name of the field from the other table involved in the join. |
tripal_remove_views_integration | ( | $identifiers, | |
$options = [] |
|||
) |
Removes a View Integration Entry when you only know the table the integration was created for and the priority.
This should only be used to remove integrations created by your own module (possibly on uninstall of your module). To override existing integrations simply create your own integration with a lighter priority using tripal_clone_views_integration() or tripal_export_views_integration() to create a template.
$identifies | An array of identifiers where the keys indicate what the identifier is. One of the following compinations must be present: 1) table_name & priority: the name of the table & the priority to remove a views integration entry for. 2) setup_id: the setup_id of the entry to remove. |
$options | An array of options, currently none are supported. |
tripal_update_views_integration | ( | $setup_id, | |
$defn_array | |||
) |
Update an existing Views Intregration Entry. This essentially removes and then re-adds the integration.
$setup_id | The setup ID of the views integration entry to update |
$defn_array | An array describing the structure and fields of the table as is used in tripal_add_views_integration(). |