function views_ui_get_display_tab_details
Helper function to get the display details section of the edit UI.
Parameters
view $view: The full view object.
object $display: The display object to work with.
Return value
array A renderable page build array.
1 call to views_ui_get_display_tab_details()
- views_ui_get_display_tab in includes/
admin.inc - Returns a renderable array representing the edit page for one display.
File
-
includes/
admin.inc, line 1613
Code
function views_ui_get_display_tab_details($view, $display) {
$display_title = views_ui_get_display_label($view, $display->id, FALSE);
$build = array(
'#theme_wrappers' => array(
'container',
),
'#attributes' => array(
'id' => 'edit-display-settings-details',
),
);
$plugin = views_fetch_plugin_data('display', $view->display[$display->id]->display_plugin);
// The following is for display purposes only. We need to determine if there
// is more than one button and wrap the buttons in a .ctools-dropbutton class
// if more than one is present. Otherwise, we'll just wrap the actions in the
// .ctools-button class.
$is_display_deleted = !empty($display->deleted);
$is_deletable = empty($plugin['no remove']);
// The master display cannot be cloned.
$is_default = $display->id == 'default';
// @todo Figure out why get_option doesn't work here.
$is_enabled = $display->handler
->get_option('enabled');
if (!$is_display_deleted && $is_deletable && !$is_default) {
$prefix = '<div class="ctools-no-js ctools-button ctools-dropbutton"><div class="ctools-link"><a href="#" class="ctools-twisty ctools-text"><span class="element-invisible">open</span></a></div><div class="ctools-content"><ul class="horizontal right actions">';
$suffix = '</ul></div></div>';
$item_element = 'li';
}
else {
$prefix = '<div class="ctools-button"><div class="ctools-content"><ul class="horizontal right actions">';
$suffix = '</ul></div></div>';
$item_element = 'li';
}
// Display warning if argument handler has exception overriding validation.
foreach ($display->handler
->get_handlers('argument') as $handler) {
if (!empty($handler->options['exception']['value']) && $handler->options['specify_validation'] && !empty($handler->options['validate_options'])) {
$build['message']['validation_warning'] = array(
'#theme_wrappers' => array(
'container',
),
'#attributes' => array(
'class' => array(
'messages',
'warning',
),
),
'#markup' => t('The view display has a contextual filter exception that overrides the validation criterion.'),
);
break;
}
}
if ($display->id != 'default') {
$build['top']['#theme_wrappers'] = array(
'container',
);
$build['top']['#attributes']['id'] = 'edit-display-settings-top';
$build['top']['#attributes']['class'] = array(
'views-ui-display-tab-actions',
'views-ui-display-tab-bucket',
'clearfix',
);
// The Delete, Duplicate and Undo Delete buttons.
$build['top']['actions'] = array(
'#prefix' => $prefix,
'#suffix' => $suffix,
);
if (!$is_display_deleted) {
if (!$is_enabled) {
$build['top']['actions']['enable'] = array(
'#type' => 'submit',
'#value' => t('enable @display_title', array(
'@display_title' => $display_title,
)),
'#limit_validation_errors' => array(),
'#submit' => array(
'views_ui_edit_form_submit_enable_display',
'views_ui_edit_form_submit_delay_destination',
),
'#prefix' => '<' . $item_element . ' class="enable">',
"#suffix" => '</' . $item_element . '>',
);
}
elseif ($display->handler
->has_path()) {
$path = $display->handler
->get_path();
if (strpos($path, '%') === FALSE) {
$build['top']['actions']['path'] = array(
'#type' => 'link',
'#title' => t('view @display', array(
'@display' => $display->display_title,
)),
'#options' => array(
'alt' => array(
t('Go to the real page for this display'),
),
),
'#href' => $path,
'#prefix' => '<' . $item_element . ' class="view">',
"#suffix" => '</' . $item_element . '>',
);
}
}
if (!$is_default) {
$build['top']['actions']['duplicate'] = array(
'#type' => 'submit',
'#value' => t('clone @display_title', array(
'@display_title' => $display_title,
)),
'#limit_validation_errors' => array(),
'#submit' => array(
'views_ui_edit_form_submit_duplicate_display',
'views_ui_edit_form_submit_delay_destination',
),
'#prefix' => '<' . $item_element . ' class="duplicate">',
"#suffix" => '</' . $item_element . '>',
);
foreach (views_fetch_plugin_names('display', NULL, array(
$view->base_table,
)) as $type => $label) {
if ($type == $display->display_plugin) {
continue;
}
$build['top']['actions']['clone_as'][$type] = array(
'#type' => 'submit',
'#value' => t('clone as @type', array(
'@type' => $label,
)),
'#limit_validation_errors' => array(),
'#submit' => array(
'views_ui_edit_form_submit_clone_display_as_type',
'views_ui_edit_form_submit_delay_destination',
),
'#prefix' => '<' . $item_element . ' class="duplicate">',
"#suffix" => '</' . $item_element . '>',
);
}
}
if ($is_deletable) {
$build['top']['actions']['delete'] = array(
'#type' => 'submit',
'#value' => t('delete @display_title', array(
'@display_title' => $display_title,
)),
'#limit_validation_errors' => array(),
'#submit' => array(
'views_ui_edit_form_submit_delete_display',
'views_ui_edit_form_submit_delay_destination',
),
'#prefix' => '<' . $item_element . ' class="delete">',
"#suffix" => '</' . $item_element . '>',
);
}
if ($is_enabled) {
$build['top']['actions']['disable'] = array(
'#type' => 'submit',
'#value' => t('disable @display_title', array(
'@display_title' => $display_title,
)),
'#limit_validation_errors' => array(),
'#submit' => array(
'views_ui_edit_form_submit_disable_display',
'views_ui_edit_form_submit_delay_destination',
),
'#prefix' => '<' . $item_element . ' class="disable">',
"#suffix" => '</' . $item_element . '>',
);
}
}
else {
$build['top']['actions']['undo_delete'] = array(
'#type' => 'submit',
'#value' => t('undo delete of @display_title', array(
'@display_title' => $display_title,
)),
'#limit_validation_errors' => array(),
'#submit' => array(
'views_ui_edit_form_submit_undo_delete_display',
'views_ui_edit_form_submit_delay_destination',
),
'#prefix' => '<' . $item_element . ' class="undo-delete">',
"#suffix" => '</' . $item_element . '>',
);
}
// The area above the three columns.
$build['top']['display_title'] = array(
'#theme' => 'views_ui_display_tab_setting',
'#description' => t('Display name'),
'#link' => $display->handler
->option_link(check_plain($display_title), 'display_title'),
);
}
$build['columns'] = array();
$build['columns']['#theme_wrappers'] = array(
'container',
);
$build['columns']['#attributes'] = array(
'id' => 'edit-display-settings-main',
'class' => array(
'clearfix',
'views-display-columns',
),
);
$build['columns']['first']['#theme_wrappers'] = array(
'container',
);
$build['columns']['first']['#attributes'] = array(
'class' => array(
'views-display-column',
'first',
),
);
$build['columns']['second']['#theme_wrappers'] = array(
'container',
);
$build['columns']['second']['#attributes'] = array(
'class' => array(
'views-display-column',
'second',
),
);
$build['columns']['second']['settings'] = array();
$build['columns']['second']['header'] = array();
$build['columns']['second']['footer'] = array();
$build['columns']['second']['pager'] = array();
// The third column buckets are wrapped in a CTools collapsible div.
$build['columns']['third']['#theme_wrappers'] = array(
'container',
);
$build['columns']['third']['#attributes'] = array(
'class' => array(
'views-display-column',
'third',
'ctools-collapsible-container',
'ctools-collapsible-remember',
),
);
// Specify an id that won't change after AJAX requests, so ctools can keep
// track of the user's preferred collapsible state. Use the same id across
// different displays of the same view, so changing displays doesn't
// recollapse the column.
$build['columns']['third']['#attributes']['id'] = 'views-ui-advanced-column-' . $view->name;
// Collapse the div by default.
if (!variable_get('views_ui_show_advanced_column', FALSE)) {
$build['columns']['third']['#attributes']['class'][] = 'ctools-collapsed';
}
$build['columns']['third']['advanced'] = array(
'#markup' => '<h3 class="ctools-collapsible-handle"><a href="">' . t('Advanced') . '</a></h3>',
);
$build['columns']['third']['collapse']['#theme_wrappers'] = array(
'container',
);
$build['columns']['third']['collapse']['#attributes'] = array(
'class' => array(
'ctools-collapsible-content',
),
);
// Each option (e.g. title, access, display as grid/table/list) fits into one
// of several "buckets," or boxes (Format, Fields, Sort, and so on).
$buckets = array();
// Fetch options from the display plugin, with a list of buckets they go into.
$options = array();
$display->handler
->options_summary($buckets, $options);
// Place each option into its bucket.
foreach ($options as $id => $option) {
// Each option self-identifies as belonging in a particular bucket.
$buckets[$option['category']]['build'][$id] = views_ui_edit_form_get_build_from_option($id, $option, $view, $display);
}
// Place each bucket into the proper column.
foreach ($buckets as $id => $bucket) {
// Let buckets identify themselves as belonging in a column.
if (isset($bucket['column']) && isset($build['columns'][$bucket['column']])) {
$column = $bucket['column'];
}
else {
$column = 'third';
}
if (isset($bucket['build']) && is_array($bucket['build'])) {
// The third column is a CTools collapsible div, so
// the structure of the form is a little different for this column.
if ($column === 'third') {
$build['columns'][$column]['collapse'][$id] = $bucket['build'];
$build['columns'][$column]['collapse'][$id]['#theme_wrappers'][] = 'views_ui_display_tab_bucket';
$build['columns'][$column]['collapse'][$id]['#title'] = !empty($bucket['title']) ? $bucket['title'] : '';
$build['columns'][$column]['collapse'][$id]['#name'] = !empty($bucket['title']) ? $bucket['title'] : $id;
}
else {
$build['columns'][$column][$id] = $bucket['build'];
$build['columns'][$column][$id]['#theme_wrappers'][] = 'views_ui_display_tab_bucket';
$build['columns'][$column][$id]['#title'] = !empty($bucket['title']) ? $bucket['title'] : '';
$build['columns'][$column][$id]['#name'] = !empty($bucket['title']) ? $bucket['title'] : $id;
}
}
}
$build['columns']['first']['fields'] = views_ui_edit_form_get_bucket('field', $view, $display);
$build['columns']['first']['filters'] = views_ui_edit_form_get_bucket('filter', $view, $display);
$build['columns']['first']['sorts'] = views_ui_edit_form_get_bucket('sort', $view, $display);
$build['columns']['second']['header'] = views_ui_edit_form_get_bucket('header', $view, $display);
$build['columns']['second']['footer'] = views_ui_edit_form_get_bucket('footer', $view, $display);
$build['columns']['third']['collapse']['arguments'] = views_ui_edit_form_get_bucket('argument', $view, $display);
$build['columns']['third']['collapse']['relationships'] = views_ui_edit_form_get_bucket('relationship', $view, $display);
$build['columns']['third']['collapse']['empty'] = views_ui_edit_form_get_bucket('empty', $view, $display);
return $build;
}