tripal_analysis.admin.inc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /**
  3. * @file
  4. * Contains functions displaying administrative pages and forms.
  5. *
  6. * @ingroup tripal_legacy_analysis
  7. */
  8. /**
  9. * Landing page for administration. Ensures Views are enabled & if not provides
  10. * links to do so.
  11. *
  12. * @ingroup tripal_legacy_analysis
  13. */
  14. function tripal_analysis_admin_analysis_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('Analysis', 'admin/tripal/legacy/tripal_analysis');
  23. drupal_set_breadcrumb($breadcrumb);
  24. // Add the view
  25. $view = views_embed_view('tripal_analysis_admin_analyses', 'default');
  26. if (isset($view)) {
  27. $output .= $view;
  28. }
  29. else {
  30. $output .= '<p>The Analysis 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('Analysis View', 'admin/tripal/legacy/tripal_analysis/views/analyses/enable') . '</li>';
  36. $output .= '</ul>';
  37. }
  38. return $output;
  39. }
  40. /**
  41. * Administration page callbacks for the Tripal Analysis module
  42. *
  43. * @return
  44. * A form API array describing an administrative form
  45. *
  46. * @ingroup tripal_legacy_analysis
  47. */
  48. function tripal_analysis_admin() {
  49. // Create a new administrative form. We'll add main functions to the form
  50. // first (Sync, Reindex, Clean, Taxonify). Thereafter, any sub-module that
  51. // has a setting will be added.
  52. $form = [];
  53. // If your module is using the Chado Node: Title & Path API to allow custom titles
  54. // for your node type then you need to add the configuration form for this functionality.
  55. $details = [
  56. 'module' => 'tripal_analysis',
  57. // the name of the MODULE implementing the content type
  58. 'content_type' => 'chado_analysis',
  59. // the name of the content type
  60. // An array of options to use under "Page Titles"
  61. // the key should be the token and the value should be the human-readable option
  62. 'options' => [
  63. '[analysis.name]' => 'Analysis Name Only',
  64. // there should always be one options matching the unique constraint.
  65. '[analysis.name] ([analysis.sourcename]) [analysis.program] version [analysis.programversion]' => 'Unique Contraint: Includes the name, source and program name/version',
  66. ],
  67. // the token indicating the unique constraint in the options array
  68. 'unique_option' => '[analysis.name] ([analysis.sourcename]) [analysis.program] version [analysis.programversion]',
  69. ];
  70. // This call adds the configuration form to your current form
  71. // This sub-form handles it's own validation & submit
  72. chado_add_admin_form_set_title($form, $form_state, $details);
  73. // URL ALIAS
  74. $details = [
  75. 'module' => 'tripal_analysis',
  76. 'content_type' => 'chado_analysis',
  77. 'options' => [
  78. '/analysis/[analysis.analysis_id]' => 'Analysis ID',
  79. '/analysis/[analysis.program]/[analysis.programversion]/[analysis.sourcename]' => 'Unique Contraint: Includes the program name & version as well as the source name',
  80. ],
  81. ];
  82. // This call adds the configuration form to your current form
  83. // This sub-form handles it's own validation & submit
  84. chado_add_admin_form_set_url($form, $form_state, $details);
  85. return system_settings_form($form);
  86. }
  87. /**
  88. * Validate the administrative form
  89. *
  90. * @todo Stephen: Why is validate used rather then submit?
  91. *
  92. * @param $form
  93. * The form API array of the form to be validated
  94. *
  95. * @form_state
  96. * The user submitted values
  97. *
  98. * @ingroup tripal_legacy_analysis
  99. */
  100. function tripal_analysis_admin_validate($form, &$form_state) {
  101. }