Commit cdd011aafacf448f9d7e622643544e34ceec8207

Authored by omar
1 parent 7f7a9b77

Corrected some logic and added some extra querystring functionality


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1860 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/visualpatterns/PatternBrowsableSearchResults.inc
@@ -24,6 +24,8 @@ class PatternBrowseableSearchResults { @@ -24,6 +24,8 @@ class PatternBrowseableSearchResults {
24 var $sOrderByColumn; 24 var $sOrderByColumn;
25 /** direction of ordering, ascending or descending */ 25 /** direction of ordering, ascending or descending */
26 var $sOrderDirection = "ASC"; 26 var $sOrderDirection = "ASC";
  27 + /** New QueryString when submitting to self */
  28 + var $sQueryString;
27 29
28 function PatternBrowseableSearchResults($sTmpQuery, $iTmpResultsToDisplay, $aTmpColumns, $aTmpColumnTypes, $aTmpColumnHeaders, $aTmpLinkURLs = null, $aTmpDBQueryStringColumns = null, $aTmpQueryStringVariableNames = null) { 30 function PatternBrowseableSearchResults($sTmpQuery, $iTmpResultsToDisplay, $aTmpColumns, $aTmpColumnTypes, $aTmpColumnHeaders, $aTmpLinkURLs = null, $aTmpDBQueryStringColumns = null, $aTmpQueryStringVariableNames = null) {
29 $this->sQuery = $sTmpQuery; 31 $this->sQuery = $sTmpQuery;
@@ -33,7 +35,16 @@ class PatternBrowseableSearchResults { @@ -33,7 +35,16 @@ class PatternBrowseableSearchResults {
33 $this->aColumnTypes = $aTmpColumnTypes; 35 $this->aColumnTypes = $aTmpColumnTypes;
34 $this->aLinkURLs = $aTmpLinkURLs; 36 $this->aLinkURLs = $aTmpLinkURLs;
35 $this->aDBQueryStringColumns = $aTmpDBQueryStringColumns; 37 $this->aDBQueryStringColumns = $aTmpDBQueryStringColumns;
36 - $this->aQueryStringVariableNames = $aTmpQueryStringVariableNames; 38 + $this->aQueryStringVariableNames = $aTmpQueryStringVariableNames;
  39 + $this->sQueryString = "";
  40 + }
  41 +
  42 + function setQueryString($sNewQueryString) {
  43 + $this->sQueryString = $sNewQueryString;
  44 + }
  45 +
  46 + function getQueryString() {
  47 + return $this->sOrderByColumn;
37 } 48 }
38 49
39 function setStartIndex($iNewValue) { 50 function setStartIndex($iNewValue) {
@@ -111,15 +122,18 @@ class PatternBrowseableSearchResults { @@ -111,15 +122,18 @@ class PatternBrowseableSearchResults {
111 break; 122 break;
112 case 3: 123 case 3:
113 //display a url 124 //display a url
114 - $sToRender .= "<td><a href=\"" . $this->aLinkURLs[$i]; 125 + $sToRender .= "<td><a href=\"" ;
  126 + $sURLplusQuery = $this->aLinkURLs[$i];
115 for ($j = 0; $j < count($this->aDBQueryStringColumns); $j++) { 127 for ($j = 0; $j < count($this->aDBQueryStringColumns); $j++) {
116 - if (strpos($sToRender, "?") === false) {  
117 - $sToRender .= "?" . $this->aQueryStringVariableNames[$j] . "=" . $sql->f($this->aDBQueryStringColumns[$j]); 128 + if (strpos($sURLplusQuery, "?") === false) {
  129 + $sURLplusQuery .= "?" . $this->aQueryStringVariableNames[$j] . "=" . $sql->f($this->aDBQueryStringColumns[$j]);
118 } else { 130 } else {
119 - $sToRender .= "&" . $this->aQueryStringVariableNames[$j] . "=" . $sql->f($this->aDBQueryStringColumns[$j]); 131 + $sURLplusQuery .= "&" . $this->aQueryStringVariableNames[$j] . "=" . $sql->f($this->aDBQueryStringColumns[$j]);
120 } 132 }
121 } 133 }
  134 + $sToRender .= $sURLplusQuery;
122 $sToRender .= "\">" . $sql->f($this->aColumns[$i]) . "</a></td>\n"; 135 $sToRender .= "\">" . $sql->f($this->aColumns[$i]) . "</a></td>\n";
  136 +
123 break; 137 break;
124 case 4: 138 case 4:
125 //diplay an image URL 139 //diplay an image URL
@@ -155,16 +169,16 @@ class PatternBrowseableSearchResults { @@ -155,16 +169,16 @@ class PatternBrowseableSearchResults {
155 if (($this->iStartIndex + $this->iResultsToDisplay) < $this->getResultCount($sql) && $this->iStartIndex == 0) { 169 if (($this->iStartIndex + $this->iResultsToDisplay) < $this->getResultCount($sql) && $this->iStartIndex == 0) {
156 $sToRender .= "<td>"; 170 $sToRender .= "<td>";
157 //$sToRender .= ("<a href=\"" . $_SERVER["PHP_SELF"] . "?fStartIndex=" . ($this->iStartIndex + $this->iResultsToDisplay) . "\">Next</a>"); 171 //$sToRender .= ("<a href=\"" . $_SERVER["PHP_SELF"] . "?fStartIndex=" . ($this->iStartIndex + $this->iResultsToDisplay) . "\">Next</a>");
158 - $sToRender .= ("<input type=\"image\" src=\"$default->graphicsUrl/widgets/next.gif\" onClick=\"setActionAndSubmit('" . $_SERVER["PHP_SELF"] . "?fStartIndex=" . ($this->iStartIndex + $this->iResultsToDisplay) . "')\" />"); 172 + $sToRender .= ("<input type=\"image\" src=\"$default->graphicsUrl/widgets/next.gif\" onClick=\"setActionAndSubmit('" . $_SERVER["PHP_SELF"] . "?fStartIndex=" . ($this->iStartIndex + $this->iResultsToDisplay) . $this->sQueryString . "')\" />");
159 $sToRender .= "</td>\n"; 173 $sToRender .= "</td>\n";
160 } 174 }
161 /* Display both the next and the previous buttons */ 175 /* Display both the next and the previous buttons */
162 else if (($this->iStartIndex + $this->iResultsToDisplay) < $this->getResultCount($sql) && $this->iStartIndex > 0) { 176 else if (($this->iStartIndex + $this->iResultsToDisplay) < $this->getResultCount($sql) && $this->iStartIndex > 0) {
163 $sToRender .= "<td>"; 177 $sToRender .= "<td>";
164 - $sToRender .= ("<input type=\"image\" src=\"$default->graphicsUrl/widgets/next.gif\" onClick=\"setActionAndSubmit('" . $_SERVER["PHP_SELF"] . "?fStartIndex=" . ($this->iStartIndex + $this->iResultsToDisplay) . "')\" />"); 178 + $sToRender .= ("<input type=\"image\" src=\"$default->graphicsUrl/widgets/next.gif\" onClick=\"setActionAndSubmit('" . $_SERVER["PHP_SELF"] . "?fStartIndex=" . ($this->iStartIndex + $this->iResultsToDisplay) . $this->sQueryString . "')\" />");
165 $sToRender .= "</td>"; 179 $sToRender .= "</td>";
166 $sToRender .= "<td>"; 180 $sToRender .= "<td>";
167 - $sToRender .= ("<input type=\"image\" src=\"$default->graphicsUrl/widgets/previous.gif\" onClick=\"setActionAndSubmit('" . $_SERVER["PHP_SELF"] . "?fStartIndex=" . ($this->iStartIndex - $this->iResultsToDisplay) . "')\" />"); 181 + $sToRender .= ("<input type=\"image\" src=\"$default->graphicsUrl/widgets/previous.gif\" onClick=\"setActionAndSubmit('" . $_SERVER["PHP_SELF"] . "?fStartIndex=" . ($this->iStartIndex - $this->iResultsToDisplay) . $this->sQueryString . "')\" />");
168 $sToRender .= "</td>\n"; 182 $sToRender .= "</td>\n";
169 183
170 } 184 }
@@ -174,7 +188,7 @@ class PatternBrowseableSearchResults { @@ -174,7 +188,7 @@ class PatternBrowseableSearchResults {
174 $sToRender .= ("&nbsp"); 188 $sToRender .= ("&nbsp");
175 $sToRender .= "</td>"; 189 $sToRender .= "</td>";
176 $sToRender .= "<td>\n"; 190 $sToRender .= "<td>\n";
177 - $sToRender .= ("<input type=\"image\" src=\"$default->graphicsUrl/widgets/previous.gif\" onClick=\"setActionAndSubmit('" . $_SERVER["PHP_SELF"] . "?fStartIndex=" . ($this->iStartIndex - $this->iResultsToDisplay) . "')\" />"); 191 + $sToRender .= ("<input type=\"image\" src=\"$default->graphicsUrl/widgets/previous.gif\" onClick=\"setActionAndSubmit('" . $_SERVER["PHP_SELF"] . "?fStartIndex=" . ($this->iStartIndex - $this->iResultsToDisplay) . $this->sQueryString . "')\" />");
178 $sToRender .= "</td>"; 192 $sToRender .= "</td>";
179 } 193 }
180 194