tripal_featuremap.module 8.8 KB

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