tripal_contact.admin.inc 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /**
  3. * @file
  4. * Handle administration of contacts.
  5. *
  6. * @ingroup tripal_legacy_contact
  7. */
  8. /**
  9. * Launchpage for contact administration. Makes sure views are enabled and if
  10. * not provides links to enable them.
  11. *
  12. * @ingroup tripal_legacy_contact
  13. */
  14. function tripal_contact_admin_contact_view() {
  15. $output = '';
  16. // set the breadcrumb
  17. $breadcrumb = [];
  18. $breadcrumb[] = l('Home', '<front>');
  19. $breadcrumb[] = l('Administration', 'admin');
  20. $breadcrumb[] = l('Tripal', 'admin/tripal');
  21. $breadcrumb[] = l('Chado', 'admin/tripal/legacy');
  22. $breadcrumb[] = l('Contacts', 'admin/tripal/legacy/tripal_contact');
  23. drupal_set_breadcrumb($breadcrumb);
  24. // Add the view
  25. $view = views_embed_view('tripal_contact_admin_contacts', 'default');
  26. if (isset($view)) {
  27. $output .= $view;
  28. }
  29. else {
  30. $output .= '<p>The Contact module uses primarily views to provide an '
  31. . 'administrative interface. Currently one or more views needed for this '
  32. . 'administrative interface are disabled. <strong>Click each of the following links to '
  33. . 'enable the pertinent views</strong>:</p>';
  34. $output .= '<ul>';
  35. $output .= '<li>' . l('Contacts View', 'admin/tripal/legacy/tripal_contact/views/contacts/enable') . '</li>';
  36. $output .= '</ul>';
  37. }
  38. return $output;
  39. }
  40. /**
  41. * Administrative settings form
  42. *
  43. * @ingroup tripal_legacy_contact
  44. */
  45. function tripal_contact_admin() {
  46. $form = [];
  47. // If your module is using the Chado Node: Title & Path API to allow custom titles
  48. // for your node type then you need to add the configuration form for this functionality.
  49. $details = [
  50. 'module' => 'tripal_contact',
  51. // the name of the MODULE implementing the content type
  52. 'content_type' => 'chado_contact',
  53. // the name of the content type
  54. // An array of options to use under "Page Titles"
  55. // the key should be the token and the value should be the human-readable option
  56. 'options' => [
  57. '[contact.name]' => 'Contact Name Only',
  58. // there should always be one options matching the unique constraint.
  59. '[contact.name]' => 'Unique Contraint: The name of the contact',
  60. ],
  61. // the token indicating the unique constraint in the options array
  62. 'unique_option' => '[contact.name]',
  63. ];
  64. // This call adds the configuration form to your current form
  65. // This sub-form handles it's own validation & submit
  66. chado_add_admin_form_set_title($form, $form_state, $details);
  67. // URL ALIAS
  68. $details = [
  69. 'module' => 'tripal_contact',
  70. 'content_type' => 'chado_contact',
  71. 'options' => [
  72. '/contact/[contact.contact_id]' => 'Contact ID',
  73. '/contact/[contact.name]' => 'Unique Contraint: The name of the contact',
  74. ],
  75. ];
  76. // This call adds the configuration form to your current form
  77. // This sub-form handles it's own validation & submit
  78. chado_add_admin_form_set_url($form, $form_state, $details);
  79. return system_settings_form($form);
  80. }
  81. /**
  82. * Reindex nodes for drupal search
  83. *
  84. * @ingroup tripal_legacy_contact
  85. */
  86. function get_tripal_contact_admin_form_reindex_set(&$form) {
  87. }
  88. /**
  89. * Validate the contact settings form.
  90. *
  91. * @ingroup tripal_legacy_contact
  92. */
  93. function tripal_contact_admin_validate($form, &$form_state) {
  94. }