1 views_ui_base_views_wizard.php | protected ViewsUiBaseViewsWizard::build_sorts(&$form, &$form_state) |
Build the part of the form that allows the user to select the view's sort order.
By default, this adds a "sorted by [date]" filter (when it is available).
File
- core/
modules/ views_ui/ wizards/ views_ui_base_views_wizard.php, line 460 - Provides the interface and base class for Views Wizard plugins.
Class
- ViewsUiBaseViewsWizard
- A very generic Views Wizard class - can be constructed for any base table.
Code
protected function build_sorts(&$form, &$form_state) {
$sorts = array(
'none' => t('Unsorted'),
);
// Check if we are allowed to sort by creation date.
if (!empty($this->plugin['created_column'])) {
$sorts += array(
$this->plugin['created_column'] . ':DESC' => t('Newest first'),
$this->plugin['created_column'] . ':ASC' => t('Oldest first'),
);
}
if (isset($this->plugin['available_sorts'])) {
$sorts += $this->plugin['available_sorts'];
}
// If there is no sorts option available continue.
if (!empty($sorts)) {
$form['displays']['show']['sort'] = array(
'#type' => 'select',
'#title' => t('sorted by'),
'#options' => $sorts,
'#default_value' => isset($this->plugin['created_column']) ? $this->plugin['created_column'] . ':DESC' : 'none',
);
}
}