I have tryed to convert the database overview according to the new forms api: it ssems to work now, but some more testing needed.
May be the forms api is not the best choise for impelemting such complex dynamic forms:
function dba_database_overview() {
$rows = array();
$database = dba_get_database();
drupal_set_title(t('View database \'%database\'', array('%database' => "$database")));
// it'd be great to use the pager and tablesort, but doesn't appear possible
$header = array('', t('tables'), t('rows'), t('actions'));
$tables = dba_get_tables();
$form['table_options'] = array(
'#type' => 'fieldset',
'#title' => t('Database Tables'),
'#collapsible' => FALSE,
'#collapsed' => FALSE
);
foreach ($tables as $table) {
$action = NULL;
$count = dba_get_row_count($table);
$action = '['. l(t('view'), "admin/database/table/$table/view", array('title' => t('View all rows of table \'%table\'', array('%table' => "$table")))) .']';
$action .= ' ['. l(t('describe'), "admin/database/table/$table/describe", array('title' => t('Describe table \'%table\'', array('%table' => "$table")))) .']';
$action .= _is_mysql() ? ' ['. l(t('check'), "admin/database/table/$table/check", array('title' => t('Check integrity of table \'%table\'', array('%table' => "$table")))) .']' : '';
if (user_access('dba administer database')) {
$action .= ' ['. l(t('backup'), "admin/database/table/$table/backup", array('title' => t('Backup all data from table \'%table\' to file', array('%table' => "$table")))) .']';
$action .= ' ['. l(t('empty'), "admin/database/table/$table/empty", array('title' => t('Delete all rows from table \'%table\'', array('%table' => "$table")))) .']';
$action .= ' ['. l(t('drop'), "admin/database/table/$table/drop", array('title' => t('Drop table \'%table\'', array('%table' => "$table")))) .']';
//$checkbox = form_checkbox('', $table, 1, $edit['$table']);
}
//$rows[] = array($checkbox, $table, $count, $action);
$form['table_options'][$table] = array(
'#type' => 'checkbox',
'#title' => '',
'#default_value' => 0,
'#description' => $table . ', ' . $count . ' rows. ' . $action
);
}
//$output .= theme('table', $header, $rows);
//$output .= _is_mysql() ? form_submit(t('Check')) : '';
if ( _is_mysql() ) {
$form['table_options']['Check'] = array(
'#type' => 'submit',
'#value' => 'Check'
);
}
if (user_access('dba administer database')) {
//$output .= form_submit(t('Backup'));
//$output .= form_submit(t('Empty'));
//$output .= form_submit(t('Drop'));
$form['table_options']['Backup'] = array(
'#type' => 'submit',
'#value' => 'Backup'
);
$form['table_options']['Empty'] = array(
'#type' => 'submit',
'#value' => 'Empty'
);
$form['table_options']['Drop'] = array(
'#type' => 'submit',
'#value' => 'Drop'
);
}
$output= drupal_get_form('admin/database', $form);
return $output;
}
Comments
Comment #1
dwwagain, please post patch files, instead of pasting a new copy of a given function. it makes it easier for others to review and test your changes, and makes it easier for dba maintainers to apply your changes.
http://drupal.org/patch
thanks for your help porting DBA to 4.7!
-derek
Comment #2
aam commentedI have made a patch based on the current cvs version, but some more testing and code adjustments needed...
May be a field set is good for usability too:
Comment #3
aam commentedand once again the issue status...
Comment #4
dwwthis patch is completely broken. :(
i'm working on a new version now.
Comment #5
dwwthis is a mostly working version of the admin/database overview page for 4.7.x. it's still got a few // TODO items, but i wanted to post what i've got so far. in particular, the overview stuff doesn't work correctly for "Check" or "Empty" operations. however, "Backup", "Drop" and "Optimize" are done, and the plumbing is in place to get "Check" and "Empty" working, too.
in addition to getting the crazy FAPI stuff to work right for this whole mess, i did a bunch of cleanup of related code (improper translation and theme stuff, obfuscated ways of declaring the menu items, etc, etc). so, it's turning into a giant, monolithic patch, which i usually don't like doing. but in this case, the scale of the changes required to get this working with 4.7.x FAPI required a pretty huge redesign of some of the code, and it seemed dumb to leave all the translation and theme stuff broken as i was changing the code, anyway.
Comment #6
dwwupon futher consideration, this issue really is duplicate with http://drupal.org/node/40661.
since that's the older issue, i'm marking this as the duplicate and moving my efforts there...