heaps of fixes to table browser. (added features as well - naughty of me). Display...
authorchriskl <chriskl>
Thu, 15 May 2003 09:48:39 +0000 (09:48 +0000)
committerchriskl <chriskl>
Thu, 15 May 2003 09:48:39 +0000 (09:48 +0000)
classes/Misc.php
classes/database/Postgres.php
conf/config.inc.php-dist
lang/english.php
lang/recoded/english.php
tables.php

index 4ecd0d9d43605cbbd54fac253b716fcfbf436dca..9e890cccb729936f923995503a841cdf8c832c0b 100644 (file)
@@ -2,7 +2,7 @@
        /**
         * Class to hold various commonly used functions
         *
-        * $Id: Misc.php,v 1.31 2003/05/08 14:15:57 chriskl Exp $
+        * $Id: Misc.php,v 1.32 2003/05/15 09:48:40 chriskl Exp $
         */
         
        class Misc {
@@ -47,7 +47,8 @@
                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, '  '))
+                       if ($str === null) return '<i>NULL</i>';
+                       elseif (strstr($str, '  '))
                                return nl2br(str_replace(' ', '&nbsp;', htmlspecialchars($str)));
                        else
                                return nl2br(htmlspecialchars($str));
index cc4aa522c2b2c0146e33558d184a4a2ad1295ef1..0cf27dd8563522e96310d6a35469b11b57a8d5dd 100755 (executable)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres.php,v 1.103 2003/05/15 08:59:48 chriskl Exp $
+ * $Id: Postgres.php,v 1.104 2003/05/15 09:48:40 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -666,6 +666,7 @@ class Postgres extends BaseDB {
         * Returns a recordset of all columns in a relation.  Supports paging.
         * @param $relation The name of a relation
         * @param $sortkey Field over which to sort.  '' for no sort.
+        * @param $sortdir 'asc' or 'desc'
         * @param $page The page of the relation to retrieve
         * @param $page_size The number of rows per page
         * @param &$max_pages (return-by-ref) The max number of pages in the relation
@@ -674,7 +675,7 @@ class Postgres extends BaseDB {
         * @return -2 counting error
         * @return -3 page or page_size invalid
         */
-       function &browseRelation($relation, $sortkey, $page, $page_size, &$max_pages) {
+       function &browseRelation($relation, $sortkey, $sortdir, $page, $page_size, &$max_pages) {
                $oldrelation = $relation;
                $this->fieldClean($relation);
 
@@ -706,6 +707,11 @@ class Postgres extends BaseDB {
                if ($sortkey != '') {
                        $this->fieldClean($sortkey);
                        $orderby = " ORDER BY \"{$sortkey}\"";
+                       // Add sort order
+                       if ($sortdir == 'desc')
+                               $orderby .= ' DESC';
+                       else
+                               $orderby .= ' ASC';
                }
                else $orderby = '';
 
@@ -716,9 +722,9 @@ class Postgres extends BaseDB {
 
                // Actually retrieve the rows, with offset and limit
                if ($hasID)
-                       $rs = $this->selectSet("SELECT \"{$this->id}\",* FROM \"{$relation}\" {$orderby}LIMIT {$page_size} OFFSET " . ($page - 1) * $page_size);
+                       $rs = $this->selectSet("SELECT \"{$this->id}\",* FROM \"{$relation}\" {$orderby} LIMIT {$page_size} OFFSET " . ($page - 1) * $page_size);
                else
-                       $rs = $this->selectSet("SELECT * FROM \"{$relation}\" {$orderby}LIMIT {$page_size} OFFSET " . ($page - 1) * $page_size);
+                       $rs = $this->selectSet("SELECT * FROM \"{$relation}\" {$orderby} LIMIT {$page_size} OFFSET " . ($page - 1) * $page_size);
                        
                $status = $this->endTransaction();
                if ($status != 0) {
index f96ff50528eba49fb3725d920e335f9815b9a5ee..674d94a3138655007a42447dcb01119f1c4f2583 100644 (file)
@@ -4,7 +4,7 @@
         * Central phpPgAdmin configuration.  As a user you may modify the
         * settings here for your particular configuration.
         *
-        * $Id: config.inc.php-dist,v 1.20 2003/05/08 15:14:15 chriskl Exp $
+        * $Id: config.inc.php-dist,v 1.21 2003/05/15 09:48:41 chriskl Exp $
         */
 
        // An example server.  Create as many of these as you wish,
@@ -52,6 +52,9 @@
        // Max rows to show on a page when browsing record sets
        $conf['max_rows'] = 30;
 
+       // Max chars of each field to display by default in browse mode
+       $conf['max_chars'] = 50;
+
        // Send XHTML headers?  Unless debugging, it's best to leave this off
        $conf['use_xhtml'] = false;
 
index 2e2f087b27aa586972c3418665c3709184c18c72..0cb435c15ad87f40f50408d1fb339e778d91369c 100755 (executable)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.77 2003/05/10 13:15:42 chriskl Exp $
+        * $Id: english.php,v 1.78 2003/05/15 09:48:41 chriskl Exp $
         */
 
        // Language and character set
@@ -84,6 +84,9 @@
        $lang['strdata'] = 'Data';
        $lang['strconfirm'] = 'Confirm';
        $lang['strexpression'] = 'Expression';
+       $lang['strellipsis'] = '...';
+       $lang['strexpand'] = 'Expand';
+       $lang['strcollapse'] = 'Collapse';
 
        // Error handling
        $lang['strnoframes'] = 'You need a frames-enabled browser to use this application.';
index 246b8666943c8100ce6fdf1ca1d2cb5f9fa4f80f..ba7b7061bf256ae6afa97bd600ba468f8c38c2d9 100644 (file)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.29 2003/05/10 13:15:43 chriskl Exp $
+        * $Id: english.php,v 1.30 2003/05/15 09:48:42 chriskl Exp $
         */
 
        // Language and character set
@@ -84,6 +84,9 @@
        $lang['strdata'] = 'Data';
        $lang['strconfirm'] = 'Confirm';
        $lang['strexpression'] = 'Expression';
+       $lang['strellipsis'] = '...';
+       $lang['strexpand'] = 'Expand';
+       $lang['strcollapse'] = 'Collapse';
 
        // Error handling
        $lang['strnoframes'] = 'You need a frames-enabled browser to use this application.';
index eb5e517a7d7c0636e3e8ed324dcb90e2f5357d08..f6e11bc50275ccac3d71d19c726a64b6d68ab281 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List tables in a database
         *
-        * $Id: tables.php,v 1.21 2003/05/15 03:35:08 chriskl Exp $
+        * $Id: tables.php,v 1.22 2003/05/15 09:48:39 chriskl Exp $
         */
 
        // Include application functions
                        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=\"sortdir\" value=\"", htmlspecialchars($_REQUEST['sortdir']), "\" />\n";
+                       echo "<input type=\"hidden\" name=\"strings\" value=\"", htmlspecialchars($_REQUEST['strings']), "\" />\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 $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=\"sortdir\" value=\"", htmlspecialchars($_REQUEST['sortdir']), "\" />\n";
+                       echo "<input type=\"hidden\" name=\"strings\" value=\"", htmlspecialchars($_REQUEST['strings']), "\" />\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";
                
                if (!isset($_REQUEST['page'])) $_REQUEST['page'] = 1;
                if (!isset($_REQUEST['sortkey'])) $_REQUEST['sortkey'] = '';
+               if (!isset($_REQUEST['sortdir'])) $_REQUEST['sortdir'] = '';
+               if (!isset($_REQUEST['strings'])) $_REQUEST['strings'] = 'collapsed';
 
                // Retrieve page from table.  $max_pages is returned by reference.
-               $rs = &$localData->browseRelation($_REQUEST['table'], $_REQUEST['sortkey'], $_REQUEST['page'], $conf['max_rows'], $max_pages);
+               $rs = &$localData->browseRelation($_REQUEST['table'], $_REQUEST['sortkey'], $_REQUEST['sortdir'], 
+                                                                                                               $_REQUEST['page'], $conf['max_rows'], $max_pages);
 
                // Fetch unique row identifier, if there is one
                $key = $localData->getRowIdentifier($_REQUEST['table']);
                if (is_object($rs) && $rs->recordCount() > 0) {
                        // Show page navigation
                        $misc->printPages($_REQUEST['page'], $max_pages, "{$PHP_SELF}?action=browse&page=%s&{$misc->href}&sortkey=" .
-                               urlencode($_REQUEST['sortkey']) . "&table=" . urlencode($_REQUEST['table']));
+                               urlencode($_REQUEST['sortkey']) . "&sortdir=" . urlencode($_REQUEST['sortdir']) . 
+                               "&strings=" . urlencode($_REQUEST['strings']) . "&table=" . urlencode($_REQUEST['table']));
                        echo "<table>\n<tr>";
 
                        // @@ CHECK THAT KEY ACTUALLY IS IN THE RESULT SET...
                        reset($rs->f);
                        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=", 
+                               echo "<th class=\"data\"><a href=\"{$PHP_SELF}?action=browse&page=", $_REQUEST['page'], 
+                                       "&{$misc->href}&sortkey=", urlencode($k), "&sortdir=";
+                                       // Sort direction opposite to current direction, unless it's currently ''
+                                       echo ($_REQUEST['sortdir'] == 'asc' && $_REQUEST['sortkey'] == $k) ? 'desc' : 'asc';
+                                       echo "&strings=", urlencode($_REQUEST['strings']), "&table=", 
                                        urlencode($_REQUEST['table']), "\">", $misc->printVal($k), "</a></th>\n";
                        }
                                                
                                                echo "<td class=\"opbutton{$id}\">&nbsp;</td>\n<td class=\"opbutton{$id}\">&nbsp;</td>\n";
                                        } else {
                                                echo "<td class=\"opbutton{$id}\"><a href=\"{$PHP_SELF}?action=confeditrow&{$misc->href}&sortkey=", 
-                                                       urlencode($_REQUEST['sortkey']), "&table=", urlencode($_REQUEST['table']), 
+                                                       urlencode($_REQUEST['sortkey']), "&sortdir=", urlencode($_REQUEST['sortdir']), 
+                                                       "&table=", urlencode($_REQUEST['table']), "&strings=", urlencode($_REQUEST['strings']), 
                                                        "&page=", $_REQUEST['page'], "&{$key_str}\">{$lang['stredit']}</a></td>\n";
                                                echo "<td class=\"opbutton{$id}\"><a href=\"{$PHP_SELF}?action=confdelrow&{$misc->href}&sortkey=", 
-                                                       urlencode($_REQUEST['sortkey']), "&table=", urlencode($_REQUEST['table']), 
+                                                       urlencode($_REQUEST['sortkey']), "&sortdir=", urlencode($_REQUEST['sortdir']), 
+                                                       "&table=", urlencode($_REQUEST['table']),  "&strings=", urlencode($_REQUEST['strings']), 
                                                        "&page=", $_REQUEST['page'], "&{$key_str}\">{$lang['strdelete']}</a></td>\n";
                                        }
                                }
                                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}\">", $misc->printVal($v), "</td>";
+                                       elseif ($v !== null && $v == '') echo "<td class=\"data{$id}\">&nbsp;</td>";
+                                       else {
+                                               // Trim strings if over length
+                                               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 "</tr>\n";
                                $rs->moveNext();
                }
                else echo "<p>{$lang['strnodata']}</p>\n";
                
-               echo "<p><a class=\"navlink\" href=\"$PHP_SELF?{$misc->href}\">{$lang['strshowalltables']}</a></p>\n";
+               echo "<p><a class=\"navlink\" href=\"$PHP_SELF?{$misc->href}\">{$lang['strshowalltables']}</a> |\n";
+               if ($_REQUEST['strings'] == 'expanded')
+                       echo "<a class=\"navlink\" href=\"{$PHP_SELF}?action=browse&{$misc->href}&sortkey=", 
+                               urlencode($_REQUEST['sortkey']), "&sortdir=", urlencode($_REQUEST['sortdir']), "&table=", urlencode($_REQUEST['table']), 
+                               "&strings=collapsed&page=", $_REQUEST['page'], "&{$key_str}\">{$lang['strcollapse']}</a></p>\n";
+               else
+                       echo "<a class=\"navlink\" href=\"{$PHP_SELF}?action=browse&{$misc->href}&sortkey=", 
+                               urlencode($_REQUEST['sortkey']), "&sortdir=", urlencode($_REQUEST['sortdir']), "&table=", urlencode($_REQUEST['table']), 
+                               "&strings=expanded&page=", $_REQUEST['page'], "&{$key_str}\">{$lang['strexpand']}</a></p>\n";
+               
        }
 
        /**