/**
* Class to hold various commonly used functions
*
- * $Id: Misc.php,v 1.32 2003/05/15 09:48:40 chriskl Exp $
+ * $Id: Misc.php,v 1.33 2003/05/19 06:08:07 chriskl Exp $
*/
class Misc {
/**
* Replace all spaces with in a string
* @param $str The string to change
+ * @param $shownull True to show NULLs, false otherwise
* @return The string with replacements
*/
- function printVal($str) {
- // If the string contains at least one instance of >1 space in a row, then
+ function printVal($str, $shownull = false) {
+ // 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) return '<i>NULL</i>';
- elseif (strstr($str, ' '))
- return nl2br(str_replace(' ', ' ', htmlspecialchars($str)));
+ if ($str === null && $shownull) return '<i>NULL</i>';
+ elseif (strstr($str, ' ') || strstr($str, "\t") || strstr($str, "\n ") || ereg('^[ ]', $str)) {
+ $str = str_replace(' ', ' ', htmlspecialchars($str));
+ // Replace tabs with 8 spaces
+ $str = str_replace("\t", ' ', $str);
+ return nl2br($str);
+ }
else
return nl2br(htmlspecialchars($str));
}
* @param $return_desc The return link name
* @param $page The current page
*
- * $Id: display.php,v 1.16 2003/05/18 11:53:27 chriskl Exp $
+ * $Id: display.php,v 1.17 2003/05/19 06:08:07 chriskl Exp $
*/
// Include application functions
$id = (($i % 2) == 0 ? '1' : '2');
echo "<tr>\n";
foreach ($rs->f as $k => $v) {
- echo "<td class=\"data{$id}\">", $misc->printVal($v), "</td>";
+ echo "<td class=\"data{$id}\">", $misc->printVal($v, true), "</td>";
}
echo "</tr>\n";
$rs->moveNext();
* @param $return_url The return URL
* @param $return_desc The return link name
*
- * $Id: sql.php,v 1.3 2003/05/06 06:17:23 chriskl Exp $
+ * $Id: sql.php,v 1.4 2003/05/19 06:08:07 chriskl Exp $
*/
// Include application functions
$id = (($i % 2) == 0 ? '1' : '2');
echo "<tr>\n";
foreach ($rs->f as $k => $v) {
- echo "<td class=\"data{$id}\">", $misc->printVal($v), "</td>";
+ echo "<td class=\"data{$id}\">", $misc->printVal($v, true), "</td>";
}
echo "</tr>\n";
$rs->moveNext();
/**
* List tables in a database
*
- * $Id: tables.php,v 1.23 2003/05/15 14:37:42 chriskl Exp $
+ * $Id: tables.php,v 1.24 2003/05/19 06:08:07 chriskl 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), "</td>";
+ echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", $misc->printVal($v, true), "</td>";
}
}
echo "</tr>\n";