tripal_phylogeny.module 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <?php
  2. /**
  3. * @file
  4. * Integrates the Chado Phylotree module with Drupal Nodes & Views
  5. */
  6. /**
  7. * @defgroup tripal_phylogeny Phylotree Module
  8. * @ingroup tripal_modules
  9. * @{
  10. * Integrates the Chado Phylotree module with Drupal Nodes
  11. * @}
  12. */
  13. require_once 'api/tripal_phylogeny.api.inc';
  14. require_once 'theme/tripal_phylogeny.theme.inc';
  15. require_once 'includes/tripal_phylogeny.admin.inc';
  16. require_once 'includes/tripal_phylogeny.chado_node.inc';
  17. require_once 'includes/tripal_phylogeny.import_tree.inc';
  18. require_once 'includes/tripal_phylogeny.taxonomy_import.inc';
  19. /**
  20. * Implements hook_permission().
  21. *
  22. * Set the permission types that the chado module uses. Essentially we
  23. * want permissionis that protect creation, editing and deleting of chado
  24. * data objects
  25. *
  26. * @ingroup tripal_phylogeny
  27. */
  28. function tripal_phylogeny_permission() {
  29. return array(
  30. 'access chado_phylotree content' => array(
  31. 'title' => t('View Phylotrees'),
  32. 'description' => t('Allow users to view phylotree pages.'),
  33. ),
  34. 'administer tripal phylotree' => array(
  35. 'title' => t('Administer Phylotrees'),
  36. 'description' => t('Allow users to administer all phylotrees.'),
  37. ),
  38. );
  39. }
  40. /**
  41. * Implements hook_menu().
  42. *
  43. * Menu items are automatically added for the new node types created
  44. * by this module to the 'Create Content' Navigation menu item. This function
  45. * adds more menu items needed for this module.
  46. *
  47. * @ingroup tripal_phylogeny
  48. */
  49. function tripal_phylogeny_menu() {
  50. $items = array();
  51. // administration landing page. currently has no content but is
  52. // apparently required for the Sync and Help links to work.
  53. $items['admin/tripal/extension/tripal_phylogeny'] = array(
  54. 'title' => 'Phylotrees',
  55. 'description' => 'Phylogenetic trees & gene families',
  56. 'page callback' => 'tripal_phylogeny_admin_phylotrees_listing',
  57. 'access arguments' => array('administer tripal phylotree'),
  58. 'type' => MENU_NORMAL_ITEM,
  59. );
  60. // help menu
  61. $items['admin/tripal/extension/tripal_phylogeny/help'] = array(
  62. 'title' => 'Help',
  63. 'description' => 'Basic Description of Tripal Phylotree Module Functionality',
  64. 'page callback' => 'theme',
  65. 'page arguments' => array('tripal_phylogeny_help'),
  66. 'access arguments' => array('administer tripal phylotree'),
  67. 'type' => MENU_LOCAL_TASK,
  68. 'weight' => 10
  69. );
  70. // configuration menu item
  71. $items['admin/tripal/extension/tripal_phylogeny/configuration'] = array(
  72. 'title' => 'Settings',
  73. 'description' => 'Configure the Tripal Phylotree module',
  74. 'page callback' => 'drupal_get_form',
  75. 'page arguments' => array('tripal_phylogeny_admin'),
  76. 'access arguments' => array('administer tripal phylotree'),
  77. 'type' => MENU_LOCAL_TASK,
  78. 'weight' => 1
  79. );
  80. $items['admin/tripal/extension/tripal_phylogeny/plots'] = array(
  81. 'title' => 'Plot Defaults',
  82. 'description' => 'Set defaults for the trees, dendrograms and bubble plot',
  83. 'page callback' => 'drupal_get_form',
  84. 'page arguments' => array('tripal_phylogeny_default_plots_form'),
  85. 'access arguments' => array('administer tripal phylotree'),
  86. 'type' => MENU_LOCAL_TASK,
  87. 'weight' => 2
  88. );
  89. // sync menu item (will be rendered as a tab by tripal)
  90. $items['admin/tripal/extension/tripal_phylogeny/sync'] = array(
  91. 'title' => ' Sync',
  92. 'description' => 'Create pages on this site for phylotrees stored in Chado',
  93. 'page callback' => 'drupal_get_form',
  94. 'page arguments' => array('chado_node_sync_form', 'tripal_phylogeny', 'chado_phylotree'),
  95. 'access arguments' => array('administer tripal phylotree'),
  96. 'type' => MENU_LOCAL_TASK,
  97. 'weight' => 3
  98. );
  99. // Enable admin view
  100. $items['admin/tripal/extension/tripal_phylogeny/views/phylotree/enable'] = array(
  101. 'title' => 'Enable Phylotree Administrative View',
  102. 'page callback' => 'tripal_enable_view',
  103. 'page arguments' => array('tripal_phylogeny_admin_phylotree', 'admin/tripal/chado/tripal_phylogeny'),
  104. 'access arguments' => array('administer tripal phylotree'),
  105. 'type' => MENU_CALLBACK,
  106. );
  107. $items['chado_phylotree/%'] = array(
  108. 'page callback' => 'phylotree_by_name',
  109. 'page arguments' => array(1),
  110. 'access callback' => TRUE // allow all anonymous http clients
  111. );
  112. // create a route for viewing json of all phylonodes having this phylotree_id
  113. $items['chado_phylotree/%/json'] = array(
  114. 'page callback' => 'phylotree_json',
  115. 'page arguments' => array(1),
  116. 'access callback' => TRUE // allow all anonymous http clients
  117. );
  118. // Data Loaders
  119. $items['admin/tripal/loaders/newic_tree_loader'] = array(
  120. 'title' => 'Phylogenetic Trees',
  121. 'description' => 'Loads phylogenetic trees. (Redirects to create a phylogenetic tree content type)',
  122. 'page callback' => 'drupal_goto',
  123. 'page arguments' => array('node/add/chado-phylotree'),
  124. 'access arguments' => array('administer tripal phylotree'),
  125. 'type' => MENU_NORMAL_ITEM,
  126. );
  127. $items['admin/tripal/loaders/taxonomy_loader'] = array(
  128. 'title' => 'NCBI Taxonomy Loader',
  129. 'description' => 'Loads taxonomic details about installed organisms.',
  130. 'page callback' => 'drupal_get_form',
  131. 'page arguments' => array('tripal_phylogeny_taxonomy_load_form'),
  132. 'access arguments' => array('administer tripal phylotree'),
  133. 'file' => '/includes/tripal_phylogeny.taxonomy_import.inc',
  134. 'type' => MENU_NORMAL_ITEM,
  135. );
  136. return $items;
  137. }
  138. /**
  139. * Implements hook_search_biological_data_views().
  140. *
  141. * Adds the described views to the "Search Data" Page created by Tripal Views
  142. */
  143. function tripal_phylogeny_search_biological_data_views() {
  144. return array(
  145. 'tripal_phylogeny_user_phylotree' => array(
  146. 'machine_name' => 'tripal_phylogeny_user_phylotree',
  147. 'human_name' => 'Phylogenetic Trees',
  148. 'description' => 'Gene trees, species trees, etc.',
  149. 'link' => 'chado/phylotree'
  150. ),
  151. );
  152. }
  153. /**
  154. * Implements hook_views_api().
  155. *
  156. * Essentially this hook tells drupal that there is views support for
  157. * for this module which then includes tripal_db.views.inc where all the
  158. * views integration code is
  159. *
  160. * @ingroup tripal_phylogeny
  161. */
  162. function tripal_phylogeny_views_api() {
  163. return array(
  164. 'api' => 3.0,
  165. );
  166. }
  167. /**
  168. * Implements hook_theme().
  169. *
  170. * We need to let drupal know about our theme functions and their arguments.
  171. * We create theme functions to allow users of the module to customize the
  172. * look and feel of the output generated in this module
  173. *
  174. * @ingroup tripal_phylogeny
  175. */
  176. function tripal_phylogeny_theme($existing, $type, $theme, $path) {
  177. $core_path = drupal_get_path('module', 'tripal_core');
  178. $items = array(
  179. // built-in theme
  180. 'node__chado_phylotree' => array(
  181. 'template' => 'node--chado-generic',
  182. 'render element' => 'node',
  183. 'base hook' => 'node',
  184. 'path' => "$core_path/theme/templates",
  185. ),
  186. // base template for this page (default tab) includes the phylogram
  187. 'tripal_phylogeny_base' => array(
  188. 'variables' => array('node' => NULL),
  189. 'template' => 'tripal_phylogeny_base',
  190. 'path' => "$path/theme/templates",
  191. ),
  192. // Template for the phylogram.
  193. 'tripal_phylogeny_phylogram' => array(
  194. 'variables' => array('node' => NULL),
  195. 'template' => 'tripal_phylogeny_phylogram',
  196. 'path' => "$path/theme/templates",
  197. ),
  198. // Template for the taxonomic tree.
  199. 'tripal_phylogeny_taxonomic_tree' => array(
  200. 'variables' => array('node' => NULL),
  201. 'template' => 'tripal_phylogeny_taxonomic_tree',
  202. 'path' => "$path/theme/templates",
  203. ),
  204. // partial for organisms block
  205. 'tripal_phylogeny_organisms' => array(
  206. 'variables' => array('node' => NULL),
  207. 'template' => 'tripal_phylogeny_organisms',
  208. 'path' => "$path/theme/templates",
  209. ),
  210. // partial for phylotree radial block
  211. 'tripal_phylogeny_radial' => array(
  212. 'variables' => array('node' => NULL),
  213. 'template' => 'tripal_phylogeny_radial',
  214. 'path' => "$path/theme/templates",
  215. ),
  216. // partial for cross references block
  217. 'tripal_phylogeny_references' => array(
  218. 'variables' => array('node' => NULL),
  219. 'template' => 'tripal_phylogeny_references',
  220. 'path' => "$path/theme/templates",
  221. ),
  222. // partial for cross references block
  223. 'tripal_phylogeny_analysis' => array(
  224. 'variables' => array('node' => NULL),
  225. 'template' => 'tripal_phylogeny_analysis',
  226. 'path' => "$path/theme/templates",
  227. ),
  228. // partial for teaser view
  229. 'tripal_phylogeny_teaser' => array(
  230. 'variables' => array('node' => NULL),
  231. 'template' => 'tripal_phylogeny_teaser',
  232. 'path' => "$path/theme/templates",
  233. ),
  234. // FORM THEMES
  235. // Theme function for the project table in admin projects form
  236. 'tripal_phylogeny_admin_org_color_tables' => array(
  237. 'render element' => 'element',
  238. )
  239. );
  240. return $items;
  241. }
  242. /**
  243. * Implements hook_help().
  244. * Adds a help page to the module list
  245. *
  246. * @ingroup tripal_phylogeny
  247. */
  248. function tripal_phylogeny_help ($path, $arg) {
  249. if ($path == 'admin/help#tripal_phylogeny') {
  250. return theme('tripal_phylogeny_help', array());
  251. }
  252. }
  253. // hack to suppress the 'Submitted by...' info drupal adds to nodes
  254. $variables['display_submitted'] = FALSE;