diff --git a/include/class_divSelectBox.inc b/include/class_divSelectBox.inc index cbfcfe9f5ee98a0ec42079cc55fb8649cc2c42e9..93da2fb0cdc35c4ca30cc2ca948d4a8c1603316d 100644 --- a/include/class_divSelectBox.inc +++ b/include/class_divSelectBox.inc @@ -31,6 +31,7 @@ */ class divSelectBox { + var $headers = FALSE; var $a_entries; var $summary; var $cols; @@ -43,9 +44,9 @@ class divSelectBox */ function __construct() { - $this->s_summary = ''; - $this->a_entries = array(); - $this->cols = 0; + $this->s_summary = ''; + $this->a_entries = array(); + $this->cols = 0; } /*! @@ -72,12 +73,22 @@ class divSelectBox $this->a_entries[] = $a_entriedata; } + /*! + * \brief Set column headers + * + * \param array $a_entriedata + */ + function SetHeaders($headers) + { + $this->headers = $headers; + } + /*! * \brief Draw the list */ function DrawList() { - $s_return = ""; + $s_return = ''; $s_return .= '<div style="padding-right:1px;padding-bottom:2px;height:'.$this->height.';width:100%">'."\n"; $s_return .= '<div style="overflow: auto;width:100%;height:100%;">'."\n"; $s_return .= '<table '. @@ -117,6 +128,25 @@ class divSelectBox * \brief Generate the page */ function _generatePage() + { + $display = ''; + if ($this->headers !== FALSE) { + $display .= '<thead><tr>'; + foreach ($this->headers as $header) { + if ($header === '') { + $header = ' '; + } + $display .= '<th>'.$header.'</th>'; + } + $display .= '</tr></thead>'."\n"; + } + return $display.'<tbody>'.$this->_generateBody().'</tbody>'; + } + + /*! + * \brief Generate the body + */ + function _generateBody() { $s_value = ''; $s_key = ''; @@ -125,7 +155,20 @@ class divSelectBox /* If divlist is empty, append a single white entry */ if (count($this->a_entries) == 0) { - $str .= '<tr><td style="height:100%; border-right:0px;"> </td></tr>'; + if ($this->headers !== FALSE) { + $this->cols = count($this->headers); + $str .= '<tr>'; + for ($i = 0; $i < ($this->cols); $i++) { + if ($i >= ($this->cols - 1)) { + $str .= '<td style="height:100%;border:0px;"> </td>'; + } else { + $str .= '<td style="height:100%;"> </td>'; + } + } + $str .= '</tr>'; + } else { + $str .= '<tr><td style="height:100%; border-right:0px;"> </td></tr>'; + } return $str; } @@ -137,8 +180,8 @@ class divSelectBox $cnt = 0; + $this->cols = count($s_value); foreach ($s_value as $s_key2 => $s_value2) { - $this->cols = count($s_value); $cnt++; if (!isset($s_value2['class'])) {