function _radioactivity_oclassdef_to_form in Radioactivity 5
Same name and namespace in other branches
- 6 radioactivity-admin-ui.inc \_radioactivity_oclassdef_to_form()
1 call to _radioactivity_oclassdef_to_form()
File
- ./
radioactivity.module, line 191
Code
function _radioactivity_oclassdef_to_form($oclass, $name, $def, $sources, $energy, $level = 0) {
$form = array(
'#type' => 'fieldset',
'#tree' => TRUE,
'#collapsible' => TRUE,
'#title' => t('Energy settings for @oclass', array(
'@oclass' => $name,
)),
);
$collapsed = TRUE;
if (count($sources) == 0) {
$form['no_sources'] = array(
'#type' => 'item',
'#value' => t('You must enable at least one plug-in that provides an energy source for this target class.'),
);
}
if ($level == 0 && @is_array($def['subclasses'])) {
$form[] = array(
'#type' => 'item',
'#value' => t('The default settings for #type.', array(
'#type' => $name,
)),
);
}
elseif ($level > 0) {
$form[] = array(
'#type' => 'item',
'#value' => t('Specific settings for #type. Empty field uses setting from parent.', array(
'#type' => $name,
)),
);
}
foreach ($sources as $source => $sdef) {
@($energy_value = $energy[$source]);
$form[$source] = array(
'#type' => 'textfield',
'#title' => t('Incident energy from %s', array(
'%s' => $sdef['title_placeholder'],
)),
'#default_value' => $energy_value,
);
if (strlen($energy_value) > 0) {
$collapsed = FALSE;
}
}
if (@is_array($def['subclasses'])) {
foreach ($def['subclasses'] as $subclass => $subclassdef) {
$form['subclasses'][$subclass] = _radioactivity_oclassdef_to_form($subclass, $name . ' / ' . $subclass, $subclassdef, $sources, @$energy['subclasses'][$subclass], $level + 1);
if (!$form['subclasses'][$subclass]['#collapsed']) {
$collapsed = FALSE;
}
}
}
$form['#collapsed'] = $collapsed;
return $form;
}