Special Ops 2.50
[specialops2.git] / lib / HTML_Checkbox.php
blobb652e5b5e64a0463960c28f042402bedb30bd63b
1 <?php
2 /**
3 * HTML checkbox object
5 * @author Ant P <p@cpi.merseine.nu>
6 * @license http://specialops.ath.cx/repos/so2/trunk/COPYING (New BSD Licence)
7 * @version 2.15
8 */
9 class HTML_Checkbox
11 public $name;
12 public $label;
13 public $value;
15 function __construct($name, $label)
17 $this->name = $name;
18 $this->label = $label;
19 $this->value = isset($_POST[$this->name]);
22 function is_selected()
24 return isset($_POST[$this->name]);
27 function __toString()
29 return '<label>'.
30 '<input type="checkbox" name="'.$this->name.'"'.($this->value ? ' checked="checked"' : '').'/>'.
31 htmlspecialchars($this->label).'</label>';
34 static function factory(array $boxes)
36 $ret = array();
37 foreach ( $boxes as $name => $label ) {
38 $ret[$name] = new HTML_Checkbox($name, $label);
40 return $ret;