public function views_handler_field_publication_date::query in Publication Date 7.2
Called to add the field to a query.
Overrides views_handler_field::query
File
- includes/
views_handler_field_publication_date.inc, line 52 - Definition of views_handler_field_publication_date.
Class
- views_handler_field_publication_date
- A handler to provide proper displays for publication dates.
Code
public function query() {
$this
->ensure_my_table();
$params = $this->options['group_type'] != 'group' ? array(
'function' => $this->options['group_type'],
) : array();
if ($this->options['null_date'] == 'null') {
$field_name = $this->real_field;
$field = $this->table_alias . '.' . $field_name;
}
else {
$field_name = $this->real_field . '_or_' . $this->options['null_date'];
switch ($this->options['null_date']) {
case 'now':
$alt_value = REQUEST_TIME;
break;
case 'created':
$alt_value = "node.created";
break;
case 'changed':
$alt_value = "node.changed";
break;
}
$field = "COALESCE({$this->table_alias}.{$this->real_field}, {$alt_value})";
}
// Add the field.
$this->field_alias = $this->query
->add_field(NULL, $field, $this->table_alias . '_' . $field_name, $params);
$this
->add_additional_fields();
}