ChadoDataTypeUIController.inc 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * @file
  4. */
  5. /**
  6. * UI controller.
  7. */
  8. class ChadoDataTypeUIController 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 Chado data types, including adding
  15. and removing fields and the display of fields.';
  16. // We don't want to let the user add new Chado data types. They
  17. // are added automatically.
  18. unset($items[$this->path . '/add']);
  19. unset($items[$this->path . '/import']);
  20. return $items;
  21. }
  22. }
  23. /**
  24. * Access callback for the entity API.
  25. */
  26. function chado_data_type_access($op, $type = NULL, $account = NULL) {
  27. return user_access('administer chado data types', $account);
  28. }
  29. /**
  30. * Generates the chado data type editing form.
  31. */
  32. function chado_data_type_form($form, &$form_state, $chado_data_type, $op = 'edit') {
  33. if ($op == 'clone') {
  34. $chado_data_type->label .= ' (cloned)';
  35. $chado_data_type->type = '';
  36. }
  37. $form['label'] = array(
  38. '#title' => t('Label'),
  39. '#type' => 'textfield',
  40. '#default_value' => $chado_data_type->label,
  41. '#description' => t('The human-readable name of this chado data type.'),
  42. '#required' => TRUE,
  43. '#size' => 30,
  44. );
  45. return $form;
  46. }
  47. /**
  48. * Form API submit callback for the type form.
  49. */
  50. function chado_data_type_form_submit(&$form, &$form_state) {
  51. $chado_data_type = entity_ui_form_submit_build_entity($form, $form_state);
  52. $chado_data_type->save();
  53. $form_state['redirect'] = 'admin/structure/chado_data_types';
  54. }
  55. /**
  56. * Form API submit callback for the delete button.
  57. */
  58. function chado_data_type_form_submit_delete(&$form, &$form_state) {
  59. $form_state['redirect'] = 'admin/structure/chado_data_types/manage/' . $form_state['chado_data_type']->type . '/delete';
  60. }