tripal_phylogeny.module 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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.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/chado/tripal_phylogeny'] = array(
  54. 'title' => 'Phylogeny and Taxonomy',
  55. 'description' => 'Phylogenetic and taxonomic trees.',
  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/chado/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/chado/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/chado/tripal_phylogeny/plots'] = array(
  81. 'title' => 'Plot Defaults',
  82. 'description' => 'Set defaults for the trees',
  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/chado/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/chado/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. // allow all anonymous http clients
  111. 'access callback' => TRUE
  112. );
  113. // create a route for viewing json of all phylonodes having this phylotree_id
  114. $items['chado_phylotree/%/json'] = array(
  115. 'page callback' => 'phylotree_json',
  116. 'page arguments' => array(1),
  117. // allow all anonymous http clients
  118. 'access callback' => TRUE
  119. );
  120. // Data Loaders
  121. $items['admin/tripal/loaders/newic_phylotree_loader'] = array(
  122. 'title' => 'Phylogenetic Trees (Newic format)',
  123. 'description' => 'Loads phylogenetic trees in Newic format. (Redirects to create a phylogenetic tree content type)',
  124. 'page callback' => 'drupal_goto',
  125. 'page arguments' => array('node/add/chado-phylotree'),
  126. 'access arguments' => array('administer tripal phylotree'),
  127. 'type' => MENU_NORMAL_ITEM,
  128. );
  129. $items['admin/tripal/loaders/ncbi_taxonomy_loader'] = array(
  130. 'title' => 'NCBI Taxonomy Loader',
  131. 'description' => 'Loads taxonomic details about installed organisms.',
  132. 'page callback' => 'drupal_get_form',
  133. 'page arguments' => array('tripal_phylogeny_taxonomy_load_form'),
  134. 'access arguments' => array('administer tripal phylotree'),
  135. 'file' => '/includes/tripal_phylogeny.taxonomy.inc',
  136. 'type' => MENU_NORMAL_ITEM,
  137. );
  138. $items['taxonomy_view'] = array(
  139. 'title' => 'Site Taxonomy',
  140. 'description' => 'A taxonomy viewer for the species on this site.',
  141. 'page callback' => 'drupal_get_form',
  142. 'page arguments' => array('tripal_phylogeny_taxonomy_viewer'),
  143. 'access arguments' => array('access taxonomy content'),
  144. 'file' => '/includes/tripal_phylogeny.taxonomy.inc',
  145. 'type' => MENU_NORMAL_ITEM,
  146. );
  147. return $items;
  148. }
  149. /**
  150. * Implements hook_search_biological_data_views().
  151. *
  152. * Adds the described views to the "Search Data" Page created by Tripal Views
  153. */
  154. function tripal_phylogeny_search_biological_data_views() {
  155. return array(
  156. 'tripal_phylogeny_user_phylotree' => array(
  157. 'machine_name' => 'tripal_phylogeny_user_phylotree',
  158. 'human_name' => 'Phylogenetic Trees',
  159. 'description' => 'Gene trees, species trees, etc.',
  160. 'link' => 'chado/phylotree'
  161. ),
  162. );
  163. }
  164. /**
  165. * Implements hook_views_api().
  166. *
  167. * Essentially this hook tells drupal that there is views support for
  168. * for this module which then includes tripal_db.views.inc where all the
  169. * views integration code is
  170. *
  171. * @ingroup tripal_phylogeny
  172. */
  173. function tripal_phylogeny_views_api() {
  174. return array(
  175. 'api' => 3.0,
  176. );
  177. }
  178. /**
  179. * Implements hook_theme().
  180. *
  181. * We need to let drupal know about our theme functions and their arguments.
  182. * We create theme functions to allow users of the module to customize the
  183. * look and feel of the output generated in this module
  184. *
  185. * @ingroup tripal_phylogeny
  186. */
  187. function tripal_phylogeny_theme($existing, $type, $theme, $path) {
  188. $core_path = drupal_get_path('module', 'tripal_core');
  189. $items = array(
  190. // built-in theme
  191. 'node__chado_phylotree' => array(
  192. 'template' => 'node--chado-generic',
  193. 'render element' => 'node',
  194. 'base hook' => 'node',
  195. 'path' => "$core_path/theme/templates",
  196. ),
  197. // base template for this page (default tab) includes the phylogram
  198. 'tripal_phylogeny_base' => array(
  199. 'variables' => array('node' => NULL),
  200. 'template' => 'tripal_phylogeny_base',
  201. 'path' => "$path/theme/templates",
  202. ),
  203. // Template for the phylogram.
  204. 'tripal_phylogeny_phylogram' => array(
  205. 'variables' => array('node' => NULL),
  206. 'template' => 'tripal_phylogeny_phylogram',
  207. 'path' => "$path/theme/templates",
  208. ),
  209. // Template for the taxonomic tree.
  210. 'tripal_phylogeny_taxonomic_tree' => array(
  211. 'variables' => array('node' => NULL),
  212. 'template' => 'tripal_phylogeny_taxonomic_tree',
  213. 'path' => "$path/theme/templates",
  214. ),
  215. // partial for organisms block
  216. 'tripal_phylogeny_organisms' => array(
  217. 'variables' => array('node' => NULL),
  218. 'template' => 'tripal_phylogeny_organisms',
  219. 'path' => "$path/theme/templates",
  220. ),
  221. // partial for cross references block
  222. 'tripal_phylogeny_references' => array(
  223. 'variables' => array('node' => NULL),
  224. 'template' => 'tripal_phylogeny_references',
  225. 'path' => "$path/theme/templates",
  226. ),
  227. // partial for cross references block
  228. 'tripal_phylogeny_analysis' => array(
  229. 'variables' => array('node' => NULL),
  230. 'template' => 'tripal_phylogeny_analysis',
  231. 'path' => "$path/theme/templates",
  232. ),
  233. // partial for teaser view
  234. 'tripal_phylogeny_teaser' => array(
  235. 'variables' => array('node' => NULL),
  236. 'template' => 'tripal_phylogeny_teaser',
  237. 'path' => "$path/theme/templates",
  238. ),
  239. // FORM THEMES
  240. // Theme function for the project table in admin projects form
  241. 'tripal_phylogeny_admin_org_color_tables' => array(
  242. 'render element' => 'element',
  243. )
  244. );
  245. return $items;
  246. }
  247. /**
  248. * Implements hook_help().
  249. * Adds a help page to the module list
  250. *
  251. * @ingroup tripal_phylogeny
  252. */
  253. function tripal_phylogeny_help ($path, $arg) {
  254. if ($path == 'admin/help#tripal_phylogeny') {
  255. return theme('tripal_phylogeny_help', array());
  256. }
  257. }
  258. // hack to suppress the 'Submitted by...' info drupal adds to nodes
  259. $variables['display_submitted'] = FALSE;