• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List

E:/E/GEAMP/www/openbiz/openbiz/bin/easy/element/Listbox.php

00001 <?PHP
00017 include_once("OptionElement.php");
00018 
00027 class Listbox extends OptionElement
00028 {
00029     public $m_BlankOption;
00030 
00037     protected function readMetaData(&$xmlArr)
00038     {
00039         parent::readMetaData($xmlArr);
00040         $this->m_BlankOption = isset($xmlArr["ATTRIBUTES"]["BLANKOPTION"]) ? $xmlArr["ATTRIBUTES"]["BLANKOPTION"] : null;
00041     }
00042 
00048     public function render()
00049     {
00050         $fromList = array();
00051         $this->getFromList($fromList);
00052         $value = $this->getValue()!==null?$this->getValue():$this->getDefaultValue();
00053         $valueArray = explode(',', $value);
00054         
00055         $disabledStr = ($this->getEnabled() == "N") ? "DISABLED=\"true\"" : "";
00056         $style = $this->getStyle();
00057         $func = $this->getFunction();
00058 
00059         //$sHTML = "<SELECT NAME=\"" . $this->m_Name . "[]\" ID=\"" . $this->m_Name ."\" $disabledStr $this->m_HTMLAttr $style $func>";
00060         $sHTML = "<SELECT NAME=\"" . $this->m_Name . "\" ID=\"" . $this->m_Name ."\" $disabledStr $this->m_HTMLAttr $style $func>";
00061 
00062         if ($this->m_BlankOption) // ADD a blank option
00063         {
00064             $entry = explode(",",$this->m_BlankOption);
00065             $text = $entry[0];
00066             $value = ($entry[1]!= "") ? $entry[1] : null;
00067             $entryList = array(array("val" => $value, "txt" => $text ));
00068             $fromList = array_merge($entryList, $fromList);
00069         }
00070 
00071         $defaultValue = null;
00072         foreach ($fromList as $option)
00073         {
00074             $test = array_search($option['val'], $valueArray);
00075             if ($test === false)
00076             {
00077                 $selectedStr = '';
00078             }
00079             else
00080             {
00081                 $selectedStr = "SELECTED";
00082                 $defaultValue = $option['val'];                
00083             }
00084             $sHTML .= "<OPTION VALUE=\"" . $option['val'] . "\" $selectedStr>" . $option['txt'] . "</OPTION>";
00085         }
00086         if($defaultValue == null){
00087               $defaultOpt = array_shift($fromList);
00088               $defaultValue = $defaultOpt['val'];
00089               array_unshift($fromList,$defaultOpt);
00090         }
00091      
00092         
00093         $this->setValue($defaultValue);
00094         $sHTML .= "</SELECT>";
00095         return $sHTML;
00096     }
00097 }
00098 
00099 ?>

Generated on Thu Apr 19 2012 17:09:13 for openbiz by  doxygen 1.7.2