Newer
Older
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
<?php
/**
* Add body classes if certain regions have content.
*/
function bipaa_preprocess_html(&$variables) {
if (!empty($variables['page']['featured'])) {
$variables['classes_array'][] = 'featured';
}
if (!empty($variables['page']['triptych_first'])
|| !empty($variables['page']['triptych_middle'])
|| !empty($variables['page']['triptych_last'])) {
$variables['classes_array'][] = 'triptych';
}
if (!empty($variables['page']['footer_firstcolumn'])
|| !empty($variables['page']['footer_secondcolumn'])
|| !empty($variables['page']['footer_thirdcolumn'])
|| !empty($variables['page']['footer_fourthcolumn'])) {
$variables['classes_array'][] = 'footer-columns';
}
// Add conditional stylesheets for IE
drupal_add_css(path_to_theme() . '/css/ie.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 7', '!IE' => FALSE), 'preprocess' => FALSE));
drupal_add_css(path_to_theme() . '/css/ie6.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'IE 6', '!IE' => FALSE), 'preprocess' => FALSE));
}
/**
* Override or insert variables into the page template for HTML output.
*/
function bipaa_process_html(&$variables) {
// Hook into color.module.
if (module_exists('color')) {
_color_html_alter($variables);
}
}
/**
* Override or insert variables into the page template.
*/
function bipaa_process_page(&$variables) {
// Move user login to footer
//$variables['page']['footer'][] = $variables['page']['sidebar_first']['user_login'];
unset($variables['page']['sidebar_first']['user_login']);
unset($variables['page']['footer']['system_powered-by']);
// Hook into color.module.
if (module_exists('color')) {
_color_page_alter($variables);
}
// Always print the site name and slogan, but if they are toggled off, we'll
// just hide them visually.
$variables['hide_site_name'] = theme_get_setting('toggle_name') ? FALSE : TRUE;
$variables['hide_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TRUE;
if ($variables['hide_site_name']) {
// If toggle_name is FALSE, the site_name will be empty, so we rebuild it.
$variables['site_name'] = filter_xss_admin(variable_get('site_name', 'Drupal'));
}
if ($variables['hide_site_slogan']) {
// If toggle_site_slogan is FALSE, the site_slogan will be empty, so we rebuild it.
$variables['site_slogan'] = filter_xss_admin(variable_get('site_slogan', ''));
}
// Since the title and the shortcut link are both block level elements,
// positioning them next to each other is much simpler with a wrapper div.
if (!empty($variables['title_suffix']['add_or_remove_shortcut']) && $variables['title']) {
// Add a wrapper div using the title_prefix and title_suffix render elements.
$variables['title_prefix']['shortcut_wrapper'] = array(
'#markup' => '<div class="shortcut-wrapper clearfix">',
'#weight' => 100,
);
$variables['title_suffix']['shortcut_wrapper'] = array(
'#markup' => '</div>',
'#weight' => -99,
);
// Make sure the shortcut link is the first item in title_suffix.
$variables['title_suffix']['add_or_remove_shortcut']['#weight'] = -100;
}
if (array_key_exists('node', $variables) && $variables['node']->type == 'chado_feature' && ($variables['node']->feature->type_id->name == 'polypeptide' || $variables['node']->feature->type_id->name == 'mRNA')) {
$variables['title'] = substr(strstr($variables['title'], ', '), 2);
drupal_set_title($variables['title']);
}
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
}
/**
* Implements hook_preprocess_maintenance_page().
*/
function bipaa_preprocess_maintenance_page(&$variables) {
// By default, site_name is set to Drupal if no db connection is available
// or during site installation. Setting site_name to an empty string makes
// the site and update pages look cleaner.
// @see template_preprocess_maintenance_page
if (!$variables['db_is_active']) {
$variables['site_name'] = '';
}
drupal_add_css(drupal_get_path('theme', 'bipaa') . '/css/maintenance-page.css');
}
/**
* Override or insert variables into the maintenance page template.
*/
function bipaa_process_maintenance_page(&$variables) {
// Always print the site name and slogan, but if they are toggled off, we'll
// just hide them visually.
$variables['hide_site_name'] = theme_get_setting('toggle_name') ? FALSE : TRUE;
$variables['hide_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TRUE;
if ($variables['hide_site_name']) {
// If toggle_name is FALSE, the site_name will be empty, so we rebuild it.
$variables['site_name'] = filter_xss_admin(variable_get('site_name', 'Drupal'));
}
if ($variables['hide_site_slogan']) {
// If toggle_site_slogan is FALSE, the site_slogan will be empty, so we rebuild it.
$variables['site_slogan'] = filter_xss_admin(variable_get('site_slogan', ''));
}
}
/**
* Override or insert variables into the node template.
*/
function bipaa_preprocess_node(&$variables) {
if ($variables['view_mode'] == 'full' && node_is_page($variables['node'])) {
$variables['classes_array'][] = 'node-full';
}
unset($variables['content']['links']['node']['#links']['node-readmore']);
unset($variables['content']['links']['comment']['#links']);
}
/**
* Override or insert variables into the block template.
*/
function bipaa_preprocess_block(&$variables) {
// In the header region visually hide block titles.
if ($variables['block']->region == 'header') {
$variables['title_attributes_array']['class'][] = 'element-invisible';
}
if ($variables['block']->module == 'user' && $variables['block']->delta == 'login') {
$variables['block']->region = 'footer';
}
}
/**
* Implements theme_menu_tree().
*/
function bipaa_menu_tree($variables) {
return '<ul class="menu clearfix">' . $variables['tree'] . '</ul>';
}
/**
* Implements theme_field__field_type().
*/
function bipaa_field__taxonomy_term_reference($variables) {
$output = '';
// Render the label, if it's not hidden.
if (!$variables['label_hidden']) {
$output .= '<h3 class="field-label">' . $variables['label'] . ': </h3>';
}
// Render the items.
$output .= ($variables['element']['#label_display'] == 'inline') ? '<ul class="links inline">' : '<ul class="links">';
foreach ($variables['items'] as $delta => $item) {
$output .= '<li class="taxonomy-term-reference-' . $delta . '"' . $variables['item_attributes'][$delta] . '>' . drupal_render($item) . '</li>';
}
$output .= '</ul>';
// Render the top-level DIV.
$output = '<div class="' . $variables['classes'] . (!in_array('clearfix', $variables['classes_array']) ? ' clearfix' : '') . '"' . $variables['attributes'] .'>' . $output . '</div>';
return $output;
}
function bipaa_theme($existing, $type, $theme, $path) {
$items['website_search_box_form'] = array(
'template' => 'website_search_box_form',
'path' => drupal_get_path('theme', 'bipaa') . '/templates/form',
);
$items['tripal_orthology_links'] = array(
'variables' => array('node' => NULL),
'template' => 'tripal_orthology_links',
'path' => drupal_get_path('theme', 'bipaa') . '/templates',
'theme path' => '',
'type' => 'module',
'preprocess functions' => array(),
'process function' => '',
);
$items['tripal_aureme_links'] = array(
'variables' => array('node' => NULL),
'template' => 'tripal_aureme_links',
'path' => drupal_get_path('theme', 'bipaa') . '/templates',
'theme path' => '',
'type' => 'module',
'preprocess functions' => array(),
'process function' => '',
);
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
/**
* Override the theme registry.
*/
function bipaa_theme_registry_alter(&$theme_registry) {
$theme_registry['tripal_orthology_links'] = array(
'variables' => array('node' => NULL),
'template' => 'tripal_orthology_links',
'path' => drupal_get_path('theme', 'bipaa') . '/templates',
'theme path' => '',
'type' => 'module',
'preprocess functions' => array(),
'process function' => '',
);
$theme_registry['tripal_aureme_links'] = array(
'variables' => array('node' => NULL),
'template' => 'tripal_aureme_links',
'path' => drupal_get_path('theme', 'bipaa') . '/templates',
'theme path' => '',
'type' => 'module',
'preprocess functions' => array(),
'process function' => '',
);
}
function bipaa_node_view_alter(&$build) {
if ($build['#bundle'] == 'chado_feature') {
if ($build['#view_mode'] != 'full' || array_key_exists('tripal_orthology_links', $build)) {
return;
}
if (getenv('ENABLE_ORTHOLOGY_LINKS')) {
$build['tripal_orthology_links'] = array(
'#theme' => 'tripal_orthology_links',
'#node' => $build['#node'],
'#tripal_toc_id' => 'orthology',
'#tripal_toc_title' => 'Orthology',
);
}
if (array_key_exists('tripal_aureme_links', $build)) {
return;
}
if (getenv('ENABLE_AUREME_LINKS')) {
$build['tripal_aureme_links'] = array(
'#theme' => 'tripal_aureme_links',
'#node' => $build['#node'],
'#tripal_toc_id' => 'aureme',
'#tripal_toc_title' => 'Metabolic model',
);
}
}
}
function bipaa_module_implements_alter(&$implementations, $hook) {
if ($hook == "node_view_alter") {
$implementations = array('bipaa' => FALSE) + $implementations;
}
}
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
// Disable default favicon
function bipaa_html_head_alter(&$head_elements) {
foreach ($head_elements as $key => $element) {
if ( 0 === strpos($key, 'drupal_add_html_head_link:shortcut icon:')
&& !empty($element['#attributes']['href'])
&& 'shortcut icon' === $element['#attributes']['rel']) {
unset($head_elements[$key]);
}
}
}
// Disable registration
function bipaa_form_alter(&$form, &$form_state, $form_id) {
switch($form_id) {
case 'user_register_form':
$form['#access'] = FALSE;
break;
}
}
// By default, select only mRNA and polypeptide in feature listing
// Also, list analysis by default
function bipaa_views_default_views_alter(&$views) {
$sql = 'SELECT cvterm_id FROM {cvterm} WHERE name = :name1 or name = :name2';
$results = chado_query($sql, array(':name1' => 'mRNA', ':name2' => 'polypeptide'))->fetchAll();
foreach ($results as $res) {
$views['tripal_feature_user_feature']->display['default']->display_options['filters']['type_id']['value'][] = $res->cvterm_id;
}
$views['tripal_feature_user_feature']->display['default']->display_options['filters']['type_id']['expose']['select_multiple'] = TRUE;
$views['tripal_feature_user_feature']->display['default']->display_options['filters']['common_name']['expose']['select_multiple'] = TRUE;
$views['tripal_analysis_user_analyses']->display['default']->display_options['exposed_form']['type'] = 'basic';
}