You are here

function features_dom_encode_options in Features 7.2

Same name and namespace in other branches
  1. 6 features.admin.inc \features_dom_encode_options()
  2. 7 features.admin.inc \features_dom_encode_options()

Make a Drupal options array safe for usage with jQuery DOM selectors.

Encodes known bad characters into __[ordinal]__ so that they may be safely referenced by JS behaviors.

Parameters

string[] $options: Format: $[$key] = $value Raw options array.

bool $keys_only: If TRUE, only the keys will be encoded, while values remain unchanged. If FALSE, both keys and values are encoded.

Return value

string[] Format, if $keys_only: $[$key_encoded] = $value Format, if !$keys_only: $[$key_encoded] = $value_encoded Encoded version of the options array.

See also

\features_dom_decode_options()

1 call to features_dom_encode_options()
_features_export_form_components in ./features.admin.inc
Adds form elements for component selection on the export form.

File

./features.admin.inc, line 1751
Forms for Features admin screens.

Code

function features_dom_encode_options($options = array(), $keys_only = TRUE) {
  $replacements = features_dom_encode_map();
  $encoded = array();
  foreach ($options as $key => $value) {
    $encoded[strtr($key, $replacements)] = $keys_only ? $value : strtr($value, $replacements);
  }
  return $encoded;
}