tripal_ds.module 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. require_once "includes/tripal_ds.inc";
  3. require_once "includes/tripal_ds.ds.inc";
  4. require_once "includes/tripal_ds.field_group.inc";
  5. require_once "includes/tripal_ds.field_formatter.inc";
  6. function tripal_ds_init() {
  7. drupal_add_css(drupal_get_path('module', 'tripal_ds') . '/theme/css/tripaldsfeature.css');
  8. drupal_add_js(drupal_get_path('module', 'tripal_ds') . '/theme/js/tripal_ds.js');
  9. $theme_dir = url(drupal_get_path('module', 'tripal_ds') . '/theme');
  10. drupal_add_js("var ds_theme_dir = '$theme_dir';", 'inline', 'header');
  11. }
  12. /**
  13. * Implements hook_views_api().
  14. */
  15. function tripal_ds_views_api() {
  16. return array(
  17. 'api' => 3,
  18. 'path' => drupal_get_path('module', 'tripal_ds') . '/includes/views',
  19. );
  20. }
  21. /**
  22. * Implements hook_bundle_postcreate().
  23. *
  24. * This is a Triapl defined hook and is called in the TripalBundle::create()
  25. * function to allow modules to perform tasks when a bundle is created.
  26. */
  27. function tripal_ds_bundle_postcreate($bundle) {
  28. $bundle_name = $bundle->name;
  29. $instances = field_info_instances('TripalEntity', $bundle_name);
  30. _ds_layout_settings_info($bundle_name, $instances);
  31. }
  32. function tripal_ds_table_column_delete($bundle){
  33. $bundle_name = $bundle->name;
  34. db_delete('tripal_ds')
  35. ->condition('bundle', $bundle_name, '=')
  36. ->execute();
  37. }
  38. function tripal_ds_bundle_delete($bundle){
  39. tripal_ds_table_column_delete($bundle);
  40. }
  41. /*
  42. * Implements hook_ds_layout_info() to define layouts from code in a module for
  43. * display suite
  44. */
  45. function tripal_ds_ds_layout_info() {
  46. $path = drupal_get_path('module', 'tripal_ds');
  47. $layouts = array(
  48. 'tripal_ds_feature' => array(
  49. 'label' => t('Tripal Feature Layout'),
  50. 'path' => $path . '/theme/templates',
  51. 'regions' => array(
  52. 'left' => t('Left'),
  53. 'right' => t('Right'),
  54. ),
  55. 'css' => TRUE,
  56. ),
  57. );
  58. return $layouts;
  59. }
  60. /*
  61. * Code for the view of the menu items
  62. //get tripal entity id from url then run it against tripal entity db
  63. //and grab the bundle id, then pass bundle id to view
  64. $url = current_path();
  65. $url_exploded = explode("/", $url);
  66. $tripal_entity_id = (int)$url_exploded[1];
  67. $result = db_select('tripal_entity', 'te')
  68. ->fields('te', array('bundle'))
  69. ->condition('id', $tripal_entity_id, '=')
  70. ->execute()
  71. ->fetchField();
  72. */