tripal_featuremap.module 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <?php
  2. /**
  3. * @file
  4. * Integrates the Chado Map module with Drupal Nodes & Views
  5. */
  6. /**
  7. * @defgroup tripal_legacy_featuremap Feature Map Module
  8. * @ingroup tripal_legacy_modules
  9. * @{
  10. * Integrates the Chado Map module with Drupal Nodes & Views
  11. * @}
  12. */
  13. require_once 'api/tripal_featuremap.DEPRECATED.inc';
  14. require_once 'theme/tripal_featuremap.theme.inc';
  15. require_once 'includes/tripal_featuremap.admin.inc';
  16. require_once 'includes/tripal_featuremap.chado_node.inc';
  17. /**
  18. * Implements hook_help().
  19. * Display help and module information
  20. *
  21. * @param path
  22. * which path of the site we're displaying help
  23. * @param arg
  24. * array that holds the current path as would be returned from arg() function
  25. * @return
  26. * help text for the path
  27. *
  28. * @ingroup tripal_legacy_featuremap
  29. */
  30. function tripal_featuremap_help($path, $arg) {
  31. $output = '';
  32. switch ($path) {
  33. case "admin/help#tripal_featuremap":
  34. $output = '<p>'.
  35. t("Displays links to nodes created on this date") .
  36. '</p>';
  37. break;
  38. }
  39. return $output;
  40. }
  41. /**
  42. * Implements hook_permission().
  43. *
  44. * Set the permission types that the chado module uses. Essentially we
  45. * want permissionis that protect creation, editing and deleting of chado
  46. * data objects
  47. *
  48. * @ingroup tripal_legacy_featuremap
  49. */
  50. function tripal_featuremap_permission() {
  51. return array(
  52. /*
  53. 'access chado_featuremap content' => array(
  54. 'title' => t('View Maps'),
  55. 'description' => t('Allow users to view map pages.'),
  56. ),
  57. 'create chado_featuremap content' => array(
  58. 'title' => t('Create Maps'),
  59. 'description' => t('Allow users to create new map pages.'),
  60. ),
  61. 'delete chado_featuremap content' => array(
  62. 'title' => t('Delete Maps'),
  63. 'description' => t('Allow users to delete map pages.'),
  64. ),
  65. 'edit chado_featuremap content' => array(
  66. 'title' => t('Edit Maps'),
  67. 'description' => t('Allow users to edit map pages.'),
  68. ),
  69. 'administer tripal featuremap' => array(
  70. 'title' => t('Administer Maps'),
  71. 'description' => t('Allow users to administer all maps.'),
  72. ),
  73. */
  74. );
  75. }
  76. /**
  77. * Implements hook_menu().
  78. *
  79. * Menu items are automatically added for the new node types created
  80. * by this module to the 'Create Content' Navigation menu item. This function
  81. * adds more menu items needed for this module.
  82. *
  83. * @ingroup tripal_legacy_featuremap
  84. */
  85. function tripal_featuremap_menu() {
  86. $items = array();
  87. // The administative settings menu
  88. $items['admin/tripal/legacy/tripal_featuremap'] = array(
  89. 'title' => 'Feature Maps',
  90. 'description' => 'A map of features from the chado database (e.g. genetic map)',
  91. 'page callback' => 'tripal_featuremap_admin_featuremaps_listing',
  92. 'access arguments' => array('administer tripal featuremap'),
  93. 'type' => MENU_NORMAL_ITEM,
  94. );
  95. $items['admin/tripal/legacy/tripal_featuremap/help'] = array(
  96. 'title' => 'Help',
  97. 'description' => 'Basic Description of Tripal Map Module Functionality',
  98. 'page callback' => 'theme',
  99. 'page arguments' => array('tripal_featuremap_help'),
  100. 'access arguments' => array('administer tripal featuremap'),
  101. 'type' => MENU_LOCAL_TASK,
  102. 'weight' => 10
  103. );
  104. $items['admin/tripal/legacy/tripal_featuremap/configuration'] = array(
  105. 'title' => 'Settings',
  106. 'description' => 'Manage integration of Chado maps including associated features.',
  107. 'page callback' => 'drupal_get_form',
  108. 'page arguments' => array('tripal_featuremap_admin'),
  109. 'access arguments' => array('administer tripal featuremap'),
  110. 'type' => MENU_LOCAL_TASK,
  111. 'weight' => 2
  112. );
  113. $items['admin/tripal/legacy/tripal_featuremap/sync'] = array(
  114. 'title' => ' Sync',
  115. 'description' => 'Sync featuremaps from Chado with Drupal',
  116. 'page callback' => 'drupal_get_form',
  117. 'page arguments' => array('chado_node_sync_form', 'tripal_featuremap', 'chado_featuremap'),
  118. 'access arguments' => array('administer tripal featuremap'),
  119. 'type' => MENU_LOCAL_TASK,
  120. 'weight' => 0
  121. );
  122. $items['admin/tripal/legacy/tripal_featuremap/chado_featuremap_toc'] = array(
  123. 'title' => ' TOC',
  124. 'description' => 'Manage the table of contents for feature map nodes.',
  125. 'page callback' => 'drupal_get_form',
  126. 'page arguments' => array('tripal_core_content_type_toc_form', 'chado_featuremap'),
  127. 'access arguments' => array('administer tripal featuremap'),
  128. 'type' => MENU_LOCAL_TASK,
  129. 'file' => 'includes/tripal_core.toc.inc',
  130. 'file path' => drupal_get_path('module', 'tripal_core'),
  131. 'weight' => 3
  132. );
  133. $items['admin/tripal/legacy/tripal_featuremap/views/featuremaps/enable'] = array(
  134. 'title' => 'Enable featuremap Administrative View',
  135. 'page callback' => 'tripal_enable_view',
  136. 'page arguments' => array('tripal_featuremap_admin_featuremaps', 'admin/tripal/legacy/tripal_featuremap'),
  137. 'access arguments' => array('administer tripal featuremap'),
  138. 'type' => MENU_CALLBACK,
  139. );
  140. return $items;
  141. }
  142. /**
  143. * Implements hook_search_biological_data_views().
  144. *
  145. * Adds the described views to the "Search Data" Page created by Tripal Views
  146. */
  147. function tripal_featuremap_search_biological_data_views() {
  148. return array(
  149. 'tripal_featuremap_user_featuremaps' => array(
  150. 'machine_name' => 'tripal_featuremap_user_featuremaps',
  151. 'human_name' => 'Maps',
  152. 'description' => 'A map of features from the chado database (e.g. genetic map)',
  153. 'link' => 'chado/featuremap'
  154. ),
  155. );
  156. }
  157. /**
  158. * Implements hook_views_api().
  159. *
  160. * Essentially this hook tells drupal that there is views support for
  161. * for this module which then includes tripal_featuremap.views.inc where all the
  162. * views integration code is
  163. *
  164. * @ingroup tripal_legacy_featuremap
  165. */
  166. function tripal_featuremap_views_api() {
  167. return array(
  168. 'api' => 3.0,
  169. );
  170. }
  171. /**
  172. * Implements hook_theme().
  173. *
  174. * We need to let drupal know about our theme functions and their arguments.
  175. * We create theme functions to allow users of the module to customize the
  176. * look and feel of the output generated in this module
  177. *
  178. * @ingroup tripal_legacy_featuremap
  179. */
  180. function tripal_featuremap_theme($existing, $type, $theme, $path) {
  181. $core_path = drupal_get_path('module', 'tripal_core');
  182. $items = array(
  183. 'node__chado_featuremap' => array(
  184. 'template' => 'node--chado-generic',
  185. 'render element' => 'node',
  186. 'base hook' => 'node',
  187. 'path' => "$core_path/theme/templates",
  188. ),
  189. 'tripal_featuremap_base' => array(
  190. 'variables' => array('node' => NULL),
  191. 'template' => 'tripal_featuremap_base',
  192. 'path' => "$path/theme/templates",
  193. ),
  194. 'tripal_featuremap_properties' => array(
  195. 'variables' => array('node' => NULL),
  196. 'template' => 'tripal_featuremap_properties',
  197. 'path' => "$path/theme/templates",
  198. ),
  199. 'tripal_featuremap_featurepos' => array(
  200. 'variables' => array('node' => NULL),
  201. 'template' => 'tripal_featuremap_featurepos',
  202. 'path' => "$path/theme/templates",
  203. ),
  204. 'tripal_featuremap_publication' => array(
  205. 'variables' => array('node' => NULL),
  206. 'template' => 'tripal_featuremap_publication',
  207. 'path' => "$path/theme/templates",
  208. ),
  209. 'tripal_featuremap_references' => array(
  210. 'variables' => array('node' => NULL),
  211. 'template' => 'tripal_featuremap_references',
  212. 'path' => "$path/theme/templates",
  213. ),
  214. 'tripal_featuremap_help' => array(
  215. 'template' => 'tripal_featuremap_help',
  216. 'variables' => array(NULL),
  217. 'path' => "$path/theme/templates",
  218. ),
  219. 'tripal_featuremap_teaser' => array(
  220. 'template' => 'tripal_featuremap_teaser',
  221. 'variables' => array(NULL),
  222. 'path' => "$path/theme/templates",
  223. ),
  224. // templates for the chado_feature nodes:
  225. 'tripal_feature_featurepos' => array(
  226. 'variables' => array('node' => NULL),
  227. 'template' => 'tripal_feature_featurepos',
  228. 'path' => "$path/theme/templates",
  229. ),
  230. );
  231. return $items;
  232. }
  233. /**
  234. * Implementation of hook_form_alter()
  235. *
  236. * @param $form
  237. * @param $form_state
  238. * @param $form_id
  239. *
  240. * @ingroup tripal_legacy_featuremap
  241. */
  242. function tripal_featuremap_form_alter(&$form, &$form_state, $form_id) {
  243. if ($form_id == "chado_featuremap_node_form") {
  244. // turn of preview button for insert/updates
  245. $form['actions']['preview']['#access'] = FALSE;
  246. //remove the body field
  247. unset($form['body']);
  248. }
  249. }