function birthdays_field_views_handler_field::click_sort in Birthdays 7
Overrides views_handler_field_field::click_sort().
Overrides views_handler_field_field::click_sort
File
- views/
birthdays_field_views_handler_field.inc, line 52 - The birthdays_field_views_handler_field class.
Class
- birthdays_field_views_handler_field
- A Views field handler that provides click sorting of birthday fields.
Code
function click_sort($order) {
// Ensure the table exists.
$this
->ensure_my_table();
// Look up the real column names.
$columns = array(
'day' => NULL,
'month' => NULL,
'year' => NULL,
);
foreach ($columns as $delta => $column) {
$column = _field_sql_storage_columnname($this->definition['field_name'], $delta);
if (!isset($this->aliases[$column])) {
$this->aliases[$column] = $this->table_alias . '.' . $column;
}
$columns[$delta] = $this->aliases[$column];
}
// Add sorting to the query.
$mode = $this->options['click_sort_mode'];
if ($mode == 'all') {
$this->query
->add_orderby(NULL, NULL, $order, $columns['year']);
}
if ($mode == 'all' || $mode == 'year') {
$this->query
->add_orderby(NULL, NULL, $order, $columns['month']);
$this->query
->add_orderby(NULL, NULL, $order, $columns['day']);
}
else {
birthdays_field_views_handler_sort::addOrderBy($this->query, $order, $columns, $this->definition['field_name'] . '_sort');
}
}