You are here

function views_raw_sql_get_query_tokens_recursive in Views Raw SQL 7

Get recursive tokens from $_GET value. Straight copy from \views_handler_field::get_token_values_recursive().

1 call to views_raw_sql_get_query_tokens_recursive()
views_raw_sql_get_query_tokens in ./views_raw_sql.module
Get query tokens. Nearly straight copy (without self tokens) from \views_handler_field::get_render_tokens().

File

./views_raw_sql.module, line 152

Code

function views_raw_sql_get_query_tokens_recursive(array $array, array $parent_keys = array()) {
  $tokens = array();
  foreach ($array as $param => $val) {
    if (is_array($val)) {

      // Copy parent_keys array, so we don't afect other elements of this iteration.
      $child_parent_keys = $parent_keys;
      $child_parent_keys[] = $param;

      // Get the child tokens.
      $child_tokens = views_raw_sql_get_query_tokens_recursive($val, $child_parent_keys);

      // Add them to the current tokens array.
      $tokens += $child_tokens;
    }
    else {

      // Create a token key based on array element structure.
      $token_string = !empty($parent_keys) ? implode('_', $parent_keys) . '_' . $param : $param;
      $tokens['%' . $token_string] = strip_tags(decode_entities($val));
    }
  }
  return $tokens;
}