Commit 25f260bfa15d1bbecd0da6d21eb8773b9a38ddcf

Authored by rob
1 parent be5cb808

Added functionality to support checboxes and boolean fields


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@856 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/store.php
@@ -38,31 +38,43 @@ for ($i = 0; $i < count($aKeys); $i++) { @@ -38,31 +38,43 @@ for ($i = 0; $i < count($aKeys); $i++) {
38 $iColumnCount = 0; 38 $iColumnCount = 0;
39 39
40 //get all the values for the table 40 //get all the values for the table
41 - while (strncasecmp("unique_end", $sRowStart, 10) != 0) {  
42 - $aColumns[$iColumnCount] = $_POST[$aKeys[$i]];  
43 - $i++;  
44 - $aTypes[$iColumnCount]= $_POST[$aKeys[$i]]; 41 + while ((strncasecmp("unique_end", $sRowStart, 10) != 0) && ($i <= count($aKeys))) {
  42 + $aColumns[$iColumnCount] = $_POST[$aKeys[$i]];
45 $i++; 43 $i++;
  44 + $aTypes[$iColumnCount]= $_POST[$aKeys[$i]];
  45 +
46 46
47 - //uncheck checkboxes don't generate any name/value pairs  
48 - //so if the next key doesn't contain the word "value" and it's type  
49 - //is checkbox, then we have an unchecked check box  
50 - /*echo "Type: " . $aTypes[$iColumnCount] . "<br>";  
51 - if ($aTypes[$iColumnCount] == 2) {  
52 - if (strpos("value", $aKeys[$i]) == 0) {  
53 - //uncheck check box  
54 - $aValues[$iColumnCount] = 0;  
55 - } else {  
56 - $aValues[$iColumnCount] = 1; 47 + switch ($aTypes[$iColumnCount]) {
  48 + case 0:
  49 + //id's
  50 + $i++;
  51 + $aValues[$iColumnCount] = $_POST[$aKeys[$i]];
  52 + break;
  53 + case 1:
  54 + //normal text
  55 + $i++;
  56 + $aValues[$iColumnCount] = $_POST[$aKeys[$i]];
  57 + break;
  58 + case 2:
  59 + //uncheck checkboxes don't generate any name/value pairs
  60 + //so if the next key doesn't contain the word "value" and it's type
  61 + //is checkbox, then we have an unchecked check box
  62 + if (strpos($aKeys[$i + 1], "value") === false) {
  63 + $aValues[$iColumnCount] = false;
  64 + } else {
  65 + $i++;
  66 + $aValues[$iColumnCount] = true;
  67 + }
  68 + //check box
  69 + break;
  70 + case 3:
  71 + //drop down
57 $i++; 72 $i++;
58 - }  
59 - } else {  
60 - $aValues[$iColumnCount] = $_POST[$aKeys[$i]];  
61 - $i++;  
62 - }*/  
63 - 73 + $aValues[$iColumnCount] = $_POST[$aKeys[$i]];
  74 + break;
  75 + }
64 76
65 - $aValues[$iColumnCount] = $_POST[$aKeys[$i]]; 77 + //$aValues[$iColumnCount] = $_POST[$aKeys[$i]];
66 $i++; 78 $i++;
67 79
68 $sRowStart = $aKeys[$i]; 80 $sRowStart = $aKeys[$i];
@@ -88,9 +100,11 @@ for ($i = 0; $i &lt; count($aKeys); $i++) { @@ -88,9 +100,11 @@ for ($i = 0; $i &lt; count($aKeys); $i++) {
88 $sQuery .= "'" . addslashes($aValues[$j]) . "', "; 100 $sQuery .= "'" . addslashes($aValues[$j]) . "', ";
89 break; 101 break;
90 case 2: 102 case 2:
  103 + $sQuery .= $aValues[$j] . ", ";
91 //boolean 104 //boolean
92 break; 105 break;
93 case 3: 106 case 3:
  107 + $sQuery .= $aValues[$j] . ", ";
94 //drop down list 108 //drop down list
95 break; 109 break;
96 default: 110 default:
@@ -108,9 +122,11 @@ for ($i = 0; $i &lt; count($aKeys); $i++) { @@ -108,9 +122,11 @@ for ($i = 0; $i &lt; count($aKeys); $i++) {
108 break; 122 break;
109 case 2: 123 case 2:
110 //boolean 124 //boolean
  125 + $sQuery .= $aValues[count($aColumns) - 1] . ") ";
111 break; 126 break;
112 - case 3: 127 + case 3:
113 //drop down list 128 //drop down list
  129 + $sQuery .= $aValues[count($aColumns) - 1] . ") ";
114 break; 130 break;
115 default: 131 default:
116 break; 132 break;
@@ -131,6 +147,12 @@ for ($i = 0; $i &lt; count($aKeys); $i++) { @@ -131,6 +147,12 @@ for ($i = 0; $i &lt; count($aKeys); $i++) {
131 case 1: 147 case 1:
132 $sQuery .= "'" . addslashes($aValues[$j]) . "', "; 148 $sQuery .= "'" . addslashes($aValues[$j]) . "', ";
133 break; 149 break;
  150 + case 2:
  151 + $sQuery .= $aValues[$j] . ", ";
  152 + break;
  153 + case 3:
  154 + $sQuery .= $aValues[$j] . ", ";
  155 + break;
134 default: 156 default:
135 break; 157 break;
136 } 158 }
@@ -144,6 +166,12 @@ for ($i = 0; $i &lt; count($aKeys); $i++) { @@ -144,6 +166,12 @@ for ($i = 0; $i &lt; count($aKeys); $i++) {
144 case 1: 166 case 1:
145 $sQuery .= "'" . addslashes($aValues[count($aTypes) -1]) . "' "; 167 $sQuery .= "'" . addslashes($aValues[count($aTypes) -1]) . "' ";
146 break; 168 break;
  169 + case 2:
  170 + $sQuery .= ($aValues[count($aTypes) -1] ? 1 : 0) . " ";
  171 + break;
  172 + case 3:
  173 + $sQuery .= $aValues[count($aTypes) -1] . " ";
  174 + break;
147 default: 175 default:
148 break; 176 break;
149 } 177 }