function views_handler_filter_string::operators

This kind of construct makes it relatively easy for a child class to add or remove functionality by overriding this function and adding/removing items from this array.

4 calls to views_handler_filter_string::operators()
views_handler_filter_combine::query in handlers/views_handler_filter_combine.inc
Add this filter to the query.
views_handler_filter_string::operator_options in handlers/views_handler_filter_string.inc
Build strings from the operators() for 'select' options.
views_handler_filter_string::operator_values in handlers/views_handler_filter_string.inc
views_handler_filter_string::query in handlers/views_handler_filter_string.inc
Add this filter to the query.

File

handlers/views_handler_filter_string.inc, line 37

Class

views_handler_filter_string
Basic textfield filter to handle string filtering commands including equality, like, not like, etc.

Code

public function operators() {
    $operators = array(
        '=' => array(
            'title' => t('Is equal to'),
            'short' => t('='),
            'method' => 'op_equal',
            'values' => 1,
        ),
        '!=' => array(
            'title' => t('Is not equal to'),
            'short' => t('!='),
            'method' => 'op_equal',
            'values' => 1,
        ),
        'contains' => array(
            'title' => t('Contains'),
            'short' => t('contains'),
            'method' => 'op_contains',
            'values' => 1,
        ),
        'word' => array(
            'title' => t('Contains any word'),
            'short' => t('has word'),
            'method' => 'op_word',
            'values' => 1,
        ),
        'allwords' => array(
            'title' => t('Contains all words'),
            'short' => t('has all'),
            'method' => 'op_word',
            'values' => 1,
        ),
        'starts' => array(
            'title' => t('Starts with'),
            'short' => t('begins'),
            'method' => 'op_starts',
            'values' => 1,
        ),
        'not_starts' => array(
            'title' => t('Does not start with'),
            'short' => t('not_begins'),
            'method' => 'op_not_starts',
            'values' => 1,
        ),
        'ends' => array(
            'title' => t('Ends with'),
            'short' => t('ends'),
            'method' => 'op_ends',
            'values' => 1,
        ),
        'not_ends' => array(
            'title' => t('Does not end with'),
            'short' => t('not_ends'),
            'method' => 'op_not_ends',
            'values' => 1,
        ),
        'not' => array(
            'title' => t('Does not contain'),
            'short' => t('!has'),
            'method' => 'op_not',
            'values' => 1,
        ),
        'shorterthan' => array(
            'title' => t('Length is shorter than'),
            'short' => t('shorter than'),
            'method' => 'op_shorter',
            'values' => 1,
        ),
        'longerthan' => array(
            'title' => t('Length is longer than'),
            'short' => t('longer than'),
            'method' => 'op_longer',
            'values' => 1,
        ),
    );
    // If the definition allows for the empty operator, add it.
    if (!empty($this->definition['allow empty'])) {
        $operators += array(
            'empty' => array(
                'title' => t('Is empty (NULL)'),
                'method' => 'op_empty',
                'short' => t('empty'),
                'values' => 0,
            ),
            'not empty' => array(
                'title' => t('Is not empty (NOT NULL)'),
                'method' => 'op_empty',
                'short' => t('not empty'),
                'values' => 0,
            ),
        );
    }
    // Add regexp support for MySQL.
    if (Database::getConnection()->databaseType() == 'mysql') {
        $operators += array(
            'regular_expression' => array(
                'title' => t('Regular expression'),
                'short' => t('regex'),
                'method' => 'op_regex',
                'values' => 1,
            ),
            'not_regular_expression' => array(
                'title' => t('Not regular expression'),
                'short' => t('not regex'),
                'method' => 'op_not_regex',
                'values' => 1,
            ),
        );
    }
    return $operators;
}