00001 <?PHP 00016 include_once ("InputElement.php"); 00017 00026 class AutoSuggest extends OptionElement 00027 { 00028 00029 public function readMetaData (&$xmlArr) 00030 { 00031 parent::readMetaData($xmlArr); 00032 $this->m_cssClass = isset($xmlArr["ATTRIBUTES"]["CSSCLASS"]) ? $xmlArr["ATTRIBUTES"]["CSSCLASS"] : "input_text"; 00033 $this->m_cssErrorClass = isset($xmlArr["ATTRIBUTES"]["CSSERRORCLASS"]) ? $xmlArr["ATTRIBUTES"]["CSSERRORCLASS"] : $this->m_cssClass . "_error"; 00034 $this->m_cssFocusClass = isset($xmlArr["ATTRIBUTES"]["CSSFOCUSCLASS"]) ? $xmlArr["ATTRIBUTES"]["CSSFOCUSCLASS"] : $this->m_cssClass . "_focus"; 00035 } 00036 00042 public function render () 00043 { 00044 BizSystem::clientProxy()->appendScripts("scriptaculous", "scriptaculous.js"); 00045 $selFrom = $this->m_SelectFrom; 00046 $pos0 = strpos($selFrom, "["); 00047 $pos1 = strpos($selFrom, "]"); 00048 $first_half = substr($selFrom, 0, $pos1); 00049 $inputName = $this->m_Name; 00050 $inputChoice = $this->m_Name . '_choices'; 00051 $style = $this->getStyle(); 00052 if ($formobj->m_Errors[$this->m_Name]) { 00053 $func .= "onchange=\"this.className='$this->m_cssClass'\""; 00054 } else { 00055 $func .= "onfocus=\"this.className='$this->m_cssFocusClass'\" onblur=\"this.className='$this->m_cssClass'\""; 00056 } 00057 if (strpbrk($first_half, ':')) { 00058 $hInputName = $this->m_Name . '_hidden'; 00059 $inputChoice = $this->m_Name . '_hidden_choices'; 00060 $sHTML = "<input type=\"text\" id=\"$hInputName\" name=\"$hInputName\" value=\"$this->m_Value\" $style $func/>\n"; 00061 $sHTML .= "<div id=\"$inputChoice\" class=\"autocomplete\" style=\"display:none\"></div>\n"; 00062 $sHTML .= "<script>Openbiz.AutoSuggest.init('$this->m_FormName','AutoSuggest','$hInputName','$inputChoice');</script>"; 00063 $sHTML .= "<INPUT NAME=\"" . $inputName . "\" ID=\"" . $inputName . "\" VALUE=\"" . $this->m_Value . "\" type=\"hidden\" >"; 00064 } else { 00065 $sHTML = "<input type=\"text\" id=\"$inputName\" name=\"$inputName\" value=\"$this->m_Value\" $style $func/>\n"; 00066 $sHTML .= "<div id=\"$inputChoice\" class=\"autocomplete\" style=\"display:none\"></div>\n"; 00067 $sHTML .= "<script>Openbiz.AutoSuggest.init('$this->m_FormName','AutoSuggest','$inputName','$inputChoice');</script>"; 00068 } 00069 return $sHTML; 00070 } 00071 00072 public function matchRemoteMethod ($method) 00073 { 00074 return ($method == "autosuggest"); 00075 } 00076 } 00077 ?>