Révision 32700c57
Ajouté par Assos Assos il y a environ 5 ans
drupal7/sites/all/modules/ldap/ldap_query/ldap_query.theme.inc | ||
---|---|---|
2 | 2 |
|
3 | 3 |
/** |
4 | 4 |
* @file |
5 |
* theming functions for ldap_query module |
|
6 |
* |
|
5 |
* Theming functions for ldap_query module. |
|
7 | 6 |
*/ |
8 | 7 |
|
9 | 8 |
/** |
... | ... | |
11 | 10 |
* |
12 | 11 |
* @param $variables |
13 | 12 |
* An associative array containing: |
14 |
* - ldap_query: an array of one or more ldap server configurations.
|
|
13 |
* - ldap_queries: an array of one or more ldap server configurations.
|
|
15 | 14 |
* - actions: true or false indicating include update, delete, etc. links |
16 | 15 |
* - type: 'table', 'list', etc for style to render |
17 | 16 |
* |
18 | 17 |
* @ingroup themeable |
19 | 18 |
*/ |
20 | 19 |
function theme_ldap_query_list($variables) { |
20 |
/** @var array $ldap_queries */ |
|
21 |
/** @var bool $actions */ |
|
22 |
/** @var string $type */ |
|
21 | 23 |
extract($variables); |
22 | 24 |
|
23 |
$table = array(
|
|
24 |
'header' => array(t('Name'), t('Base DN'), t('Filter'), t('Attributes'), t('Enabled')),
|
|
25 |
'attributes' => array('id' => 'ldap_queries', 'class' => 'data'),
|
|
26 |
'colgroups' => array(),
|
|
25 |
$table = [
|
|
26 |
'header' => [t('Name'), t('Base DN'), t('Filter'), t('Attributes'), t('Enabled')],
|
|
27 |
'attributes' => ['id' => 'ldap_queries', 'class' => 'data'],
|
|
28 |
'colgroups' => [],
|
|
27 | 29 |
'sticky' => FALSE, |
28 | 30 |
'empty' => '', |
29 | 31 |
'caption' => 'LDAP Queries', |
30 |
);
|
|
32 |
];
|
|
31 | 33 |
|
32 | 34 |
if ($actions) { |
33 | 35 |
$table['header'][] = "Operations"; |
34 | 36 |
} |
35 | 37 |
|
36 | 38 |
if (count($ldap_queries)) { |
37 |
foreach ($ldap_queries as $qid => $ldap_query ) {
|
|
38 |
$row = array(
|
|
39 |
foreach ($ldap_queries as $qid => $ldap_query) { |
|
40 |
$row = [
|
|
39 | 41 |
$ldap_query->name, |
40 | 42 |
$ldap_query->base_dn_str, |
41 | 43 |
$ldap_query->filter, |
42 | 44 |
$ldap_query->attributes_str, |
43 | 45 |
($ldap_query->status == 1) ? "Yes" : "No", |
44 |
);
|
|
46 |
];
|
|
45 | 47 |
if ($actions) { |
46 | 48 |
$admin = new LdapQueryAdmin($ldap_query->qid); |
47 | 49 |
$row[] = join(' | ', $admin->getActions()); |
... | ... | |
50 | 52 |
} |
51 | 53 |
} |
52 | 54 |
else { |
53 |
$table['rows'] = array();
|
|
55 |
$table['rows'] = [];
|
|
54 | 56 |
} |
55 | 57 |
$output = theme('table', $table); |
56 | 58 |
|
... | ... | |
67 | 69 |
* - type: 'table', 'list', etc for style to render |
68 | 70 |
* |
69 | 71 |
* @ingroup themeable |
72 |
* |
|
73 |
* @return string |
|
70 | 74 |
*/ |
71 |
|
|
72 | 75 |
function theme_ldap_query($variables) { |
73 |
|
|
74 |
extract($variables); // $ldap_query, $actions, $type (see above) |
|
76 |
/** @var array $ldap_query */ |
|
77 |
/** @var bool $actions */ |
|
78 |
/** @var string $type */ |
|
79 |
extract($variables); |
|
75 | 80 |
|
76 | 81 |
ldap_servers_module_load_include('php', 'ldap_query', 'LdapQuery.class'); |
77 |
$properties = array();
|
|
82 |
$properties = [];
|
|
78 | 83 |
foreach (LdapQuery::fields() as $field_id => $field) { |
79 | 84 |
$value = $ldap_query->{$field['property_name']}; |
80 | 85 |
if (is_scalar($value)) { |
81 |
$properties[] = $field_id . " = " . $value; // $value";
|
|
86 |
$properties[] = $field_id . " = " . $value; |
|
82 | 87 |
} |
83 | 88 |
} |
84 | 89 |
|
... | ... | |
88 | 93 |
} |
89 | 94 |
|
90 | 95 |
$output = theme_item_list( |
91 |
array(
|
|
96 |
[
|
|
92 | 97 |
'items' => $properties, |
93 | 98 |
'type' => 'ul', |
94 | 99 |
'title' => 'Query Properties', |
95 |
'attributes' => array()
|
|
96 |
)
|
|
100 |
'attributes' => [],
|
|
101 |
]
|
|
97 | 102 |
); |
98 | 103 |
|
99 | 104 |
return $output; |
100 | 105 |
} |
101 | 106 |
|
107 |
/** |
|
108 |
* @param $variables |
|
109 |
* |
|
110 |
* @return string |
|
111 |
*/ |
|
102 | 112 |
function theme_ldap_query_results($variables) { |
103 |
extract($variables); // $ldap_query, $results, $show_query |
|
113 |
// $ldap_query, $results, $show_query. |
|
114 |
/** @var array $ldap_query */ |
|
115 |
/** @var array $results */ |
|
116 |
/** @var mixed $show_query */ |
|
117 |
extract($variables); |
|
104 | 118 |
|
105 |
$query = theme('ldap_query', array('ldap_query' => $ldap_query));
|
|
106 |
$results_text = t('LDAP Query Results: count=%count', array('%count' => $results['count']));
|
|
119 |
$query = theme('ldap_query', ['ldap_query' => $ldap_query]);
|
|
120 |
$results_text = t('LDAP Query Results: count=%count', ['%count' => $results['count']]);
|
|
107 | 121 |
|
108 | 122 |
if (!$results['count']) { |
109 | 123 |
return $query . '<br/>' . $results_text; |
110 | 124 |
} |
111 | 125 |
|
112 |
$table = array(
|
|
113 |
'header' => array('DN'),
|
|
114 |
'attributes' => array('id' => 'ldap_query_resultset', 'class' => 'data'),
|
|
115 |
'colgroups' => array(),
|
|
126 |
$table = [
|
|
127 |
'header' => ['DN'],
|
|
128 |
'attributes' => ['id' => 'ldap_query_resultset', 'class' => 'data'],
|
|
129 |
'colgroups' => [],
|
|
116 | 130 |
'sticky' => FALSE, |
117 | 131 |
'empty' => '', |
118 | 132 |
'caption' => $results_text, |
119 |
);
|
|
133 |
];
|
|
120 | 134 |
unset($results['count']); |
121 | 135 |
|
122 |
$attributes_display = array(); |
|
123 |
if (isset($results[0]) && $results[0]) { // searching on all attributes |
|
136 |
$attributes_display = []; |
|
137 |
// Searching on all attributes. |
|
138 |
if (isset($results[0]) && $results[0]) { |
|
124 | 139 |
foreach ($results[0] as $k => $v) { |
125 | 140 |
if (is_numeric($k)) { |
126 | 141 |
$attributes_display[] = $v; |
... | ... | |
128 | 143 |
} |
129 | 144 |
} |
130 | 145 |
|
131 |
|
|
132 | 146 |
foreach ($attributes_display as $attr) { |
133 | 147 |
$table['header'][] = $attr; |
134 | 148 |
} |
135 | 149 |
|
136 | 150 |
foreach ($results as $i => $entry) { |
137 |
$row = array($entry['dn']);
|
|
151 |
$row = [$entry['dn']];
|
|
138 | 152 |
foreach ($attributes_display as $i => $attr_name) { |
139 |
$attr_name = ldap_server_massage_text($attr_name, 'attr_name', LDAP_SERVER_MASSAGE_QUERY_ARRAY); // drupal_strtolower($attr_name); |
|
153 |
// drupal_strtolower($attr_name); |
|
154 |
$attr_name = ldap_server_massage_text($attr_name, 'attr_name', LDAP_SERVER_MASSAGE_QUERY_ARRAY); |
|
140 | 155 |
if (!isset($entry[$attr_name])) { |
141 | 156 |
$row[] = 'no data'; |
142 | 157 |
} |
... | ... | |
147 | 162 |
else { |
148 | 163 |
$row[] = $entry[$attr_name]; |
149 | 164 |
} |
150 |
// unset($attr_data['count']); |
|
151 |
|
|
152 | 165 |
} |
153 | 166 |
unset($entry['count']); |
154 | 167 |
$table['rows'][] = $row; |
Formats disponibles : Unified diff
Weekly update of contrib modules