1
|
<?php
|
2
|
/**
|
3
|
function _init_vocabulary_tids(){
|
4
|
//FIXME: execute this during module installation
|
5
|
//FIXME: check for variable_get('expertsdb_vocabs') && tids are valid for system status
|
6
|
$expertsdb_vocabs = array(
|
7
|
'expertdb_taxomony' => 12,
|
8
|
'expertdb_georegions' => 13,
|
9
|
'expertdb_environment' => 10,
|
10
|
'expertdb_activity' => 6,
|
11
|
'expertdb_methods' => 5,
|
12
|
);
|
13
|
|
14
|
taxonomy_get_vocabulary()
|
15
|
|
16
|
variable_set('expertsdb_vocabs', $expertsdb_vocabs);
|
17
|
}
|
18
|
*/
|
19
|
|
20
|
|
21
|
|
22
|
/**
|
23
|
* Template for BLOCK of view 'taxonomic_interest_by_uid'
|
24
|
*
|
25
|
* @param unknown_type $view
|
26
|
* @param unknown_type $nodes
|
27
|
*/
|
28
|
function phptemplate_views_view_table_interest_by_uid($view, $nodes){
|
29
|
|
30
|
if(user_access('create expertsdb_interest content')){
|
31
|
$add_op_link = l(t('Add Interest'),'node/add/expertsdb_interest', null, drupal_get_destination().'&field_parent_person='._taxon_experts_get_profile_nid('expertsbd_person'));
|
32
|
}
|
33
|
|
34
|
$operations = array('view');
|
35
|
if(user_access('edit expertsdb_interest content')){
|
36
|
$operations[] = 'edit';
|
37
|
$operations[] = 'delete';
|
38
|
}
|
39
|
|
40
|
return theme('views_view_optable', $view, $nodes, 'table', $add_op_link, $operations);
|
41
|
}
|
42
|
|
43
|
//address_by_contact
|
44
|
function phptemplate_views_view_table_address_by_contact($view, $nodes){
|
45
|
|
46
|
if(user_access('create expertsdb_address content')){
|
47
|
$add_op_link = l(t('Add Address'),'node/add/expertsdb_address', null, drupal_get_destination().'&field_parent_contact='._taxon_experts_get_profile_nid('expertsdb_contact'));
|
48
|
}
|
49
|
|
50
|
$operations = array('view');
|
51
|
if(user_access('edit expertsdb_address content')){
|
52
|
$operations[] = 'edit';
|
53
|
$operations[] = 'delete';
|
54
|
}
|
55
|
|
56
|
$output .= theme('views_view_optable', $view, $nodes, 'table', $add_op_link, $operations);
|
57
|
|
58
|
return $output;
|
59
|
}
|
60
|
|
61
|
//projects_by_interest
|
62
|
function phptemplate_views_view_table_projects_by_interest($view, $nodes){
|
63
|
|
64
|
if(user_access('create expertsdb_project content')){
|
65
|
$add_op_link = l(t('Add Project'),'node/60/edit', null, drupal_get_destination().'#field_taxon_project');
|
66
|
}
|
67
|
|
68
|
$operations = array();
|
69
|
if(user_access('edit expertsdb_project')){
|
70
|
$operations[] = 'edit';
|
71
|
$operations[] = 'delete';
|
72
|
}
|
73
|
|
74
|
$output .= theme('views_view_optable', $view, $nodes, 'table', $add_op_link, $operations);
|
75
|
|
76
|
return $output;
|
77
|
}
|
78
|
|
79
|
|
80
|
/*
|
81
|
* Theme function for the nodeprofile display as teaser
|
82
|
*/
|
83
|
function phptemplate_nodeprofile_display_teaser(&$element) {
|
84
|
|
85
|
if ($node = nodeprofile_load($element['#content_type'], $element['#uid'])) {
|
86
|
|
87
|
switch($element['#content_type']){
|
88
|
|
89
|
case 'expertsbd_person':
|
90
|
|
91
|
$node = node_build_content($node, $teaser, $page);
|
92
|
|
93
|
$output = '<div class="person">';
|
94
|
//$output = '<h2 class="person">'.l($node->title, 'node/'.$node->nid).' <span class="operations">['. l('edit', 'node/'.$node->nid.'/edit', null, drupal_get_destination()).']</span></h2>';
|
95
|
//$output = '<h2 class="person">'.l($node->title, 'node/'.$node->nid).'</h2>';
|
96
|
$output .= '<h2 class="title">'.$node->title;
|
97
|
|
98
|
$aliases = array();
|
99
|
foreach($node->field_name_aliases as $entry){
|
100
|
$aliases[] = $entry['value'];
|
101
|
}
|
102
|
if( count($aliases) && !empty($aliases[0])){
|
103
|
$output .= ' <span class="name_aliases">('.join(', ', $aliases).')</span>';
|
104
|
}
|
105
|
$output .= '</h2>'; // end of h2.title
|
106
|
|
107
|
if( !(isset($node->field_lifespan['#access']) && $node->field_lifespan['#access']=== false) ){
|
108
|
$output .= $node->field_lifespan[0]['view'];
|
109
|
}
|
110
|
|
111
|
if($node->field_retirement_year[0]['value'] && !(isset($node->field_retirement_year['#access']) && $node->field_retirement_year['#access'] === false) ) {
|
112
|
$output .= '<div class="field_retirement_year">'.t('Foreseen Year of Retirement:').' '.$node->field_retirement_year[0]['view'].'</div>'.chr(10);
|
113
|
}
|
114
|
$output .= '</div><div class="clear-float"></div>';// end of div.person
|
115
|
|
116
|
$view = views_get_view('interest_by_uid');
|
117
|
$output .= '<h3 class="title">'.t('Taxonomic Interests').'</h3>';
|
118
|
$output .= '<dl><dd class="nodeprofile-nodeprofile-display"><div class="nodeprofile-display">';
|
119
|
$output .= views_build_view('block', $view, array($node->nid));
|
120
|
$output .= '</dl></dd></div>';
|
121
|
|
122
|
return $output;
|
123
|
|
124
|
case 'expertsdb_contact':
|
125
|
$view = views_get_view('address_by_contact');
|
126
|
// remove all tabs
|
127
|
unset($element['#tabs']);
|
128
|
// themed in theme_nodeprofile_display_box() file /modules/nodeprofile/nodeprofile.module
|
129
|
$content_addon = views_build_view('block', $view, array($node->nid) );
|
130
|
|
131
|
|
132
|
default:
|
133
|
// copied from theme_nodeprofile_display_teaser
|
134
|
if (node_access('view', $node)) {
|
135
|
$element['#node'] = $node;
|
136
|
return theme('nodeprofile_display_box', $element, node_view($node, TRUE, TRUE, FALSE).$content_addon);
|
137
|
}
|
138
|
//# end default
|
139
|
}//# end switch
|
140
|
}
|
141
|
}
|
142
|
|
143
|
|
144
|
/**
|
145
|
* Theme a user page
|
146
|
* @param $account the user object
|
147
|
* @param $fields a multidimensional array for the fields, in the form of array (
|
148
|
* 'category1' => array(item_array1, item_array2), 'category2' => array(item_array3,
|
149
|
* .. etc.). Item arrays are formatted as array(array('title' => 'item title',
|
150
|
* 'value' => 'item value', 'class' => 'class-name'), ... etc.). Module names are incorporated
|
151
|
* into the CSS class.
|
152
|
*/
|
153
|
function phptemplate_user_profile($account, $fields) {
|
154
|
$output = '<div class="profile">';
|
155
|
$output .= theme('user_picture', $account);
|
156
|
|
157
|
foreach ($fields as $category => $items) {
|
158
|
switch ($category){
|
159
|
case 'Person':
|
160
|
$output .= $items['expertsbd_person']['value'];
|
161
|
break;
|
162
|
default:
|
163
|
if (strlen($category) > 0) {
|
164
|
$output .= '<h3 class="title">'.$category .'</h3>';
|
165
|
}
|
166
|
$output .= '<dl>';
|
167
|
foreach ($items as $item) {
|
168
|
if (isset($item['title'])) {
|
169
|
$output .= '<dt class="'. $item['class'] .'">'. $item['title'] .'</dt>';
|
170
|
}
|
171
|
$output .= '<dd class="'. $item['class'] .'">'. $item['value'] .'</dd>';
|
172
|
}
|
173
|
$output .= '</dl>';
|
174
|
}
|
175
|
}
|
176
|
$output .= '</div>';
|
177
|
|
178
|
return $output;
|
179
|
}
|
180
|
|
181
|
|
182
|
function phptemplate_date_display_combination($field, $dates, $node = NULL) {
|
183
|
switch ($field['field_name']){
|
184
|
case 'field_lifespan': //field_retirement_year
|
185
|
return theme_date_lifespan($field, $dates, $node);
|
186
|
|
187
|
default:
|
188
|
return theme_date_display_combination($field, $dates, $node);
|
189
|
}
|
190
|
}
|
191
|
|
192
|
function phptemplate_views_handle_field_search_person_node_title($fields, $field, $data){
|
193
|
$field['handler'] = 'taxon_experts_handler_user_link';
|
194
|
return theme_views_handle_field($fields, $field, $data);
|
195
|
}
|
196
|
|
197
|
|
198
|
function phptemplate_views_filters($form) {
|
199
|
switch($form['#view_name']){
|
200
|
|
201
|
case 'search_interest':
|
202
|
|
203
|
static $filter_layout = array(
|
204
|
'term_node_12.tid' => // taxa
|
205
|
array(
|
206
|
'row' => 0,
|
207
|
'colspan' => false,
|
208
|
'label_position' => 'inline-first',
|
209
|
'operator_position' => 'inline-first',
|
210
|
),
|
211
|
'node.title' => // person name
|
212
|
array(
|
213
|
'row' => 0,
|
214
|
'colspan' => false,
|
215
|
'label_position' => 'inline-first',
|
216
|
'operator_position' => 'inline-first',
|
217
|
),
|
218
|
|
219
|
'term_node_13.tid' => // geography
|
220
|
array(
|
221
|
'row' => 1,
|
222
|
'colspan' => false,
|
223
|
'label_position' => 'inline-first',
|
224
|
'operator_position' => 'inline-first',
|
225
|
),
|
226
|
'term_node_10.tid' => // environment
|
227
|
array(
|
228
|
'row' => 1,
|
229
|
'colspan' => false,
|
230
|
'label_position' => 'inline-first',
|
231
|
'operator_position' => 'inline-first',
|
232
|
),
|
233
|
'term_node_6.tid' => // activity
|
234
|
array(
|
235
|
'row' => 2,
|
236
|
'colspan' => false,
|
237
|
'label_position' => 'inline-first',
|
238
|
'operator_position' => 'inline-first',
|
239
|
),
|
240
|
'term_node_5.tid' => // methodology
|
241
|
array(
|
242
|
'row' => 2,
|
243
|
'colspan' => false,
|
244
|
'label_position' => 'inline-first',
|
245
|
'operator_position' => 'inline-first',
|
246
|
),
|
247
|
);
|
248
|
|
249
|
$view = $form['view']['#value'];
|
250
|
foreach ($view->exposed_filter as $count => $expose) {
|
251
|
$layout = $filter_layout[$expose['field']];
|
252
|
$rows[$layout['row']][] = '<h3>'.$expose['label'].'</h3>'.drupal_render($form["op$count"]) . drupal_render($form["filter$count"]);
|
253
|
}
|
254
|
|
255
|
$rows[count($rows)][] = drupal_render($form['submit']);
|
256
|
$label[] = ''; // so the column count is the same.
|
257
|
return theme('table', null, $rows) . drupal_render($form);
|
258
|
break;
|
259
|
|
260
|
default:
|
261
|
return theme_views_filters($form);
|
262
|
}
|
263
|
}
|
264
|
|
265
|
function phptemplate_field(&$node, &$field, &$items, $teaser, $page) {
|
266
|
$field_empty = TRUE;
|
267
|
foreach ($items as $delta => $item) {
|
268
|
if (!empty($item['view']) || $item['view'] === "0") {
|
269
|
$field_empty = FALSE;
|
270
|
break;
|
271
|
}
|
272
|
}
|
273
|
|
274
|
$variables = array(
|
275
|
'node' => $node,
|
276
|
'field' => $field,
|
277
|
'field_type' => $field['type'],
|
278
|
'field_name' => $field['field_name'],
|
279
|
'field_type_css' => strtr($field['type'], '_', '-'),
|
280
|
'field_name_css' => strtr($field['field_name'], '_', '-'),
|
281
|
'label' => t($field['widget']['label']),
|
282
|
'label_display' => isset($field['display_settings']['label']['format']) ? $field['display_settings']['label']['format'] : 'above',
|
283
|
'field_empty' => $field_empty,
|
284
|
'items' => $items,
|
285
|
'teaser' => $teaser,
|
286
|
'page' => $page,
|
287
|
);
|
288
|
|
289
|
return _phptemplate_callback('field', $variables, array('field-'. $field['field_name']));
|
290
|
}
|
291
|
|
292
|
|
293
|
?>
|