home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (views_handler_filter_group_by_numeric.inc)

This example Drupal source code file (views_handler_filter_group_by_numeric.inc) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

array, false, field, function, if, info, is, operator, php, placeholder, placeholder_max, placeholder_min, return, short

The views_handler_filter_group_by_numeric.inc Drupal example source code

<?php
// $Id: views_handler_filter_group_by_numeric.inc,v 1.1.4.7 2011/01/04 00:55:39 dereine Exp $

/**
 * Simple filter to handle greater than/less than filters
 */
class views_handler_filter_group_by_numeric extends views_handler_filter_numeric {
  function query() {
    $this->ensure_my_table();
    $field = $this->get_field();

    $info = $this->operators();
    if (!empty($info[$this->operator]['method'])) {
      $this->{$info[$this->operator]['method']}($field);
    }
  }
  function op_between($field) {
    $placeholder = $this->placeholder();
    if ($this->operator == 'between') {
      $this->query->add_having_expression($this->options['group'], "$field >= $placeholder", array($placeholder => $this->value['min']));
      $this->query->add_having_expression($this->options['group'], "$field <= $placeholder", array($placeholder => $this->value['max']));
    }
    else {
      $placeholder_min = $placeholder;
      $placeholder_max = $this->placeholder();
      $this->query->add_having_expression($this->options['group'], "$field <= $placeholder_min OR $field >= $placeholder_max", array($placeholder_min => $this->value['min'], $placeholder_max => $this->value['max']));
    }
  }

  function op_simple($field) {
    $placeholder = $this->placeholder();
    $this->query->add_having_expression($this->options['group'], "$field $this->operator $placeholder", array($placeholder => $this->value['value']));
  }

  function op_empty($field) {
    if ($this->operator == 'empty') {
      $operator = "IS NULL";
    }
    else {
      $operator = "IS NOT NULL";
    }

    $this->query->add_having_expression($this->options['group'], "$field $operator");
  }

  function ui_name($short = FALSE) {
    return $this->get_field(parent::ui_name($short));
  }

  function can_group() { return FALSE; }
}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal views_handler_filter_group_by_numeric.inc source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.