You are here

class views_handler_filter_block_cache in Views Hacks 6

Same name and namespace in other branches
  1. 7 views_block/handlers/views_handler_filter_block_cache.inc \views_handler_filter_block_cache

Filter based on block cache settings.

Hierarchy

Expanded class hierarchy of views_handler_filter_block_cache

1 string reference to 'views_handler_filter_block_cache'
views_block_views_data in views_block/views_block.views.inc
Implementation of hook_views_data()

File

views_block/handlers/views_handler_filter_block_cache.inc, line 6

View source
class views_handler_filter_block_cache extends views_handler_filter {
  var $no_single = TRUE;
  function admin_summary() {
    if (!empty($this->options['exposed'])) {
      return t('exposed');
    }
    return parent::admin_summary();
  }
  function value_form(&$form, &$form_state) {
    $options = array(
      BLOCK_NO_CACHE => 'BLOCK_NO_CACHE',
      BLOCK_CACHE_PER_ROLE => 'BLOCK_CACHE_PER_ROLE',
      BLOCK_CACHE_PER_USER => 'BLOCK_CACHE_PER_USER',
      BLOCK_CACHE_PER_PAGE => 'BLOCK_CACHE_PER_PAGE',
      BLOCK_CACHE_GLOBAL => 'BLOCK_CACHE_GLOBAL',
    );
    $form['value'] = array(
      '#type' => 'checkboxes',
      '#options' => $options,
    );
  }
  function query() {
    $this
      ->ensure_my_table();
    if (in_array(BLOCK_NO_CACHE, $this->value)) {
      $this->query
        ->add_where($this->options['group'], "{$this->table_alias}.{$this->real_field} = %d", BLOCK_NO_CACHE);
    }
    else {
      $val = 0;
      if (!empty($this->value)) {
        foreach ($this->value as $bit) {
          $val |= $bit;
        }
      }
      $this->query
        ->add_where($this->options['group'], "{$this->table_alias}.{$this->real_field} & %d = %d", $val, $val);
      $this->query
        ->add_where($this->options['group'], "{$this->table_alias}.{$this->real_field} != %d", BLOCK_NO_CACHE);
    }
  }

}

Members