round one of preserving spaces in user data when displaying. Because a browser will...
authorchriskl <chriskl>
Mon, 5 May 2003 03:03:53 +0000 (03:03 +0000)
committerchriskl <chriskl>
Mon, 5 May 2003 03:03:53 +0000 (03:03 +0000)
HISTORY
TODO
classes/Misc.php
display.php
sql.php
tables.php

diff --git a/HISTORY b/HISTORY
index fbae6231d01ca9931b1f64c54959d52a911d9366..8eeffad75deacc8587387c0b8b7bc3b7ba2d4ae9 100644 (file)
--- a/HISTORY
+++ b/HISTORY
@@ -6,6 +6,7 @@ Version 3.0.0-dev-5
 
 * Cascade drop on columns and constraints
 * Czech translation
+* Preserve spaces when displaying data
 
 Version 3.0.0-dev-4
 -------------------
diff --git a/TODO b/TODO
index 302b087bce90302478562c2f6520cad1b1497d0d..fc4a6aa97ab179779bc44e9d5ddacee71d0db78f 100644 (file)
--- a/TODO
+++ b/TODO
@@ -73,6 +73,7 @@ Tables
 * Insert needs the ability to use functions. It should also be able to handle 
   some keywords (like DEFAULT) though it might be able to use function tech i
   to accomplish this.
+* Preserve spaces when displaying user data (half done) (chriskl)
 
 Views
 -----
index 98d08de19b3b344b470a39dcce75ec60238617f4..4ef555a3abe48e9975d6c0b6270c4dabaa6c4d6e 100644 (file)
@@ -2,7 +2,7 @@
        /**
         * Class to hold various commonly used functions
         *
-        * $Id: Misc.php,v 1.28 2003/04/29 03:05:44 chriskl Exp $
+        * $Id: Misc.php,v 1.29 2003/05/05 03:03:53 chriskl Exp $
         */
         
        class Misc {
                        }
                }
 
+               /**
+                * Replace all spaces with &nbsp; in a string
+                * @param $str The string to change
+                * @return The string with replacements
+                */
+               function printVal($str) {
+                       // If the string contains at least one instance of >1 space in a row, then
+                       // substitute all spaces for &nbsp;s
+                       if (strstr($str, '  '))
+                               return nl2br(str_replace(' ', '&nbsp;', htmlspecialchars($str)));
+                       else
+                               return nl2br(htmlspecialchars($str));
+               }
+
                /**
                 * A function to recursively strip slashes.  Used to
                 * enforce magic_quotes_gpc being off.
index ecce1b5db629490f036e54b6d0368eb023f4df50..e652e747504430ef6a0cf4172800512b9aa5ea35 100644 (file)
@@ -9,7 +9,7 @@
         * @param $return_desc The return link name
         * @param $page The current page
         *
-        * $Id: display.php,v 1.12 2003/04/21 06:36:23 chriskl Exp $
+        * $Id: display.php,v 1.13 2003/05/05 03:03:53 chriskl Exp $
         */
 
        // Include application functions
@@ -50,7 +50,7 @@
                echo "<table>\n<tr>";
                reset($rs->f);
                while(list($k, ) = each($rs->f)) {
-                       echo "<th class=data>", htmlspecialchars($k), "</th>";
+                       echo "<th class=\"data\">", $misc->printVal($k), "</th>";
                }
 
                $i = 0;
@@ -59,7 +59,7 @@
                        $id = (($i % 2) == 0 ? '1' : '2');
                        echo "<tr>\n";
                        while(list($k, $v) = each($rs->f)) {
-                               echo "<td class=\"data{$id}\">", nl2br(htmlspecialchars($v)), "</td>";
+                               echo "<td class=\"data{$id}\">", $misc->printVal($v), "</td>";
                        }                                                       
                        echo "</tr>\n";
                        $rs->moveNext();
diff --git a/sql.php b/sql.php
index 63b2b40ebdf983e252f55531d6348efc5c2c93ea..1a7505423f6bcdf501983f33536f6c56241b0c0e 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.1 2003/04/19 11:59:09 chriskl Exp $
+        * $Id: sql.php,v 1.2 2003/05/05 03:03:53 chriskl Exp $
         */
 
        // Include application functions
