You are here

function _key_element_expand in Key 7

Same name and namespace in other branches
  1. 7.2 key.module \_key_element_expand()

Process function to expand the key element.

1 string reference to '_key_element_expand'
key_element_info in ./key.module
Implements hook_element_info().

File

./key.module, line 114
Provides the ability to manage keys, which can be used by other modules.

Code

function _key_element_expand($element) {
  $element['#options'] = key_get_configs_as_options();
  if (!empty($element['#filters'])) {
    $element['#options'] = _key_configs_filter($element['#options'], $element['#filters']);
  }

  // Prefix the default description with a information about keys.
  if ($element['#key_description']) {
    $key_description = t('Choose an available key to use.');
    if (module_exists('key_ui')) {
      $key_description .= ' ' . t('If your key is not listed, <a href="@url">create a new key</a>.', array(
        '@url' => '/' . KEY_MENU_PATH,
      ));
    }
    else {
      $key_description .= ' ' . t('If your key is not listed, enable the Keys UI module and create a new key.');
    }
    $element['#description'] = $key_description . ' ' . $element['#description'];
  }
  return $element;
}