diff --git a/classes/Misc.php b/classes/Misc.php index 4848efb64..a84f46de3 100644 --- a/classes/Misc.php +++ b/classes/Misc.php @@ -2,7 +2,7 @@ /** * Class to hold various commonly used functions * - * $Id: Misc.php,v 1.138 2007/01/10 01:56:06 soranzo Exp $ + * $Id: Misc.php,v 1.139 2007/03/03 20:00:48 xzilla Exp $ */ class Misc { @@ -1523,6 +1523,24 @@ function printUrlVars(&$vars, &$fields) { * 'vars' => Associative array of (URL variable => field name), * ), ... * ); + * @param $multiactions Actions to be provided to a series of items defined by checkboxes + * $multiactions = array( + * 'keycols' => array('table' => 'relname'), + * 'url' => "{$PHP_SELF}", + * 'actions' => array( + * 'empty' => array( + * 'action' => 'confirm_empty', + * 'title' => $lang['strempty'], + * ), + * 'drop' => array( + * 'action' => 'confirm_drop', + * 'title' => $lang['strdrop'], + * ), + * 'vacuum' => array( + * 'action' => 'confirm_vacuum', + * 'title' => $lang['strvacuum'], + * ) + * ) * @param $nodata (optional) Message to display if data set is empty. * @param $pre_fn (optional) Name of a function to call for each row, * it will be passed two params: $rowdata and $actions, @@ -1531,8 +1549,8 @@ function printUrlVars(&$vars, &$fields) { * or if nothing is returned then the standard actions are used. * (see functions.php and constraints.php for examples) */ - function printTable(&$tabledata, &$columns, &$actions, $nodata = null, $pre_fn = null) { - global $data, $conf, $misc; + function printTable(&$tabledata, &$columns, &$actions, $nodata = null, $pre_fn = null, &$multiactions = null) { + global $data, $conf, $misc, $lang; global $PHP_SELF; if ($tabledata->recordCount() > 0) { @@ -1547,7 +1565,7 @@ function printTable(&$tabledata, &$columns, &$actions, $nodata = null, $pre_fn = // (Remove this section to keep the 'Properties' button instead of links) if (isset($actions['properties'])) { reset($columns); - $first_column = key($columns); + list($first_column) = each($columns); $columns[$first_column]['url'] = $actions['properties']['url']; $columns[$first_column]['vars'] = $actions['properties']['vars']; unset($actions['properties']); @@ -1558,10 +1576,18 @@ function printTable(&$tabledata, &$columns, &$actions, $nodata = null, $pre_fn = // TODO: This should be a user option. //$columns['comment']['params']['clip'] = true; } - + + if (isset($multiactions)) { + echo "
'; + }; return true; } else { diff --git a/lang/english.php b/lang/english.php index 1f74a46a8..b9e668a48 100755 --- a/lang/english.php +++ b/lang/english.php @@ -4,7 +4,7 @@ * English language file for phpPgAdmin. Use this as a basis * for new translations. * - * $Id: english.php,v 1.200 2007/02/10 03:48:34 xzilla Exp $ + * $Id: english.php,v 1.201 2007/03/03 20:00:48 xzilla Exp $ */ // Language and character set @@ -136,6 +136,9 @@ $lang['strfile'] = 'File'; $lang['strfileimported'] = 'File imported.'; $lang['strtrycred'] = 'Use these credentials for all servers'; + $lang['stractionsonmultiplelines'] = 'Actions on multiple lines'; + $lang['strcheckall'] = 'Check All'; + $lang['struncheckall'] = 'Uncheck All'; // Database sizes $lang['strsize'] = 'Size'; diff --git a/lang/recoded/english.php b/lang/recoded/english.php index 50c97ed35..5cd3d6800 100644 --- a/lang/recoded/english.php +++ b/lang/recoded/english.php @@ -4,7 +4,7 @@ * English language file for phpPgAdmin. Use this as a basis * for new translations. * - * $Id: english.php,v 1.152 2006/12/31 16:21:27 soranzo Exp $ + * $Id: english.php,v 1.153 2007/03/03 20:00:48 xzilla Exp $ */ // Language and character set @@ -136,6 +136,9 @@ $lang['strfile'] = 'File'; $lang['strfileimported'] = 'File imported.'; $lang['strtrycred'] = 'Use these credentials for all servers'; + $lang['stractionsonmultiplelines'] = 'Actions on multiple lines'; + $lang['strcheckall'] = 'Check All'; + $lang['struncheckall'] = 'Uncheck All'; // Database sizes $lang['strsize'] = 'Size'; @@ -872,7 +875,7 @@ $lang['strvacuumcostdelay'] = 'Vacuum Cost Delay'; $lang['strvacuumcostlimit'] = 'Vacuum Cost Limit'; - // Table-level Locks + // Table-level Locks $lang['strlocks'] = 'Locks'; $lang['strtransaction'] = 'Transaction ID'; $lang['strprocessid'] = 'Process ID'; diff --git a/multiactionform.js b/multiactionform.js new file mode 100644 index 000000000..1950608a4 --- /dev/null +++ b/multiactionform.js @@ -0,0 +1,9 @@ +function checkAll(bool) { + + var inputs = document.getElementById('multi_form').getElementsByTagName('input'); + + for (var i=0; i", sprintf($lang['strconfemptytable'], $misc->printVal($_REQUEST['table'])), "
\n"; + echo "\n"; - } - else { - $status = $data->emptyTable($_POST['table']); - if ($status == 0) - doDefault($lang['strtableemptied']); - else - doDefault($lang['strtableemptiedbad']); - } - + } // END if confirm + else { // Do Empty + if (is_array($_REQUEST['table'])) { + $msg=''; + foreach($_REQUEST['table'] as $t) { + $status = $data->emptyTable($t); + if ($status == 0) + $msg.= sprintf('%s: %s", sprintf($lang['strconfvacuumtable'], $misc->printVal($_REQUEST['table'])), "
\n"; + echo "\n"; - } + } // END single vacuum else { - $status = $data->vacuumDB($_POST['table'], isset($_REQUEST['vacuum_analyze']), isset($_REQUEST['vacuum_full']), ''); - if ($status == 0) { - $_reload_browser = true; - doDefault($lang['strvacuumgood']); + //If multi drop + if (is_array($_REQUEST['table'])) { + $msg=''; + foreach($_REQUEST['table'] as $t) { + $status = $data->vacuumDB($t, isset($_REQUEST['vacuum_analyze']), isset($_REQUEST['vacuum_full']), ''); + if ($status == 0) + $msg.= sprintf('%s: %s