Skip to content

Commit 0fa8012

Browse files
committed
Ongoing refactoring of Checkbox class.
1 parent cd5e077 commit 0fa8012

3 files changed

Lines changed: 18 additions & 20 deletions

File tree

WEB-INF/lib/form/Checkbox.class.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import('form.FormElement');
3030

3131
class Checkbox extends FormElement {
32-
var $mChecked = false;
32+
var $checked = false;
3333
var $mOptions = null;
3434

3535
function __construct($name, $value = '') {
@@ -38,27 +38,28 @@ function __construct($name, $value = '') {
3838
$this->value = $value;
3939
}
4040

41-
function setChecked($value) { $this->mChecked = $value; }
42-
function isChecked() { return $this->mChecked; }
41+
function setChecked($value) { $this->checked = $value; }
42+
function isChecked() { return $this->checked; }
4343

4444
function setData($value) { $this->mOptions = $value; }
4545
function getData() { return $this->mOptions; }
46-
47-
function getHtml() {
4846

49-
if ($this->id=="") $this->id = $this->name;
50-
51-
$html = "\n\t<input type=\"checkbox\"";
52-
$html .= " name=\"$this->name\" id=\"$this->id\"";
47+
function getHtml() {
48+
if ($this->id == '') $this->id = $this->name;
49+
50+
$html = "\n\t<input type=\"checkbox\"";
51+
$html.= " id=\"$this->id\" name=\"$this->name\"";
52+
53+
if ($this->checked || (($this->value == $this->mOptions) && ($this->value != null)))
54+
$html.= " checked=\"true\"";
5355

5456
if ($this->on_change!="")
5557
$html .= " onchange=\"$this->on_change\"";
5658

5759
if ($this->style!="")
5860
$html .= " style=\"$this->style\"";
5961

60-
if ($this->mChecked || (($this->value == $this->mOptions) && ($this->value != null)))
61-
$html .= " checked=\"true\"";
62+
6263

6364
if (!$this->isEnabled())
6465
$html .= " disabled=\"disabled\"";

WEB-INF/lib/form/Form.class.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,9 @@
2626
// | https://www.anuko.com/time_tracker/credits.htm
2727
// +----------------------------------------------------------------------+
2828

29-
// +----------------------------------------------------------------------+
30-
// |
31-
// | Class generates elements of specification HTML 4.01
32-
// | http://www.w3.org/TR/1999/REC-html401-19991224
33-
// |
34-
// +----------------------------------------------------------------------+
35-
29+
// Form class is a container for HTML forms we use in the application.
30+
// It contains an array of $elements - which are individual input controls
31+
// belonging to a form.
3632
class Form {
3733
var $name = ''; // Form name.
3834
var $elements = array(); // An array of input controls in form.
@@ -89,8 +85,9 @@ function addInput($params) {
8985
case 'checkbox':
9086
import('form.Checkbox');
9187
$el = new Checkbox($params['name']);
88+
if (isset($params['checked'])) $el->setChecked(true);
89+
9290
// TODO: refactoring ongoing down from here.
93-
if (@$params["checked"]) $el->setChecked(true);
9491
$el->setData(@$params["data"]);
9592
break;
9693

WEB-INF/templates/footer.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<br>
1313
<table cellspacing="0" cellpadding="4" width="100%" border="0">
1414
<tr>
15-
<td align="center">&nbsp;Anuko Time Tracker 1.10.38.3618 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
15+
<td align="center">&nbsp;Anuko Time Tracker 1.10.38.3619 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
1616
<a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
1717
<a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
1818
<a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>

0 commit comments

Comments
 (0)