tripal_feature.admin.inc

  1. 2.x tripal_feature/includes/tripal_feature.admin.inc
  2. 3.x legacy/tripal_feature/includes/tripal_feature.admin.inc
  3. 1.x tripal_feature/includes/tripal_feature.admin.inc

Administration of features

File

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