function _term_level_extract_levels in Term Level Field 7
Extracts levels (level-key => level-label) out of the field settings.
Level-label are not yet sanitized.
3 calls to _term_level_extract_levels()
- term_level_field_settings_levels_validate in ./
term_level.module - Validates that level settings are correct.
- term_level_i18n_string_list_field_alter in ./
term_level.module - Implements hook_i18n_string_list_field_alter().
- term_level_options_list in ./
term_level.module - Implements hook_options_list().
File
- ./
term_level.module, line 364 - Field type for referencing terms with a level to an entity.
Code
function _term_level_extract_levels($level_settings) {
$levels = array();
$list = explode("\n", $level_settings);
$list = array_map('trim', $list);
$list = array_filter($list, 'strlen');
foreach ($list as $key => $value) {
if (strpos($value, '|') !== FALSE) {
list($level_key, $label) = explode('|', $value);
}
if (isset($level_key) && isset($level_key)) {
$levels[$level_key] = $label;
}
}
return $levels;
}