class = 'CheckboxGroup'; $this->name = $name; } function setChecked($value) { $this->mChecked = $value; } function isChecked() { return $this->mChecked; } function setData($value) { $this->mOptions = $value; } function getData() { return $this->mOptions; } function setDataKeys($keys) { $this->mDataKeys = $keys; $this->mDataDeep = 2; } function getDataKeys() { return $this->mDataKeys; } function setLayout($value) { $this->mLayout = $value; } function getLayout() { return $this->mLayout; } function setGroupIn($value) { $this->mGroupIn = $value; if ($this->mGroupIn<1) $this->mGroupIn = 1;} function getGroupIn() { return $this->mGroupIn; } function localize($i18n) { $this->lSelAll = $i18n->getKey('label.select_all'); $this->lSelNone = $i18n->getKey('label.select_none'); } function getHtml() { if ($this->id=="") $this->id = $this->name; $renderArray = array(); $renderCols = 0; $renderRows = 0; if ($this->mLayout=="H") { $i = 0; if (is_array($this->mOptions)) { $renderCols = $this->mGroupIn; $renderRows = ceil(count($this->mOptions) / $this->mGroupIn); $col = $row = 0; foreach ($this->mOptions as $optkey=>$optval) { if ($this->mDataDeep>1) { $optkey = $optval[$this->mDataKeys[0]]; $optval = $optval[$this->mDataKeys[1]]; } $html = "name[]\" id=\"$this->id"."_".$i."\""; if (is_array($this->value)) { foreach ($this->value as $element) { if (($element == $optkey) && ($element != null)) $html .= " checked=\"true\""; } } $html .= " value=\"".htmlspecialchars($optkey)."\"> "; $renderArray[$col][$row] = $html; $col++; if ($col==$this->mGroupIn) { $col = 0; $row++; } $i++; } } } if ($this->mLayout=="V") { $i = 0; if (is_array($this->mOptions)) { $renderCols = ceil(count($this->mOptions) / $this->mGroupIn); $renderRows = $this->mGroupIn; $col = $row = 0; foreach ($this->mOptions as $optkey=>$optval) { if ($this->mDataDeep>1) { $optkey = $optval[$this->mDataKeys[0]]; $optval = $optval[$this->mDataKeys[1]]; } $html = "name[]\" id=\"$this->id"."_".$i."\""; if (is_array($this->value)) { foreach ($this->value as $element) { if (($element == $optkey) && ($element != null)) $html .= " checked=\"true\""; } } $html .= " value=\"".htmlspecialchars($optkey)."\"> "; $renderArray[$col][$row] = $html; $row++; if ($row==$this->mGroupIn) { $row = 0; $col++; } $i++; } } } $html = "\n\t
\n"; $html .= ''.$this->lSelAll.' / '.$this->lSelNone.''; $html .= " | |
";
$html .= "\n\t
|