TripalEntityUIController.inc 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. // Change the add page menu to multiple types of entities
  26. $items[$this->path . '/add'] = array(
  27. 'title' => 'Add new biological data',
  28. 'description' => 'Add new biological data',
  29. 'page callback' => 'drupal_get_form',
  30. 'page arguments' => array('tripal_entities_entity_form'),
  31. 'access callback' => 'tripal_entities_entity_access',
  32. 'access arguments' => array('administer tripal data'),
  33. 'file' => 'includes/tripal_entities.entity_form.inc',
  34. 'file path' => drupal_get_path('module', 'tripal_entities'),
  35. 'type' => MENU_LOCAL_ACTION,
  36. 'weight' => 20,
  37. );
  38. // Set a custom page for adding new tripal data entities.
  39. $items['data/add'] = array(
  40. 'title' => 'Add Tripal data',
  41. 'description' => 'Add a new tripal data record',
  42. 'page callback' => 'drupal_get_form',
  43. 'page arguments' => array('tripal_entities_entity_form'),
  44. 'access callback' => 'tripal_entities_entity_access',
  45. 'access arguments' => array('edit'),
  46. 'file' => 'includes/tripal_entities.entity_form.inc',
  47. 'file path' => drupal_get_path('module', 'tripal_entities'),
  48. 'type' => MENU_NORMAL_ITEM,
  49. 'weight' => 20,
  50. );
  51. // Link for viewing a tripal data type.
  52. $items['data/' . $wildcard] = array(
  53. 'title callback' => 'tripal_entities_entity_title',
  54. 'title arguments' => array(1),
  55. 'page callback' => 'tripal_entities_view_entity',
  56. 'page arguments' => array(1),
  57. 'access callback' => 'tripal_entities_entity_access',
  58. 'access arguments' => array('view', 1),
  59. 'type' => MENU_CALLBACK,
  60. );
  61. // 'View' tab for an individual entity page.
  62. $items['data/' . $wildcard . '/view'] = array(
  63. 'title' => 'View',
  64. 'page callback' => 'tripal_entities_view_entity',
  65. 'page arguments' => array(1),
  66. 'access callback' => 'tripal_entities_entity_access',
  67. 'access arguments' => array('view', 1),
  68. 'type' => MENU_DEFAULT_LOCAL_TASK,
  69. 'weight' => -10,
  70. );
  71. // 'Edit' tab for an individual entity page.
  72. $items['data/' . $wildcard . '/edit'] = array(
  73. 'title' => 'Edit',
  74. 'page callback' => 'drupal_get_form',
  75. 'page arguments' => array('tripal_entities_entity_form', 1),
  76. 'access callback' => 'tripal_entities_entity_access',
  77. 'access arguments' => array('edit', 1),
  78. 'file' => 'includes/tripal_entities.entity_form.inc',
  79. 'file path' => drupal_get_path('module', 'tripal_entities'),
  80. 'type' => MENU_LOCAL_TASK,
  81. );
  82. // Menu item for deleting tripal data entities.
  83. $items['data/' . $wildcard . '/delete'] = array(
  84. 'title' => 'Delete',
  85. 'page callback' => 'drupal_get_form',
  86. 'page arguments' => array('tripal_entities_entity_delete_form', 1),
  87. 'access callback' => 'tripal_entities_entity_access',
  88. 'access arguments' => array('edit', 1),
  89. 'file' => 'includes/tripal_entities.entity_form.inc',
  90. 'file path' => drupal_get_path('module', 'tripal_entities'),
  91. 'type' => MENU_CALLBACK,
  92. 'weight' => 10,
  93. );
  94. return $items;
  95. }
  96. }