You are here

function devel_variable in Devel 5

1 string reference to 'devel_variable'
devel_variable_page in ./devel.module
Menu callback; display all variables.

File

./devel.module, line 933

Code

function devel_variable() {
  $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 (has_krumo()) {
      $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;
}