Retrieves sort information based on user input for the default display.
array $form: The full wizard form array.
array $form_state: The current state of the wizard form.
array An array of sort arrays keyed by ID. A sort array contains the options accepted by a sort handler.
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;
}