function views_ui::list_form

Overrides ctools_export_ui::list_form

File

plugins/export_ui/views_ui.class.php, line 80

Class

views_ui
CTools Export UI class handler for Views UI.

Code

public function list_form(&$form, &$form_state) {
    $row_class = 'container-inline';
    if (!variable_get('views_ui_show_listing_filters', FALSE)) {
        $row_class .= " element-invisible";
    }
    views_include('admin');
    parent::list_form($form, $form_state);
    // CTools only has two rows. We want four. That's why we create our own
    // structure.
    $form['bottom row']['submit']['#attributes']['class'][] = 'js-hide';
    $form['first row'] = array(
        '#prefix' => '<div class="' . $row_class . ' ctools-export-ui-row ctools-export-ui-first-row clearfix">',
        '#suffix' => '</div>',
        'search' => $form['top row']['search'],
        'submit' => $form['bottom row']['submit'],
        'reset' => $form['bottom row']['reset'],
    );
    $form['second row'] = array(
        '#prefix' => '<div class="' . $row_class . ' ctools-export-ui-row ctools-export-ui-second-row clearfix">',
        '#suffix' => '</div>',
        'storage' => $form['top row']['storage'],
        'disabled' => $form['top row']['disabled'],
    );
    $form['third row'] = array(
        '#prefix' => '<div class="' . $row_class . ' ctools-export-ui-row ctools-export-ui-third-row clearfix element-hidden">',
        '#suffix' => '</div>',
        'order' => $form['bottom row']['order'],
        'sort' => $form['bottom row']['sort'],
    );
    unset($form['top row']);
    unset($form['bottom row']);
    // Modify the look and contents of existing form elements.
    $form['second row']['storage']['#title'] = '';
    $form['second row']['storage']['#options'] = array(
        'all' => t('All storage'),
        t('Normal') => t('In database'),
        t('Default') => t('In code'),
        t('Overridden') => t('Database overriding code'),
    );
    $form['second row']['disabled']['#title'] = '';
    $form['second row']['disabled']['#options']['all'] = t('All status');
    $form['third row']['sort']['#title'] = '';
    // And finally, add our own.
    $this->bases = array();
    foreach (views_fetch_base_tables() as $table => $info) {
        $this->bases[$table] = $info['title'];
    }
    $form['second row']['base'] = array(
        '#type' => 'select',
        '#options' => array_merge(array(
            'all' => t('All types'),
        ), $this->bases),
        '#default_value' => 'all',
        '#weight' => -1,
    );
    $tags = array();
    if (isset($form_state['object']->items)) {
        foreach ($form_state['object']->items as $view) {
            if (!empty($view->tag)) {
                $view_tags = drupal_explode_tags($view->tag);
                foreach ($view_tags as $tag) {
                    $tags[$tag] = $tag;
                }
            }
        }
    }
    asort($tags);
    $form['second row']['tag'] = array(
        '#type' => 'select',
        '#title' => t('Filter'),
        '#options' => array_merge(array(
            'all' => t('All tags'),
        ), array(
            'none' => t('No tags'),
        ), $tags),
        '#default_value' => 'all',
        '#weight' => -9,
    );
    $displays = array();
    foreach (views_fetch_plugin_data('display') as $id => $info) {
        if (!empty($info['admin'])) {
            $displays[$id] = $info['admin'];
        }
    }
    asort($displays);
    $form['second row']['display'] = array(
        '#type' => 'select',
        '#options' => array_merge(array(
            'all' => t('All displays'),
        ), $displays),
        '#default_value' => 'all',
        '#weight' => -1,
    );
}