function strongarm_admin_form in Strongarm 7.2
Same name and namespace in other branches
- 6.2 strongarm.admin.inc \strongarm_admin_form()
- 6 strongarm.admin.inc \strongarm_admin_form()
Variable management strongarm form.
1 string reference to 'strongarm_admin_form'
- strongarm_menu in ./
strongarm.module - Implements hook_menu().
File
- ./
strongarm.admin.inc, line 6
Code
function strongarm_admin_form($form_state) {
global $conf;
$vars = strongarm_vars_load(TRUE, TRUE);
$form = array(
'#theme' => 'strongarm_admin_form',
);
foreach ($vars as $name => $variable) {
if ($variable->export_type & EXPORT_IN_CODE) {
$default = ctools_get_default_object('variable', $name);
// If variable value does not match global $conf, this value has been
// hardcoded (e.g. in settings.php) and has been allowed to pass
// through. It cannot be reverted.
$hardcoded = FALSE;
$restorable = FALSE;
if (isset($conf[$name]) && $conf[$name] !== $variable->value) {
$storage = t('Hardcoded');
$hardcoded = TRUE;
}
elseif (!empty($variable->in_code_only)) {
$storage = t('In code');
$restorable = TRUE;
}
elseif ($variable->value != $default->value) {
$storage = t('Overridden');
$restorable = TRUE;
}
else {
$storage = t('Saved to DB');
}
$value = $hardcoded ? $conf[$name] : $variable->value;
// If the variable is in the database and differs from its code value,
// allow administrator to revert its value.
if ($restorable) {
$form['revert']['#tree'] = TRUE;
$form['revert'][$name]['revert'] = array(
'#type' => 'checkbox',
);
$form['revert'][$name]['value'] = array(
'#type' => 'value',
'#value' => $default->value,
);
}
if (module_exists('variable') && ($info = variable_get_info($name))) {
$form['name'][$name] = array(
'#markup' => $info['title'] . '<br/>' . $name,
);
$form['storage'][$name] = array(
'#markup' => $storage,
);
$info['value'] = $variable->value;
$form['value'][$name] = array(
'#markup' => variable_format_value($info),
);
}
else {
$form['name'][$name] = array(
'#markup' => $name,
);
$form['storage'][$name] = array(
'#markup' => $storage,
);
$form['value'][$name] = array(
'#markup' => check_plain(_strongarm_readable($value)),
);
}
}
}
if (!empty($form['revert'])) {
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Restore values to DB'),
'#submit' => array(
'strongarm_admin_revert_submit',
),
);
}
return $form;
}