/**
* Manage databases within a server
*
- * $Id: all_db.php,v 1.55 2007/07/16 21:27:28 ioguix Exp $
+ * $Id: all_db.php,v 1.56 2007/07/17 14:59:52 ioguix Exp $
*/
// Include application functions
}
} else {
-
echo "<p>", sprintf($lang['strconfdropdatabase'], $misc->printVal($_REQUEST['dropdatabase'])), "</p>\n";
echo "<input type=\"hidden\" name=\"dropdatabase\" value=\"", htmlspecialchars($_REQUEST['dropdatabase']), "\" />\n";
- }// END if multi drop
+ }// END if multi drop
echo "<input type=\"hidden\" name=\"action\" value=\"drop\" />\n";
echo $misc->form;
$databases = $data->getDatabases();
- $multiactions = array(
- 'keycols' => array('database' => 'datname'),
- 'url' => "",
- 'actions' => array(
- 'drop' => array(
- 'action' => 'confirm_drop',
- 'title' => $lang['strdrop'],
- )
- )
- );
-
$columns = array(
'database' => array(
'title' => $lang['strdatabase'],
);
$actions = array(
+ 'multiactions' => array(
+ 'keycols' => array('database' => 'datname'),
+ 'url' => 'all_db.php',
+ 'default' => null,
+ ),
'drop' => array(
'title' => $lang['strdrop'],
'url' => "all_db.php?action=confirm_drop&subject=database&{$misc->href}&",
'vars' => array('dropdatabase' => 'datname'),
+ 'multiaction' => 'confirm_drop',
),
'privileges' => array(
'title' => $lang['strprivileges'],
if (!$data->hasServerAdminFuncs()) unset($columns['dbsize']);
if (!isset($data->privlist['database'])) unset($actions['privileges']);
- $misc->printTable($databases, $columns, $actions, $lang['strnodatabases'], null, $multiactions);
+ $misc->printTable($databases, $columns, $actions, $lang['strnodatabases']);
echo "<p><a class=\"navlink\" href=\"all_db.php?action=create&{$misc->href}\">{$lang['strcreatedatabase']}</a></p>\n";
/**
* Class to hold various commonly used functions
*
- * $Id: Misc.php,v 1.154 2007/07/12 19:26:22 xzilla Exp $
+ * $Id: Misc.php,v 1.155 2007/07/17 14:59:52 ioguix Exp $
*/
class Misc {
* ), ...
* );
* @param $actions Actions that can be performed on each object:
- * $actions = array(
+ * $actions = array(
+ * * multi action support
+ * * parameters are serialized for each entries and given in $_REQUEST['ma']
+ * 'multiactions' => array(
+ * 'keycols' => Associative array of (URL variable => field name), // fields included in the form
+ * 'url' => URL submission,
+ * 'default' => Default selected action in the form.
+ * if null, an empty action is added & selected
+ * ),
+ * * actions *
* action_id => array(
* 'title' => Action heading,
* 'url' => Static part of URL. Often we rely
- * relative urls, usually '', or just a query string,
+ * relative urls, usually the page itself (not '' !), or just a query string,
* 'vars' => Associative array of (URL variable => field name),
+ * 'multiaction' => Name of the action to execute.
+ * Add this action to the multi action form
* ), ...
* );
- * @param $multiactions Actions to be provided to a series of items defined by checkboxes
- * $multiactions = array(
- * 'keycols' => array('table' => 'relname'),
- * 'url' => "", (See $actions['url'])
- * '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,
* (see tblproperties.php and constraints.php for examples)
* The function must not must not store urls because
* they are relative and won't work out of context.
-
*/
- function printTable(&$tabledata, &$columns, &$actions, $nodata = null, $pre_fn = null, $multiactions = null) {
+ function printTable(&$tabledata, &$columns, &$actions, $nodata = null, $pre_fn = null) {
global $data, $conf, $misc, $lang;
+ if ($has_ma = isset($actions['multiactions']))
+ $ma = $actions['multiactions'];
+ unset($actions['multiactions']);
+
if ($tabledata->recordCount() > 0) {
// Remove the 'comment' column if they have been disabled
//$columns['comment']['params']['clip'] = true;
}
- if (isset($multiactions)) {
+ if ($has_ma) {
echo "<script src=\"multiactionform.js\" type=\"text/javascript\"></script>\n";
- echo "<form id=\"multi_form\" action=\"{$multiactions['url']}\" method=\"post\" enctype=\"multipart/form-data\">\n";
- if (isset($multiactions['vars']))
- foreach ($multiactions['vars'] as $k => $v)
+ echo "<form id=\"multi_form\" action=\"{$ma['url']}\" method=\"post\" enctype=\"multipart/form-data\">\n";
+ if (isset($ma['vars']))
+ foreach ($ma['vars'] as $k => $v)
echo "<input type=\"hidden\" name=\"$k\" value=\"$v\" />";
}
echo "<table>\n";
echo "<tr>\n";
// Display column headings
- if (isset($multiactions)) echo "<th></th>";
+ if ($has_ma) echo "<th></th>";
foreach ($columns as $column_id => $column) {
switch ($column_id) {
case 'actions':
if (!isset($alt_actions)) $alt_actions =& $actions;
echo "<tr>\n";
- if (isset($multiactions)) {
- foreach ($multiactions['keycols'] as $k => $v)
+ if ($has_ma) {
+ foreach ($ma['keycols'] as $k => $v)
$a[$k] = $tabledata->fields[$v];
echo "<td class=\"data{$id}\">";
echo "<input type=\"checkbox\" name=\"ma[]\" value=\"". htmlentities(serialize($a)) ."\" />";
echo "</table>\n";
// Multi action table footer w/ options & [un]check'em all
- if (isset($multiactions)) {
+ if ($has_ma) {
+ // if default is not set or doesn't exist, set it to null
+ if (!isset($ma['default']) || !isset($actions[$ma['default']]))
+ $ma['default'] = null;
echo "<table>\n";
echo "<tr>\n";
echo "<th class=\"data\" style=\"text-align: left\" colspan=\"3\">{$lang['stractionsonmultiplelines']}</th>\n";
echo "<td class=\"data1\"> ---> </td>\n";
echo "<td class=\"data1\">\n";
echo "\t<select name=\"action\">\n";
- foreach($multiactions['actions'] as $o)
- echo "\t\t<option value=\"{$o['action']}\">{$o['title']}</option>\n";
+ if ($ma['default'] == null)
+ echo "\t\t<option value=\"\">--</option>\n";
+ foreach($actions as $k => $a)
+ if (isset($a['multiaction']))
+ echo "\t\t<option value=\"{$a['multiaction']}\"", ($ma['default'] == $k? ' selected="selected"': ''), ">{$a['title']}</option>\n";
echo "\t</select>\n";
echo "<input type=\"submit\" value=\"{$lang['strexecute']}\" />\n";
echo $misc->form;
/**
* List tables in a database
*
- * $Id: tables.php,v 1.99 2007/07/16 21:27:29 ioguix Exp $
+ * $Id: tables.php,v 1.100 2007/07/17 14:59:52 ioguix Exp $
*/
// Include application functions
$tables = $data->getTables();
- $multiactions = array(
- 'keycols' => array('table' => 'relname'),
- 'url' => 'tables.php',
- 'actions' => array(
- 'analyze' => array(
- 'action' => 'confirm_analyze',
- 'title' => $lang['stranalyze'],
- ),
- 'drop' => array(
- 'action' => 'confirm_drop',
- 'title' => $lang['strdrop'],
- ),
- 'empty' => array(
- 'action' => 'confirm_empty',
- 'title' => $lang['strempty'],
- ),
- 'vacuum' => array(
- 'action' => 'confirm_vacuum',
- 'title' => $lang['strvacuum'],
- )
- )
- );
-
$columns = array(
'table' => array(
'title' => $lang['strtable'],
);
$actions = array(
+ 'multiactions' => array(
+ 'keycols' => array('table' => 'relname'),
+ 'url' => 'tables.php',
+ 'default' => 'analyze',
+ ),
'browse' => array(
'title' => $lang['strbrowse'],
'url' => "display.php?{$misc->href}&subject=table&return_url=".urlencode("tables.php?{$misc->href}")."&return_desc=".urlencode($lang['strback'])."&",
'title' => $lang['strempty'],
'url' => "tables.php?action=confirm_empty&{$misc->href}&",
'vars' => array('table' => 'relname'),
+ 'multiaction' => 'confirm_empty',
),
'drop' => array(
'title' => $lang['strdrop'],
'url' => "tables.php?action=confirm_drop&{$misc->href}&",
'vars' => array('table' => 'relname'),
+ 'multiaction' => 'confirm_drop',
),
'vacuum' => array(
'title' => $lang['strvacuum'],
'url' => "tables.php?action=confirm_vacuum&{$misc->href}&",
'vars' => array('table' => 'relname'),
+ 'multiaction' => 'confirm_vacuum',
),
'analyze' => array(
'title' => $lang['stranalyze'],
'url' => "tables.php?action=confirm_analyze&{$misc->href}&",
'vars' => array('table' => 'relname'),
+ 'multiaction' => 'confirm_analyze',
),
);
if (!$data->hasAnalyze()) unset($actions['analyze'], $multiactions['actions']['analyze']);
if (!$data->hasTablespaces()) unset($columns['tablespace']);
- $misc->printTable($tables, $columns, $actions, $lang['strnotables'], null, $multiactions);
+ $misc->printTable($tables, $columns, $actions, $lang['strnotables']);
echo "<p><a class=\"navlink\" href=\"tables.php?action=create&{$misc->href}\">{$lang['strcreatetable']}</a></p>\n";
}