Refactor column properties into thier own page.
authorxzilla <xzilla>
Thu, 3 Aug 2006 19:03:32 +0000 (19:03 +0000)
committerxzilla <xzilla>
Thu, 3 Aug 2006 19:03:32 +0000 (19:03 +0000)
Columns properties can now be accessed from the tree.
Browsing via a column icon gives you the aggregate count of the values in that table.

Patch from JGuillaume 'ioguix' De Rorthais

HISTORY
classes/Misc.php
lang/english.php
lang/french.php
lang/recoded/english.php
lang/recoded/french.php
lang/recoded/spanish.php
lang/spanish.php
libraries/decorator.inc.php
tblproperties.php
viewproperties.php

diff --git a/HISTORY b/HISTORY
index 61164f58bf53bc7c7ffb9909295b7a685931962e..62bf3c544ccd30d8704321284d74cdfc67d75ae3 100644 (file)
--- a/HISTORY
+++ b/HISTORY
@@ -19,6 +19,7 @@ Features
 * Re-enable table browsing from tree icons (ioguix) 
 * Add Support For IN/OUT Parameters (John Jawed)
 * Add column level information into the tree browser (ioguix) 
+* Promote column level interaction into its own page (ioguix) 
 
 Version 4.0
 -----------
index 65a6a263f9d2387a9c2988b1734f9273bc1f0c84..b96a4e35cb0f4768d27d7a1cc99a77a32f42598b 100644 (file)
@@ -2,7 +2,7 @@
        /**
         * Class to hold various commonly used functions
         *
-        * $Id: Misc.php,v 1.131 2006/06/23 00:57:37 xzilla Exp $
+        * $Id: Misc.php,v 1.132 2006/08/03 19:03:33 xzilla Exp $
         */
         
        class Misc {
                                                        'icon'  => 'ReplicationSets',
                                                ),
                                        );
+
+                               case 'column':
+                                       return array(
+                                               'properties' => array (
+                                                       'title'         => $lang['strcolprop'],
+                                                       'url'           => 'colproperties.php',
+                                                       'urlvars'       => array('subject' => 'column', 'table' => field('table'), 'column' => field('column')),
+                                                       'icon'          => 'Column'
+                                               )
+                                       );
                                        
                                default:
                                        return array();
                                                        'icon'  => 'AvailableReplicationSet'
                                                );
                                                break;
