TripalDataTypeUIController.inc 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * @file
  4. */
  5. /**
  6. * UI controller.
  7. */
  8. class TripalDataTypeUIController extends EntityDefaultUIController {
  9. /**
  10. * Overrides hook_menu() defaults.
  11. */
  12. public function hook_menu() {
  13. $items = parent::hook_menu();
  14. $items[$this->path]['description'] = 'Manage Tripal data types, including adding
  15. and removing fields and the display of fields.';
  16. // We don't want to let the user add new Tripal data types. They
  17. // are added automatically.
  18. //unset($items[$this->path . '/add']);
  19. //unset($items[$this->path . '/import']);
  20. drupal_debug($items);
  21. return $items;
  22. }
  23. }
  24. /**
  25. * Access callback for the entity API.
  26. */
  27. function tripal_data_type_access($op, $type = NULL, $account = NULL) {
  28. return user_access('administer tripal data types', $account);
  29. }
  30. /**
  31. * Generates the tripal data type editing form.
  32. */
  33. function tripal_data_type_form($form, &$form_state, $tripal_data_type, $op = 'edit') {
  34. if ($op == 'clone') {
  35. $tripal_data_type->label .= ' (cloned)';
  36. $tripal_data_type->type = '';
  37. }
  38. $form['label'] = array(
  39. '#title' => t('Label'),
  40. '#type' => 'textfield',
  41. '#default_value' => $tripal_data_type->label,
  42. '#description' => t('The human-readable name of this tripal data type.'),
  43. '#required' => TRUE,
  44. '#size' => 30,
  45. );
  46. return $form;
  47. }
  48. /**
  49. * Form API submit callback for the type form.
  50. */
  51. function tripal_data_type_form_submit(&$form, &$form_state) {
  52. $tripal_data_type = entity_ui_form_submit_build_entity($form, $form_state);
  53. $tripal_data_type->save();
  54. $form_state['redirect'] = 'admin/structure/tripal_data_types';
  55. }
  56. /**
  57. * Form API submit callback for the delete button.
  58. */
  59. function tripal_data_type_form_submit_delete(&$form, &$form_state) {
  60. $form_state['redirect'] = 'admin/structure/tripal_data_types/manage/' . $form_state['tripal_data_type']->type . '/delete';
  61. }