tripal_core.module 6.3 KB

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