1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* LDAP field handler
|
6 |
|
|
*
|
7 |
|
|
* Defines a new class field handler for a default ldap field
|
8 |
|
|
*/
|
9 |
|
|
class ldap_views_handler_field extends views_handler_field {
|
10 |
|
|
|
11 |
|
|
function render($values) {
|
12 |
|
|
return array_key_exists($this->field_alias, $values) ? check_plain($values[$this->field_alias]) : '';
|
13 |
|
|
}
|
14 |
|
|
|
15 |
|
|
function element_type($none_supported = FALSE, $default_empty = FALSE, $inline = FALSE) {
|
16 |
|
|
if (isset($this->definition['element type'])) {
|
17 |
|
|
return $this->definition['element type'];
|
18 |
|
|
}
|
19 |
|
|
|
20 |
|
|
return 'div';
|
21 |
|
|
}
|
22 |
|
|
|
23 |
|
|
function option_definition() {
|
24 |
|
|
$options = parent::option_definition();
|
25 |
|
|
$options['multivalue'] = array('default' => 'v-all');
|
26 |
|
|
$options['value_separator'] = array('default' => '');
|
27 |
|
|
$options['index_value'] = array('default' => 0);
|
28 |
|
|
return $options;
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
/*
|
32 |
|
|
* Add the field for the LDAP Attribute
|
33 |
|
|
*/
|
34 |
|
|
function options_form(&$form, &$form_state) {
|
35 |
|
|
parent::options_form($form, $form_state);
|
36 |
|
|
$form['multivalue'] = array(
|
37 |
|
|
'#type' => 'select', // it should be 'radios', but it makes #dependency not to work
|
38 |
|
|
'#title' => t('Values to show'),
|
39 |
|
|
'#description' => t('What to do whith multivalue attributes'),
|
40 |
|
|
'#options' => array(
|
41 |
|
|
'v-all' => t('All values'),
|
42 |
|
|
'v-index' => t('Show Nth value'),
|
43 |
|
|
'v-count' => t('Count values'),
|
44 |
|
|
),
|
45 |
|
|
'#default_value' => $this->options['multivalue'],
|
46 |
|
|
'#required' => TRUE,
|
47 |
|
|
);
|
48 |
|
|
$form['value_separator'] = array(
|
49 |
|
|
'#type' => 'textfield',
|
50 |
|
|
'#title' => t('Value separator'),
|
51 |
|
|
'#description' => t('Separator to use between values in multivalued attributes'),
|
52 |
|
|
'#default_value' => $this->options['value_separator'],
|
53 |
|
|
'#dependency' => array(
|
54 |
|
|
'edit-options-multivalue' => array('v-all'),
|
55 |
|
|
),
|
56 |
|
|
);
|
57 |
|
|
$form['index_value'] = array(
|
58 |
|
|
'#type' => 'textfield',
|
59 |
|
|
'#title' => t('Index'),
|
60 |
|
|
'#description' => t('Index of the value to show. Use negative numbers to index from last item (0=First, -1=Last)'),
|
61 |
|
|
'#default_value' => $this->options['index_value'],
|
62 |
|
|
'#dependency' => array(
|
63 |
|
|
'edit-options-multivalue' => array('v-index'),
|
64 |
|
|
),
|
65 |
|
|
);
|
66 |
|
|
}
|
67 |
|
|
} |