function views_handler_field::get_token_values_recursive

cis7 views_handler_field.inc views_handler_field::get_token_values_recursive(array $array, array $parent_keys = array())
cle7 views_handler_field.inc views_handler_field::get_token_values_recursive(array $array, array $parent_keys = array())
elmsmedia7 views_handler_field.inc views_handler_field::get_token_values_recursive(array $array, array $parent_keys = array())
icor7 views_handler_field.inc views_handler_field::get_token_values_recursive(array $array, array $parent_keys = array())
meedjum_blog7 views_handler_field.inc views_handler_field::get_token_values_recursive(array $array, array $parent_keys = array())
mooc7 views_handler_field.inc views_handler_field::get_token_values_recursive(array $array, array $parent_keys = array())

Recursive function to add replacements for nested query string parameters.

E.g. if you pass in the following array: array( 'foo' => array( 'a' => 'value', 'b' => 'value', ), 'bar' => array( 'a' => 'value', 'b' => array( 'c' => value, ), ), );

Would yield the following array of tokens: array( '%foo_a' => 'value' '%foo_b' => 'value' '%bar_a' => 'value' '%bar_b_c' => 'value' );

Parameters

$array: An array of values.

$parent_keys: An array of parent keys. This will represent the array depth.

Return value

An array of available tokens, with nested keys representative of the array structure.

1 call to views_handler_field::get_token_values_recursive()
views_handler_field::get_render_tokens in sites/all/modules/ulmus/views/handlers/views_handler_field.inc
Get the 'render' tokens to use for advanced rendering.

File

sites/all/modules/ulmus/views/handlers/views_handler_field.inc, line 1462
@todo.

Class

views_handler_field
Base field handler that has no options and renders an unformatted field.

Code

function get_token_values_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 = $this->get_token_values_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;
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.