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