tripal_core.module 6.0 KB

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