function template_preprocess_views_maintenance_views_table in Views Maintenance 6
Same name and namespace in other branches
- 7 theme/theme.inc \template_preprocess_views_maintenance_views_table()
Prepares views info for output and includes required CSS/JS.
Parameters
array $vars:
File
- theme/
theme.inc, line 121 - Preprocessing and theming functions for Views Maintenance.
Code
function template_preprocess_views_maintenance_views_table(&$vars) {
// Add primary views table header.
$vars['views_header'] = array(
array(
'data' => ' ',
'class' => 'views-mnt-view-toggle-all',
),
array(
'data' => t('View name'),
'field' => 'name',
'sort' => 'asc',
),
array(
'data' => t('Type'),
'field' => 'type',
),
array(
'data' => t('Storage'),
'field' => 'storage',
),
array(
'data' => t('Status'),
'field' => 'status',
),
array(
'data' => t('Actions'),
'class' => 'views-mnt-view-links',
),
);
// Add headers for display tables.
$vars['displays_header'] = array(
t('Name'),
t('Type'),
t('Status'),
t('Use case'),
t('Description'),
t('Actions'),
);
// Theme thead.
$vars['thead'] = theme('views_maintenance_views_thead', $vars['views_header']);
// Sort views before replacing storage and status with themed values.
_views_maintenance_views_sort($vars['views'], $vars['views_header']);
// Convert display status info to table and prepare view info for printing.
foreach ($vars['views'] as $view_id => &$view_info) {
$rows = array();
foreach ($view_info['displays'] as $display_id => $display_info) {
// Convert associative arrays to table rows.
$table_rows = array();
$first = TRUE;
foreach ($display_info['use_cases'] as $use_case) {
// Description can be an array or HTML string.
$description = '';
if (!empty($use_case['description'])) {
$description = theme('item_list', (array) $use_case['description']);
}
$use_case_row = array(
theme('views_maintenance_display_status', $use_case['status']),
isset($use_case['type']) ? $use_case['type'] : '',
$description,
!empty($use_case['links']) ? theme('item_list', $use_case['links']) : '',
);
if ($first) {
// Add name and type to the first row of this display.
array_unshift($use_case_row, array(
'data' => check_plain($display_info['name']),
'rowspan' => count($display_info['use_cases']),
'class' => 'views-mnt-display-name',
), array(
'data' => check_plain($display_info['type']),
'rowspan' => count($display_info['use_cases']),
'class' => 'views-mnt-display-type',
));
$first = FALSE;
}
$rows[] = $use_case_row;
}
}
$view_info['name'] = check_plain($view_info['name']);
// Save displays table.
$view_info['rows'] = $rows;
$view_info['table'] = theme('table', $vars['displays_header'], $view_info['rows'], array(
'class' => 'views-mnt-display-table',
));
// Convert links array to string.
$view_info['links'] = implode(' | ', $view_info['links']);
// Theme view status and storage.
$view_info['status'] = theme_views_maintenance_view_status($view_info['status']);
$view_info['storage'] = theme_views_maintenance_view_storage($view_info['storage']);
// Filter view description.
$view_info['description'] = trim($view_info['description']) != '' ? check_plain($view_info['description']) : NULL;
}
// Include required JS and CSS.
$module_path = drupal_get_path('module', 'views_maintenance');
drupal_add_css($module_path . '/css/views-maintenance-admin.css');
drupal_add_js($module_path . '/js/views-maintenance-admin.js');
}