00001 <?PHP
00017 include_once("OptionElement.php");
00018
00027 class EditCombobox extends OptionElement
00028 {
00029 public $m_BlankOption;
00030 protected $m_WidthInput = "128px";
00031 protected $m_Onchange = "";
00032
00039 protected function readMetaData(&$xmlArr)
00040 {
00041 parent::readMetaData($xmlArr);
00042 $this->m_BlankOption=isset($xmlArr["ATTRIBUTES"]["BLANKOPTION"]) ? $xmlArr["ATTRIBUTES"]["BLANKOPTION"] : null;
00043 }
00044
00050 protected function getStyle()
00051 {
00052 $htmlClass = $this->m_cssClass ? "class='".$this->m_cssClass."' " : "class='editcombobox'";
00053
00054
00055
00056
00057
00058
00059 if ($this->m_Style)
00060 $style .= $this->m_Style;
00061 if (!isset($style) && !$htmlClass)
00062 return null;
00063 if (isset($style))
00064 {
00065 $formObj = $this->getFormObj();
00066 $style = Expression::evaluateExpression($style, $formObj);
00067 $style = "style='$style'";
00068 }
00069 if ($htmlClass)
00070 $style = $htmlClass." ".$style;
00071 return $style;
00072 }
00073
00079 public function render()
00080 {
00081 $fromList = array();
00082 $this->getFromList($fromList);
00083 $valueArr = explode(',', $this->m_Value);
00084 $disabledStr = ($this->getEnabled() == "N") ? "disabled=\"true\"" : "";
00085 $style = $this->getStyle();
00086 $func = $this->getFunction();
00087 $selName = $this->m_Name . "_sel";
00088
00089 $onChange = "onchange=\"$('$this->m_Name').value=this.value; $('$this->m_Name').triggerEvent('change');\" $func";
00090
00091 $sHTML = "<div $style>\n";
00092 $sHTML .= "<select name=\"" . $selName . "\" id=\"" . $selName ."\" $disabledStr $this->m_HTMLAttr $onChange>\n";
00093
00094 if ($this->m_BlankOption)
00095
00096 {
00097 $entry = explode(",",$this->m_BlankOption);
00098 $text = $entry[0];
00099 $value = ($entry[1]!="") ? $entry[1] : null;
00100 $entryList = array(array("val" => $value, "txt" => $text ));
00101 $fromList = array_merge($entryList, $fromList);
00102 }
00103
00104 foreach ($fromList as $opt)
00105 {
00106 $test = array_search($opt['val'], $valueArr);
00107 if ($test === false)
00108 {
00109 $selectedStr = '';
00110 }
00111 else
00112 {
00113 $selectedStr = "selected";
00114 $selVal = $opt['val'];
00115 }
00116 $sHTML .= "<option value=\"" . $opt['val'] . "\" $selectedStr>" . $opt['txt'] . "</option>\n";
00117 }
00118
00119 if (!$selVal)
00120 $selVal = $this->m_Value?$this->m_Value:$this->getDefaultValue();
00121
00122 $sHTML .= "</select>\n";
00123 $sHTML .= "<div><input id=\"$this->m_Name\" name=\"$this->m_Name\" type=\"text\" value=\"$selVal\" $func/></div>\n";
00124 $sHTML .= "</div>\n";
00125
00126 return $sHTML;
00127 }
00128 }
00129
00130 ?>