-
Notifications
You must be signed in to change notification settings - Fork 0
/
tripal_network.module
322 lines (293 loc) · 11.4 KB
/
tripal_network.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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
<?php
require_once "api/tripal_network.api.inc";
require_once "includes/tripal_network.schema.inc";
require_once "includes/tripal_network.fields.inc";
require_once "includes/tripal_network.viewer.inc";
require_once "includes/tripal_network.neighborhood_viewer.inc";
require_once "includes/tripal_network.entity.inc";
require_once "includes/TripalNetwork.inc";
require_once "includes/TripalNetworkEdge.inc";
require_once "includes/TripalNetworkPlot/TripalNetworkPlot.inc";
require_once "includes/TripalNetworkPlot/TripalNetworkPlotDegreeDist.inc";
require_once "includes/TripalNetworkPlot/TripalNetworkPlot3DExpression.inc";
require_once "includes/TripalNetworkPlot/TripalNetworkPlotNetwork.inc";
require_once "includes/TripalNetworkPlotEngine/TripalNetworkPlotEngine.inc";
require_once "includes/TripalNetworkPlotEngine/TripalNetworkPlotlyEngine.inc";
require_once "includes/TripalNetworkPlotly/TripalNetworkPlotlyDegreeDist.inc";
require_once "includes/TripalNetworkPlotly/TripalNetworkPlotly3DExpression.inc";
require_once "includes/TripalNetworkPlotly/TripalNetworkPlotlyNetwork.inc";
require_once "includes/TripalNetworkLayout/TripalNetworkLayout.inc";
require_once "includes/TripalNetworkLayout/TripalNetworkLayoutFA2.inc";
require_once "includes/TripalNetworkLayout/TripalNetworkLayoutRandom.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
*/
function tripal_network_permission() {
return [];
}
/**
* Implements hook_menu()
*
* Specifies menu items and URLs used by this module.
*
* @ingroup tripal_network
*/
function tripal_network_menu() {
$items = [];
/*
* Module Search Form
*/
$term = tripal_load_term_entity(['vocabulary' => 'NCIT', 'accession' => 'C61377']);
$bundle = tripal_load_bundle_entity(['term_id' => $term->id]);
$items['networks/viewer'] = [
'page callback' => 'tripal_network_viewer_page',
'page arguments' => [],
'access arguments' => ['view ' . $bundle->name],
'file' => '/includes/tripal_network.viewer.inc',
'file path' => drupal_get_path('module','tripal_network'),
'type' => MENU_CALLBACK,
];
$items['networks/viewer/retrieve'] = [
'page callback' => 'tripal_network_viewer_ajax_retrieve',
'page arguments' => [],
'access arguments' => ['view ' . $bundle->name],
'file' => '/includes/tripal_network.viewer.inc',
'file path' => drupal_get_path('module','tripal_network'),
'type' => MENU_CALLBACK,
];
$items['networks/viewer/init'] = [
'page callback' => 'tripal_network_viewer_ajax_init',
'page arguments' => [],
'access arguments' => ['view ' . $bundle->name],
'file' => '/includes/tripal_network.viewer.inc',
'file path' => drupal_get_path('module','tripal_network'),
'type' => MENU_CALLBACK,
];
$items['networks/viewer/update/layers'] = [
'page callback' => 'tripal_network_viewer_ajax_get_layers_form',
'page arguments' => [],
'access arguments' => ['view ' . $bundle->name],
'file' => '/includes/tripal_network.viewer.inc',
'file path' => drupal_get_path('module','tripal_network'),
'type' => MENU_CALLBACK,
];
$items['networks/viewer/update/filter'] = [
'page callback' => 'tripal_network_viewer_ajax_get_filter_form',
'page arguments' => [],
'access arguments' => ['view ' . $bundle->name],
'file' => '/includes/tripal_network.viewer.inc',
'file path' => drupal_get_path('module','tripal_network'),
'type' => MENU_CALLBACK,
];
$items['networks/viewer/update/node-neighbors'] = [
'page callback' => 'tripal_network_viewer_ajax_get_node_neighbors',
'page arguments' => [],
'access arguments' => ['view ' . $bundle->name],
'file' => '/includes/tripal_network.viewer.inc',
'file path' => drupal_get_path('module','tripal_network'),
'type' => MENU_CALLBACK,
];
$items['networks/viewer/update/nodedata'] = [
'page callback' => 'tripal_network_viewer_ajax_get_node_data_form',
'page arguments' => [],
'access arguments' => ['view ' . $bundle->name],
'file' => '/includes/tripal_network.viewer.inc',
'file path' => drupal_get_path('module','tripal_network'),
'type' => MENU_CALLBACK,
];
$items['networks/viewer/update/edgedata'] = [
'page callback' => 'tripal_network_viewer_ajax_get_edge_data_form',
'page arguments' => [],
'access arguments' => ['view ' . $bundle->name],
'file' => '/includes/tripal_network.viewer.inc',
'file path' => drupal_get_path('module','tripal_network'),
'type' => MENU_CALLBACK,
];
$items['networks/viewer/update/analysis'] = [
'page callback' => 'tripal_network_viewer_ajax_get_analysis_form',
'page arguments' => [],
'access arguments' => ['view ' . $bundle->name],
'file' => '/includes/tripal_network.viewer.inc',
'file path' => drupal_get_path('module','tripal_network'),
'type' => MENU_CALLBACK,
];
$items['networks/viewer/details/node'] = [
'page callback' => 'tripal_network_viewer_ajax_get_node_details',
'page arguments' => [],
'access arguments' => ['view ' . $bundle->name],
'file' => '/includes/tripal_network.viewer.inc',
'file path' => drupal_get_path('module','tripal_network'),
'type' => MENU_CALLBACK,
];
$items['networks/viewer/select/nodes'] = [
'page callback' => 'tripal_network_viewer_ajax_set_node_selection',
'page arguments' => [],
'access arguments' => ['view ' . $bundle->name],
'file' => '/includes/tripal_network.viewer.inc',
'file path' => drupal_get_path('module','tripal_network'),
'type' => MENU_CALLBACK,
];
$items['networks/viewer/details/edge'] = [
'page callback' => 'tripal_network_viewer_ajax_get_edge_details',
'page arguments' => [],
'access arguments' => ['view ' . $bundle->name],
'file' => '/includes/tripal_network.viewer.inc',
'file path' => drupal_get_path('module','tripal_network'),
'type' => MENU_CALLBACK,
];
$items['networks/viewer/details/edge-expression'] = [
'page callback' => 'tripal_network_viewer_ajax_get_edge_expression',
'page arguments' => [],
'access arguments' => ['view ' . $bundle->name],
'file' => '/includes/tripal_network.viewer.inc',
'file path' => drupal_get_path('module','tripal_network'),
'type' => MENU_CALLBACK,
];
$items['networks/viewer/neighborhood/retrieve'] = [
'page callback' => 'tripal_network_neighborhood_viewer_ajax_retrieve',
'page arguments' => [],
'access arguments' => ['view ' . $bundle->name],
'file' => '/includes/tripal_network.viewer.inc',
'file path' => drupal_get_path('module','tripal_network'),
'type' => MENU_CALLBACK,
];
// All extension modules should have an administrative menu item
// with the path set to 'admin/tripal/extension/[module name]'.
$items['admin/tripal/extension/network'] = [
'title' => 'Biological Networks',
'description' => 'Manage biological networks made available by this site.',
'page callback' => 'tripal_network_admin_home',
'access arguments' => ['administer tripal_network'],
'file' => '/includes/tripal_network.admin.inc',
'file path' => drupal_get_path('module','tripal_network'),
'type' => MENU_NORMAL_ITEM,
];
$items['admin/tripal/extension/network/overview'] = [
'title' => 'Overview',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 0,
];
$items['admin/tripal/extension/network/help'] = [
'title' => 'Help',
'description' => 'Documentation for the Tripal Network module..',
'page callback' => 'tripal_network_admin_help',
'access arguments' => ['administer tripal_network'],
'type' => MENU_LOCAL_TASK,
'file' => '/includes/tripal_network.graphML_loader.inc',
'file path' => drupal_get_path('module','tripal_network'),
'weight' => 2,
];
return $items;
}
/**
* Implements hook_views_api()
*
* This hook tells drupal that there is views support for
* for this module which then automatically includes the tripal_db.views.inc
* where all the views integration code is found.
*
* @ingroup tripal_network
*/
function tripal_network_views_api() {
return array(
'api' => 3.0,
);
}
/**
* Implements hook_theme()
*
* @ingroup tripal_network
*/
function tripal_network_theme($existing, $type, $theme, $path) {
$items = array(
// HTML AND PAGE THEMES
'html__networks__viewer' => array(
'template' => 'html--networks--viewer',
'render element' => 'html',
'base hook' => 'html',
'path' => drupal_get_path('module', 'tripal_network') . "/theme/templates",
),
'page__networks__viewer' => array(
'template' => 'page--networks--viewer',
'render element' => 'page',
'base hook' => 'page',
'path' => drupal_get_path('module', 'tripal_network') . "/theme/templates",
),
'tripal_network_viewer' => array(
'template' => 'tripal_network_viewer',
'variables' => [],
'path' => drupal_get_path('module', 'tripal_network') . "/theme/templates",
),
'tripal_network_viewer_property' => array(
'render element' => 'element',
'path' => drupal_get_path('module', 'tripal_network') . "/includes/tripal_network.viewer.inc",
),
'tripal_network_viewer_filter_form_list' => array(
'function' => 'theme_tripal_network_viewer_filter_form_list',
'render element' => 'element',
'file' => 'includes/tripal_network.viewer.inc',
),
);
return $items;
}
/**
* Implements hook_help()
*
* Adds a help $formpage to the module list
*/
function tripal_network_help ($path, $arg) {
// EXPLANATION: in the tripal_network_menu() function above we created
// a menu item for the help documentation. The menu item specified
// a function that should be called when the menu item is clicked. This
// is that function. But, rather than place HTML code in this function
// we want to have our help documentation in a template galaxy. We
// specified in the tripal_network.theme() function that we have a template
// galaxy so now we want to use get the contents of that template galaxy and
// return it.
if ($path == 'admin/help#tripal_network') {
return theme('tripal_network_help', []);
}
}
/**
* Impelmentation of hook_ajax_render_alter().
*
* This function allows us to add new command to the ajax callback when
* it returns. This way we can call Javascript functions directly from our
* PHP code.
*
* @param $commands
*/
function tripal_network_ajax_render_alter(&$commands) {
// always update the sidebar on every ajax return.
if(array_key_exists('tripal-network-ajax-commands', $_SESSION)) {
foreach ($_SESSION['tripal-network-ajax-commands'] as $command) {
$commands[] = $command;
}
unset($_SESSION['tripal-network-ajax-commands']);
}
}
/**
* A helper function for adding new command to ajax calls.
*
* When we want to call a function in JavaScript we use this function to
* add new "commands". These commands are added to the ajax response by
* the tripal_network_ajax_render_alter() function before the AJAX is
* returned. This function stores all of the commands that are requested
* until that AJAX call is returned.
*
* @param $commands
* A single Drupal compatible ajax command created by calling
* ajax_command_invoke().
*/
function tripal_network_add_ajax_command($command) {
if(!array_key_exists('tripal-network-ajax-commands', $_SESSION)) {
$_SESSION['tripal-network-ajax-commands'] = [];
}
$_SESSION['tripal-network-ajax-commands'][] = $command;
}