Merged printCell() and clipString() into printVal().
authorjollytoad <jollytoad>
Tue, 13 Jul 2004 16:13:14 +0000 (16:13 +0000)
committerjollytoad <jollytoad>
Tue, 13 Jul 2004 16:13:14 +0000 (16:13 +0000)
IMPORTANT: printVal prototype has changed - all calls have been fixed though.

15 files changed:
aggregates.php
casts.php
classes/Misc.php
constraints.php
conversions.php
display.php
domains.php
functions.php
indexes.php
info.php
languages.php
opclasses.php
sql.php
tblproperties.php
users.php

index b7257d119b58c2f2ae5b416932001144f13a63b4..b67316062f05b57b35611700af8358a0159c4d0c 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * 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);
                
@@ -36,7 +31,8 @@
                        ),
                        'type' => array(
                                'title' => $lang['strtype'],
-                               'field' => '+argtypes',
+                               'field' => 'proargtypes',
+                               'params'=> array('null' => $lang['stralltypes']),
                        ),
                        'comment' => array(
                                'title' => $lang['strcomment'],
@@ -46,7 +42,7 @@
                
                $actions = array();
                
-               $misc->printTable($aggregates, $columns, $actions, $lang['strnoaggregates'], 'aggPre');
+               $misc->printTable($aggregates, $columns, $actions, $lang['strnoaggregates']);
        }
 
        $misc->printHeader($lang['straggregates']);
index 5ffd288ef48ea7c028fe337ceae69c5d903976b9..31792dee30ba0dda3820a9629dd38617fed89f5d 100644 (file)
--- a/casts.php
+++ b/casts.php
@@ -3,7 +3,7 @@
        /**
         * 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']);
index 936596376f2d9ee3b648eb21526d0e12dac4f143..9e5571f3a92d857b8280e803ef9f05c655480fd3 100644 (file)
@@ -2,7 +2,7 @@
        /**
         * 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 &nbsp; 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 &nbsp;'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 &nbsp;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(' ', '&nbsp;', htmlspecialchars($str));
-                                                       // Replace tabs with 8 spaces
-                                                       $str = str_replace("\t", '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', $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(' ', '&nbsp;', 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]), "&amp;";
                        }
                }
                
-               /**
-                * 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(' ', '&nbsp;', 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;
                        }
                }
-       
        }
 ?>
index 255c2d9dbf18a40f1f40436c13b43f19887f8166..573b19e6348e507d7368117bc17b3ef29c64ba49 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * 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'],
index ce99a7ea57bbd5f68a784d234360e75482962f8a..87b1a2db7fea5b63f61d210a1d0696f823dbbb9e 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * 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
@@ -41,9 +41,7 @@
                        'default' => array(
                                'title' => $lang['strdefault'],
                                'field' => 'condefault',
-                               'type'  => 'bool',
-                               'true'  => $lang['stryes'],
-                               'false' => $lang['strno'],
+                               'type'  => 'yesno',
                        ),
                        'comment' => array(
                                'title' => $lang['strcomment'],
index b455796fe075fe011d78a5ebd0197f080a7c4f27..11f10efdb6c223f2b51eabd249850fae8df99cd5 100644 (file)
@@ -9,7 +9,7 @@
         * @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";
index 0f574d30b65d2eeb8413bc1e84c1e2e1689b0dae..9edad18808762c7ace61f27d8b719fa887ed21cc 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * 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'],
index 2eb0c0ee3b3bf406b9a1f36647e7e3bcde2a92f0..eb12306e98c7dbc2c1400d4f43ae55302c227621 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * 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'],
index f79d6dd0ca90026e99fb67a3f28491b46cd1c041..585a5f130a51aa6c85db172addb245c0db25df26 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * 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'],
index 31d3215fb43ef8569a6b694a9e49437f41877caf..79177f47e749d5f16e868e8260ec6781c6f31f1b 100644 (file)
--- a/info.php
+++ b/info.php
@@ -3,7 +3,7 @@
        /**
         * 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
@@ -23,6 +23,9 @@
                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();
index f3f6819db862e53e6c54e242003d259bbb0e49df..b77d454c8a57073797922e064f91d1059cb37328 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * 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
@@ -33,9 +33,7 @@
                        'trusted' => array(
                                'title' => $lang['strtrusted'],
                                'field' => 'lanpltrusted',
-                               'type'  => 'bool',
-                               'true'  => $lang['stryes'],
-                               'false' => $lang['strno'],
+                               'type'  => 'yesno',
                        ),
                        'function' => array(
                                'title' => $lang['strfunction'],
index ad21602c060777ddcb78c045afec18e86bdc5004..77b0f61c9d99bfac1d86ded44f6740cd33d6a989 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * 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
@@ -40,9 +40,7 @@
                        'default' => array(
                                'title' => $lang['strdefault'],
                                'field' => 'opcdefault',
-                               'type'  => 'bool',
-                               'true'  => $lang['stryes'],
-                               'false' => $lang['strno'],
+                               'type'  => 'yesno',
                        ),
                        'comment' => array(
                                'title' => $lang['strcomment'],
diff --git a/sql.php b/sql.php
index 94bbd2548d0eed965cc0adcef43d07a675be11e8..fd5a7cc03df47800bb4b264e5941e952d9ec4a89 100644 (file)
--- a/sql.php
+++ b/sql.php
@@ -6,7 +6,7 @@
         * 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
@@ -87,7 +87,7 @@
                                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();
index 38703e087f1b3df55aa615bd36142fc0a17a7ed4..9930d93eb90172cdc3fb9488fbfcf7f89ac74cd2 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * 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'],
index db97e43513546424308913dccd18f17f38542c81..2dec8e64933db05e2e446b71e9de38af31e17908 100644 (file)
--- a/users.php
+++ b/users.php
@@ -3,7 +3,7 @@
        /**
         * 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";