Fix autocompletion for PHP < 4.2.0
authorsoranzo <soranzo>
Tue, 2 Jan 2007 19:04:27 +0000 (19:04 +0000)
committersoranzo <soranzo>
Tue, 2 Jan 2007 19:04:27 +0000 (19:04 +0000)
display.php
tables.php

index 49a5dde39c86bf2e0926db814bbe45597a3a89fd..9d55e5f9d8347c5c553d8f1bf8c0b1c4a59e9f71 100644 (file)
@@ -9,7 +9,7 @@
         * @param $return_desc The return link name
         * @param $page The current page
         *
-        * $Id: display.php,v 1.55 2006/08/04 20:42:24 xzilla Exp $
+        * $Id: display.php,v 1.56 2007/01/02 19:04:27 soranzo Exp $
         */
 
        // Prevent timeouts on large exports (non-safe mode only)
                                $nC = 0;
                                // A word of caution, the following does not support multicolumn FK's at the moment
                                while(!$constraints->EOF) {
-                                       preg_match('/foreign key \((\w+)\) references ([\w]+)\((\w+)\)/i',$constraints->fields["consrc"],$matches);
+                                       preg_match('/foreign key \((\w+)\) references ([\w]+)\((\w+)\)/i', $constraints->fields["consrc"], $matches);
                                        if(!empty($matches)) {
                                                $arrayLocals[$nC] = $matches[1];
-                                               $arrayRefs[$nC] = array($matches[2],$matches[3]);
+                                               $arrayRefs[$nC] = array($matches[2], $matches[3]);
                                                $nC++;
                                        }
                                        $constraints->moveNext();
                                echo "<th class=\"data\">{$lang['strnull']}</th><th class=\"data\">{$lang['strvalue']}</th></tr>";
 
                                $i = 0;
-                               $nCC = 0;
                                while (!$attrs->EOF) {
                                        $szValueName = "values[{$attrs->f['attname']}]";
                                        $szEvents = "";
                                        $szDivPH = "";
                                        if($bAllowAC) {
-                                               if(($idxFound = array_search($attrs->f['attname'],$arrayLocals))!==false) {
+                                               $idxFound = array_search($attrs->f['attname'], $arrayLocals);
+                                               // In PHP < 4.2.0 array_search returns NULL on failure
+                                               if ($idxFound !== NULL && $idxFound !== FALSE) {
                                                        $szEvent = "makeAC('{$szValueName}',{$i},'{$arrayRefs[$idxFound][0]}','{$arrayRefs[$idxFound][1]}','{$_REQUEST["server"]}','{$_REQUEST["database"]}');";
                                                        $szEvents = "onfocus=\"{$szEvent}\" onblur=\"hideAC();document.getElementById('ac_form').onsubmit=function(){return true;};\" onchange=\"{$szEvent}\" id=\"{$szValueName}\" onkeyup=\"{$szEvent}\" autocomplete=\"off\" class='ac_field'";
                                                        $szDivPH = "<div id=\"fac{$i}_ph\"></div>";
index ca533d06eff65f1dab45d4535df8a43b8c62c9db..b7cbb5783aca7751c05d94089f5fc680568425a3 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List tables in a database
         *
-        * $Id: tables.php,v 1.83 2007/01/02 17:24:44 soranzo Exp $
+        * $Id: tables.php,v 1.84 2007/01/02 19:04:27 soranzo Exp $
         */
 
        // Include application functions
                                $nC = 0;
                                // A word of caution, the following does not support multicolumn FK's at the moment
                                while(!$constraints->EOF) {
-                                       preg_match('/foreign key \((\w+)\) references ([\w]+)\((\w+)\)/i',$constraints->fields["consrc"],$matches);
+                                       preg_match('/foreign key \((\w+)\) references ([\w]+)\((\w+)\)/i', $constraints->fields["consrc"], $matches);
                                        if(!empty($matches)) {
                                                $arrayLocals[$nC] = $matches[1];
-                                               $arrayRefs[$nC] = array($matches[2],$matches[3]);
+                                               $arrayRefs[$nC] = array($matches[2], $matches[3]);
                                                $nC++;
                                        }
                                        $constraints->moveNext();
                                        $szEvents = "";
                                        $szDivPH = "";
                                        if($bAllowAC) {
-                                               if(($idxFound = array_search($attrs->f['attname'],$arrayLocals))!==false) {
+                                               $idxFound = array_search($attrs->f['attname'], $arrayLocals);
+                                               // In PHP < 4.2.0 array_search returns NULL on failure
+                                               if ($idxFound !== NULL && $idxFound !== FALSE) { 
                                                        $szEvent = "makeAC('{$szValueName}',{$i},'{$arrayRefs[$idxFound][0]}','{$arrayRefs[$idxFound][1]}','{$_REQUEST["server"]}','{$_REQUEST["database"]}');";
                                                        $szEvents = "onfocus=\"{$szEvent}\" onblur=\"hideAC();document.getElementById('ac_form').onsubmit=function(){return true;};\" onchange=\"{$szEvent}\" id=\"{$szValueName}\" onkeyup=\"{$szEvent}\" autocomplete=\"off\" class='ac_field'";
                                                        $szDivPH = "<div id=\"fac{$i}_ph\"></div>";