function views_ui_standard_display_dropdown

Add a <select> dropdown for a given section.

Allows the user to change whether this info is stored on the default display or on the current display.

6 calls to views_ui_standard_display_dropdown()
views_plugin_display::options_form in plugins/views_plugin_display.inc
Provide the default form for setting options.
views_ui_add_item_form in includes/admin.inc
Form to add_item items in the views UI.
views_ui_config_item_form in includes/admin.inc
Form to config_item items in the views UI.
views_ui_config_type_form in includes/admin.inc
Form to config items in the views UI.
views_ui_rearrange_filter_form in includes/admin.inc
Form to rearrange items in the views UI.

... See full list

File

includes/admin.inc, line 2794

Code

function views_ui_standard_display_dropdown(&$form, &$form_state, $section) {
    $view =& $form_state['view'];
    $display_id = $form_state['display_id'];
    $displays = $view->display;
    $current_display = $view->display[$display_id];
    // Add the "2 of 3" progress indicator.
    // @todo Move this to a separate function if it's needed on any forms that
    // don't have the display dropdown.
    if ($form_progress = views_ui_get_form_progress($view)) {
        $form['progress']['#markup'] = '<div id="views-progress-indicator">' . t('@current of @total', array(
            '@current' => $form_progress['current'],
            '@total' => $form_progress['total'],
        )) . '</div>';
        $form['progress']['#weight'] = -1001;
    }
    if ($current_display->handler
        ->is_default_display()) {
        return;
    }
    // Determine whether any other displays have overrides for this section.
    $section_overrides = FALSE;
    $section_defaulted = $current_display->handler
        ->is_defaulted($section);
    foreach ($displays as $id => $display) {
        if ($id === 'default' || $id === $display_id) {
            continue;
        }
        if ($display->handler && !$display->handler
            ->is_defaulted($section)) {
            $section_overrides = TRUE;
        }
    }
    $display_dropdown['default'] = $section_overrides ? t('All displays (except overridden)') : t('All displays');
    $display_dropdown[$display_id] = t('This @display_type (override)', array(
        '@display_type' => $current_display->display_plugin,
    ));
    // Only display the revert option if we are in a overridden section.
    if (!$section_defaulted) {
        $display_dropdown['default_revert'] = t('Revert to default');
    }
    $form['override'] = array(
        '#prefix' => '<div class="views-override clearfix container-inline">',
        '#suffix' => '</div>',
        '#weight' => -1000,
        '#tree' => TRUE,
    );
    $form['override']['dropdown'] = array(
        '#type' => 'select',
        '#title' => t('For'),
        // @todo Translators may need more context than this.
'#options' => $display_dropdown,
    );
    if ($current_display->handler
        ->is_defaulted($section)) {
        $form['override']['dropdown']['#default_value'] = 'defaults';
    }
    else {
        $form['override']['dropdown']['#default_value'] = $display_id;
    }
}