00001 <?PHP
00002 include_once("OptionElement.php");
00003
00004 class ImageSelector extends OptionElement
00005 {
00006 public $m_BlankOption;
00007
00008
00009 protected function readMetaData(&$xmlArr)
00010 {
00011 parent::readMetaData($xmlArr);
00012 $this->m_BlankOption = isset($xmlArr["ATTRIBUTES"]["BLANKOPTION"]) ? $xmlArr["ATTRIBUTES"]["BLANKOPTION"] : null;
00013 $this->m_cssClass = isset($xmlArr["ATTRIBUTES"]["CSSCLASS"]) ? $xmlArr["ATTRIBUTES"]["CSSCLASS"] : 'image_selector';
00014 $this->m_cssErrorClass = isset($xmlArr["ATTRIBUTES"]["CSSERRORCLASS"]) ? $xmlArr["ATTRIBUTES"]["CSSERRORCLASS"] : $this->m_cssClass . "_error";
00015 $this->m_cssFocusClass = isset($xmlArr["ATTRIBUTES"]["CSSFOCUSCLASS"]) ? $xmlArr["ATTRIBUTES"]["CSSFOCUSCLASS"] : $this->m_cssClass . "_focus";
00016 }
00017
00018
00019 public function render()
00020 {
00021 $fromList = array();
00022 $this->getFromList($fromList);
00023 $valueArray = explode(',', $this->m_Value);
00024 $disabledStr = ($this->getEnabled() == "N") ? "DISABLED=\"true\"" : "";
00025 $style = $this->getStyle();
00026 $func = $this->getFunction();
00027
00028 $formobj = $this->GetFormObj();
00029 if($formobj->m_Errors[$this->m_Name]){
00030 $func .= "onclick=\"this.className='$this->m_cssClass'\"";
00031 }else{
00032 $func .= "onmouseover=\"this.className='$this->m_cssFocusClass'\" onmouseout=\"this.className='$this->m_cssClass'\"";
00033 }
00034
00035 $sHTML = "<input type=\"hidden\" NAME=\"" . $this->m_Name . "\" ID=\"" . $this->m_Name ."\" value=\"".$this->m_Value."\" $disabledStr $this->m_HTMLAttr />";
00036 $sHTML .= "<ul id=\"image_list_" . $this->m_Name ."\" $style $func >";
00037 if ($this->m_BlankOption)
00038 {
00039 $entry = explode(",",$this->m_BlankOption);
00040 $text = $entry[0];
00041 $value = ($entry[1]!= "") ? $entry[1] : null;
00042 $entryList = array(array("val" => $value, "txt" => $text ));
00043 $fromList = array_merge($entryList, $fromList);
00044 }
00045
00046 foreach ($fromList as $option)
00047 {
00048 $test = array_search($option['val'], $valueArray);
00049 if ($test === false)
00050 {
00051 $selectedStr = 'normal';
00052 }
00053 else
00054 {
00055 $selectedStr = "current";
00056 }
00057 if($this->m_Width){
00058 $width_str = " width=\"".$this->m_Width."\" ";
00059 }
00060 if($this->m_Height){
00061 $height_str = " height=\"".$this->m_Height."\" ";
00062 }
00063 $image_url = $option['pic'];
00064 if(preg_match("/\{.*\}/si",$image_url))
00065 {
00066 $formobj = $this->getFormObj();
00067 $image_url = Expression::evaluateExpression($image_url, $formobj);
00068 }else{
00069 $image_url = Resource::getImageUrl()."/".$image_url;
00070 }
00071 $sHTML .= "<a title=\"" . $option['txt'] . "\"
00072 href=\"javascript:;\"
00073 class=\"$selectedStr\"
00074 onclick =\"$('".$this->m_Name."').value='". $option['val']."';
00075 Openbiz.ImageSelector.reset('image_list_".$this->m_Name."');
00076 this.className='current';
00077 \"
00078 >
00079 <img
00080 $width_str $height_str
00081 src=\"".$image_url."\"
00082 title=\"" . $option['txt'] . "\"
00083 /></a>";
00084
00085 }
00086 $sHTML .= "</ul>";
00087
00088 return $sHTML;
00089 }
00090 }
00091
00092 ?>