You are here

function finder_match_operator in Finder 6

Get data about finder match methods.

Parameters

$match: The match method if a specific operator is needed.

Return value

A specific operator string if $match is set. Otherwise returns the full array of data about all match methods including operators and descriptions.

5 calls to finder_match_operator()
finder_admin_element_edit in includes/finder.admin.inc
Admin finder element add/edit page. Must have a Finder object at this point.
finder_autocomplete_form_finder_admin_element_edit_alter in modules/finder_autocomplete/finder_autocomplete.module
Implementation of hook_form_FORM_ID_alter().
finder_find_query in ./finder.module
Build basic finder query arrays.
finder_views_finder_find in modules/finder_views/finder_views.module
Implementation of hook_finder_find().
finder_views_plugin_display_finder::query in modules/finder_views/includes/finder_views_plugin_display_finder.inc

File

./finder.module, line 1410
The finder module.

Code

function finder_match_operator($match = NULL) {
  static $operators;
  if (empty($operators)) {

    // Operators use abbreviated key names because they need to be tiny in cache ID's.
    $operators = array(
      'c' => array(
        'operator' => " LIKE '%%%s%%'",
        'description' => t('<em>Contains</em> - Results <em>contain</em> the submitted values.'),
      ),
      'cw' => array(
        'operator' => " REGEXP '[[:<:]]%s[[:>:]]'",
        'description' => t('<em>Contains word</em> - Results <em>contain</em> the submitted values as whole words.'),
      ),
      'e' => array(
        'operator' => " = '%s'",
        'description' => t('<em>Equals</em> - Results must match the submitted values <em>exactly</em>.'),
      ),
      'sw' => array(
        'operator' => " LIKE '%s%%'",
        'description' => t('<em>Starts with</em> - Results must <em>start with</em> the submitted values.'),
      ),
      'ew' => array(
        'operator' => " LIKE '%%%s'",
        'description' => t('<em>Ends with</em> - Results must <em>end with</em> the submitted values.'),
      ),
      'lt' => array(
        'operator' => " < '%s'",
        'description' => t('<em>Less than</em> - Results must be <em>less than</em> the submitted values.'),
      ),
      'lte' => array(
        'operator' => " <= '%s'",
        'description' => t('<em>Less than or equals</em> - Results must be <em>less than or equal to</em> the submitted values.'),
      ),
      'gt' => array(
        'operator' => " > '%s'",
        'description' => t('<em>Greater than</em> - Results must be <em>greater than</em> the submitted values.'),
      ),
      'gte' => array(
        'operator' => " >= '%s'",
        'description' => t('<em>Greater than or equals</em> - Results must be <em>greater than or equal to</em> the submitted values.'),
      ),
      'nc' => array(
        'operator' => " NOT LIKE '%%%s%%'",
        'description' => t("<em>Doesn't contain</em> - Results <em>don't contain</em> the submitted values."),
      ),
      'ncw' => array(
        'operator' => " NOT REGEXP '[[:<:]]%s[[:>:]]'",
        'description' => t("<em>Doesn't contain word</em> - Results <em>don't contain</em> the submitted values as whole words."),
      ),
      'ne' => array(
        'operator' => " != '%s'",
        'description' => t('<em>Not equals</em> - Results must <em>not</em> match the submitted values.'),
      ),
    );
    drupal_alter('finder_match_operators', $operators);
  }
  if (!is_null($match)) {
    return $operators[$match]['operator'];
  }
  return $operators;
}