You are here

function schema_inspect in Schema 7

Same name and namespace in other branches
  1. 5 schema.module \schema_inspect()
  2. 6 schema.module \schema_inspect()

"Inspect" menu callback.

@todo Convert this into a true page callback. Somehow fieldsets do not work without being used with drupal_get_form().

1 string reference to 'schema_inspect'
schema_menu in ./schema.module
Implements hook_menu().

File

./schema.pages.inc, line 194
Page callbacks for the Schema module.

Code

function schema_inspect() {
  $build = array();
  $mods = module_list();
  sort($mods);
  $mods = array_flip($mods);
  $schema = schema_get_schema();
  $inspect = schema_dbobject()
    ->inspect();
  foreach ($inspect as $name => $table) {
    $module = isset($schema[$name]['module']) ? $schema[$name]['module'] : 'Unknown';
    if (!isset($build[$module])) {
      $build[$module] = array(
        '#type' => 'fieldset',
        '#access' => TRUE,
        '#title' => check_plain($module),
        '#collapsible' => TRUE,
        '#collapsed' => $module != 'Unknown',
        '#weight' => $module == 'Unknown' ? 0 : $mods[$module] + 1,
      );
    }
    $build[$module][$name] = array(
      '#type' => 'markup',
      '#markup' => '<textarea style="width:100%" rows="10">' . check_plain(schema_phpprint_table($name, $table)) . '</textarea>',
    );
  }
  return $build;
}