Esempio n. 1
0
 public function render($buffer = false)
 {
     $this->inset_val = '';
     ob_start();
     if (!is_array($this->select_value)) {
         settype($this->select_value, 'string');
     }
     //============================================
     // Added "Blank" Options
     //============================================
     foreach ($this->blank as $bv) {
         //-----------------------------------------
         // Option Attributes: Value
         //-----------------------------------------
         $o_attrs = array('value' => $bv[0]);
         //-----------------------------------------
         // Selected Value
         //-----------------------------------------
         if (isset($this->select_value)) {
             if (is_array($this->select_value) && isset($this->select_value[$bv[0]])) {
                 $o_attrs['selected'] = 'selected';
             } else {
                 settype($bv[0], 'string');
                 if ($this->select_value === $bv[0]) {
                     $o_attrs['selected'] = 'selected';
                 }
             }
         }
         //-----------------------------------------
         // Create Option Element
         //-----------------------------------------
         $o = new gen_element('option', $bv[1], $o_attrs);
         $o->force_endtag(1);
         //-----------------------------------------
         // Element Attributes
         //-----------------------------------------
         if (isset($this->elements_attrs[$bv[0]])) {
             $o->attrs($this->elements_attrs[$bv[0]]);
         }
         $o->render();
     }
     //============================================
     // Options
     //============================================
     $opt_group = null;
     foreach ($this->select_vals as $key => $value) {
         //-----------------------------------------
         // Option Attributes: Value
         //-----------------------------------------
         $o_attrs = array('value' => $key);
         //-----------------------------------------
         // Option Group
         //-----------------------------------------
         if (is_array($value)) {
             $tmp_val_arr = $value;
             $value = isset($tmp_val_arr[0]) ? $tmp_val_arr[0] : '';
             if (isset($tmp_val_arr[1]) && $tmp_val_arr[1] !== $opt_group) {
                 $opt_group = $tmp_val_arr[1];
                 print new gen_element('optgroup', '', array('label' => $tmp_val_arr[1]));
             }
         }
         //-----------------------------------------
         // Selected Value
         //-----------------------------------------
         if (isset($this->select_value)) {
             if (is_array($this->select_value) && isset($this->select_value[$key])) {
                 $o_attrs['selected'] = 'selected';
             } else {
                 settype($key, 'string');
                 if ($this->select_value === $key) {
                     $o_attrs['selected'] = 'selected';
                 }
             }
         }
         //-----------------------------------------
         // Create Option Element
         //-----------------------------------------
         $o = new gen_element('option', $value, $o_attrs);
         $o->force_endtag(1);
         //-----------------------------------------
         // Element Attributes
         //-----------------------------------------
         if (isset($this->elements_attrs[$key])) {
             $o->attrs($this->elements_attrs[$key]);
         }
         //-----------------------------------------
         // Output
         //-----------------------------------------
         $o->render();
     }
     $this->inset_val .= ob_get_clean();
     parent::render($buffer);
 }
Esempio n. 2
0
 public function render($buffer = false)
 {
     //============================================
     // Pull items from database
     //============================================
     $data = new data_trans($this->data_src);
     $data->data_query($this->strsql);
     $result = $data->data_assoc_result();
     $this->inset_val = '';
     ob_start();
     if (!is_array($this->select_value)) {
         settype($this->select_value, 'string');
     }
     //============================================
     // Added "Blank" Options
     //============================================
     foreach ($this->blank as $bv) {
         //-----------------------------------------
         // Option Attributes: Value
         //-----------------------------------------
         $o_attrs = array('value' => $bv[0]);
         //-----------------------------------------
         // Selected Value
         //-----------------------------------------
         if (isset($this->select_value)) {
             if (is_array($this->select_value) && isset($this->select_value[$bv[0]])) {
                 $o_attrs['selected'] = 'selected';
             } else {
                 settype($bv[0], 'string');
                 if ($this->select_value === $bv[0]) {
                     $o_attrs['selected'] = 'selected';
                 }
             }
         }
         //-----------------------------------------
         // Create Option Element
         //-----------------------------------------
         $o = new gen_element('option', $bv[1], $o_attrs);
         $o->force_endtag(1);
         //-----------------------------------------
         // Element Attributes
         //-----------------------------------------
         if (isset($this->elements_attrs[$bv[0]])) {
             $o->attrs($this->elements_attrs[$bv[0]]);
         }
         $o->render();
     }
     //============================================
     // Options
     //============================================
     $opt_group = null;
     foreach ($result as $row) {
         //-----------------------------------------
         // Option Attributes: Value
         //-----------------------------------------
         $o_attrs = array('value' => $row[$this->opt_key]);
         //-----------------------------------------
         // Option Group
         //-----------------------------------------
         if ($this->opt_group && isset($row[$this->opt_group]) && $row[$this->opt_group] !== $opt_group) {
             $opt_group = $row[$this->opt_group];
             print new gen_element('optgroup', '', array('label' => $row[$this->opt_group]));
         }
         //-----------------------------------------
         // Selected Value
         //-----------------------------------------
         if (isset($this->select_value)) {
             settype($row[$this->opt_key], 'string');
             if ($this->select_value === $row[$this->opt_key]) {
                 $o_attrs['selected'] = 'selected';
             }
         }
         //-----------------------------------------
         // Selected Value
         //-----------------------------------------
         if (isset($this->select_value)) {
             if (is_array($this->select_value) && isset($this->select_value[$row[$this->opt_key]])) {
                 $o_attrs['selected'] = 'selected';
             } else {
                 settype($row[$this->opt_key], 'string');
                 if ($this->select_value === $row[$this->opt_key]) {
                     $o_attrs['selected'] = 'selected';
                 }
             }
         }
         //-----------------------------------------
         // Create Option Element
         //-----------------------------------------
         $o = new gen_element('option', $row[$this->opt_val], $o_attrs);
         $o->force_endtag(1);
         //-----------------------------------------
         // Element Attributes
         //-----------------------------------------
         if (isset($this->elements_attrs[$row[$this->opt_key]])) {
             $o->attrs($this->elements_attrs[$row[$this->opt_key]]);
         }
         //-----------------------------------------
         // Output
         //-----------------------------------------
         $o->render();
     }
     $this->inset_val .= ob_get_clean();
     parent::render($buffer);
 }