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