function devel_variable_form

Same name in other branches
  1. 7.x-1.x devel.pages.inc \devel_variable_form()
1 string reference to 'devel_variable_form'
devel_variable_page in ./devel.module
Menu callback; display all variables.

File

./devel.module, line 1333

Code

function devel_variable_form() {
    $header = array(
        array(
            '',
        ),
        array(
            'data' => t('Name'),
            'field' => 'name',
            'sort' => 'asc',
        ),
        array(
            'data' => t('Value'),
            'field' => 'value',
        ),
        array(
            'data' => t('Length'),
            'field' => 'length',
        ),
        array(
            'data' => t('Operations'),
        ),
    );
    // TODO: we could get variables out of $conf but that would include hard coded ones too. ideally i would highlight overrridden/hard coded variables
    switch ($GLOBALS['db_type']) {
        case 'mssql':
            $sql = "SELECT *, COL_LENGTH('{variable}', 'value') AS length FROM {variable}";
            break;
        default:
            $sql = "SELECT *, LENGTH(value) AS length FROM {variable}";
            break;
    }
    $result = db_query($sql . tablesort_sql($header));
    while ($row = db_fetch_object($result)) {
        $variables[$row->name] = '';
        $form['name'][$row->name] = array(
            '#value' => 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);
            }
        }
        $form[$row->name]['value'] = array(
            '#value' => $value,
        );
        $form[$row->name]['length'] = array(
            '#value' => $row->length,
        );
        $form[$row->name]['edit'] = array(
            '#value' => l(t('edit'), "devel/variable/edit/{$row->name}"),
        );
    }
    $form['variables'] = array(
        '#type' => 'checkboxes',
        '#options' => $variables,
    );
    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Delete'),
    );
    return $form;
}