1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
*
|
6
|
* @author greenSkin
|
7
|
*/
|
8
|
|
9
|
function theme_module_filter($variables) {
|
10
|
$element = $variables['element'];
|
11
|
return '<div class="module-filter-inputs-wrapper">' . drupal_render_children($element) . '</div>';
|
12
|
}
|
13
|
|
14
|
/**
|
15
|
* Theme callback for the modules tabbed form.
|
16
|
*/
|
17
|
function theme_module_filter_system_modules_tabs($variables) {
|
18
|
if (module_exists('views_ui')) {
|
19
|
// Hack to get consistent style with views ctools dropbutton.
|
20
|
if (module_load_include('inc', 'views_ui', 'includes/admin')) {
|
21
|
foreach (views_ui_get_admin_css() as $file => $options) {
|
22
|
drupal_add_css($file, $options);
|
23
|
}
|
24
|
}
|
25
|
}
|
26
|
|
27
|
$form = $variables['form'];
|
28
|
|
29
|
if (!module_exists('page_actions')) {
|
30
|
$form['actions']['#prefix'] = '<div id="module-filter-submit">';
|
31
|
$form['actions']['#suffix'] = '</div>';
|
32
|
}
|
33
|
|
34
|
$header = array(
|
35
|
t('Enabled'),
|
36
|
t('Name'),
|
37
|
t('Version'),
|
38
|
t('Description')
|
39
|
);
|
40
|
$package_ids = array('all');
|
41
|
$enabled['all'] = array();
|
42
|
|
43
|
if (variable_get('module_filter_track_recent_modules', 1)) {
|
44
|
$recent_modules = array_filter(variable_get('module_filter_recent_modules', array()), 'module_filter_recent_filter');
|
45
|
// Save the filtered results.
|
46
|
variable_set('module_filter_recent_modules', $recent_modules);
|
47
|
|
48
|
$package_ids[] = 'recent';
|
49
|
$enabled['recent'] = array();
|
50
|
}
|
51
|
|
52
|
// Determine what modules are new (within a week).
|
53
|
$new_modules = module_filter_new_modules();
|
54
|
$package_ids[] = 'new';
|
55
|
$enabled['new'] = array();
|
56
|
|
57
|
$rows = array();
|
58
|
$flip = array('even' => 'odd', 'odd' => 'even');
|
59
|
foreach (element_children($form['modules']) as $package) {
|
60
|
$package_id = module_filter_get_id($package);
|
61
|
$package_ids[] = $package_id;
|
62
|
|
63
|
// Package title and header.
|
64
|
$rows[] = array('data' => array(array('data' => '<h3>' . $form['modules'][$package]['#title'] . '</h3>', 'colspan' => 4)), 'id' => $package_id . '-package', 'class' => array('admin-package-title'));
|
65
|
$rows[] = array('data' => $header, 'class' => array('admin-package-header'));
|
66
|
|
67
|
$stripe = 'odd';
|
68
|
$enabled[$package_id] = array();
|
69
|
foreach (element_children($form['modules'][$package]) as $key) {
|
70
|
$module = &$form['modules'][$package][$key];
|
71
|
|
72
|
$is_enabled = isset($module['enable']['#default_value']) ? $module['enable']['#default_value'] : '';
|
73
|
$enabled['all'][] = $enabled[$package_id][] = $is_enabled;
|
74
|
if (isset($recent_modules[$key])) {
|
75
|
$enabled['recent'][] = $is_enabled;
|
76
|
}
|
77
|
if (isset($new_modules[$key])) {
|
78
|
$enabled['new'][] = $is_enabled;
|
79
|
}
|
80
|
|
81
|
$row = array();
|
82
|
$toggle_enable = '';
|
83
|
if (isset($module['enable']['#type']) && $module['enable']['#type'] == 'checkbox') {
|
84
|
unset($module['enable']['#title']);
|
85
|
$class = ($is_enabled ? 'enabled' : 'off');
|
86
|
if (!empty($module['enable']['#disabled'])) {
|
87
|
$class .= ' disabled';
|
88
|
}
|
89
|
$toggle_enable = '<div class="js-hide toggle-enable ' . $class . '"><div> </div></div>';
|
90
|
}
|
91
|
$row[] = array('class' => array('checkbox'), 'data' => $toggle_enable . drupal_render($module['enable']));
|
92
|
$label = '<label';
|
93
|
if (isset($module['enable']['#id'])) {
|
94
|
$label .= ' for="' . $module['enable']['#id'] . '"';
|
95
|
}
|
96
|
$row[] = array('class' => array('name'), 'data' => $label . '><strong>' . drupal_render($module['name']) . '</strong><br><span class="module-machine-name">(' . $key . ')</span></label>');
|
97
|
$row[] = array('class' => array('version'), 'data' => drupal_render($module['version']));
|
98
|
// Add the description, along with any modules it requires and any
|
99
|
// operation links.
|
100
|
$description = drupal_render($module['description']);
|
101
|
if ($module['#requires']) {
|
102
|
$description .= '<div class="admin-requirements">' . t('Requires: !module-list', array('!module-list' => implode(', ', $module['#requires']))) . '</div>';
|
103
|
}
|
104
|
if ($module['#required_by']) {
|
105
|
$description .= '<div class="admin-requirements">' . t('Required by: !module-list', array('!module-list' => implode(', ', $module['#required_by']))) . '</div>';
|
106
|
}
|
107
|
$operations = (module_exists('ctools')) ? theme('module_filter_operations', array('links' => $module['links'], 'dropbutton' => TRUE)) : theme('module_filter_operations', array('links' => $module['links']));
|
108
|
if (!empty($operations)) {
|
109
|
$description .= $operations;
|
110
|
}
|
111
|
$row[] = array('data' => $description, 'class' => array('description'));
|
112
|
|
113
|
$class = array(module_filter_get_id($package) . '-tab', 'module', $stripe);
|
114
|
if (isset($recent_modules[$key])) {
|
115
|
$class[] = 'recent-module';
|
116
|
}
|
117
|
if (isset($new_modules[$key])) {
|
118
|
$class[] = 'new-module';
|
119
|
}
|
120
|
$rows[] = array('data' => $row, 'no_striping' => TRUE, 'class' => $class);
|
121
|
$stripe = $flip[$stripe];
|
122
|
}
|
123
|
|
124
|
// Set the package as printed.
|
125
|
$form['modules'][$package]['#printed'] = TRUE;
|
126
|
}
|
127
|
|
128
|
if (variable_get('module_filter_count_enabled', 1)) {
|
129
|
$enabled_counts = array();
|
130
|
foreach ($enabled as $package_id => $value) {
|
131
|
$enabled_counts[$package_id] = array(
|
132
|
'enabled' => count(array_filter($value)),
|
133
|
'total' => count($value),
|
134
|
);
|
135
|
}
|
136
|
drupal_add_js(array(
|
137
|
'moduleFilter' => array(
|
138
|
'packageIDs' => $package_ids,
|
139
|
'enabledCounts' => $enabled_counts,
|
140
|
)
|
141
|
), 'setting');
|
142
|
}
|
143
|
|
144
|
// Add first and last class to rows.
|
145
|
$rows[0]['class'][] = 'first';
|
146
|
$rows[count($rows) - 1]['class'][] = 'last';
|
147
|
|
148
|
$output = '<div id="module-filter-wrapper">';
|
149
|
$output .= '<div id="module-filter-modules">' . drupal_render($form['module_filter']);
|
150
|
$output .= theme('table', array('header' => $header, 'rows' => $rows));
|
151
|
$output .= drupal_render_children($form);
|
152
|
$output .= '</div>';
|
153
|
$output .= '</div>';
|
154
|
return $output;
|
155
|
}
|
156
|
|
157
|
function theme_module_filter_operations(&$vars) {
|
158
|
$links = &$vars['links'];
|
159
|
$dropbutton = $vars['dropbutton'];
|
160
|
|
161
|
$operations = array();
|
162
|
foreach (array('configure', 'permissions', 'help') as $key) {
|
163
|
if ($dropbutton) {
|
164
|
hide($links[$key]);
|
165
|
if (!empty($links[$key]['#href'])) {
|
166
|
$operations[] = array(
|
167
|
'title' => $links[$key]['#title'],
|
168
|
'href' => $links[$key]['#href'],
|
169
|
);
|
170
|
}
|
171
|
}
|
172
|
else {
|
173
|
$data = drupal_render($links[$key]);
|
174
|
if (!empty($data)) {
|
175
|
$operations[] = array('data' => $data);
|
176
|
}
|
177
|
}
|
178
|
}
|
179
|
if (!empty($operations)) {
|
180
|
if ($dropbutton) {
|
181
|
return '<div class="admin-operations">' . theme('links__ctools_dropbutton', array('title' => t('Operations'), 'links' => $operations, 'attributes' => array('class' => array('links')))) . '</div>';
|
182
|
}
|
183
|
return '<div class="admin-operations">' . theme('item_list', array('items' => $operations, 'attributes' => array('class' => array('links', 'inline')))) . '</div>';
|
184
|
}
|
185
|
}
|