MDL-14679 ok, here is the big patch with new dmllib and ddlib API, some code is already converted, XML db editor works; see tracker for details of regressions and TODOs

This commit is contained in:
skodak
2008-05-15 21:40:00 +00:00
parent 469dcbcc8b
commit f33e1ed4ae
112 changed files with 8225 additions and 6596 deletions
@@ -58,7 +58,8 @@ class view_structure_sql extends XMLDBAction {
$this->does_generate = ACTION_GENERATE_HTML;
/// These are always here
global $CFG, $XMLDB;
global $CFG, $XMLDB, $DB;
$dbman = $DB->get_manager();
/// Do the job, setting result as needed
/// Get the dir containing the file
@@ -77,23 +78,6 @@ class view_structure_sql extends XMLDBAction {
}
/// ADD YOUR CODE HERE
/// Get parameters
$generatorparam = optional_param('generator', null, PARAM_ALPHANUM);
if (empty($generatorparam)) {
$generatorparam = $CFG->dbtype;
}
/// Calculate list of available SQL generators
$plugins = get_list_of_plugins('lib/xmldb/classes/generators');
$generators = array();
foreach($plugins as $plugin) {
$generators[$plugin] = $plugin;
}
/// Check we have the selected generator
if (!in_array($generatorparam, $generators)) {
$generatorparam = reset($generators);
}
/// The back to edit table button
$b = ' <p class="centerpara buttons">';
$b .= '<a href="index.php?action=edit_xml_file&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['back'] . ']</a>';
@@ -101,15 +85,10 @@ class view_structure_sql extends XMLDBAction {
$o = $b;
$o.= ' <table id="formelements" class="boxaligncenter" cellpadding="5">';
$o.= ' <tr><td align="center">' . $this->str['selectdb'];
/// Show the popup of generators
$url = 'index.php?action=view_structure_sql&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&amp;generator=';
$o.= popup_form($url, $generators, 'selectgenerator', $generatorparam, '', '', '' , true);
$o.= ' </td></tr>';
$o.= ' <tr><td><textarea cols="80" rows="32">';
/// Get an array of statements
if ($starr = $structure->getCreateStructureSQL($generatorparam, $CFG->prefix)) {
if ($starr = $DB->get_manager()->generator->getCreateStructureSQL($structure)) {
$starr = $dbman->generator->getEndedStatements($starr);
$sqltext = '';
foreach ($starr as $st) {
$sqltext .= s($st) . "\n\n";