function template_preprocess_views_ui_edit_view
Preprocess the view edit page.
1 call to template_preprocess_views_ui_edit_view()
- views_ui_reorder_view in includes/
admin.inc - Page callback to display analysis information on a view.
File
-
includes/
admin.inc, line 1007
Code
function template_preprocess_views_ui_edit_view(&$vars) {
$view =& $vars['view'];
$vars['save_button'] = drupal_get_form('views_ui_edit_view_form', $view);
$table = views_fetch_data($view->base_table);
$vars['base_table'] = !empty($table['table']['base']['title']) ? $table['table']['base']['title'] : t('Unknown or missing table name');
views_include('tabs');
$tabs = new views_tabset();
$vars['message'] = '<div class="message">' . t("Click on an item to edit that item's details.") . '</div>';
if (!$view->set_display('default')) {
drupal_set_message(t('This view has a broken default display and cannot be used.'), 'error');
}
foreach ($view->display as $display) {
list($title, $body) = views_ui_display_tab($view, $display);
// The first display is the default.
$tabs->set($display->id, $title, $body);
}
// This is the area that will render beneath the links
$form_state = array(
'view' => &$view,
'ajax' => FALSE,
);
$display_button = drupal_build_form('views_ui_add_display_form', $form_state);
$analyze_button = drupal_get_form('views_ui_analyze_view_button', $view);
$reorder_button = drupal_get_form('views_ui_reorder_displays_button', $view);
$tabs->add_extra($display_button . $reorder_button . $analyze_button);
$vars['tabs'] = $tabs->render();
$form_state = array(
'display_id' => 'default',
'view_args' => '',
'rerender' => FALSE,
'no_redirect' => TRUE,
'view' => &$view,
'input' => array(),
);
$vars['preview'] = drupal_build_form('views_ui_preview_form', $form_state);
$vars['locked'] = NULL;
if (isset($view->locked) && is_object($view->locked)) {
$account = user_load($view->locked->uid);
$vars['locked'] = theme('username', $account);
$vars['lock_age'] = format_interval(time() - $view->locked->updated);
$vars['break'] = url('admin/build/views/break-lock/' . $view->name);
}
$vars['quick_links_raw'] = array(
array(
'title' => t('Export'),
'alt' => t("Export this view"),
'href' => "admin/build/views/export/{$view->name}",
),
array(
'title' => t('Clone'),
'alt' => t("Create a copy of this view"),
'href' => "admin/build/views/clone/{$view->name}",
),
);
$paths = array();
foreach ($view->display as $id => $display) {
if (!empty($display->handler) && $display->handler
->has_path()) {
$path = $display->handler
->get_path();
if (strpos($path, '%') === FALSE && !isset($paths[$path])) {
$vars['quick_links_raw'][] = array(
'title' => t('View "@display"', array(
'@display' => $display->display_title,
)),
'alt' => t("Go to the real page for this display"),
'href' => $path,
);
// Displays can have the same path; no point in showing more than one link.
$paths[$path] = TRUE;
}
}
}
$vars['quick_links'] = theme('links', $vars['quick_links_raw']);
views_add_css('views-admin');
drupal_add_js('misc/tabledrag.js', 'core');
views_add_js('ajax');
drupal_add_js('misc/jquery.form.js', 'core');
// Also add any js files required by plugins:
$plugins = views_fetch_plugin_data();
foreach ($plugins as $type => $type_plugins) {
foreach ($type_plugins as $name => $plugin) {
if (!empty($plugin['js'])) {
foreach ($plugin['js'] as $file) {
drupal_add_js($file);
}
}
}
}
$settings = array(
'views' => array(
'ajax' => array(
'id' => '#views-ajax-pad',
'title' => '#views-ajax-title',
'defaultForm' => $vars['message'],
),
),
);
drupal_add_js($settings, 'setting');
}