IMPORTANT: printVal prototype has changed - all calls have been fixed though.
/**
* Manage aggregates in a database
*
- * $Id: aggregates.php,v 1.6 2004/07/13 15:24:40 jollytoad Exp $
+ * $Id: aggregates.php,v 1.7 2004/07/13 16:13:15 jollytoad Exp $
*/
// Include application functions
global $data, $conf, $misc;
global $lang;
- function aggPre(&$rowdata) {
- global $data, $lang;
- $rowdata->f['+argtypes'] = is_null($rowdata->f['proargtypes']) ? $lang['stralltypes'] : $rowdata->f['proargtypes'];
- }
-
$misc->printTitle(array($misc->printVal($_REQUEST['database']), $lang['straggregates']), 'aggregates');
$misc->printMsg($msg);
),
'type' => array(
'title' => $lang['strtype'],
- 'field' => '+argtypes',
+ 'field' => 'proargtypes',
+ 'params'=> array('null' => $lang['stralltypes']),
),
'comment' => array(
'title' => $lang['strcomment'],
$actions = array();
- $misc->printTable($aggregates, $columns, $actions, $lang['strnoaggregates'], 'aggPre');
+ $misc->printTable($aggregates, $columns, $actions, $lang['strnoaggregates']);
}
$misc->printHeader($lang['straggregates']);
/**
* Manage casts in a database
*
- * $Id: casts.php,v 1.7 2004/07/13 15:24:40 jollytoad Exp $
+ * $Id: casts.php,v 1.8 2004/07/13 16:13:15 jollytoad Exp $
*/
// Include application functions
global $data, $misc, $database;
global $PHP_SELF, $lang;
- function castPre(&$rowdata) {
- global $data, $lang;
- $rowdata->f['+castfunc'] = is_null($rowdata->f['castfunc']) ? $lang['strbinarycompat'] : $rowdata->f['castfunc'];
- switch ($rowdata->f['castcontext']) {
- case 'e':
- $rowdata->f['+castcontext'] = $lang['strno'];
- break;
- case 'a':
- $rowdata->f['+castcontext'] = $lang['strinassignment'];
- break;
- default:
- $rowdata->f['+castcontext'] = $lang['stryes'];
+ function renderCastContext($val) {
+ global $lang;
+ switch ($val) {
+ case 'e': return $lang['strno'];
+ case 'a': return $lang['strinassignment'];
+ default: return $lang['stryes'];
}
}
),
'function' => array(
'title' => $lang['strfunction'],
- 'field' => '+castfunc',
+ 'field' => 'castfunc',
+ 'params'=> array('null' => $lang['strbinarycompat']),
),
'implicit' => array(
'title' => $lang['strimplicit'],
- 'field' => '+castcontext',
- 'type' => 'verbatim',
+ 'field' => 'castcontext',
+ 'type' => 'callback',
+ 'params'=> array('function' => 'renderCastContext', 'align' => 'center'),
),
);
$actions = array();
- $misc->printTable($casts, $columns, $actions, $lang['strnocasts'], 'castPre');
+ $misc->printTable($casts, $columns, $actions, $lang['strnocasts']);
}
$misc->printHeader($lang['strcasts']);
/**
* Class to hold various commonly used functions
*
- * $Id: Misc.php,v 1.72 2004/07/13 15:24:40 jollytoad Exp $
+ * $Id: Misc.php,v 1.73 2004/07/13 16:13:14 jollytoad Exp $
*/
class Misc {
}
/**
- * Replace all spaces with in a string
+ * Render a value into HTML using formatting rules specified
+ * by a type name and parameters.
+ *
* @param $str The string to change
- * @param $shownull True to show NULLs, false otherwise
- * @param $type Field type if available, other NULL
- * @return The string with replacements
+ *
+ * @param $type Field type (optional), this may be an internal PostgreSQL type, or:
+ * yesno - same as bool, but renders as 'Yes' or 'No'.
+ * pre - render in a <pre> block.
+ * nbsp - replace all spaces with 's
+ * verbatim - render exactly as supplied, no escaping what-so-ever.
+ * callback - render using a callback function supplied in the 'function' param.
+ *
+ * @param $params Type parameters (optional), known parameters:
+ * null - string to display if $str is null, or set to TRUE to use a default 'NULL' string,
+ * otherwise nothing is rendered.
+ * clip - if true, clip the value to a fixed length, and append an ellipsis...
+ * cliplen - the maximum length when clip is enabled (defaults to $conf['max_chars'])
+ * ellipsis - the string to append to a clipped value (defaults to $lang['strellipsis'])
+ * tag - an HTML element name to surround the value.
+ * class - a class attribute to apply to any surrounding HTML element.
+ * align - an align attribute ('left','right','center' etc.)
+ * true - (type='bool') the representation of true.
+ * false - (type='bool') the representation of false.
+ * function - (type='callback') a function name, accepts args ($str, $params) and returns a rendering.
+ *
+ * @return The HTML rendered value
*/
- function printVal($str, $shownull = false, $type = null) {
- global $lang;
-
- // If the string contains at least one instance of >1 space in a row, a tab character, a
- // space at the start of a line, or a space at the start of the whole string then
- // substitute all spaces for s
- if ($str === null && $shownull) return '<i>NULL</i>';
- elseif ($str) {
- switch ($type) {
- case 'int2':
- case 'int4':
- case 'int8':
- case 'float4':
- case 'float8':
- case 'money':
- case 'numeric':
- case 'oid':
- case 'xid':
- case 'cid':
- case 'tid':
- return "<div align=\"right\">" . nl2br(htmlspecialchars($str)) . "</div>";
- break;
- case 'bool':
- case 'boolean':
- if ($str == 't') return $lang['strtrue'];
- elseif ($str == 'f') return $lang['strfalse'];
- else return nl2br(htmlspecialchars($str));
- break;
- case 'bytea':
- // addCSlashes converts all weird ASCII characters to octal representation,
- // EXCEPT the 'special' ones like \r \n \t, etc.
- return htmlspecialchars(addCSlashes($str, "\0..\37\177..\377"));
- break;
- default:
- if (strstr($str, ' ') || strstr($str, "\t") || strstr($str, "\n ") || $str{0} == ' ') {
- $str = str_replace(' ', ' ', htmlspecialchars($str));
- // Replace tabs with 8 spaces
- $str = str_replace("\t", ' ', $str);
- return nl2br($str);
- }
- else
- return nl2br(htmlspecialchars($str));
- }
- } else
- return '';
+ function printVal($str, $type = null, $params = array()) {
+ global $lang, $conf;
+
+ // Shortcircuit for a NULL value
+ if (is_null($str))
+ return isset($params['null'])
+ ? ($params['null'] === true ? '<i>NULL</i>' : $params['null'])
+ : '';
+
+ // Clip the value if the 'clip' parameter is true.
+ if (isset($params['clip']) && $params['clip'] === true) {
+ $maxlen = isset($params['cliplen']) && is_integer($params['cliplen']) ? $params['cliplen'] : $conf['max_chars'];
+ $ellipsis = isset($params['ellipsis']) ? $params['ellipsis'] : $lang['strellipsis'];
+ if (strlen($str) > $maxlen) {
+ $str = substr($str, 0, $maxlen-1) . $ellipsis;
+ }
+ }
+
+ $out = '';
+
+ switch ($type) {
+ case 'int2':
+ case 'int4':
+ case 'int8':
+ case 'float4':
+ case 'float8':
+ case 'money':
+ case 'numeric':
+ case 'oid':
+ case 'xid':
+ case 'cid':
+ case 'tid':
+ $align = 'right';
+ $out = nl2br(htmlspecialchars($str));
+ break;
+ case 'yesno':
+ if (!isset($params['true'])) $params['true'] = $lang['stryes'];
+ if (!isset($params['false'])) $params['false'] = $lang['strno'];
+ // No break - fall through to boolean case.
+ case 'bool':
+ case 'boolean':
+ if (is_bool($str)) $str = $str ? 't' : 'f';
+ switch ($str) {
+ case 't':
+ $out = (isset($params['true']) ? $params['true'] : $lang['strtrue']);
+ $align = 'center';
+ break;
+ case 'f':
+ $out = (isset($params['false']) ? $params['false'] : $lang['strfalse']);
+ $align = 'center';
+ break;
+ default:
+ $out = htmlspecialchars($str);
+ }
+ break;
+ case 'bytea':
+ // addCSlashes converts all weird ASCII characters to octal representation,
+ // EXCEPT the 'special' ones like \r \n \t, etc.
+ $out = htmlspecialchars(addCSlashes($str, "\0..\37\177..\377"));
+ break;
+ case 'pre':
+ $tag = 'pre';
+ $out = htmlspecialchars($str);
+ break;
+ case 'nbsp':
+ $out = nl2br(str_replace(' ', ' ', htmlspecialchars($str)));
+ break;
+ case 'verbatim':
+ $out = $str;
+ break;
+ case 'callback':
+ $out = $params['function']($str, $params);
+ break;
+ default:
+ // If the string contains at least one instance of >1 space in a row, a tab
+ // character, a space at the start of a line, or a space at the start of
+ // the whole string then render within a pre-formatted element (<pre>).
+ if (preg_match('/(^ | |\t|\n )/m', $str)) {
+ $tag = 'pre';
+ $out = htmlspecialchars($str);
+ } else {
+ $out = nl2br(htmlspecialchars($str));
+ }
+ }
+
+ if (isset($params['class'])) $class = $params['class'];
+ if (isset($params['align'])) $align = $params['align'];
+
+ if (!isset($tag) && (isset($class) || isset($align))) $tag = 'div';
+
+ if (isset($tag)) {
+ $alignattr = isset($align) ? " align=\"{$align}\"" : '';
+ $classattr = isset($class) ? " class=\"{$class}\"" : '';
+ return "<{$tag}{$alignattr}{$classattr}>{$out}</{$tag}>";
+ }
+
+ return $out;
}
/**
}
}
- /**
- * Clip a string down to a specified length, and append an ellipsis.
- * @param $str The string to be clipped.
- * @param $maxlen (optional) Maximum length of string (defaults to the configuration value 'max_chars'.
- * @param $ellipsis (optional) The string to append if clipping was performed.
- */
- function clipString($str, $maxlen = null, $ellipsis = null) {
- global $lang, $conf;
- if (is_null($maxlen)) $maxlen = $conf['max_chars'];
- if (is_null($ellipsis)) $ellipsis = $lang['strellipsis'];
- if (strlen($str) > $maxlen) {
- return substr($str, 0, $maxlen-1) . $ellipsis;
- } else {
- return $str;
- }
- }
-
- function printUrlVars($vars, $fields) {
+ function printUrlVars(&$vars, &$fields) {
foreach ($vars as $var => $varfield) {
echo "{$var}=", urlencode($fields[$varfield]), "&";
}
}
- /**
- * Format a table cell according to a set of parameters.
- * @param $value The value to display
- * @param $params Associative array of type parameters, or just a type name.
- * @return The HTML formatted string
- */
- function printCell($value, $params) {
- global $lang, $data;
-
- if (is_string($params)) {
- $type = $params;
- $params = array();
- } else {
- $type = isset($params['type']) ? $params['type'] : 'str';
- }
- $out = '';
-
- switch ($type) {
- case 'bool':
- case 'boolean':
- $out = $data->phpBool($value)
- ? (isset($params['true']) ? $params['true'] : $lang['strtrue'])
- : (isset($params['false']) ? $params['false'] : $lang['strfalse']);
- break;
- case 'num':
- case 'numeric':
- $align = 'right';
- $out = nl2br(htmlspecialchars($value));
- break;
- case 'pre':
- $tag = 'pre';
- $out = htmlspecialchars($value);
- break;
- case 'nbsp':
- $out = nl2br(str_replace(' ', ' ', htmlspecialchars($value)));
- break;
- case 'verbatim':
- $out = $value;
- break;
- case 'str':
- case 'string':
- default:
- $out = nl2br(htmlspecialchars($value));
- break;
- }
-
- if (isset($params['class'])) $class = $params['class'];
-
- if (!isset($tag) && (isset($class) || isset($align))) $tag = 'div';
-
- if (isset($tag)) {
- $alignattr = isset($align) ? " align=\"{$align}\"" : '';
- $classattr = isset($class) ? " class=\"{$class}\"" : '';
- return "<{$tag}{$alignattr}{$classattr}>{$out}</{$tag}>";
- }
-
- return $out;
- }
-
/**
* Display a table of data.
* @param $tabledata A set of data to be formatted, as returned by $data->getDatabases() etc.
unset($actions['properties']);
}
- // TEMP: Display field keys
- //echo "<p>", join(', ', array_keys($tabledata->f)), "</p>";
- // END OF TEMP
+ if (isset($columns['comment'])) {
+ // Uncomment this for clipped comments.
+ // TODO: This should be a user option.
+ //$columns['comment']['params']['clip'] = true;
+ }
echo "<table>\n";
echo "<tr>\n";
}
echo "</tr>\n";
- if (function_exists('ob_start')) ob_start();
-
$i = 0;
while (!$tabledata->EOF) {
$id = ($i % 2) + 1;
unset($alt_actions);
- if (!is_null($pre_fn)) $alt_actions = $pre_fn(&$tabledata, $actions);
+ if (!is_null($pre_fn)) $alt_actions = $pre_fn($tabledata, $actions);
if (!isset($alt_actions)) $alt_actions =& $actions;
echo "<tr>\n";
} else {
echo "<td class=\"opbutton{$id}\">";
echo "<a href=\"{$action['url']}";
- $misc->printUrlVars($action['vars'], &$tabledata->f);
+ $misc->printUrlVars($action['vars'], $tabledata->f);
echo "\">{$action['title']}</a></td>";
}
}
break;
- case 'comment':
- // Uncomment this for clipped comments.
- //$tabledata->f[$column['field']] = $misc->clipString($tabledata->f[$column['field']]);
default;
echo "<td class=\"data{$id}\">";
if (isset($column['url'])) {
echo "<a href=\"{$column['url']}";
- $misc->printUrlVars($column['vars'], &$tabledata->f);
+ $misc->printUrlVars($column['vars'], $tabledata->f);
echo "\">";
}
- $cell = $misc->printCell($tabledata->f[$column['field']], &$column);
- echo $cell;
+ $type = isset($column['type']) ? $column['type'] : null;
+ $params = isset($column['params']) ? $column['params'] : array();
+ echo $misc->printVal($tabledata->f[$column['field']], $type, $params);
if (isset($column['url'])) echo "</a>";
}
echo "</tr>\n";
- if (function_exists('ob_flush')) ob_flush();
$tabledata->moveNext();
$i++;
}
- if (function_exists('ob_end_flush')) ob_end_flush();
-
echo "</table>\n";
-
+
return true;
} else {
if (!is_null($nodata)) {
return false;
}
}
-
}
?>
/**
* List constraints on a table
*
- * $Id: constraints.php,v 1.33 2004/07/13 15:24:40 jollytoad Exp $
+ * $Id: constraints.php,v 1.34 2004/07/13 16:13:15 jollytoad Exp $
*/
// Include application functions
'clustered' => array(
'title' => $lang['strclustered'],
'field' => '+clustered',
- 'type' => 'bool',
- 'true' => $lang['stryes'],
- 'false' => $lang['strno'],
+ 'type' => 'yesno',
),
'actions' => array(
'title' => $lang['stractions'],
/**
* Manage conversions in a database
*
- * $Id: conversions.php,v 1.7 2004/07/13 15:24:40 jollytoad Exp $
+ * $Id: conversions.php,v 1.8 2004/07/13 16:13:15 jollytoad Exp $
*/
// Include application functions
'default' => array(
'title' => $lang['strdefault'],
'field' => 'condefault',
- 'type' => 'bool',
- 'true' => $lang['stryes'],
- 'false' => $lang['strno'],
+ 'type' => 'yesno',
),
'comment' => array(
'title' => $lang['strcomment'],
* @param $return_desc The return link name
* @param $page The current page
*
- * $Id: display.php,v 1.40 2004/07/07 02:59:57 chriskl Exp $
+ * $Id: display.php,v 1.41 2004/07/13 16:13:15 jollytoad Exp $
*/
// Include application functions
if ($_REQUEST['strings'] == 'collapsed' && strlen($v) > $conf['max_chars']) {
$v = substr($v, 0, $conf['max_chars'] - 1) . $lang['strellipsis'];
}
- echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", $misc->printVal($v, true, $finfo->type), "</td>";
+ echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", $misc->printVal($v, $finfo->type, array('null' => true)), "</td>";
}
}
echo "</tr>\n";
/**
* Manage domains in a database
*
- * $Id: domains.php,v 1.15 2004/07/13 15:24:40 jollytoad Exp $
+ * $Id: domains.php,v 1.16 2004/07/13 16:13:15 jollytoad Exp $
*/
// Include application functions
'title' => $lang['strnotnull'],
'field' => 'domnotnull',
'type' => 'bool',
- 'true' => 'NOT NULL',
- 'false' => '',
+ 'params'=> array('true' => 'NOT NULL', 'false' => ''),
),
'default' => array(
'title' => $lang['strdefault'],
/**
* Manage functions in a database
*
- * $Id: functions.php,v 1.36 2004/07/13 15:24:41 jollytoad Exp $
+ * $Id: functions.php,v 1.37 2004/07/13 16:13:15 jollytoad Exp $
*/
// Include application functions
echo "<td class=\"data1\" colspan=\"2\">", $misc->printVal($funcdata->f['prosrc']), "</td></tr>\n";
} else {
echo "<tr><th class=\"data\" colspan=\"4\">{$lang['strdefinition']}</th></tr>\n";
- echo "<tr><td class=\"data1\" colspan=\"4\">", $misc->printCell($funcdata->f['prosrc'], 'pre'), "</td></tr>\n";
+ echo "<tr><td class=\"data1\" colspan=\"4\">", $misc->printVal($funcdata->f['prosrc'], 'pre'), "</td></tr>\n";
}
// Show flags
'function' => array(
'title' => $lang['strfunction'],
'field' => '+proproto',
+ 'type' => 'verbatim',
),
'returns' => array(
'title' => $lang['strreturns'],
'field' => '+proreturns',
+ 'type' => 'verbatim',
),
'actions' => array(
'title' => $lang['stractions'],
/**
* List indexes on a table
*
- * $Id: indexes.php,v 1.29 2004/07/13 15:24:41 jollytoad Exp $
+ * $Id: indexes.php,v 1.30 2004/07/13 16:13:15 jollytoad Exp $
*/
// Include application functions
'clustered' => array(
'title' => $lang['strclustered'],
'field' => 'indisclustered',
- 'type' => 'bool',
- 'true' => $lang['stryes'],
- 'false' => $lang['strno'],
+ 'type' => 'yesno',
),
'actions' => array(
'title' => $lang['stractions'],
/**
* List extra information on a table
*
- * $Id: info.php,v 1.7 2004/07/13 15:24:41 jollytoad Exp $
+ * $Id: info.php,v 1.8 2004/07/13 16:13:15 jollytoad Exp $
*/
// Include application functions
echo "<h2>", $misc->printVal($_REQUEST['database']), ": ", $misc->printVal($_REQUEST['table']), ": {$lang['strinfo']}</h2>\n";
$misc->printMsg($msg);
+ // common params for printVal
+ $shownull = array('null' => true);
+
// Fetch info
$referrers = &$data->getReferrers($_REQUEST['table']);
$parents = &$data->getTableParents($_REQUEST['table']);
while (!$tablestatstups->EOF) {
$id = ( ($i % 2 ) == 0 ? '1' : '2' );
echo "\t<tr>\n";
- echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatstups->f['seq_scan'], true, 'int4'), "</td>\n";
- echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatstups->f['seq_tup_read'], true, 'int4'), "</td>\n";
- echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatstups->f['idx_scan'], true, 'int4'), "</td>\n";
- echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatstups->f['idx_tup_fetch'], true, 'int4'), "</td>\n";
- echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatstups->f['n_tup_ins'], true, 'int4'), "</td>\n";
- echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatstups->f['n_tup_upd'], true, 'int4'), "</td>\n";
- echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatstups->f['n_tup_del'], true, 'int4'), "</td>\n";
+ echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatstups->f['seq_scan'], 'int4', $shownull), "</td>\n";
+ echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatstups->f['seq_tup_read'], 'int4', $shownull), "</td>\n";
+ echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatstups->f['idx_scan'], 'int4', $shownull), "</td>\n";
+ echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatstups->f['idx_tup_fetch'], 'int4', $shownull), "</td>\n";
+ echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatstups->f['n_tup_ins'], 'int4', $shownull), "</td>\n";
+ echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatstups->f['n_tup_upd'], 'int4', $shownull), "</td>\n";
+ echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatstups->f['n_tup_del'], 'int4', $shownull), "</td>\n";
echo "\t</tr>\n";
$tablestatstups->movenext();
$i++;
$total = $tablestatsio->f['heap_blks_hit'] + $tablestatsio->f['heap_blks_read'];
if ($total > 0) $percentage = round(($tablestatsio->f['heap_blks_hit'] / $total) * 100);
else $percentage = 0;
- echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatsio->f['heap_blks_read'], true, 'int4'), "</td>\n";
- echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatsio->f['heap_blks_hit'], true, 'int4'), "</td>\n";
+ echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatsio->f['heap_blks_read'], 'int4', $shownull), "</td>\n";
+ echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatsio->f['heap_blks_hit'], 'int4', $shownull), "</td>\n";
echo "\t\t<td class=\"data{$id}\">({$percentage}{$lang['strpercent']})</td>\n";
$total = $tablestatsio->f['idx_blks_hit'] + $tablestatsio->f['idx_blks_read'];
if ($total > 0) $percentage = round(($tablestatsio->f['idx_blks_hit'] / $total) * 100);
else $percentage = 0;
- echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatsio->f['idx_blks_read'], true, 'int4'), "</td>\n";
- echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatsio->f['idx_blks_hit'], true, 'int4'), "</td>\n";
+ echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatsio->f['idx_blks_read'], 'int4', $shownull), "</td>\n";
+ echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatsio->f['idx_blks_hit'], 'int4', $shownull), "</td>\n";
echo "\t\t<td class=\"data{$id}\">({$percentage}{$lang['strpercent']})</td>\n";
$total = $tablestatsio->f['toast_blks_hit'] + $tablestatsio->f['toast_blks_read'];
if ($total > 0) $percentage = round(($tablestatsio->f['toast_blks_hit'] / $total) * 100);
else $percentage = 0;
- echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatsio->f['toast_blks_read'], true, 'int4'), "</td>\n";
- echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatsio->f['toast_blks_hit'], true, 'int4'), "</td>\n";
+ echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatsio->f['toast_blks_read'], 'int4', $shownull), "</td>\n";
+ echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatsio->f['toast_blks_hit'], 'int4', $shownull), "</td>\n";
echo "\t\t<td class=\"data{$id}\">({$percentage}{$lang['strpercent']})</td>\n";
$total = $tablestatsio->f['tidx_blks_hit'] + $tablestatsio->f['tidx_blks_read'];
if ($total > 0) $percentage = round(($tablestatsio->f['tidx_blks_hit'] / $total) * 100);
else $percentage = 0;
- echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatsio->f['tidx_blks_read'], true, 'int4'), "</td>\n";
- echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatsio->f['tidx_blks_hit'], true, 'int4'), "</td>\n";
+ echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatsio->f['tidx_blks_read'], 'int4', $shownull), "</td>\n";
+ echo "\t\t<td class=\"data{$id}\">", $misc->printVal($tablestatsio->f['tidx_blks_hit'], 'int4', $shownull), "</td>\n";
echo "\t\t<td class=\"data{$id}\">({$percentage}{$lang['strpercent']})</td>\n";
echo "\t</tr>\n";
$tablestatsio->movenext();
$id = ( ($i % 2 ) == 0 ? '1' : '2' );
echo "\t<tr>\n";
echo "\t\t<td class=\"data{$id}\">", $misc->printVal($indexstatstups->f['indexrelname']), "</td>\n";
- echo "\t\t<td class=\"data{$id}\">", $misc->printVal($indexstatstups->f['idx_scan'], true, 'int4'), "</td>\n";
- echo "\t\t<td class=\"data{$id}\">", $misc->printVal($indexstatstups->f['idx_tup_read'], true, 'int4'), "</td>\n";
- echo "\t\t<td class=\"data{$id}\">", $misc->printVal($indexstatstups->f['idx_tup_fetch'], true, 'int4'), "</td>\n";
+ echo "\t\t<td class=\"data{$id}\">", $misc->printVal($indexstatstups->f['idx_scan'], 'int4', $shownull), "</td>\n";
+ echo "\t\t<td class=\"data{$id}\">", $misc->printVal($indexstatstups->f['idx_tup_read'], 'int4', $shownull), "</td>\n";
+ echo "\t\t<td class=\"data{$id}\">", $misc->printVal($indexstatstups->f['idx_tup_fetch'], 'int4', $shownull), "</td>\n";
echo "\t</tr>\n";
$indexstatstups->movenext();
$i++;
if ($total > 0) $percentage = round(($indexstatsio->f['idx_blks_hit'] / $total) * 100);
else $percentage = 0;
echo "\t\t<td class=\"data{$id}\">", $misc->printVal($indexstatsio->f['indexrelname']), "</td>\n";
- echo "\t\t<td class=\"data{$id}\">", $misc->printVal($indexstatsio->f['idx_blks_read'], true, 'int4'), "</td>\n";
- echo "\t\t<td class=\"data{$id}\">", $misc->printVal($indexstatsio->f['idx_blks_hit'], true, 'int4'), "</td>\n";
+ echo "\t\t<td class=\"data{$id}\">", $misc->printVal($indexstatsio->f['idx_blks_read'], 'int4', $shownull), "</td>\n";
+ echo "\t\t<td class=\"data{$id}\">", $misc->printVal($indexstatsio->f['idx_blks_hit'], 'int4', $shownull), "</td>\n";
echo "\t\t<td class=\"data{$id}\">({$percentage}{$lang['strpercent']})</td>\n";
echo "\t</tr>\n";
$indexstatsio->movenext();
/**
* Manage languages in a database
*
- * $Id: languages.php,v 1.5 2004/07/13 15:24:41 jollytoad Exp $
+ * $Id: languages.php,v 1.6 2004/07/13 16:13:15 jollytoad Exp $
*/
// Include application functions
'trusted' => array(
'title' => $lang['strtrusted'],
'field' => 'lanpltrusted',
- 'type' => 'bool',
- 'true' => $lang['stryes'],
- 'false' => $lang['strno'],
+ 'type' => 'yesno',
),
'function' => array(
'title' => $lang['strfunction'],
/**
* Manage opclasss in a database
*
- * $Id: opclasses.php,v 1.4 2004/07/13 15:24:41 jollytoad Exp $
+ * $Id: opclasses.php,v 1.5 2004/07/13 16:13:15 jollytoad Exp $
*/
// Include application functions
'default' => array(
'title' => $lang['strdefault'],
'field' => 'opcdefault',
- 'type' => 'bool',
- 'true' => $lang['stryes'],
- 'false' => $lang['strno'],
+ 'type' => 'yesno',
),
'comment' => array(
'title' => $lang['strcomment'],
* how many SQL statements have been strung together with semi-colons
* @param $query The SQL query string to execute
*
- * $Id: sql.php,v 1.23 2004/07/13 15:24:41 jollytoad Exp $
+ * $Id: sql.php,v 1.24 2004/07/13 16:13:15 jollytoad Exp $
*/
// Include application functions
echo "<tr>\n";
foreach ($rs->f as $k => $v) {
$finfo = $rs->fetchField($k);
- echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", $misc->printVal($v, true, $finfo->type), "</td>";
+ echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", $misc->printVal($v, $finfo->type, array('null' => true)), "</td>";
}
echo "</tr>\n";
$rs->moveNext();
/**
* List tables in a database
*
- * $Id: tblproperties.php,v 1.55 2004/07/13 15:24:41 jollytoad Exp $
+ * $Id: tblproperties.php,v 1.56 2004/07/13 16:13:15 jollytoad Exp $
*/
// Include application functions
'title' => $lang['strnotnull'],
'field' => 'attnotnull',
'type' => 'bool',
- 'true' => 'NOT NULL',
- 'false' => '',
+ 'params'=> array('true' => 'NOT NULL', 'false' => ''),
),
'default' => array(
'title' => $lang['strdefault'],
/**
* Manage users in a database cluster
*
- * $Id: users.php,v 1.25 2004/07/13 15:24:41 jollytoad Exp $
+ * $Id: users.php,v 1.26 2004/07/13 16:13:15 jollytoad Exp $
*/
// Include application functions
global $data, $misc;
global $PHP_SELF, $lang;
- function uPre(&$rowdata) {
- global $data, $lang;
- $rowdata->f['+useexpires'] = $rowdata->f['useexpires'] == 'infinity' ? '' : $rowdata->f['useexpires'];
- }
+ function renderUseExpires($val) {
+ return $val == 'infinity' ? '' : htmlspecialchars($val);
+ }
$misc->printTitle(array($lang['strusers']), 'users');
$misc->printMsg($msg);
'superuser' => array(
'title' => $lang['strsuper'],
'field' => 'usesuper',
- 'type' => 'bool',
- 'true' => $lang['stryes'],
- 'false' => $lang['strno'],
+ 'type' => 'yesno',
),
'createdb' => array(
'title' => $lang['strcreatedb'],
'field' => 'usecreatedb',
- 'type' => 'bool',
- 'true' => $lang['stryes'],
- 'false' => $lang['strno'],
+ 'type' => 'yesno',
),
'expires' => array(
'title' => $lang['strexpires'],
- 'field' => '+useexpires',
+ 'field' => 'useexpires',
+ 'type' => 'callback',
+ 'params'=> array('function' => 'renderUseExpires'),
),
'defaults' => array(
'title' => $lang['strsessiondefaults'],
if (!$data->hasUserSessionDefaults()) unset($columns['defaults']);
- $misc->printTable($users, $columns, $actions, $lang['strnousers'], 'uPre');
+ $misc->printTable($users, $columns, $actions, $lang['strnousers']);
echo "<p><a class=\"navlink\" href=\"$PHP_SELF?action=create\">{$lang['strcreateuser']}</a></p>\n";