+                                       case 'column':
+                                               $vars .= "&column={$_REQUEST['column']}&subject=column";
+                                               $trail['column'] = array (
+                                                       'title' => $lang['strcolumn'],
+                                                       'text'  => $_REQUEST['column'],
+                                                       'icon'  => 'Column',
+                                                       'url'   => "redirect.php?{$vars}"
+                                               );
+                                               break;
                                        default:
                                                if (isset($_REQUEST[$subject])) {
                                                        switch ($subject) {
index 90218344307a9354cef4f04603b206edb50293d0..9fadc28d720eaae589ed51c038be34e377f66aae 100755 (executable)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.191 2006/06/28 00:56:10 soranzo Exp $
+        * $Id: english.php,v 1.192 2006/08/03 19:03:33 xzilla Exp $
         */
 
        // Language and character set
        $lang['strconfvacuumtable'] = 'Are you sure you want to vacuum "%s"?';
        $lang['strestimatedrowcount'] = 'Estimated row count';
 
+       // Columns
+       $lang['strcolprop'] = 'Column Properties';
+               
        // Users
        $lang['struser'] = 'User';
        $lang['strusers'] = 'Users';
        $lang['strargname'] = 'Name';
        $lang['strargmode'] = 'Mode';
        $lang['strargtype'] = 'Type';
-       $lang['strargadd'] = 'Add another Argument';
+       $lang['strargadd'] = 'Add another argument';
        $lang['strargremove'] = 'Remove this argument';
        $lang['strargnoargs'] = 'This function will not take any arguments.';
        $lang['strargenableargs'] = 'Enable arguments being passed to this function.';
index b5cf66dc11fdbe6ad0fc2b21d4d0461f837f4f4c..7b029451f7757897b97a46b104ef7938746a37b4 100644 (file)
@@ -4,7 +4,7 @@
      * French Language file for phpPgAdmin. 
      * @maintainer Pascal PEYRE [pascal.peyre@cir.fr]
      *
-     * $Id: french.php,v 1.18 2006/06/29 15:43:03 xzilla Exp $
+     * $Id: french.php,v 1.19 2006/08/03 19:03:33 xzilla Exp $
      */
 
     // Language and character set
     $lang['strconfvacuumtable']  =  'Êtes-vous sur de vouloir faire un vacuum de « %s » ?';
     $lang['strestimatedrowcount']  =  'Nombre d\'enregistrements estimés';
 
+       // Columns
+       $lang['strcolprop']  =  'Propriétés de la Colonne';
+               
     // Users
     $lang['struser'] = 'Utilisateur';
     $lang['strusers'] = 'Utilisateurs';
index 0fa55ad6ec881a24bb5b6a0d156311d3bbc7a574..fabd2d8e09555fa8cddd08bbc7e544e41f18a7b0 100644 (file)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.144 2006/06/28 00:56:11 soranzo Exp $
+        * $Id: english.php,v 1.145 2006/08/03 19:03:33 xzilla Exp $
         */
 
        // Language and character set
        $lang['strconfvacuumtable'] = 'Are you sure you want to vacuum &quot;%s&quot;?';
        $lang['strestimatedrowcount'] = 'Estimated row count';
 
+       // Columns
+       $lang['strcolprop'] = 'Column Properties';
+               
        // Users
        $lang['struser'] = 'User';
        $lang['strusers'] = 'Users';
index 7147ffdfea5167aac29b58313f43ed3d1be65819..c79011a1e9d636aaf36fdd76007160006c37cadf 100644 (file)
@@ -4,7 +4,7 @@
      * French Language file for phpPgAdmin. 
      * @maintainer Pascal PEYRE [pascal.peyre@cir.fr]
      *
-     * $Id: french.php,v 1.17 2006/06/29 15:43:04 xzilla Exp $
+     * $Id: french.php,v 1.18 2006/08/03 19:03:33 xzilla Exp $
      */
 
     // Language and character set
     $lang['strconfvacuumtable']  =  '&#202;tes-vous sur de vouloir faire un vacuum de &#171; %s &#187; ?';
     $lang['strestimatedrowcount']  =  'Nombre d\'enregistrements estim&#233;s';
 
+       // Columns
+       $lang['strcolprop']  =  'Propri&#233;t&#233;s de la Colonne';
+               
     // Users
     $lang['struser'] = 'Utilisateur';
     $lang['strusers'] = 'Utilisateurs';
index fe759d86a5f1b955a86b863a5ce36c42b46d2eba..5c6a441e4eb5c7a7929d27d23b65505bbf6ff3be 100644 (file)
@@ -4,7 +4,7 @@
         * Spanish language file for phpPgAdmin.
         * @maintainer Mart&#237;n Marqu&#233;s (martin@bugs.unl.edu.ar)
         *
-        * $Id: spanish.php,v 1.35 2006/06/27 21:34:22 xzilla Exp $
+        * $Id: spanish.php,v 1.36 2006/08/03 19:03:33 xzilla Exp $
         */
 
        // Language and character set
@@ -222,6 +222,9 @@ $lang['strbackslashn']  =  '\N';
     $lang['strconfvacuumtable']  =  'Esta seguro que quiere limpiar &quot;%s&quot;?';
     $lang['strestimatedrowcount']  =  'Estimaci&#243;n de filas';
 
+       // Columns
+       $lang['strcolprop'] = 'Propiedades de Columna';
+
     // Users
        $lang['struser'] = 'Usuario';
        $lang['strusers'] = 'Usuarios';
index 53ed5515e458035f2c3e372686d8f81b4b6627af..e3d9609ef358570ef1e45d6a505682d5b37bb3a0 100644 (file)
@@ -4,7 +4,7 @@
         * Spanish language file for phpPgAdmin.
         * @maintainer Martín Marqués (martin@bugs.unl.edu.ar)
         *
-        * $Id: spanish.php,v 1.34 2006/06/27 21:34:22 xzilla Exp $
+        * $Id: spanish.php,v 1.35 2006/08/03 19:03:33 xzilla Exp $
         */
 
        // Language and character set
@@ -222,6 +222,9 @@ $lang['strbackslashn']  =  '\N';
     $lang['strconfvacuumtable']  =  'Esta seguro que quiere limpiar "%s"?';
     $lang['strestimatedrowcount']  =  'Estimación de filas';
 
+       // Columns
+       $lang['strcolprop'] = 'Propiedades de Columna';
+
     // Users
        $lang['struser'] = 'Usuario';
        $lang['strusers'] = 'Usuarios';
index 2615b6c5de165a48e1be0f83d3320699ed35af4b..a93e66caf76d16f059ff737c1d22d295526a8bbb 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-// $Id: decorator.inc.php,v 1.5 2005/10/18 04:11:58 mr-russ Exp $
+// $Id: decorator.inc.php,v 1.6 2006/08/03 19:03:33 xzilla Exp $
 
 // This group of functions and classes provides support for
 // resolving values in a lazy manner (ie, as and when required)
@@ -56,6 +56,10 @@ function noEscape($value) {
        return new Decorator($value, false);
 }
 
+function prepareSQL($sql, $params) {
+       return new PrepareSQL($sql, $params);
+}
+
 // Resolving functions:
 
 function value(&$var, &$fields, $esc = null) {
@@ -210,4 +214,20 @@ class UrlDecorator extends Decorator
                return $url;
        }
 }
+
+class PrepareSQL extends Decorator
+{
+       function PrepareSQL($sql, $params) {
+               $this->q = $sql;
+               $this->p = $params;
+       }
+
+       function value($fields) {
+               $req = $this->q;
+               foreach ($this->p as $k => $v) {
+                       $req = str_replace($k, value($v, $fields), $req);
+               }
+               return $req;
+       }
+}
 ?>
index bba9e9439d6f09cccd8601d3612e14b61af4ae36..b7e053f3c58a8f1e35ff335d92dd2e6cb1624397 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List tables in a database
         *
-        * $Id: tblproperties.php,v 1.70 2006/06/29 18:22:34 xzilla Exp $
+        * $Id: tblproperties.php,v 1.71 2006/08/03 19:03:32 xzilla Exp $
         */
 
        // Include application functions
         * Displays a screen where they can add a column
         */
        function doAddColumn($msg = '') {
-               global $data, $misc;
+               global $data, $misc, $_reload_browser;
                global $PHP_SELF, $lang;
 
                if (!isset($_REQUEST['stage'])) $_REQUEST['stage'] = 1;
                                $status = $data->addColumn($_POST['table'], $_POST['field'],
                                                           $_POST['type'], $_POST['array'] != '', $_POST['length'], isset($_POST['notnull']),
                                                           $_POST['default'], $_POST['comment']);
-                               if ($status == 0)
+                               if ($status == 0) {
+                                       $_reload_browser = true;
                                        doDefault($lang['strcolumnadded']);
+                               }
                                else {
                                        $_REQUEST['stage'] = 1;
                                        doAddColumn($lang['strcolumnaddedbad']);
         * Displays a screen where they can alter a column
         */
        function doProperties($msg = '') {
-               global $data, $misc;
+               global $data, $misc, $_reload_browser;
                global $PHP_SELF, $lang;
 
                if (!isset($_REQUEST['stage'])) $_REQUEST['stage'] = 1;
                                                             $_REQUEST['default'], $_REQUEST['olddefault'],
                                                             $_REQUEST['type'], $_REQUEST['length'], $_REQUEST['array'], $_REQUEST['oldtype'],
                                                             $_REQUEST['comment']);
-                               if ($status == 0)
+                               if ($status == 0) {
+                                       if ($_REQUEST['column'] != $_REQUEST['field']) {
+                                               $_reload_browser = true;
+                                               $_REQUEST['column'] = $_REQUEST['field'];
+                                       }
                                        doDefault($lang['strcolumnaltered']);
+                               }
                                else {
                                        $_REQUEST['stage'] = 1;
                                        doProperties($lang['strcolumnalteredbad']);
         * Show confirmation of drop column and perform actual drop
         */
        function doDrop($confirm) {
-               global $data, $database, $misc;
+               global $data, $database, $misc, $_reload_browser;
                global $PHP_SELF, $lang;
 
                if ($confirm) {
                }
                else {
                        $status = $data->dropColumn($_POST['table'], $_POST['column'], isset($_POST['cascade']));
-                       if ($status == 0)
+                       if ($status == 0) {
+                               $_reload_browser = true;
                                doDefault($lang['strcolumndropped']);
+                       }
                        else
                                doDefault($lang['strcolumndroppedbad']);
                }
                global $misc, $data;
 
                $columns = $data->getTableAttributes($_REQUEST['table']);
-               $reqvars = $misc->getRequestVars('table');
+               $reqvars = $misc->getRequestVars('column');
 
                $attrs = array (
                        'text'   => field('attname'),
+                       'action' => url('colproperties.php',
+                                                       $reqvars,
+                                                       array(
+                                                               'table'         => $_REQUEST['table'],
+                                                               'column'        => field('attname')
+                                                       )
+                                               ),
                        'icon'   => 'Column',
+                       'iconAction' => url('display.php',
+                                                               $reqvars,
+                                                               array(
+                                                                       'table'         => $_REQUEST['table'],
+                                                                       'column'        => field('attname'),
+                                                                       'query'         => prepareSQL(
+                                                                                                               "SELECT %column%, count(*) AS \"count\" FROM %table% GROUP BY %column% ORDER BY %column%", 
+                                                                                                               array (
+                                                                                                                       '%column%' => field('attname'),
+                                                                                                                       '%table%' => $_REQUEST['table']
+                                                                                                               )
+                                                                                                       )
+                                                               )
+                                                       ),
                        'toolTip'=> field('comment')
                );
 
                // Get table
                $tdata = $data->getTable($_REQUEST['table']);
                // Get columns
-               $attrs = $data->getTableAttributes($_REQUEST['table']);         
+               $attrs = $data->getTableAttributes($_REQUEST['table']);
 
                // Show comment if any
                if ($tdata->f['relcomment'] !== null)
                );
                
                $actions = array(
+                       'properties' => array(
+                               'title' => $lang['strproperties'],
+                               'url'   => "colproperties.php?subject=column&amp;{$misc->href}&amp;table=".urlencode($_REQUEST['table'])."&amp;",
+                               'vars'  => array('column' => 'attname'),
+                       ),
                        'alter' => array(
                                'title' => $lang['stralter'],
                                'url'   => "{$PHP_SELF}?action=properties&amp;{$misc->href}&amp;table=".urlencode($_REQUEST['table'])."&amp;",
index 2b23bcf22dfa37e7e1ba222579aa6a13e017548f..d6eaa17ba74b0b69081eb9dfa0728d1c8d3d1b1e 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * List views in a database
         *
-        * $Id: viewproperties.php,v 1.20 2006/06/29 18:22:34 xzilla Exp $
+        * $Id: viewproperties.php,v 1.21 2006/08/03 19:03:32 xzilla Exp $
         */
 
        // Include application functions
        function doTree () {
                global $misc, $data;
 
+               $reqvars = $misc->getRequestVars('column');
                $columns = $data->getTableAttributes($_REQUEST['view']);
-               $reqvars = $misc->getRequestVars('view');
-
+               
                $attrs = array (
                        'text'   => field('attname'),
+                       'action' => url('colproperties.php',
+                                                       $reqvars,
+                                                       array(
+                                                               'view'     => $_REQUEST['view'],
+                                                               'column'    => field('attname')
+                                                       )
+                                               ),
                        'icon'   => 'Column',
+                       'iconAction' => url('display.php',
+                                                       $reqvars,
+                                                       array(
+                                                               'view'     => $_REQUEST['view'],
+                                                               'column'    => field('attname'),
+                                                               'query'     => prepareSQL(
+                                                                       "SELECT %column%, count(*) AS \"count\" FROM %view% GROUP BY %column% ORDER BY %column%",
+                                                                       array (
+                                                                               '%column%' => field('attname'),
+                                                                               '%view%' => $_REQUEST['view']
+                                                                       )
+                                                               )
+                                                       )
+                       ),
                        'toolTip'=> field('comment')
                );