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 24 var $sOrderByColumn;
25 25 /** direction of ordering, ascending or descending */
26 26 var $sOrderDirection = "ASC";
  27 + /** New QueryString when submitting to self */
  28 + var $sQueryString;
27 29  
28 30 function PatternBrowseableSearchResults($sTmpQuery, $iTmpResultsToDisplay, $aTmpColumns, $aTmpColumnTypes, $aTmpColumnHeaders, $aTmpLinkURLs = null, $aTmpDBQueryStringColumns = null, $aTmpQueryStringVariableNames = null) {
29 31 $this->sQuery = $sTmpQuery;
... ... @@ -33,7 +35,16 @@ class PatternBrowseableSearchResults {
33 35 $this->aColumnTypes = $aTmpColumnTypes;
34 36 $this->aLinkURLs = $aTmpLinkURLs;
35 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 50 function setStartIndex($iNewValue) {
... ... @@ -111,15 +122,18 @@ class PatternBrowseableSearchResults {
111 122 break;
112 123 case 3:
113 124 //display a url
114   - $sToRender .= "<td><a href=\"" . $this->aLinkURLs[$i];
  125 + $sToRender .= "<td><a href=\"" ;
  126 + $sURLplusQuery = $this->aLinkURLs[$i];
115 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 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 135 $sToRender .= "\">" . $sql->f($this->aColumns[$i]) . "</a></td>\n";
  136 +
123 137 break;
124 138 case 4:
125 139 //diplay an image URL
... ... @@ -155,16 +169,16 @@ class PatternBrowseableSearchResults {
155 169 if (($this->iStartIndex + $this->iResultsToDisplay) < $this->getResultCount($sql) && $this->iStartIndex == 0) {
156 170 $sToRender .= "<td>";
157 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 173 $sToRender .= "</td>\n";
160 174 }
161 175 /* Display both the next and the previous buttons */
162 176 else if (($this->iStartIndex + $this->iResultsToDisplay) < $this->getResultCount($sql) && $this->iStartIndex > 0) {
163 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 179 $sToRender .= "</td>";
166 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 182 $sToRender .= "</td>\n";
169 183  
170 184 }
... ... @@ -174,7 +188,7 @@ class PatternBrowseableSearchResults {
174 188 $sToRender .= ("&nbsp");
175 189 $sToRender .= "</td>";
176 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 192 $sToRender .= "</td>";
179 193 }
180 194  
... ...