Commit b1ae0079a792635c9202bb5d2fb3468ade5e7b55
1 parent
d2c0bb58
added functionality to retrieve and set listbox values
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1510 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
35 additions
and
0 deletions
lib/visualpatterns/PatternListBox.inc
| ... | ... | @@ -43,6 +43,8 @@ class PatternListBox { |
| 43 | 43 | var $sEmptyErrorMessage = "No values"; |
| 44 | 44 | /** whether to include 'None' as an option*/ |
| 45 | 45 | var $bIncludeDefaultValue = true; |
| 46 | + /** additional list box items */ | |
| 47 | + var $aAdditionalEntries; | |
| 46 | 48 | |
| 47 | 49 | /** |
| 48 | 50 | * Constructor |
| ... | ... | @@ -89,6 +91,10 @@ class PatternListBox { |
| 89 | 91 | function setIncludeDefaultValue($bNewValue) { |
| 90 | 92 | $this->bIncludeDefaultValue = $bNewValue; |
| 91 | 93 | } |
| 94 | + | |
| 95 | + function setAdditionalEntries($aNewValue) { | |
| 96 | + $this->aAdditionalEntries = $aNewValue; | |
| 97 | + } | |
| 92 | 98 | |
| 93 | 99 | /** |
| 94 | 100 | * Create the HTML string that will be used to render the list box |
| ... | ... | @@ -128,11 +134,40 @@ class PatternListBox { |
| 128 | 134 | $sToRender .= "<OPTION value=\"" . $sql->f("value") . "\">" . stripslashes($sql->f("display")) . "</OPTION>\n"; |
| 129 | 135 | } |
| 130 | 136 | } |
| 137 | + if (isset($this->aAdditionalEntries)) { | |
| 138 | + for ($i=0; $i<count($this->aAdditionalEntries); $i++) { | |
| 139 | + $sToRender .= "<OPTION value=\"" . $this->aAdditionalEntries[$i]["value"] . "\">" . $this->aAdditionalEntries[$i]["display"] . "</OPTION>\n"; | |
| 140 | + } | |
| 141 | + } | |
| 131 | 142 | $sToRender .= "</SELECT>\n"; |
| 132 | 143 | } else { |
| 133 | 144 | $sToRender .= "<label class=\"errorText\">$this->sEmptyErrorMessage</label>\n"; |
| 134 | 145 | } |
| 135 | 146 | return $sToRender; |
| 136 | 147 | } |
| 148 | + | |
| 149 | + function getEntries() { | |
| 150 | + global $default; | |
| 151 | + | |
| 152 | + $sql = $default->db; | |
| 153 | + $sQuery = "SELECT DISTINCT ST." . $this->sDisplayColumn . " AS display, ST." . $this->sValueColumn . " AS value FROM $this->sTableName AS ST "; | |
| 154 | + if (isset($this->sFromClause)) { | |
| 155 | + $sQuery .= $this->sFromClause . " "; | |
| 156 | + } | |
| 157 | + if (isset($this->sWhereClause)) { | |
| 158 | + $sQuery .= "WHERE " . $this->sWhereClause . " "; | |
| 159 | + | |
| 160 | + } | |
| 161 | + | |
| 162 | + $sQuery .= "ORDER BY ST.$this->sDisplayColumn " . ($this->bOrderAsc ? "ASC" : "DESC"); | |
| 163 | + | |
| 164 | + $sql->query($sQuery); | |
| 165 | + $aValues = array(); | |
| 166 | + while ($sql->next_record()) { | |
| 167 | + $aValues[] = array("value" => $sql->f("value"), | |
| 168 | + "display" => stripslashes($sql->f("display"))); | |
| 169 | + } | |
| 170 | + return $aValues; | |
| 171 | + } | |
| 137 | 172 | } |
| 138 | 173 | ?> | ... | ... |