views_handler_sort.inc in Views (for Drupal 7) 6.2
File
handlers/views_handler_sort.inc
View source
<?php
class views_handler_sort extends views_handler {
function query() {
$this
->ensure_my_table();
$this->query
->add_orderby($this->table_alias, $this->real_field, $this->options['order']);
}
function option_definition() {
$options = parent::option_definition();
$options['order'] = array(
'default' => 'ASC',
);
return $options;
}
function admin_summary() {
switch ($this->options['order']) {
case 'ASC':
case 'asc':
default:
$type = t('asc');
break;
case 'DESC':
case 'desc':
$type = t('desc');
break;
}
return '<span class="views-ascending"><span>' . $type . '</span></span>';
}
function options_form(&$form, &$form_state) {
$form['order'] = array(
'#type' => 'radios',
'#title' => t('Sort order'),
'#options' => array(
'ASC' => t('Ascending'),
'DESC' => t('Descending'),
),
'#default_value' => $this->options['order'],
);
}
}
class views_handler_sort_broken extends views_handler_sort {
function ui_name($short = FALSE) {
return t('Broken/missing handler');
}
function ensure_my_table() {
}
function query() {
}
function options_form(&$form, &$form_state) {
$form['markup'] = array(
'#prefix' => '<div class="form-item description">',
'#value' => t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.'),
);
}
function broken() {
return TRUE;
}
}