protected function WizardPluginBase::default_display_sorts_user in Views (for Drupal 7) 8.3
Retrieves sort information based on user input for the default display.
Parameters
array $form: The full wizard form array.
array $form_state: The current state of the wizard form.
Return value
array An array of sort arrays keyed by ID. A sort array contains the options accepted by a sort handler.
1 call to WizardPluginBase::default_display_sorts_user()
- WizardPluginBase::default_display_sorts in lib/
Drupal/ views/ Plugin/ views/ wizard/ WizardPluginBase.php - Retrieves all sort information used by the default display.
File
- lib/
Drupal/ views/ Plugin/ views/ wizard/ WizardPluginBase.php, line 825 - Definition of Drupal\views\Plugin\views\wizard\WizardPluginBase.
Class
- WizardPluginBase
- Provides the interface and base class for Views Wizard plugins.
Namespace
Drupal\views\Plugin\views\wizardCode
protected function default_display_sorts_user($form, $form_state) {
$sorts = array();
// Don't add a sort if there is no form value or the user set the sort to
// 'none'.
if (!empty($form_state['values']['show']['sort']) && $form_state['values']['show']['sort'] != 'none') {
list($column, $sort) = explode(':', $form_state['values']['show']['sort']);
// Column either be a column-name or the table-columnn-ame.
$column = explode('-', $column);
if (count($column) > 1) {
$table = $column[0];
$column = $column[1];
}
else {
$table = $this->base_table;
$column = $column[0];
}
// If the input is invalid, for example when the #default_value contains
// created from node, but the wizard type is another base table, make
// sure it is not added. This usually don't happen if you have js
// enabled.
$data = views_fetch_data($table);
if (isset($data[$column]['sort'])) {
$sorts[$column] = array(
'id' => $column,
'table' => $table,
'field' => $column,
'order' => $sort,
);
}
}
return $sorts;
}