function template_preprocess_views_ui_list_views
Preprocess the list views theme
File
-
includes/
admin.inc, line 46
Code
function template_preprocess_views_ui_list_views(&$vars) {
$items = array();
$sorts = array();
// Add some js for easier gui.
views_add_js('view-list');
$views = views_get_all_views();
$token_enable = drupal_get_token('views-enable');
$token_disable = drupal_get_token('views-disable');
// Respond to a reset command by clearing session and doing a drupal goto
// back to the base URL.
if (isset($_GET['op']) && $_GET['op'] == t('Reset')) {
unset($_SESSION['views']['#admin']);
drupal_goto('admin/build/views');
}
if (count($_GET) <= 1) {
if (isset($_SESSION['views']['#admin']) && is_array($_SESSION['views']['#admin'])) {
$_GET += $_SESSION['views']['#admin'];
}
}
else {
$_SESSION['views']['#admin'] = $_GET;
unset($_SESSION['views']['#admin']['q']);
}
$form_state = array(
'views' => $views,
'input' => $_GET,
'method' => 'get',
'rerender' => TRUE,
'no_redirect' => TRUE,
);
$vars['widgets'] = drupal_build_form('views_ui_list_views_form', $form_state);
$vars['help_type_icon'] = theme('advanced_help_topic', 'views', 'view-type');
$base_tables = views_fetch_base_tables();
foreach ($views as $view) {
if ($form_state['values']['tag'] != 'all') {
if ($form_state['values']['tag'] == 'none') {
if (!empty($view->tag)) {
continue;
}
}
else {
if ($form_state['values']['tag'] != $view->tag) {
continue;
}
}
}
if ($form_state['values']['type'] != 'all' && $form_state['values']['type'] != $view->type) {
continue;
}
if ($form_state['values']['base'] != 'all' && $form_state['values']['base'] != $view->base_table) {
continue;
}
if ($form_state['values']['display'] != 'all' && empty($view->display[$form_state['values']['display']])) {
continue;
}
if ($form_state['values']['status'] != 'all' && !empty($view->disabled) == $form_state['values']['status']) {
continue;
}
$item = new stdClass();
$item->ops = array();
if (empty($view->disabled)) {
$item->ops[] = l(t('Edit'), "admin/build/views/edit/{$view->name}");
$item->ops[] = l(t('Export'), "admin/build/views/export/{$view->name}");
$item->ops[] = l(t('Clone'), "admin/build/views/clone/{$view->name}");
}
if ($view->type != t('Default')) {
$text = $view->type == t('Overridden') ? t('Revert') : t('Delete');
$item->ops[] = l($text, "admin/build/views/delete/{$view->name}");
}
else {
if (empty($view->disabled)) {
$item->ops[] = l(t('Disable'), "admin/build/views/disable/{$view->name}", array(
'query' => drupal_get_destination() . '&token=' . $token_disable,
));
}
else {
$item->ops[] = l(t('Enable'), "admin/build/views/enable/{$view->name}", array(
'query' => drupal_get_destination() . '&token=' . $token_enable,
));
}
}
$item->ops = implode(' | ', $item->ops);
$item->path = '';
if (empty($view->display)) {
$item->path = t('Warning! Broken view!');
}
else {
$view->init_display();
// Make sure all the handlers are set up
$all_paths = array();
foreach ($view->display as $display) {
if (!empty($display->handler) && $display->handler
->has_path()) {
$one_path = $display->handler
->get_option('path');
if (empty($path_sort)) {
$path_sort = strtolower($one_path);
}
if (empty($view->disabled) && strpos($one_path, '%') === FALSE) {
$all_paths[] = l($one_path, $one_path);
}
else {
$all_paths[] = check_plain($one_path);
}
}
}
if (!empty($all_paths)) {
$item->path = implode(', ', array_unique($all_paths));
}
}
$item->type = $view->type;
$item->name = $view->name;
if (!empty($view->tag)) {
$item->tag = check_plain($view->tag);
}
$item->title = $view->get_title();
$item->base = !empty($base_tables[$view->base_table]['title']) ? $base_tables[$view->base_table]['title'] : t('Broken');
$item->displays = array();
foreach ($view->display as $display) {
if (!empty($display->handler->definition['admin'])) {
$item->displays[$display->handler->definition['admin']] = TRUE;
}
}
if ($item->displays) {
ksort($item->displays);
$item->displays = implode(', ', array_keys($item->displays));
}
$item->description = check_plain($view->description);
$item->classes = empty($view->disabled) ? 'view-enabled' : 'view-disabled';
$items[] = $item;
$sort = intval(empty($view->disabled) xor $form_state['values']['sort'] == 'asc');
switch ($form_state['values']['order']) {
case 'name':
default:
$sort .= strtolower($view->name);
break;
case 'title':
$sort .= strtolower($item->title);
break;
case 'path':
$sort .= strtolower($raw_path);
// $path;
break;
case 'type':
$sort .= $view->type . $view->name;
break;
case 'tag':
$sort .= strtolower($view->tag);
break;
case 'desc':
$sort .= strtolower($view->description);
break;
}
$sorts[] = $sort;
}
if ($form_state['values']['sort'] == 'desc') {
arsort($sorts);
}
else {
asort($sorts);
}
$i = array();
foreach ($sorts as $id => $title) {
$i[] = $items[$id];
}
views_add_css('views-list');
$vars['views'] = $i;
$getting_started = theme('advanced_help_topic', 'views', 'getting-started', 'title');
if (!$getting_started) {
$getting_started = t('Install the advanced help module for the getting started');
}
$vars['help'] = t('Not sure what to do? Try the "!getting-started" page.', array(
'!getting-started' => $getting_started,
));
}