tripal_core.module 6.6 KB

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