name = $name; // $selected = get_POST_array($name); $this->selections = $this->_getMySelectedButtons($name); } function get() { return $this->selections; } function isNone() { return '' == $this->selections; } function &_getMySelectedButtons($name) { global $_POST; $selected = get_POST_array($name); $selections = array(); foreach ($selected as $i => $which) { $selections[$which] = $which; } return $selections; // hmmmm I wonder if we have to sanitise? } function input($name, $value, $checked) { $cb = "type=\"checkbox\""; $checked = $checked ? "checked" : ""; return ""; } /* * function toForm(&$lines, $tab = ' ') * { * formOpen($lines, $tab); * $this->toFormTable($lines, $tab . ' '); * formSubmit($lines, $tab); * formClose($lines, $tab); * } */ function toFormTable(&$lines, $tab = ' ') { $lines[] = "$tab "; $all = getSelectionSubset($this->name); foreach ($all as $i => $selection) { $this->toForm3TD($lines, $selection, $tab . ' '); } $lines[] = "$tab
"; } function toBullets($comments) { if (!is_array($comments)) return $comments; if (count($comments) == 1) return $comments[0]; $x = array(); $x[] = ""; $bullets = join(' ', $x); return $bullets; } function toForm3TD(&$lines, $selection, $tab = ' ') { $nam = $selection->getName(); $checked = array_key_exists($nam, $this->selections); $lines[] = "$tab"; $lines[] = "$tab " . $nam . " "; $lines[] = "$tab " . $this->input($this->name, $nam, $checked); " "; $lines[] = "$tab " . $this->toBullets( $selection->getComments() ) . " "; if ($selection->hasSet()) $lines[] = "$tab " . $selection->getCount(). " "; else $lines[] = "$tab "; $lines[] = "$tab"; } } ?>