tripal_featuremap.module

  1. 2.x tripal_featuremap/tripal_featuremap.module
  2. 3.x legacy/tripal_featuremap/tripal_featuremap.module
  3. 1.x tripal_featuremap/tripal_featuremap.module

Integrates the Chado Map module with Drupal Nodes & Views

File

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