implemented feature #1460852: handle duplicates fields Wizard views creation
authorioguix <ioguix>
Mon, 16 Apr 2007 21:41:14 +0000 (21:41 +0000)
committerioguix <ioguix>
Mon, 16 Apr 2007 21:41:14 +0000 (21:41 +0000)
lang/english.php
lang/french.php
lang/recoded/english.php
lang/recoded/french.php
views.php

index eddef8096adf1069cda534fe2280e0afc056531a..536b30196e1e7a4731d1b94c2f0cf74ce79d7899 100755 (executable)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.202 2007/04/01 16:02:07 xzilla Exp $
+        * $Id: english.php,v 1.203 2007/04/16 21:41:14 ioguix Exp $
         */
 
        // Language and character set
        $lang['strviewlink'] = 'Linking keys';
        $lang['strviewconditions'] = 'Additional conditions';
        $lang['strcreateviewwiz'] = 'Create view with wizard';
+       $lang['strrenamedupfields'] = 'Rename duplicate fields';
+       $lang['strdropdupfields'] = 'Drop duplicate fields';
+       $lang['strerrordupfields'] = 'Error on duplicate fields';
 
        // Sequences
        $lang['strsequence'] = 'Sequence';
index f8c91451eb38aa11b37112a8f6e212ccc7d5c37e..08a99d4b4c6c525006aedf7ee1a545ef610eafd0 100644 (file)
@@ -4,7 +4,7 @@
      * French Language file for phpPgAdmin. 
      * @maintainer Pascal PEYRE [pascal.peyre@cir.fr]
      *
-     * $Id: french.php,v 1.22 2007/04/01 16:02:07 xzilla Exp $
+     * $Id: french.php,v 1.23 2007/04/16 21:41:14 ioguix Exp $
      */
 
     // Language and character set
     $lang['strviewlink']  =  'Clés liées';
     $lang['strviewconditions']  =  'Conditions supplémentaires';
     $lang['strcreateviewwiz']  =  'Créer une vue avec l\'assistant';
+       $lang['strrenamedupfields']  =  'Renommer les champs dupliqués';
+       $lang['strdropdupfields']  =  'Ignorer les champs dupliqués';
+       $lang['strerrordupfields']  =  'Erreur en cas de champs dupliqués';
 
     // Sequences
     $lang['strsequence'] = 'Séquence';
index 1cd431f47a66fc81ed785fd7cdc32d142cc41564..a6f2ac5276d86a3e49ec86497a7eb75fe96f40b6 100644 (file)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.154 2007/04/01 16:02:06 xzilla Exp $
+        * $Id: english.php,v 1.155 2007/04/16 21:41:14 ioguix Exp $
         */
 
        // Language and character set
        $lang['strviewlink'] = 'Linking keys';
        $lang['strviewconditions'] = 'Additional conditions';
        $lang['strcreateviewwiz'] = 'Create view with wizard';
+       $lang['strrenamedupfields'] = 'Rename duplicate fields';
+       $lang['strdropdupfields'] = 'Drop duplicate fields';
+       $lang['strerrordupfields'] = 'Error on duplicate fields';
 
        // Sequences
        $lang['strsequence'] = 'Sequence';
index 645c92f51cc4aaba86f4143e9dbf138e26264d8f..83cc2d3da9937d64fdef838923bc46629b0aa25f 100644 (file)
@@ -4,7 +4,7 @@
      * French Language file for phpPgAdmin. 
      * @maintainer Pascal PEYRE [pascal.peyre@cir.fr]
      *
-     * $Id: french.php,v 1.21 2007/04/01 16:02:06 xzilla Exp $
+     * $Id: french.php,v 1.22 2007/04/16 21:41:14 ioguix Exp $
      */
 
     // Language and character set
     $lang['strviewlink']  =  'Cl&#233;s li&#233;es';
     $lang['strviewconditions']  =  'Conditions suppl&#233;mentaires';
     $lang['strcreateviewwiz']  =  'Cr&#233;er une vue avec l\'assistant';
+       $lang['strrenamedupfields']  =  'Renommer les champs dupliqu&#233;s';
+       $lang['strdropdupfields']  =  'Ignorer les champs dupliqu&#233;s';
+       $lang['strerrordupfields']  =  'Erreur en cas de champs dupliqu&#233;s';
 
     // Sequences
     $lang['strsequence'] = 'S&#233;quence';
