You are here

function views_xml_backend_handler_filter::generate in Views XML Backend 6

Same name and namespace in other branches
  1. 7 handlers/views_xml_backend_handler_filter.inc \views_xml_backend_handler_filter::generate()

File

handlers/views_xml_backend_handler_filter.inc, line 143
Base filter handler for views_xml_backend.

Class

views_xml_backend_handler_filter
@file Base filter handler for views_xml_backend.

Code

function generate() {
  $operator = $this->options['operator'];
  $xpath = $this->options['xpath_selector'];
  $value = $this->options['value'];

  // Awesome string escape.
  $value = '"' . str_replace('"', '\\"', $value) . '"';
  if ($operator == '=' || $operator == '!=') {
    return $xpath . $operator . $value;
  }
  if (strpos($operator, '!') === 0) {
    $operator = ltrim($operator, '!');
    return "not({$operator}({$xpath},{$value}))";
  }
  return "{$operator}({$xpath},{$value})";
}