function template_preprocess_views_ui_list_views in Views (for Drupal 7) 6.2
Same name and namespace in other branches
- 6.3 includes/admin.inc \template_preprocess_views_ui_list_views()
Preprocess the list views theme
File
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;
}
$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);
if (empty($view->display)) {
$item->path = t('Warning! Broken view!');
}
else {
$item->path = $raw_path = $view
->get_path();
$item->path = $item->path && empty($view->disabled) && strpos($item->path, '%') === FALSE ? l($item->path, $item->path) : check_plain($item->path);
}
$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,
));
}