-
Notifications
You must be signed in to change notification settings - Fork 4
/
tripald3.module
executable file
·166 lines (144 loc) · 4.56 KB
/
tripald3.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
<?php
/** @pedigree Comment out pedigree's until re-vamped. */
require_once('includes/stock_pedigree.inc');
require_once('includes/tripalD3.api.inc');
require_once('includes/color_scheme.inc');
/**
* Implements hook_libraries_info()
*/
function tripald3_libraries_info() {
$libraries = array();
$libraries['d3'] = array(
'name' => 'D3.js',
'vendor url' => 'http://d3js.org/',
'download url' => 'https://github.com/mbostock/d3',
'version arguments' => array(
'file' => 'd3.js',
'pattern' => '/\s*version: "(\d+\.\d+\.\d+)"\s*/',
),
'files' => array(
'js' => array(
'd3.min.js',
),
),
);
return $libraries;
}
/**
* Implements hook_menu().
*/
function tripald3_menu() {
$items = array();
/** @pedigree Comment out pedigree's until re-vamped. */
$items['ajax/tripal/d3-json/relationships/%/%'] = array(
'title' => 'JS Graph: Tree',
'page callback' => 'tripald3_get_relationship_json',
'page arguments' => array(4,5),
'access arguments' => array('view tripald3 json'),
'type' => MENU_CALLBACK
);
$items['admin/tripal/extension/tripald3'] = array(
'title' => 'Tripal D3 Diagrams',
'description' => 'Configuration for D3.js integration.',
'page callback' => 'drupal_get_form',
'page arguments' => array('tripald3_common_settings_form'),
'access arguments' => array('administer tripal'),
'file' => 'includes/settings_forms.inc',
);
$items['admin/tripal/extension/tripald3/general'] = array(
'title' => 'General',
'page callback' => 'drupal_get_form',
'page arguments' => array('tripald3_common_settings_form'),
'access arguments' => array('administer tripal'),
'file' => 'includes/settings_forms.inc',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 0,
);
$items['admin/tripal/extension/tripald3/demo'] = array(
'title' => 'Demo',
'page callback' => 'theme',
'page arguments' => array('tripald3_demo_page'),
'access arguments' => array('administer tripal'),
'type' => MENU_LOCAL_TASK,
'weight' => 1,
);
$items['admin/tripal/extension/tripald3/test'] = array(
'title' => 'Test',
'page callback' => 'theme',
'page arguments' => array('tripald3_test_page'),
'access arguments' => array('administer tripal'),
'type' => MENU_LOCAL_TASK,
'weight' => 1,
);
/** @pedigree Comment out pedigree's until re-vamped. */
$items['admin/tripal/extension/tripald3/stock_pedigree'] = array(
'title' => 'Stock Pedigree',
'page callback' => 'drupal_get_form',
'page arguments' => array('tripald3_stock_pedigree_settings_form'),
'access arguments' => array('administer tripal'),
'file' => 'includes/settings_forms.inc',
'type' => MENU_LOCAL_TASK
);
return $items;
}
/**
* Implements hook_theme().
*/
function tripald3_theme($existing, $type, $theme, $path) {
$items = array();
/** @pedigree Comment out pedigree's until re-vamped. */
$items['tripald3_stock_pedigree'] = array(
'template' => 'tripal_stock_pedigree',
'path' => $path.'/templates',
'variables' => array('node' => NULL),
);
$items['tripald3_demo_page'] = array(
'template' => 'tripald3_demo_page',
'path' => $path.'/templates',
);
$items['tripald3_test_page'] = array(
'template' => 'tripald3_test_page',
'path' => $path.'/templates',
);
return $items;
}
/**
* Implements hook_permission().
*/
function tripald3_permission() {
return array(
// @todo better permissions control.
'view tripald3 json' => array(
'title' => t('View Tripal D3 JSON'),
'description' => t('Required for anyone wanting to view a Tripal D3 diagram.'),
),
/** @pedigree Comment out pedigree's until re-vamped. */
'view tripald3 pedigree' => array(
'title' => t('View Tripal D3 Pedigree'),
'description' => t('Required to view the pedigree pane on stock pages.'),
),
);
}
/**
* Implements hook_node_view(). Acts on all content types.
* @pedigree
*/
function tripald3_node_view($node, $view_mode, $langcode) {
switch ($node->type) {
case 'chado_stock':
if ($view_mode == 'full') {
if(user_access('view tripald3 pedigree')) {
// Only add the pedigree if there is more than the root node.
if (!tripald3_is_node_leafless_tree($node->stock->stock_id)) {
$node->content['tripal_stock_pedigree'] = array(
'#theme' => 'tripald3_stock_pedigree',
'#node' => $node,
'#tripal_toc_id' => 'pedigree',
'#tripal_toc_title' => 'Pedigree'
);
}
}
}
break;
}
}