Display boolean values as TRUE/FALSE when viewing data. Brand as 3.1-dev
authorchriskl <chriskl>
Tue, 5 Aug 2003 06:04:36 +0000 (06:04 +0000)
committerchriskl <chriskl>
Tue, 5 Aug 2003 06:04:36 +0000 (06:04 +0000)
BUGS
HISTORY
classes/Misc.php
display.php
lang/english.php
lang/recoded/english.php
libraries/lib.inc.php
sql.php

diff --git a/BUGS b/BUGS
index 9f460a7163c33149173c181531299c5b080fa3a3..f6d0267900a928bf2eb855b53887b55b817aea99 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -6,4 +6,4 @@
 * Add owner everywhere
 * Cancel/<Action> buttons everywhere
 * pg_dump feature!!!
-* Add default_db_encoding support to lang files and create database
+* True/False conversion doesn't work on table browse
diff --git a/HISTORY b/HISTORY
index 4bb337b40bf8738ab4686fb1b63d8ed8510741e8..333fd8a60ae73925f4a370c8f0401e9e8123d6d2 100644 (file)
--- a/HISTORY
+++ b/HISTORY
@@ -19,6 +19,7 @@ Features:
 * Default database encoding for languages
 * Convert our images to PNG format
 * Allow creating tables WITHOUT OIDS
+* Show boolean values as TRUE or FALSE when viewing data
 
 Bug Fixes:
 * Lots of NULL value in table dump fixes (XML format changed slightly)
index 91598481f020f3645dd2879d06656024f2018a92..f4c0a48aae5261d8c44f9fe0f427b625946dc0c9 100644 (file)
@@ -2,7 +2,7 @@
        /**
         * Class to hold various commonly used functions
         *
-        * $Id: Misc.php,v 1.37 2003/07/28 07:50:32 chriskl Exp $
+        * $Id: Misc.php,v 1.38 2003/08/05 06:04:36 chriskl Exp $
         */
         
        class Misc {
                 * Replace all spaces with &nbsp; in a string
                 * @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
                 */
-               function printVal($str, $shownull = false) {
+               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 (strstr($str, '  ') || strstr($str, "\t") || strstr($str, "\n ") || ereg('^[ ]', $str)) {
-                               $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 {
+                               switch ($type) {
+                                       case 'bool':
+                                       case 'boolean':
+                                               if ($str == 't') return $lang['strtrue'];
+                                               elseif ($str == 'f') return $lang['strfalse'];
+                                               else return nl2br(htmlspecialchars($str));
+                                               break;
+                                       default:
+                                               if (strstr($str, '  ') || strstr($str, "\t") || strstr($str, "\n ") || ereg('^[ ]', $str)) {
+                                                       $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 nl2br(htmlspecialchars($str));
                }
 
                /**
index 04fe95c0f081791ff15268515e7e4ee2a1c635c9..cec600b3de565948d580c9176324b4f64a39a662 100644 (file)
@@ -9,7 +9,7 @@
         * @param $return_desc The return link name
         * @param $page The current page
         *
-        * $Id: display.php,v 1.20 2003/05/31 07:23:24 chriskl Exp $
+        * $Id: display.php,v 1.21 2003/08/05 06:04:36 chriskl Exp $
         */
 
        // Include application functions
@@ -59,7 +59,8 @@
                        $id = (($i % 2) == 0 ? '1' : '2');
                        echo "<tr>\n";
                        foreach ($rs->f as $k => $v) {
-                               echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", $misc->printVal($v, true), "</td>";
+                               $finfo = $rs->fetchField($k);
+                               echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", $misc->printVal($v, true, $finfo->type), "</td>";
                        }                                                       
                        echo "</tr>\n";
                        $rs->moveNext();
index d6f1d13e332a1bfcdd20ea491a01733feeee0ea9..9d4e59b0b0608dd32699b56b3a1ea846cb4685ef 100755 (executable)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.90 2003/08/01 01:45:30 chriskl Exp $
+        * $Id: english.php,v 1.91 2003/08/05 06:04:36 chriskl Exp $
         */
 
        // Language and character set
@@ -63,8 +63,8 @@
        $lang['strreferences'] = 'References';
        $lang['stryes'] = 'Yes';
        $lang['strno'] = 'No';
-       $lang['strtrue'] = 'True';
-       $lang['strfalse'] = 'False';
+       $lang['strtrue'] = 'TRUE';
+       $lang['strfalse'] = 'FALSE';
        $lang['stredit'] = 'Edit';
        $lang['strcolumns'] = 'Columns';
        $lang['strrows'] = 'row(s)';
index bb324d2d3885d2b35528746b7afe5992b91c13d0..24a248420ddbf54087ed94a19d15d0704570b3b9 100644 (file)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.42 2003/08/01 01:45:30 chriskl Exp $
+        * $Id: english.php,v 1.43 2003/08/05 06:04:36 chriskl Exp $
         */
 
        // Language and character set
@@ -63,8 +63,8 @@
        $lang['strreferences'] = 'References';
        $lang['stryes'] = 'Yes';
        $lang['strno'] = 'No';
-       $lang['strtrue'] = 'True';
-       $lang['strfalse'] = 'False';
+       $lang['strtrue'] = 'TRUE';
+       $lang['strfalse'] = 'FALSE';
        $lang['stredit'] = 'Edit';
        $lang['strcolumns'] = 'Columns';
        $lang['strrows'] = 'row(s)';
index 13ce3663e97d4aa468417b636cef1db730a8b9fc..79752f65815369d35b7db5a773093165eb4488b8 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Function library read in upon startup
         *
-        * $Id: lib.inc.php,v 1.54 2003/06/23 06:08:51 chriskl Exp $
+        * $Id: lib.inc.php,v 1.55 2003/08/05 06:04:36 chriskl Exp $
         */
        
        // Set error reporting level to max
@@ -13,7 +13,7 @@
        $appName = 'phpPgAdmin';
 
        // Application version
-       $appVersion = '3.0';
+       $appVersion = '3.1-dev';
 
 
        // Check to see if the configuration file exists, if not, explain
diff --git a/sql.php b/sql.php
index c8c1f3d492875f0ae14d0898a453e13b8992b28d..f2285e49ce817b4affd7054dce748b7357e12d32 100644 (file)
--- a/sql.php
+++ b/sql.php
@@ -8,7 +8,7 @@
         * @param $return_url The return URL
         * @param $return_desc The return link name
         *
-        * $Id: sql.php,v 1.7 2003/07/31 08:39:03 chriskl Exp $
+        * $Id: sql.php,v 1.8 2003/08/05 06:04:36 chriskl Exp $
         */
 
        // Include application functions
@@ -52,7 +52,8 @@
                                        $id = (($i % 2) == 0 ? '1' : '2');
                                        echo "<tr>\n";
                                        foreach ($rs->f as $k => $v) {
-                                               echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", $misc->printVal($v, true), "</td>";
+                                               $finfo = $rs->fetchField($k);
+                                               echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", $misc->printVal($v, true, $finfo->type), "</td>";
                                        }                                                       
                                        echo "</tr>\n";
                                        $rs->moveNext();