tripal_featuremap.module 9.0 KB

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