You are here

function schema_inspect in Schema 5

Same name and namespace in other branches
  1. 6 schema.module \schema_inspect()
  2. 7 schema.pages.inc \schema_inspect()
1 string reference to 'schema_inspect'
schema_menu in ./schema.module

File

./schema.module, line 664

Code

function schema_inspect() {
  $mods = module_list();
  sort($mods);
  $mods = array_flip($mods);
  $schema = drupal_get_schema(NULL, TRUE);
  $inspect = schema_invoke('inspect');
  foreach ($inspect as $name => $table) {
    $module = isset($schema[$name]) ? $schema[$name]['module'] : 'Unknown';
    if (!isset($form[$module])) {
      $form[$module] = array(
        '#type' => 'fieldset',
        '#access' => TRUE,
        '#title' => check_plain($module),
        '#collapsible' => TRUE,
        '#collapsed' => $module != 'Unknown',
        '#weight' => $module == 'Unknown' ? 0 : $mods[$module] + 1,
        '#value' => '',
      );
    }
    $form[$module][$name] = array(
      '#type' => 'markup',
      '#value' => '<textarea style="width:100%" rows="10">' . check_plain(schema_phpprint_table($name, $table)) . '</textarea>',
    );
  }
  $output = <<<EOT
<p>This page shows the live database schema as it currently
exists on this system.  Known tables are grouped by the module that
defines them; unknown tables are all grouped together.</p>

<p>To implement hook_schema() for a module that has existing tables, copy
the schema structure for those tables directly into the module's
hook_schema() and return \$schema.</p>
EOT;
  $output .= drupal_render($form);
  return $output;
}