@@ -35,7 +35,7 @@
                                echo "<table>\n<tr>";
                                reset($rs->f);
                                while(list($k, ) = each($rs->f)) {
-                                       echo "<th class=\"data\">", htmlspecialchars($k), "</th>";
+                                       echo "<th class=\"data\">", $misc->printVal($k), "</th>";
                                }
 
                                $i = 0;
@@ -44,7 +44,7 @@
                                        $id = (($i % 2) == 0 ? '1' : '2');
                                        echo "<tr>\n";
                                        while(list($k, $v) = each($rs->f)) {
-                                               echo "<td class=\"data{$id}\">", nl2br(htmlspecialchars($v)), "</td>";
+                                               echo "<td class=\"data{$id}\">", $misc->printVal($v), "</td>";
                                        }                                                       
                                        echo "</tr>\n";
                                        $rs->moveNext();
index 0e426ae81069cf1a5654287b684c8c4172b1ca91..988c89e9231e8183b6cee2804cdd7bd3fae0bfcc 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List tables in a database
         *
-        * $Id: tables.php,v 1.18 2003/04/30 06:35:41 chriskl Exp $
+        * $Id: tables.php,v 1.19 2003/05/05 03:03:53 chriskl Exp $
         */
 
        // Include application functions
                                echo "<table>\n<tr>";
 
                                // Output table header
-                               echo "<tr><th class=data>{$lang['strfield']}</th><th class=data>{$lang['strtype']}</th><th class=data>{$lang['strnull']}</th><th class=data>{$lang['strvalue']}</th></tr>";
+                               echo "<tr><th class=\"data\">{$lang['strfield']}</th><th class=\"data\">{$lang['strtype']}</th>";
+                               echo "<th class=\"data\">{$lang['strnull']}</th><th class=\"data\">{$lang['strvalue']}</th></tr>";
 
                                // @@ CHECK THAT KEY ACTUALLY IS IN THE RESULT SET...
 
                                        $attrs->f['attnotnull'] = $localData->phpBool($attrs->f['attnotnull']);
                                        $id = (($i % 2) == 0 ? '1' : '2');
                                        echo "<tr>\n";
-                                       echo "<td class=data{$id} nowrap>", htmlspecialchars($attrs->f['attname']), "</td>";
-                                       echo "<td class=data{$id} nowrap>", htmlspecialchars($attrs->f['type']), "</td>";
-                                       echo "<td class=data{$id} nowrap>";
+                                       echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", htmlspecialchars($attrs->f['attname']), "</td>";
+                                       echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", htmlspecialchars($attrs->f['type']), "</td>";
+                                       echo "<td class=\"data{$id}\" nowrap=\"nowrap\">";
                                        // Output null box if the column allows nulls (doesn't look at CHECKs or ASSERTIONS)
                                        if (!$attrs->f['attnotnull']) {
                                                // Set initial null values
                                                if ($_REQUEST['action'] == 'confeditrow' && $rs->f[$attrs->f['attname']] === null) {
                                                        $_REQUEST['nulls'][$attrs->f['attname']] = 'on';
                                                }
-                                               echo "<input type=checkbox name=\"nulls[{$attrs->f['attname']}]\"",
-                                                       isset($_REQUEST['nulls'][$attrs->f['attname']]) ? ' checked' : '', "></td>";
+                                               echo "<input type=\"checkbox\" name=\"nulls[{$attrs->f['attname']}]\"",
+                                                       isset($_REQUEST['nulls'][$attrs->f['attname']]) ? ' checked' : '', " /></td>";
                                        }
                                        else
                                                echo "&nbsp;</td>";
 
-                                       echo "<td class=data{$id} nowrap>", $localData->printField("values[{$attrs->f['attname']}]",
+                                       echo "<td class=\"data{$id}\" nowrap>", $localData->printField("values[{$attrs->f['attname']}]",
                                                $rs->f[$attrs->f['attname']], $attrs->f['type']), "</td>";
                                        echo "</tr>\n";
                                        $i++;
                        }
                        else echo "<p>{$lang['strinvalidparam']}</p>\n";
 
