fix for bug report #1868987 and some cleanup. Needs some more cleanup and work for...
authorioguix <ioguix>
Mon, 14 Jan 2008 17:55:01 +0000 (17:55 +0000)
committerioguix <ioguix>
Mon, 14 Jan 2008 17:55:01 +0000 (17:55 +0000)
aciur.js
autocomplete.php
tables.php

index a817a9a88be718d31a9470526fd61126ae5bbec2..710b2509921e34eb8e0c6168ebe7f785f587f4f9 100644 (file)
--- a/aciur.js
+++ b/aciur.js
@@ -80,10 +80,11 @@ if(!bnsr) {
         oRange.moveStart("character",p_len);
         oRange.moveEnd("character",p_len);
         oRange.select();
-       } else if (otxb.setSelectionRange) {
+       } 
+               else if (otxb.setSelectionRange) {
                 otxb.setSelectionRange(p_len,p_len);
+               }
        }
-}
     otxb.focus();
 }
 
@@ -97,12 +98,10 @@ function tA(p_suggestion) {
        }
 }
 
-function findPosX(obj)
-{
+function findPosX(obj) {
        if(obj) {
                var curleft = 0;
-               if (obj.offsetParent)
-               {
+               if (obj.offsetParent) {
                        while (obj.offsetParent)
                        {
                                curleft += obj.offsetLeft
@@ -115,18 +114,15 @@ function findPosX(obj)
        }
 }
 
-function findPosY(obj)
-{
+function findPosY(obj) {
        if(obj) {
                var curtop = 0;
                var n = 0;
                if (obj.y) {
                        curtop += obj.y;
                }
-               else if (obj.offsetParent)
-               {
-                       while (obj.offsetParent)
-                       {
+               else if (obj.offsetParent) {
+                       while (obj.offsetParent) {
                                curtop += obj.offsetTop;
                                obj = obj.offsetParent;
                        }
@@ -256,7 +252,8 @@ function makeAC(tx,n,tb,fk,sid,db) {
                curopt = 0;
                bnsr = false;
                otxb.onkeyup = function (oEvent) {
-               if (!oEvent) { oEvent = window.event; } hKU(oEvent); };
+                       if (!oEvent) { oEvent = window.event; } hKU(oEvent); 
+               };
                initac(tb,fk,sid,db,v);
        } else {
                otxb.onkeyup = function() {};
@@ -270,6 +267,7 @@ function gfacc(s) {
 function iA(parent, node, referenceNode) {
     parent.insertBefore(node, referenceNode.nextSibling);
 }
+
 var asg = new Array();
 var rasg = new Array();
 var rasgc = new Array();
index 823658c627fe926a5921307ee9d81c0be5a3fc45..d2535659354f2756864c48847b71722ad6ecce8b 100644 (file)
@@ -1,11 +1,18 @@
 <?php
        include_once('libraries/lib.inc.php');
-       $szSQL = 'SELECT * FROM ' . $data->clean($_REQUEST['tb']) . ' WHERE ' . $data->clean($_REQUEST['fk']) . " LIKE '" . $data->clean($_REQUEST['v']) . "%' LIMIT 11";
+       $data->clean($_REQUEST['tb']);
+       $data->clean($_REQUEST['fk']);
+       $data->clean($_REQUEST['v']);
+       
+       $szSQL = 'SELECT * FROM ' . $_REQUEST['tb'] . ' WHERE ' . $_REQUEST['fk']
+               . "::text LIKE '" . $_REQUEST['v'] . "%' ORDER BY ". $_REQUEST['fk'] ." LIMIT 11";
+
        $objRes = $data->selectSet($szSQL);
        $arrayRes = array();
        while (!$objRes->EOF) {
                $arrayRes[] = $objRes->fields[$_REQUEST['fk']];
                $objRes->moveNext();
        }
+
        echo implode('PPA_EOF;|', $arrayRes);
 ?>
index 329947f761c5d6295eda85ff6fccec46c3d09783..c9190261cb1e91f3f27f8ba38940376bb62d8f0a 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List tables in a database
         *
-        * $Id: tables.php,v 1.108 2007/12/27 18:28:36 ioguix Exp $
+        * $Id: tables.php,v 1.109 2008/01/14 17:55:01 ioguix Exp $
         */
 
        // Include application functions
                global $data, $misc, $conf;
                global $lang;
 
-               $bAllowAC = ($conf['autocomplete'] != 'disable') ? TRUE : FALSE;
+               $bAllowAC = (($conf['autocomplete'] != 'disable') ? TRUE : FALSE)
+                       && $data->hasConstraintsInfo();
 
                if ($confirm) {
                        $misc->printTrail('table');
 
                        $attrs = $data->getTableAttributes($_REQUEST['table']);
                        if($bAllowAC) {
-                               $constraints = $data->getConstraints($_REQUEST['table']);
+                               $constraints = $data->getConstraintsWithFields($_REQUEST['table']);
+
                                $arrayLocals = array();
                                $arrayRefs = array();
                                $nC = 0;
                                while(!$constraints->EOF) {
-                                       // The following RE will match a FK constrain with a single (quoted or not) referencing column. At the moment we don't support multicolumn FKs
-                                       preg_match('/^FOREIGN KEY \(("[^"]*"|[^\s",]*)\) REFERENCES (.*)\((.*)\)/i', $constraints->fields['consrc'], $matches);
-                                       if(!empty($matches)) {
-                                               // Strip possible quotes and save
-                                               $arrayLocals[$nC] = preg_replace('/"(.*)"/', '$1', $matches[1]);
-                                               $arrayRefs[$nC] = array(preg_replace('/"(.*)"/', '$1', $matches[2]), preg_replace('/"(.*)"/', '$1', $matches[3]));
+                                       // FIXME: add a better support for FKs on multi columns
+                                       if ($constraints->fields['contype'] == 'f') {
+                                               $arrayLocals[$nC] = $constraints->fields['p_field'];
+                                               $arrayRefs[$nC] = array($constraints->fields['f_table'], $constraints->fields['f_field']);
                                                $nC++;
                                        }
                                        $constraints->moveNext();