TripalEntityUIController.inc 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. /**
  3. * UI controller.
  4. */
  5. class TripalEntityUIController extends EntityDefaultUIController {
  6. /**
  7. * Overrides hook_menu() defaults. Main reason for doing this is that
  8. * parent class hook_menu() is optimized for entity type administration.
  9. */
  10. public function hook_menu() {
  11. $items = array();
  12. // Set this on the object so classes that extend hook_menu() can use it.
  13. $this->id_count = count(explode('/', $this->path));
  14. $wildcard = isset($this->entityInfo['admin ui']['menu wildcard']) ? $this->entityInfo['admin ui']['menu wildcard'] : '%entity_object';
  15. $id_count = count(explode('/', $this->path));
  16. // The content menu.
  17. $items[$this->path] = array(
  18. 'title' => 'Biological Data',
  19. 'page callback' => 'tripal_entities_content_view',
  20. 'file' => 'includes/tripal_entities.admin.inc',
  21. 'file path' => drupal_get_path('module', 'tripal_entities'),
  22. 'access arguments' => array('administer tripal data'),
  23. 'type' => MENU_LOCAL_TASK,
  24. );
  25. $items['BioData/add'] = array(
  26. 'title' => 'Add Biological Data',
  27. 'page callback' => 'tripal_entities_add_page',
  28. 'file' => 'includes/tripal_entities.entity_form.inc',
  29. 'file path' => drupal_get_path('module', 'tripal_entities'),
  30. 'access callback' => 'tripal_entities_entity_access',
  31. 'access arguments' => array('edit'),
  32. );
  33. // Add a menu item for creating each bundle
  34. $bundles = array_keys($this->entityInfo['bundles']);
  35. foreach ($bundles as $bundle) {
  36. $matches = array();
  37. preg_match('/^dbxref_(.*?)$/', $bundle, $matches);
  38. $dbxref_id = $matches[1];
  39. $cvterm = chado_generate_var('cvterm', array('dbxref_id' => $dbxref_id));
  40. // Set a custom page for adding new tripal data entities.
  41. $items['BioData/add/' . $dbxref_id] = array(
  42. 'title' => 'Add ' . ucfirst($cvterm->name),
  43. 'description' => 'A ' . $cvterm->name . ' record.',
  44. 'page callback' => 'drupal_get_form',
  45. 'page arguments' => array('tripal_entities_entity_form', 2),
  46. 'access callback' => 'tripal_entities_entity_access',
  47. 'access arguments' => array('edit'),
  48. 'file' => 'includes/tripal_entities.entity_form.inc',
  49. 'file path' => drupal_get_path('module', 'tripal_entities'),
  50. );
  51. }
  52. // Link for viewing a tripal data type.
  53. $items['BioData/' . $wildcard] = array(
  54. 'title callback' => 'tripal_entities_entity_title',
  55. 'title arguments' => array(1),
  56. 'page callback' => 'tripal_entities_view_entity',
  57. 'page arguments' => array(1),
  58. 'access callback' => 'tripal_entities_entity_access',
  59. 'access arguments' => array('view', 1),
  60. 'type' => MENU_CALLBACK,
  61. );
  62. // 'View' tab for an individual entity page.
  63. $items['BioData/' . $wildcard . '/view'] = array(
  64. 'title' => 'View',
  65. 'page callback' => 'tripal_entities_view_entity',
  66. 'page arguments' => array(1),
  67. 'access callback' => 'tripal_entities_entity_access',
  68. 'access arguments' => array('view', 1),
  69. 'type' => MENU_DEFAULT_LOCAL_TASK,
  70. 'weight' => -10,
  71. );
  72. // 'Edit' tab for an individual entity page.
  73. $items['BioData/' . $wildcard . '/edit'] = array(
  74. 'title' => 'Edit',
  75. 'page callback' => 'drupal_get_form',
  76. 'page arguments' => array('tripal_entities_entity_form', NULL, 1),
  77. 'access callback' => 'tripal_entities_entity_access',
  78. 'access arguments' => array('edit', 1),
  79. 'file' => 'includes/tripal_entities.entity_form.inc',
  80. 'file path' => drupal_get_path('module', 'tripal_entities'),
  81. 'type' => MENU_LOCAL_TASK,
  82. 'weight' => -8,
  83. );
  84. // Menu item for deleting tripal data entities.
  85. $items['BioData/' . $wildcard . '/delete'] = array(
  86. 'title' => 'Delete',
  87. 'page callback' => 'drupal_get_form',
  88. 'page arguments' => array('tripal_entities_entity_delete_form', 1),
  89. 'access callback' => 'tripal_entities_entity_access',
  90. 'access arguments' => array('edit', 1),
  91. 'file' => 'includes/tripal_entities.entity_form.inc',
  92. 'file path' => drupal_get_path('module', 'tripal_entities'),
  93. 'type' => MENU_CALLBACK,
  94. 'weight' => 10,
  95. );
  96. return $items;
  97. }
  98. }
  99. /**
  100. *
  101. * @param unknown $entity
  102. */
  103. function tripal_entity_manage_fields($entity) {
  104. drupal_goto('admin/structure/BioData/manage/' . $entity->bundle . '/fields');
  105. return '';
  106. }