-                       echo "<input type=hidden name=action value=editrow>\n";
-                       echo "<input type=hidden name=table value=\"", htmlspecialchars($_REQUEST['table']), "\">\n";
+                       echo "<input type=\"hidden\" name=\"action\" value=\"editrow\" />\n";
+                       echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\" />\n";
                        echo $misc->form;
-                       echo "<input type=hidden name=page value=\"", htmlspecialchars($_REQUEST['page']), "\">\n";
-                       echo "<input type=hidden name=sortkey value=\"", htmlspecialchars($_REQUEST['sortkey']), "\">\n";
-                       echo "<input type=hidden name=key value=\"", htmlspecialchars(serialize($key)), "\">\n";
-                       echo "<p><input type=submit name=save value=\"{$lang['strsave']}\"> <input type=submit name=cancel value=\"{$lang['strcancel']}\"></p>\n";
+                       echo "<input type=\"hidden\" name=\"page\" value=\"", htmlspecialchars($_REQUEST['page']), "\" />\n";
+                       echo "<input type=\"hidden\" name=\"sortkey\" value=\"", htmlspecialchars($_REQUEST['sortkey']), "\" />\n";
+                       echo "<input type=\"hidden\" name=\"key\" value=\"", htmlspecialchars(serialize($key)), "\" />\n";
+                       echo "<p><input type=\"submit\" name=\"save\" value=\"{$lang['strsave']}\" />\n";
+                       echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n";
                        echo "</form>\n";
                }
                else {
                        echo "<p>{$lang['strconfdeleterow']}</p>\n";
                        
                        echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
-                       echo "<input type=hidden name=action value=delrow>\n";
-                       echo "<input type=hidden name=table value=\"", htmlspecialchars($_REQUEST['table']), "\">\n";
+                       echo "<input type=\"hidden\" name=\"action\" value=\"delrow\" />\n";
+                       echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\" />\n";
                        echo $misc->form;
-                       echo "<input type=hidden name=page value=\"", htmlspecialchars($_REQUEST['page']), "\">\n";
-                       echo "<input type=hidden name=sortkey value=\"", htmlspecialchars($_REQUEST['sortkey']), "\">\n";
-                       echo "<input type=hidden name=key value=\"", htmlspecialchars(serialize($_REQUEST['key'])), "\">\n";
-                       echo "<input type=submit name=yes value=\"{$lang['stryes']}\"> <input type=submit name=no value=\"{$lang['strno']}\">\n";
+                       echo "<input type=\"hidden\" name=\"page\" value=\"", htmlspecialchars($_REQUEST['page']), "\" />\n";
+                       echo "<input type=\"hidden\" name=\"sortkey\" value=\"", htmlspecialchars($_REQUEST['sortkey']), "\" />\n";
+                       echo "<input type=\"hidden\" name=\"key\" value=\"", htmlspecialchars(serialize($_REQUEST['key'])), "\" />\n";
+                       echo "<input type=\"submit\" name=\"yes\" value=\"{$lang['stryes']}\" />\n";
+                       echo "<input type=\"submit\" name=\"no\" value=\"{$lang['strno']}\" />\n";
                        echo "</form>\n";
                }
                else {
                        while(list($k, ) = each($rs->f)) {
                                if ($k == $localData->id && !$conf['show_oids']) continue;
                                echo "<th class=\"data\"><a href=\"{$PHP_SELF}?action=browse&page=", $_REQUEST['page'], "&{$misc->href}&sortkey=", urlencode($k), "&table=", 
-                                       urlencode($_REQUEST['table']), "\">", htmlspecialchars($k), "</a></th>\n";
+                                       urlencode($_REQUEST['table']), "\">", $misc->printVal($k), "</a></th>\n";
                        }
                        
                        // @@ CHECK THAT KEY ACTUALLY IS IN THE RESULT SET...
                                while(list($k, $v) = each($rs->f)) {
                                        if ($k == $localData->id && !$conf['show_oids']) continue;
                                        elseif ($v == '') echo "<td class=\"data{$id}\">&nbsp;</td>";
-                                       else echo "<td class=\"data{$id}\">", nl2br(htmlspecialchars($v)), "</td>";
+                                       else echo "<td class=\"data{$id}\">", $misc->printVal($v), "</td>";
                                }
                                if (sizeof($key) > 0) {
                                        $key_str = '';