tripal_core.module 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <?php
  2. //
  3. // Copyright 2009 Clemson University
  4. //
  5. require_once "jobs.php";
  6. require_once "mviews.php";
  7. require_once "cvterms.php";
  8. require_once "chado_install.php";
  9. require_once "gff_loader.php";
  10. require_once "obo_loader.php";
  11. /*************************************************************************
  12. *
  13. */
  14. function tripal_core_init(){
  15. }
  16. /*************************************************************************
  17. *
  18. */
  19. function tripal_create_moddir($module_name){
  20. // make the data directory for this module
  21. $data_dir = file_directory_path() . "/tripal/$module_name";
  22. if(!file_check_directory($data_dir,FILE_CREATE_DIRECTORY|FILE_MODIFY_PERMISSIONS)){
  23. $message = "Cannot create directory $data_dir. This module may not ".
  24. "behave correctly without this directory. Please create ".
  25. "the directory manually or fix the problem and reinstall.";
  26. drupal_set_message($message,'error');
  27. watchdog('tripal_core',$message,array(),WATCHDOG_ERROR);
  28. }
  29. }
  30. /*************************************************************************
  31. *
  32. */
  33. function tripal_get_moddir($module_name){
  34. $data_dir = file_directory_path() . "/tripal/$module_name";
  35. return $data_dir;
  36. }
  37. /*************************************************************************
  38. *
  39. */
  40. function tripal_core_menu() {
  41. $items = array();
  42. // Triapl setting groups
  43. $items['admin/tripal'] = array(
  44. 'title' => 'Tripal Management',
  45. 'description' => "Manage the behavior or Tripal and its various modules.",
  46. 'position' => 'right',
  47. 'weight' => -5,
  48. 'page callback' => 'system_admin_menu_block_page',
  49. 'access arguments' => array('administer site configuration'),
  50. 'file' => 'system.admin.inc',
  51. 'file path' => drupal_get_path('module', 'system'),
  52. );
  53. // the administative settings menu
  54. /* $items['admin/tripal/tripal_core'] = array(
  55. 'title' => 'Tripal core settings',
  56. 'description' => 'Tripal Settings',
  57. 'page callback' => 'drupal_get_form',
  58. 'page arguments' => array('tripal_core_admin'),
  59. 'access arguments' => array('access administration pages'),
  60. 'type' => MENU_NORMAL_ITEM,
  61. );
  62. */
  63. $items['admin/tripal/tripal_jobs'] = array(
  64. 'title' => 'Jobs',
  65. 'description' => 'Jobs managed by Tripal',
  66. 'page callback' => 'tripal_jobs_report',
  67. 'access arguments' => array('access administration pages'),
  68. 'type' => MENU_NORMAL_ITEM,
  69. );
  70. $items['admin/tripal/tripal_mview/%'] = array(
  71. 'title' => 'Materialized View',
  72. 'description' => 'Materialized views are used to improve speed of large or complex queries.',
  73. 'page callback' => 'tripal_mview_report',
  74. 'page arguments' => array(3),
  75. 'access arguments' => array('access administration pages'),
  76. 'type' => MENU_NORMAL_ITEM,
  77. );
  78. $items['admin/tripal/tripal_mviews'] = array(
  79. 'title' => 'Materialized Views',
  80. 'description' => 'Materialized views are used to improve speed of large or complex queries.',
  81. 'page callback' => 'tripal_mviews_report',
  82. 'access arguments' => array('access administration pages'),
  83. 'type' => MENU_NORMAL_ITEM,
  84. );
  85. $items['admin/tripal/tripal_mviews/new'] = array(
  86. 'title' => 'Create View',
  87. 'description' => 'Materialized views are used to improve speed of large or complex queries.',
  88. 'page callback' => 'drupal_get_form',
  89. 'page arguments' => array('tripal_mviews_form'),
  90. 'access arguments' => array('access administration pages'),
  91. 'type' => MENU_NORMAL_ITEM,
  92. );
  93. $items['admin/tripal/tripal_mviews/edit/%'] = array(
  94. 'title' => 'Edit View',
  95. 'page callback' => 'drupal_get_form',
  96. 'page arguments' => array('tripal_mviews_form',4),
  97. 'access arguments' => array('access administration pages'),
  98. 'type' => MENU_NORMAL_ITEM,
  99. );
  100. $items['admin/tripal/tripal_mviews/action/%/%'] = array(
  101. 'title' => 'Create View',
  102. 'description' => 'Materialized views are used to improve speed of large or complex queries.',
  103. 'page callback' => 'tripal_mviews_action',
  104. 'page arguments' => array(4,5),
  105. 'access arguments' => array('access administration pages'),
  106. 'type' => MENU_CALLBACK,
  107. );
  108. $items['tripal_toggle_box_menu/%/%/%'] = array(
  109. 'title' => t('Libraries'),
  110. 'page callback' => 'tripal_toggle_box_menu',
  111. 'page arguments' => array(1,2,3),
  112. 'access arguments' => array('access administration pages'),
  113. 'type' => MENU_CALLBACK | MENU_LINKS_TO_PARENT
  114. );
  115. $items['admin/tripal/chado_install'] = array(
  116. 'title' => 'Install Chado v1.11',
  117. 'description' => 'Installs Chado version 1.11 inside the current Drupal database',
  118. 'page callback' => 'tripal_core_install_job',
  119. 'access arguments' => array('access administration pages'),
  120. 'type' => MENU_NORMAL_ITEM,
  121. );
  122. $items['admin/tripal/gff3_load'] = array(
  123. 'title' => 'Load a GFF3 file',
  124. 'description' => 'Loads a GFF3 file into Chado',
  125. 'page callback' => 'tripal_core_load_gff3',
  126. 'access arguments' => array('access administration pages'),
  127. 'type' => MENU_NORMAL_ITEM,
  128. );
  129. $items['admin/tripal/obo_load'] = array(
  130. 'title' => 'Load an OBO file',
  131. 'description' => 'Loads an OBO v1.2 file into Chado',
  132. 'page callback' => 'tripal_core_load_obo_job',
  133. 'access arguments' => array('access administration pages'),
  134. 'type' => MENU_NORMAL_ITEM,
  135. );
  136. return $items;
  137. }
  138. /************************************************************************
  139. * The typical display for information on feature, organism, library, etc
  140. * pages is to use the Tripal expandable boxes. However, some sites may
  141. * prefer to use a menu system to keep the pages less cluttered. This
  142. * function provides a common interface for setting a Drupal variable
  143. * that indicates whether or not the content is displayed in a box or as
  144. * a menu item. This function just reverses the setting each time it is
  145. * called
  146. */
  147. function tripal_toggle_box_menu($module,$box_name,$nid){
  148. // if the content is not in a menu then we wnat to turn on the
  149. // menu. If the content is in a menu item then we want to turn
  150. // on the box.
  151. if(strcmp(variable_get("$module-box-$box_name","menu_off"),"menu_off")==0){
  152. variable_set("$module-box-$box_name","menu_on");
  153. } else {
  154. variable_set("$module-box-$box_name","menu_off");
  155. }
  156. drupal_goto("node/$nid");
  157. }
  158. /************************************************************************
  159. *
  160. */
  161. function tripal_core_admin () {
  162. $form['chado_feature_data_url'] = array (
  163. '#title' => t('URL for data files'),
  164. '#type' => t('textfield'),
  165. '#description' => t("This is the base URL location (without a leading forward slash) for where files (e.g. blast .xml files) related to each feature are stored. All files available for download or parsing that a feature needs for display should be located in this base directory."),
  166. '#required' => TRUE,
  167. '#default_value' => variable_get('chado_feature_data_url','sites/default/files/data'),
  168. );
  169. return system_settings_form($form);
  170. }