views_handler_sort_null_field.inc in Views Sort Null Field 7
File
views_handler_sort_null_field.inc
View source
<?php
class views_handler_sort_null_field extends views_handler_sort {
function sort_options() {
return array(
'ASC' => t('Sort NULL last'),
'DESC' => t('Sort NULL first'),
);
}
function admin_summary() {
if (!empty($this->options['exposed'])) {
return t('Exposed');
}
switch ($this->options['order']) {
case 'ASC':
case 'asc':
default:
return t('NULL last');
break;
case 'DESC':
case 'desc':
return t('NULL first');
break;
}
}
function query() {
$this
->ensure_my_table();
$alias = implode('_', array(
$this->table_alias,
$this->real_field,
'isnull',
));
$this->query
->add_orderby(NULL, "{$this->table_alias}.{$this->real_field} IS NULL", $this->options['order'], $alias);
}
}