From b1ae0079a792635c9202bb5d2fb3468ade5e7b55 Mon Sep 17 00:00:00 2001 From: Michael Joseph Date: Wed, 12 Mar 2003 10:08:28 +0000 Subject: [PATCH] added functionality to retrieve and set listbox values --- lib/visualpatterns/PatternListBox.inc | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+), 0 deletions(-) diff --git a/lib/visualpatterns/PatternListBox.inc b/lib/visualpatterns/PatternListBox.inc index e7ea859..88ae1c7 100644 --- a/lib/visualpatterns/PatternListBox.inc +++ b/lib/visualpatterns/PatternListBox.inc @@ -43,6 +43,8 @@ class PatternListBox { var $sEmptyErrorMessage = "No values"; /** whether to include 'None' as an option*/ var $bIncludeDefaultValue = true; + /** additional list box items */ + var $aAdditionalEntries; /** * Constructor @@ -89,6 +91,10 @@ class PatternListBox { function setIncludeDefaultValue($bNewValue) { $this->bIncludeDefaultValue = $bNewValue; } + + function setAdditionalEntries($aNewValue) { + $this->aAdditionalEntries = $aNewValue; + } /** * Create the HTML string that will be used to render the list box @@ -128,11 +134,40 @@ class PatternListBox { $sToRender .= "\n"; } } + if (isset($this->aAdditionalEntries)) { + for ($i=0; $iaAdditionalEntries); $i++) { + $sToRender .= "\n"; + } + } $sToRender .= "\n"; } else { $sToRender .= "\n"; } return $sToRender; } + + function getEntries() { + global $default; + + $sql = $default->db; + $sQuery = "SELECT DISTINCT ST." . $this->sDisplayColumn . " AS display, ST." . $this->sValueColumn . " AS value FROM $this->sTableName AS ST "; + if (isset($this->sFromClause)) { + $sQuery .= $this->sFromClause . " "; + } + if (isset($this->sWhereClause)) { + $sQuery .= "WHERE " . $this->sWhereClause . " "; + + } + + $sQuery .= "ORDER BY ST.$this->sDisplayColumn " . ($this->bOrderAsc ? "ASC" : "DESC"); + + $sql->query($sQuery); + $aValues = array(); + while ($sql->next_record()) { + $aValues[] = array("value" => $sql->f("value"), + "display" => stripslashes($sql->f("display"))); + } + return $aValues; + } } ?> -- libgit2 0.21.4