tripal_feature.admin.inc 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?php
  2. /**
  3. * @file
  4. * Administration of features
  5. */
  6. /**
  7. * Launchpad for feature administration.
  8. *
  9. * @ingroup tripal_feature
  10. */
  11. function tripal_feature_admin_feature_view() {
  12. $output = '';
  13. // set the breadcrumb
  14. $breadcrumb = array();
  15. $breadcrumb[] = l('Home', '<front>');
  16. $breadcrumb[] = l('Administration', 'admin');
  17. $breadcrumb[] = l('Tripal', 'admin/tripal');
  18. $breadcrumb[] = l('Chado', 'admin/tripal/chado');
  19. $breadcrumb[] = l('Features', 'admin/tripal/chado/tripal_feature');
  20. drupal_set_breadcrumb($breadcrumb);
  21. // Add the view
  22. $view = views_embed_view('tripal_feature_admin_features','default');
  23. if (isset($view)) {
  24. $output .= $view;
  25. }
  26. else {
  27. $output .= '<p>The Feature 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('Features View', 'admin/tripal/chado/tripal_feature/views/features/enable').'</li>';
  33. $output .= '</ul>';
  34. }
  35. return $output;
  36. }
  37. /**
  38. * Feature Settings page
  39. *
  40. * @ingroup tripal_feature
  41. */
  42. function tripal_feature_admin() {
  43. // FEATURE PAGE TITLES
  44. // Using the Chado Node: Title & Path API
  45. $details = array(
  46. 'module' => 'tripal_feature',
  47. 'content_type' => 'chado_feature',
  48. // An array of options to use under "Page Titles"
  49. // the key should be the token and the value should be the human-readable option
  50. 'options' => array(
  51. '[feature.name]' => 'Feature Name Only',
  52. '[feature.uniquename]' => 'Feature Unique Name Only',
  53. // there should always be one options matching the unique constraint.
  54. '[feature.name], [feature.uniquename] ([feature.type_id>cvterm.name]) [feature.organism_id>organism.genus] [feature.organism_id>organism.species]' => 'Unique Contraint: Includes the name, uniquename, type and scientific name'
  55. ),
  56. // the token indicating the unique constraint in the options array
  57. 'unique_option' => '[feature.name], [feature.uniquename] ([feature.type_id>cvterm.name]) [feature.organism_id>organism.genus] [feature.organism_id>organism.species]'
  58. );
  59. // This call adds the configuration form to your current form
  60. // This sub-form handles it's own validation & submit
  61. chado_add_admin_form_set_title($form, $form_state, $details);
  62. // FEATURE NODE URL
  63. // Using the Chado Node: Title & Path API
  64. $details = array(
  65. 'module' => 'tripal_feature',
  66. 'content_type' => 'chado_feature',
  67. // An array of options to use under "Page URL"
  68. // the key should be the token and the value should be the human-readable option
  69. 'options' => array(
  70. '/feature/[feature.feature_id]' => 'Feature ID',
  71. // there should always be one options matching the unique constraint.
  72. '/feature/[feature.organism_id>organism.genus]/[feature.organism_id>organism.species]/[feature.type_id>cvterm.name]/[feature.uniquename]' => 'Unique Contraint: Includes the name, uniquename, type and scientific name'
  73. )
  74. );
  75. // This call adds the configuration form to your current form
  76. // This sub-form handles it's own validation & submit
  77. chado_add_admin_form_set_url($form, $form_state, $details);
  78. // FEATURE BROWSER
  79. $form['browser'] = array(
  80. '#type' => 'fieldset',
  81. '#title' => t('Feature Browser'),
  82. '#collapsible' => TRUE,
  83. '#collapsed' => TRUE,
  84. );
  85. $form['browser']['browser_desc'] = array(
  86. '#markup' => t('A feature browser can be added to an organism page to allow users to quickly ' .
  87. 'access a feature. This will most likely not be the ideal mechanism for accessing feature ' .
  88. 'information, especially for large sites, but it will alow users exploring the site (such ' .
  89. 'as students) to better understand the data types available on the site.'),
  90. );
  91. $form['browser']['feature_types'] = array(
  92. '#title' => t('Feature Types'),
  93. '#type' => 'textarea',
  94. '#description' => t("Enter the Sequence Ontology (SO) terms for the feature types that " .
  95. "will be shown in the feature browser."),
  96. '#default_value' => variable_get('chado_browser_feature_types', 'gene mRNA'),
  97. );
  98. $form['browser']['set_browse_button'] = array(
  99. '#type' => 'submit',
  100. '#value' => t('Set Browser'),
  101. '#weight' => 2,
  102. );
  103. // FEATURE SUMMARY REPORT
  104. $form['summary'] = array(
  105. '#type' => 'fieldset',
  106. '#title' => t('Feature Summary Report'),
  107. '#collapsible' => TRUE,
  108. '#collapsed' => TRUE,
  109. );
  110. $form['summary']['feature_mapping'] = array(
  111. '#title' => 'Map feature types',
  112. '#description' => t('You may specify which Sequence Ontology (SO) terms to show in the ' .
  113. 'feature summary report by listing them in the following text area. Enter one per line. ' .
  114. 'If left blank, all SO terms for all features will be shown in the report. Only those terms ' .
  115. 'listed below will be shown in the report. Terms will appear in the report in the same order listed. To rename a ' .
  116. 'SO term to be more human readable form, use an \'=\' sign after the SO term (e.g. \'polypeptide = Protein\')'),
  117. '#type' => 'textarea',
  118. '#rows' => 15,
  119. '#default_value' => variable_get('tripal_feature_summary_report_mapping', ''),
  120. );
  121. $form['summary']['set_summary_button'] = array(
  122. '#type' => 'submit',
  123. '#value' => t('Set Summary'),
  124. '#weight' => 2,
  125. );
  126. return system_settings_form($form);
  127. }
  128. /**
  129. * Validate the feature settings forms
  130. *
  131. * @ingroup tripal_feature
  132. */
  133. function tripal_feature_admin_validate($form, &$form_state) {
  134. global $user; // we need access to the user info
  135. $job_args = array();
  136. variable_set('chado_browser_feature_types', $form_state['values']['feature_types']);
  137. switch ($form_state['values']['op']) {
  138. case t('Set Summary') :
  139. variable_set('tripal_feature_summary_report_mapping', $form_state['values']['feature_mapping']);
  140. break;
  141. }
  142. }