Révision 32700c57
Ajouté par Assos Assos il y a environ 5 ans
drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.theme.inc | ||
---|---|---|
2 | 2 |
|
3 | 3 |
/** |
4 | 4 |
* @file |
5 |
* theming functions for ldap_servers module |
|
6 |
* |
|
5 |
* Theming functions for ldap_servers module. |
|
7 | 6 |
*/ |
8 | 7 |
|
9 | 8 |
/** |
... | ... | |
16 | 15 |
* - type: 'table', 'list', etc for style to render |
17 | 16 |
* |
18 | 17 |
* @ingroup themeable |
18 |
* |
|
19 |
* @return string |
|
19 | 20 |
*/ |
20 | 21 |
function theme_ldap_servers_list($variables) { |
22 |
/** @var array $ldap_servers */ |
|
23 |
/** @var bool $actions */ |
|
24 |
/** @var string $type */ |
|
21 | 25 |
extract($variables); |
22 | 26 |
|
23 |
$table = array(
|
|
24 |
'header' => array(t('Name'), t('Type'), t('Enabled'), t('Server Address')),
|
|
25 |
'attributes' => array('id' => 'ldap_servers_servers', 'class' => 'data'),
|
|
26 |
'colgroups' => array(),
|
|
27 |
$table = [
|
|
28 |
'header' => [t('Name'), t('Type'), t('Enabled'), t('Server Address')],
|
|
29 |
'attributes' => ['id' => 'ldap_servers_servers', 'class' => 'data'],
|
|
30 |
'colgroups' => [],
|
|
27 | 31 |
'sticky' => FALSE, |
28 | 32 |
'empty' => '', |
29 | 33 |
'caption' => 'LDAP Server Configurations', |
30 |
);
|
|
34 |
];
|
|
31 | 35 |
|
32 | 36 |
if ($actions) { |
33 | 37 |
$table['header'][] = "Operations"; |
34 | 38 |
} |
35 | 39 |
if (count($ldap_servers)) { |
36 |
foreach ($ldap_servers as $sid => $ldap_server ) {
|
|
37 |
$row = array(
|
|
40 |
foreach ($ldap_servers as $sid => $ldap_server) { |
|
41 |
$row = [
|
|
38 | 42 |
$ldap_server->name, |
39 | 43 |
$ldap_server->ldap_type, |
40 | 44 |
($ldap_server->status == 1) ? "Yes" : "No", |
41 |
$ldap_server->address |
|
42 |
);
|
|
45 |
$ldap_server->address,
|
|
46 |
];
|
|
43 | 47 |
if ($actions) { |
44 | 48 |
$admin = new LdapServerAdmin($ldap_server->sid); |
45 | 49 |
$row[] = join(' | ', $admin->getLdapServerActions()); |
... | ... | |
48 | 52 |
} |
49 | 53 |
} |
50 | 54 |
else { |
51 |
$table['rows'] = array();
|
|
55 |
$table['rows'] = [];
|
|
52 | 56 |
} |
53 | 57 |
$output = theme('table', $table); |
54 | 58 |
|
... | ... | |
60 | 64 |
* |
61 | 65 |
* @param $variables |
62 | 66 |
* An associative array containing: |
63 |
* - ldap_servers_config: an array of one or more ldap server configurations.
|
|
67 |
* - ldap_server: an array of one or more ldap server configurations. |
|
64 | 68 |
* - actions: true or false indicating include update, delete, etc. links |
65 | 69 |
* - type: 'table', 'list', etc for style to render |
66 | 70 |
* |
67 | 71 |
* @ingroup themeable |
72 |
* |
|
73 |
* @return string |
|
68 | 74 |
*/ |
69 |
|
|
70 | 75 |
function theme_ldap_servers_server($variables) { |
71 |
extract($variables); // $ldap_server, $actions, $type (see above) |
|
76 |
/** @var array $ldap_server */ |
|
77 |
/** @var bool $actions */ |
|
78 |
/** @var string $type */ |
|
79 |
extract($variables); |
|
72 | 80 |
|
73 | 81 |
ldap_servers_module_load_include('php', 'ldap_servers', 'LdapServer.class'); |
74 |
$properties = array();
|
|
82 |
$properties = [];
|
|
75 | 83 |
foreach (LdapServer::field_to_properties_map() as $field_name => $property_name) { |
76 | 84 |
$properties[] = "$field_name = " . print_r($ldap_server->$property_name, TRUE); |
77 | 85 |
} |
... | ... | |
82 | 90 |
} |
83 | 91 |
|
84 | 92 |
$output = theme_item_list( |
85 |
array(
|
|
93 |
[
|
|
86 | 94 |
'items' => $properties, |
87 | 95 |
'type' => 'ul', |
88 | 96 |
'title' => 'Server Properties', |
89 |
'attributes' => array()
|
|
90 |
)
|
|
97 |
'attributes' => [],
|
|
98 |
]
|
|
91 | 99 |
); |
92 | 100 |
|
93 | 101 |
return $output; |
94 | 102 |
} |
95 | 103 |
|
104 |
/** |
|
105 |
* |
|
106 |
*/ |
|
96 | 107 |
function theme_ldap_server_token_table($variables) { |
97 |
$header = array(
|
|
98 |
array('data' => 'Token', 'sort' => 'asc'),
|
|
99 |
array('data' => 'Value'),
|
|
100 |
);
|
|
108 |
$header = [
|
|
109 |
['data' => 'Token', 'sort' => 'asc'],
|
|
110 |
['data' => 'Value'],
|
|
111 |
];
|
|
101 | 112 |
foreach ($variables['tokens'] as $token => $value) { |
102 |
$rows[] = array('data' => array($token, $value));
|
|
113 |
$rows[] = ['data' => [$token, $value]];
|
|
103 | 114 |
} |
104 | 115 |
$token_table = '<div class="content"><h2>' . t('Available Tokens') . '</h2>' . |
105 |
theme_table(array('colgroups' => NULL, 'caption' => 'tokens', 'header' => $header, 'rows' => $rows, 'sticky' => TRUE, 'attributes' => array(), 'empty' => 'No data')) .
|
|
116 |
theme_table(['colgroups' => NULL, 'caption' => 'tokens', 'header' => $header, 'rows' => $rows, 'sticky' => TRUE, 'attributes' => [], 'empty' => 'No data']) .
|
|
106 | 117 |
'</div>'; |
107 | 118 |
|
108 | 119 |
return $token_table; |
109 | 120 |
} |
110 | 121 |
|
122 |
/** |
|
123 |
* |
|
124 |
*/ |
|
111 | 125 |
function theme_ldap_server_ldap_entry_table($variables) { |
112 | 126 |
if (!isset($variables['entry']) || !is_array($variables['entry'])) { |
113 | 127 |
return '<p>' . t('No Entry Returned.') . t('</p>'); |
114 | 128 |
} |
115 | 129 |
|
116 |
$header = array('Attribute Name', 'Instance', 'Value', 'token');
|
|
117 |
$rows = array();
|
|
130 |
$header = ['Attribute Name', 'Instance', 'Value', 'token'];
|
|
131 |
$rows = [];
|
|
118 | 132 |
foreach ($variables['entry'] as $key => $value) { |
119 | 133 |
if (is_numeric($key) || $key == 'count') { |
120 | 134 |
} |
121 |
elseif (count($value) > 1) { |
|
122 |
$count = (int)$value['count']; |
|
135 |
elseif (is_array($value) && count($value) > 1) {
|
|
136 |
$count = (int) $value['count'];
|
|
123 | 137 |
foreach ($value as $i => $value2) { |
124 | 138 |
|
125 |
if ((string)$i == 'count') { |
|
139 |
if ((string) $i == 'count') {
|
|
126 | 140 |
continue; |
127 | 141 |
} |
128 | 142 |
elseif ($i == 0 && $count == 1) { |
... | ... | |
140 | 154 |
else { |
141 | 155 |
$token = ""; |
142 | 156 |
} |
143 |
$rows[] = array('data' => array($key, $i, ldap_servers_string_binary_check($value2), $token));
|
|
157 |
$rows[] = ['data' => [$key, $i, ldap_servers_string_binary_check($value2), $token]];
|
|
144 | 158 |
} |
145 | 159 |
} |
146 | 160 |
} |
147 |
$entry_table = '<div class="content"><h2>' . t('LDAP Entry for %username (dn: %dn)', array('%dn' => $variables['dn'], '%username' => $variables['username'])) . '</h2>' . theme('table', array('colgroups' => NULL, 'caption' => 'ldap entry array', 'header' => $header, 'rows' => $rows, 'sticky' => TRUE, 'attributes' => array(), 'empty' => 'No data')) . '</div>'; |
|
161 |
$heading = sprintf('<h2>%s</h2>', t('LDAP Entry for %username (dn: %dn)', [ |
|
162 |
'%dn' => $variables['dn'], |
|
163 |
'%username' => $variables['username'], |
|
164 |
])); |
|
165 |
$table = theme('table', [ |
|
166 |
'colgroups' => NULL, |
|
167 |
'caption' => 'ldap entry array', |
|
168 |
'header' => $header, |
|
169 |
'rows' => $rows, |
|
170 |
'sticky' => TRUE, |
|
171 |
'attributes' => [], |
|
172 |
'empty' => 'No data', |
|
173 |
]); |
|
174 |
$entry_table = '<div class="content">' . $heading . $table . '</div>'; |
|
148 | 175 |
return $entry_table; |
149 | 176 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules