function views_plugin_exposed_form::query

Overrides views_plugin::query

1 call to views_plugin_exposed_form::query()
views_plugin_exposed_form_input_required::query in plugins/views_plugin_exposed_form_input_required.inc
Add anything to the query that we might need to.
1 method overrides views_plugin_exposed_form::query()
views_plugin_exposed_form_input_required::query in plugins/views_plugin_exposed_form_input_required.inc
Add anything to the query that we might need to.

File

plugins/views_plugin_exposed_form.inc, line 182

Class

views_plugin_exposed_form
The base plugin to handle exposed filter forms.

Code

public function query() {
    $view = $this->view;
    $exposed_data = isset($view->exposed_data) ? $view->exposed_data : array();
    $sort_by = isset($exposed_data['sort_by']) ? $exposed_data['sort_by'] : NULL;
    if (!empty($sort_by) && $this->view->style_plugin
        ->build_sort()) {
        // Make sure the original order of sorts is preserved
        // (e.g. a sticky sort is often first)
        if (isset($view->sort[$sort_by])) {
            $view->query->orderby = array();
            foreach ($view->sort as $key => $sort) {
                if (!$sort->is_exposed()) {
                    $sort->query();
                }
                elseif ($key == $sort_by) {
                    if (isset($exposed_data['sort_order']) && in_array($exposed_data['sort_order'], array(
                        'ASC',
                        'DESC',
                    ))) {
                        $sort->options['order'] = $exposed_data['sort_order'];
                    }
                    $sort->set_relationship();
                    $sort->query();
                }
            }
        }
    }
}