function views_ui_clone_display
2.x admin.inc | views_ui_clone_display($js, $view, $id) |
AJAX callback to add a display.
1 string reference to 'views_ui_clone_display'
File
Code
function views_ui_clone_display($js, $view, $id) {
views_include('ajax');
$form_state = array(
'view' => &$view,
'ajax' => $js,
'display_id' => $id,
);
$output = views_ajax_form_wrapper('views_ui_clone_display_form', $form_state);
if ($js) {
// If we don't have an output object, it was submitted. Set up the submission.
if (empty($output)) {
$id = $form_state['id'];
// Make sure the new display is active
if (!$view->set_display('default')) {
views_ajax_render(t('Unable to initialize default display'));
}
// Render the new display
list($title, $body) = views_ui_display_tab($view, $view->display[$id]);
// Instruct the javascript on the browser to render the new tab.
$output = new stdClass;
$output->tab = array('#views-tab-' . $id => array('title' => $title, 'body' => $body));
}
// Render the command object. This automatically exits.
views_ajax_render($output);
}
// But the non-js variant will return output if it didn't redirect us.
return $output;
}