You are here

function contextual_range_filter_explode_list_range in Views Contextual Range Filter 7

Return values of a list range as an array.

Parameters

string $range: in format parseable by contextual_range_filter()

array $allowed_values: the allowed values

Return value

array|bool array of keys into $allowed_values array, or FALSE when range 'from' was not found

1 call to contextual_range_filter_explode_list_range()
contextual_range_filter_handler_argument_list_range::query in views/contextual_range_filter_handler_argument_list_range.inc
Help build the query.

File

./contextual_range_filter.module, line 79
contextual_range_filter.module

Code

function contextual_range_filter_explode_list_range($range, $allowed_values) {
  list($from, $to) = contextual_range_filter_split($range);
  $from = strtolower($from);
  if ($to === FALSE) {
    $to = $from;
  }
  else {
    $to = strtolower($to);
  }
  foreach ($allowed_values as $key => $value) {
    $value = strtolower($value);
    if (empty($from) || $key == $from || $value == $from) {

      // Found the from value, start collecting keys.
      $keys = array();
    }
    if (isset($keys)) {
      $keys[] = $key;
    }
    if (!empty($to) && ($key == $to || $value == $to)) {
      return $keys;
    }
  }
  return isset($keys) ? $keys : FALSE;
}