You are here

function contextual_range_filter_split in Views Contextual Range Filter 7

Split a filter range string into an array containing "from" and "to" values.

Parameters

string $range: format "from--to", "from--" or "--to". A single value is also allowed. A single colon is accepted instead of --

Return value

array array of length 2, the 2nd value equals FALSE when no separator was found

2 calls to contextual_range_filter_split()
contextual_range_filter_build_range_query in views/contextual_range_filter.views.inc
Add to the query a WHERE-clause based on the range(s) passed in.
contextual_range_filter_explode_list_range in ./contextual_range_filter.module
Return values of a list range as an array.

File

./contextual_range_filter.module, line 54
contextual_range_filter.module

Code

function contextual_range_filter_split($range) {

  // Defensive programming to make sure we have a string.
  if (is_array($range)) {
    $range = reset($range);
  }
  $range = trim($range);
  $from_to = explode(CONTEXTUAL_RANGE_FILTER_SEPARATOR1, $range);
  if (count($from_to) < 2) {
    $from_to = explode(CONTEXTUAL_RANGE_FILTER_SEPARATOR2, $range);
  }
  return count($from_to) == 1 ? array(
    reset($from_to),
    FALSE,
  ) : $from_to;
}