function devel_variable_form in Devel 7
Same name and namespace in other branches
- 6 devel.module \devel_variable_form()
Form constructor for displaying and editing variables.
See also
1 string reference to 'devel_variable_form'
- devel_menu in ./
devel.module - Implements hook_menu().
File
- ./
devel.pages.inc, line 222 - Page callbacks for Devel.
Code
function devel_variable_form() {
$header = array(
'name' => array(
'data' => t('Name'),
'field' => 'name',
'sort' => 'asc',
),
'value' => array(
'data' => t('Value'),
'field' => 'value',
),
'length' => array(
'data' => t('Length'),
'field' => 'length',
),
'edit' => array(
'data' => t('Operations'),
),
);
// @todo: We could get variables out of $conf but that would include
// hard-coded ones too. Ideally I would highlight overridden/hard-coded
// variables.
$query = db_select('variable', 'v')
->extend('TableSort');
$query
->fields('v', array(
'name',
'value',
));
switch (db_driver()) {
case 'mssql':
$query
->addExpression("LEN(v.value)", 'length');
break;
default:
$query
->addExpression("LENGTH(v.value)", 'length');
break;
}
$result = $query
->orderByHeader($header)
->execute();
foreach ($result as $row) {
// $variables[$row->name] = '';
$options[$row->name]['name'] = check_plain($row->name);
if (merits_krumo($row->value)) {
$value = krumo_ob(variable_get($row->name, NULL));
}
else {
if (drupal_strlen($row->value) > 70) {
$value = check_plain(drupal_substr($row->value, 0, 65)) . '...';
}
else {
$value = check_plain($row->value);
}
}
$options[$row->name]['value'] = $value;
$options[$row->name]['length'] = $row->length;
$options[$row->name]['edit'] = l(t('Edit'), "devel/variable/edit/{$row->name}");
}
$form['variables'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
'#empty' => t('No variables.'),
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
);
$form['#after_build'][] = 'devel_variable_form_after_build';
// krumo($form);
return $form;
}