You are here

function configuration_dom_encode_options in Configuration Management 7

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.

3 calls to configuration_dom_encode_options()
ConfigurationUITest::testMigrateExportUI in tests/configuration.test
Tests the "Migrate Export" page.
configuration_migrate_form in ./configuration.admin.inc
Menu Callback Form.
configuration_notracking_form in ./configuration.admin.inc
Menu Callback Form.

File

./configuration.admin.inc, line 832

Code

function configuration_dom_encode_options($options = array(), $keys_only = TRUE) {
  $replacements = array(
    ':' => '__' . ord(':') . '__',
    '/' => '__' . ord('/') . '__',
    ',' => '__' . ord(',') . '__',
    '.' => '__' . ord(',') . '__',
    '<' => '__' . ord('<') . '__',
    '>' => '__' . ord('>') . '__',
  );
  $encoded = array();
  foreach ($options as $key => $value) {
    $encoded[strtr($key, $replacements)] = $keys_only ? $value : strtr($value, $replacements);
  }
  return $encoded;
}