Skip to content

Commit cd5e077

Browse files
committed
Some more refactoring in Form classes.
1 parent e170349 commit cd5e077

12 files changed

Lines changed: 53 additions & 67 deletions

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,14 @@ class Calendar extends FormElement {
4444

4545
var $controlName = "";
4646
var $highlight = "time"; // Determines what type of active days to highlight ("time" or "expenses").
47-
// var $mAllDays = true;
48-
var $class = "Calendar";
4947

5048
function __construct($name) {
51-
$this->controlName = $name;
52-
$this->mMonthNames = array('January','February','March','April','May','June','July','August','September','October','November','December');
53-
$this->mWeekDayShortNames = array('Su','Mo','Tu','We','Th','Fr','Sa');
49+
$this->class = 'Calendar';
50+
$this->controlName = $name; // TODO: why controlName? Other classes have "name".
51+
$this->mMonthNames = array('January','February','March','April','May','June','July','August','September','October','November','December');
52+
$this->mWeekDayShortNames = array('Su','Mo','Tu','We','Th','Fr','Sa');
5453
}
55-
54+
5655
function setHighlight($highlight) {
5756
if ($highlight && $highlight != 'time')
5857
$this->highlight = $highlight;

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,12 @@
3131
class Checkbox extends FormElement {
3232
var $mChecked = false;
3333
var $mOptions = null;
34-
var $class = 'Checkbox';
3534

36-
function __construct($name,$value="")
37-
{
38-
$this->name = $name;
39-
$this->value = $value;
40-
}
35+
function __construct($name, $value = '') {
36+
$this->class = 'Checkbox';
37+
$this->name = $name;
38+
$this->value = $value;
39+
}
4140

4241
function setChecked($value) { $this->mChecked = $value; }
4342
function isChecked() { return $this->mChecked; }

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,16 @@ class CheckboxGroup extends FormElement {
3333
var $mOptions = array();
3434
var $mLayout = "V";
3535
var $mGroupIn = 1;
36-
var $class = 'CheckboxGroup';
3736
var $mDataKeys = array();
3837
var $mDataDeep = 1;
3938
var $lSelAll = "All";
4039
var $lSelNone = "None";
4140

42-
function __construct($name,$value="")
43-
{
44-
$this->name = $name;
45-
$this->value = $value;
46-
}
41+
function __construct($name, $value = '') {
42+
$this->class = 'CheckboxGroup';
43+
$this->name = $name;
44+
$this->value = $value;
45+
}
4746

4847
function setChecked($value) { $this->mChecked = $value; }
4948
function isChecked() { return $this->mChecked; }

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,12 @@ class Combobox extends FormElement {
4444
var $mCompareOn = "key"; // or "value"
4545
var $mDataDeep = 1;
4646
var $mDataKeys = array();
47-
var $class = 'Combobox';
4847

49-
function __construct($name,$value="")
50-
{
51-
$this->name = $name;
52-
$this->value = $value;
53-
}
48+
function __construct($name, $value = '') {
49+
$this->class = 'Combobox';
50+
$this->name = $name;
51+
$this->value = $value;
52+
}
5453

5554
function setMultiple($value) { $this->mMultiple = $value; }
5655
function isMultiple() { return $this->mMultiple; }
@@ -111,4 +110,3 @@ function getHtml() {
111110
return $html;
112111
}
113112
}
114-
?>

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,14 @@ class DateField extends TextField {
3333
var $mWeekStartDay = 0;
3434
var $mDateFormat = "d/m/Y";
3535
var $lToday = "Today";
36-
3736
var $mDateObj;
38-
var $class = 'DateField';
3937

4038
var $lCalendarButtons = array('today'=>'Today', 'close'=>'Close');
4139

4240
function __construct($name) {
43-
$this->name = $name;
44-
$this->mDateObj = new DateAndTime();
41+
$this->class = 'DateField';
42+
$this->name = $name;
43+
$this->mDateObj = new DateAndTime();
4544

4645
if (isset($GLOBALS["I18N"])) {
4746
$this->localize($GLOBALS["I18N"]);

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

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

3131
class FloatField extends TextField {
32-
3332
var $mDelimiter = '.';
3433
var $mFFormat;
35-
var $class = 'FloatField';
36-
34+
3735
function __construct($name) {
36+
$this->class = 'FloatField';
3837
$this->name = $name;
3938
}
4039

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
// +----------------------------------------------------------------------+
3535

3636
class Form {
37-
3837
var $name = ''; // Form name.
3938
var $elements = array(); // An array of input controls in form.
4039

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

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,20 @@
2727
// +----------------------------------------------------------------------+
2828

2929
import('form.FormElement');
30-
30+
3131
class Hidden extends FormElement {
32-
var $class = 'Hidden';
3332

34-
function __construct($name,$value="")
35-
{
36-
$this->name = $name;
37-
$this->value = $value;
38-
}
33+
function __construct($name, $value = '') {
34+
$this->class = 'Hidden';
35+
$this->name = $name;
36+
$this->value = $value;
37+
}
38+
39+
function getHtml() {
40+
if ($this->id == '') $this->id = $this->name;
3941

40-
function getHtml() {
41-
42-
if ($this->id=="") $this->id = $this->name;
43-
44-
$html = "\n\t<input";
45-
$html .= " type=\"hidden\" name=\"$this->name\" id=\"$this->id\"";
46-
47-
$html .= " value=\"".$this->getValue()."\"";
48-
$html .= ">";
49-
50-
return $html;
51-
}
42+
$html = "\n\t<input type=\"hidden\" id=\"$this->id\" name=\"$this->name\"";
43+
$html.= ' value="'.$this->getValue().'">';
44+
return $html;
45+
}
5246
}

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

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

3131
class Submit extends FormElement {
32-
var $class = 'Submit';
3332

34-
function __construct($name,$value="")
35-
{
36-
$this->name = $name;
37-
$this->value = $value;
38-
}
33+
function __construct($name, $value = '')
34+
{
35+
$this->class = 'Submit';
36+
$this->name = $name;
37+
$this->value = $value;
38+
}
3939

40-
function getHtml() {
40+
function getHtml() {
4141

4242
if ($this->id=="") $this->id = $this->name;
4343

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ class Table extends FormElement {
4141
var $mBgColor = '#ffffff';
4242
var $mBgColorOver = '#eeeeff';
4343
var $mWidth = '';
44-
var $class = 'Table';
4544
var $mTableOptions = array();
4645
var $mRowOptions = array();
4746
var $mHeaderOptions = array();
4847
var $mProccessed = false;
4948

5049
function __construct($name, $value='') {
50+
$this->class = 'Table';
5151
$this->name = $name;
5252
$this->value = $value;
5353
}

0 commit comments

Comments
 (0)