function _radioactivity_oclassdef_to_form in Radioactivity 6
Same name and namespace in other branches
- 5 radioactivity.module \_radioactivity_oclassdef_to_form()
1 call to _radioactivity_oclassdef_to_form()
File
- ./
radioactivity-admin-ui.inc, line 87 - Radioactivity core admin UI.
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 (isset($sdef['description'])) {
$form[$source]['#description'] = t($sdef['description']);
}
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;
}