function fraction_handler_filter_decimal::query in Fraction 7
Add this filter to the query.
Due to the nature of fapi, the value and the operator have an unintended level of indirection. You will find them in $this->operator and $this->value respectively.
Overrides views_handler_filter_numeric::query
File
- views/
handlers/ fraction_handler_filter_decimal.inc, line 14 - Contains the Fraction Views filter handler.
Class
- fraction_handler_filter_decimal
- Filter handler for Fraction fields.
Code
function query() {
// Ensure the main table for this field is included.
$this
->ensure_my_table();
// Formula for calculating the final value, by dividing numerator by denominator.
// These are added as additional fields in hook_field_views_data_alter().
$formula = $this->table_alias . '.' . $this->definition['additional fields']['numerator'] . ' / ' . $this->table_alias . '.' . $this->definition['additional fields']['denominator'];
// Perform the filter using the selected operator and the formula.
$info = $this
->operators();
if (!empty($info[$this->operator]['method'])) {
$this
->{$info[$this->operator]['method']}($formula);
}
}