index 4890447f3a897822794d11b91b63e3284a4e4bc4..b4b5106eae88a4488df1fae519dc636143570334 100644 (file)
--- a/views.php
+++ b/views.php
@@ -3,7 +3,7 @@
        /**
         * Manage views in a database
         *
-        * $Id: views.php,v 1.62 2007/04/16 16:59:46 soranzo Exp $
+        * $Id: views.php,v 1.63 2007/04/16 21:41:14 ioguix Exp $
         */
 
        // Include application functions
                        echo "<tr><th class=\"data\">{$lang['strcolumns']}</th></tr>";
                        echo "<tr>\n<td class=\"data1\">\n";
                        echo GUI::printCombo($arrFields, 'formFields[]', false, '', true);
-                       echo "</td>\n</tr>\n</table>\n<br />\n";
+                       echo "</td>\n</tr>";
+                       echo "<tr><td><input type=\"radio\" name=\"dblFldMeth\" id=\"dblFldMeth1\" value=\"rename\" /><label for=\"dblFldMeth1\">{$lang['strrenamedupfields']}</label>";
+                       echo "<br /><input type=\"radio\" name=\"dblFldMeth\" id=\"dblFldMeth2\" value=\"drop\" /><label for=\"dblFldMeth2\">{$lang['strdropdupfields']}</label>";
+                       echo "<br /><input type=\"radio\" name=\"dblFldMeth\" id=\"dblFldMeth3\" value=\"\" /><label for=\"dblFldMeth3\">{$lang['strerrordupfields']}</label></td></tr></table><br />";
                        
                        // Output the Linking keys combo boxes
                        echo "<table>\n";
                                echo GUI::printCombo($arrFields, "formLink[$i][rightlink]", true, $curRightLink, false );
                                echo "</td>\n</tr>\n";
                                $rowClass = $rowClass == 'data1' ? 'data2' : 'data1';
-                       }
+                       }                       
                        echo "</table>\n<br />\n";
                        
                        // Build list of available operators (infix only)
                if (!strlen($_POST['formView']) ) doSetParamsCreate($lang['strviewneedsname']);
                else if (!isset($_POST['formFields']) || !count($_POST['formFields']) ) doSetParamsCreate($lang['strviewneedsfields']);
                else {                                          
-                       $selFields = '';                                                
+                       $selFields = '';
+
+                       if (! empty ($_POST['dblFldMeth']) )
+                               $tmpHsh = array ();
+
                        foreach ($_POST['formFields'] AS $curField) {
                                $arrTmp = unserialize($curField);
-                               if ($data->hasSchemas() ) {                                     
-                                       $selFields .= strlen($selFields) ? ", \"{$arrTmp['schemaname']}\".\"{$arrTmp['tablename']}\".\"{$arrTmp['fieldname']}\"" : "\"{$arrTmp['schemaname']}\".\"{$arrTmp['tablename']}\".\"{$arrTmp['fieldname']}\"";
+                               if ( ! empty ($_POST['dblFldMeth'] ) ) { // doublon control
+                                       if (empty ($tmpHsh[$arrTmp['fieldname']])) { // field does not exist
+                                               $selFields .= $data->hasSchemas() ? "\"{$arrTmp['schemaname']}\".":"";
+                                               $selFields .= "\"{$arrTmp['tablename']}\".\"{$arrTmp['fieldname']}\", ";
+                                               $tmpHsh[$arrTmp['fieldname']]=1;
+                                       } else if ($_POST['dblFldMeth']=="rename") { // field exist and must be renamed
+                                               $tmpHsh[$arrTmp['fieldname']]++;
+                                               $selFields .= $data->hasSchemas() ? "\"{$arrTmp['schemaname']}\".":"";
+                                               $selFields .= "\"{$arrTmp['tablename']}\".\"{$arrTmp['fieldname']}\" AS \"{$arrTmp['schemaname']}_{$arrTmp['tablename']}_{$arrTmp['fieldname']}{$tmpHsh[$arrTmp['fieldname']]}\", ";
+                                       }
+                                       /* field already exist, just ignore this one */
+                               } else { // no doublon control
+                                       $selFields .= $data->hasSchemas() ? "\"{$arrTmp['schemaname']}\".":"";
+                                       $selFields .= "\"{$arrTmp['tablename']}\".\"{$arrTmp['fieldname']}\", ";
                                }
-                               else {
-                                       $selFields .= strlen($selFields) ? ", \"{$arrTmp['tablename']}\".\"{$arrTmp['fieldname']}\"" : "\"{$arrTmp['tablename']}\".\"{$arrTmp['fieldname']}\"";
-                               }                               
-                       }                       
-                       
+                       }
+
+                       $selFields = substr ($selFields, 0, -2);
+                       unset ($arrTmp,$tmpHsh);
                        $linkFields = '';
 
                        // If we have links, out put the JOIN ... ON statements