tripal_project.admin.inc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * @file
  4. * Administration of projects
  5. */
  6. /**
  7. * Admin launchpad
  8. *
  9. * @ingroup tripal_legacy_project
  10. */
  11. function tripal_project_admin_project_view() {
  12. $output = '';
  13. // set the breadcrumb
  14. $breadcrumb = [];
  15. $breadcrumb[] = l('Home', '<front>');
  16. $breadcrumb[] = l('Administration', 'admin');
  17. $breadcrumb[] = l('Tripal', 'admin/tripal');
  18. $breadcrumb[] = l('Chado', 'admin/tripal/legacy');
  19. $breadcrumb[] = l('Projects', 'admin/tripal/legacy/tripal_project');
  20. drupal_set_breadcrumb($breadcrumb);
  21. // Add the view
  22. $view = views_embed_view('tripal_project_admin_projects', 'default');
  23. if (isset($view)) {
  24. $output .= $view;
  25. }
  26. else {
  27. $output .= '<p>The Project module uses primarily views to provide an '
  28. . 'administrative interface. Currently one or more views needed for this '
  29. . 'administrative interface are disabled. <strong>Click each of the following links to '
  30. . 'enable the pertinent views</strong>:</p>';
  31. $output .= '<ul>';
  32. $output .= '<li>' . l('Projects View', 'admin/tripal/legacy/tripal_project/views/projects/enable') . '</li>';
  33. $output .= '</ul>';
  34. }
  35. return $output;
  36. }
  37. /**
  38. * Project settings
  39. *
  40. * @ingroup tripal_legacy_project
  41. */
  42. function tripal_project_admin($form, $form_state) {
  43. $form = [];
  44. // If your module is using the Chado Node: Title & Path API to allow custom titles
  45. // for your node type then you need to add the configuration form for this functionality.
  46. $details = [
  47. 'module' => 'tripal_project',
  48. // the name of the MODULE implementing the content type
  49. 'content_type' => 'chado_project',
  50. // the name of the content type
  51. // An array of options to use under "Page Titles"
  52. // the key should be the token and the value should be the human-readable option
  53. 'options' => [
  54. '[project.name]' => 'project Name Only',
  55. // there should always be one options matching the unique constraint.
  56. '[project.name]' => 'Unique Contraint: The project name',
  57. ],
  58. // the token indicating the unique constraint in the options array
  59. 'unique_option' => '[project.name]',
  60. ];
  61. // This call adds the configuration form to your current form
  62. // This sub-form handles it's own validation & submit
  63. chado_add_admin_form_set_title($form, $form_state, $details);
  64. // If the module is using the "Chado Node: Title & Path API" to allow custom URLs
  65. // for your node type then you need to add the configuration form for this functionality.
  66. $details = [
  67. 'module' => 'tripal_project',
  68. // the name of the MODULE implementing the content type
  69. 'content_type' => 'chado_project',
  70. // the name of the content type
  71. // An array of options to use under "Page URLs"
  72. // the key should be the token and the value should be the human-readable option
  73. 'options' => [
  74. '/project/[project.name]' => 'Project Name Only',
  75. // there should always be one options matching the unique constraint.
  76. // If you have a more human-readable constraint, then that is preferrable.
  77. // See the tripal feature module for a good example of this.
  78. '/project/[project.project_id]' => 'Unique Contraint: The Project ID',
  79. ],
  80. ];
  81. // This call adds the configuration form to your current form
  82. // This sub-form handles it's own validation & submit
  83. chado_add_admin_form_set_url($form, $form_state, $details);
  84. return system_settings_form($form);
  85. }