From cd5e077ecb497431decde4835138b877d63b261c Mon Sep 17 00:00:00 2001 From: anuko Date: Fri, 3 Mar 2017 01:22:44 +0000 Subject: [PATCH] Some more refactoring in Form classes. --- WEB-INF/lib/form/Calendar.class.php | 11 ++++---- WEB-INF/lib/form/Checkbox.class.php | 11 ++++---- WEB-INF/lib/form/CheckboxGroup.class.php | 11 ++++---- WEB-INF/lib/form/Combobox.class.php | 12 ++++----- WEB-INF/lib/form/DateField.class.php | 7 +++--- WEB-INF/lib/form/FloatField.class.php | 5 ++-- WEB-INF/lib/form/Form.class.php | 1 - WEB-INF/lib/form/Hidden.class.php | 32 ++++++++++-------------- WEB-INF/lib/form/Submit.class.php | 14 +++++------ WEB-INF/lib/form/Table.class.php | 2 +- WEB-INF/lib/form/TextArea.class.php | 12 ++++----- WEB-INF/templates/footer.tpl | 2 +- 12 files changed, 53 insertions(+), 67 deletions(-) diff --git a/WEB-INF/lib/form/Calendar.class.php b/WEB-INF/lib/form/Calendar.class.php index dbe29981..ab2dcf57 100644 --- a/WEB-INF/lib/form/Calendar.class.php +++ b/WEB-INF/lib/form/Calendar.class.php @@ -44,15 +44,14 @@ class Calendar extends FormElement { var $controlName = ""; var $highlight = "time"; // Determines what type of active days to highlight ("time" or "expenses"). - // var $mAllDays = true; - var $class = "Calendar"; function __construct($name) { - $this->controlName = $name; - $this->mMonthNames = array('January','February','March','April','May','June','July','August','September','October','November','December'); - $this->mWeekDayShortNames = array('Su','Mo','Tu','We','Th','Fr','Sa'); + $this->class = 'Calendar'; + $this->controlName = $name; // TODO: why controlName? Other classes have "name". + $this->mMonthNames = array('January','February','March','April','May','June','July','August','September','October','November','December'); + $this->mWeekDayShortNames = array('Su','Mo','Tu','We','Th','Fr','Sa'); } - + function setHighlight($highlight) { if ($highlight && $highlight != 'time') $this->highlight = $highlight; diff --git a/WEB-INF/lib/form/Checkbox.class.php b/WEB-INF/lib/form/Checkbox.class.php index 4c6a9fd7..e3d9cf2e 100644 --- a/WEB-INF/lib/form/Checkbox.class.php +++ b/WEB-INF/lib/form/Checkbox.class.php @@ -31,13 +31,12 @@ import('form.FormElement'); class Checkbox extends FormElement { var $mChecked = false; var $mOptions = null; - var $class = 'Checkbox'; - function __construct($name,$value="") - { - $this->name = $name; - $this->value = $value; - } + function __construct($name, $value = '') { + $this->class = 'Checkbox'; + $this->name = $name; + $this->value = $value; + } function setChecked($value) { $this->mChecked = $value; } function isChecked() { return $this->mChecked; } diff --git a/WEB-INF/lib/form/CheckboxGroup.class.php b/WEB-INF/lib/form/CheckboxGroup.class.php index cb7c9f1f..f6722704 100644 --- a/WEB-INF/lib/form/CheckboxGroup.class.php +++ b/WEB-INF/lib/form/CheckboxGroup.class.php @@ -33,17 +33,16 @@ class CheckboxGroup extends FormElement { var $mOptions = array(); var $mLayout = "V"; var $mGroupIn = 1; - var $class = 'CheckboxGroup'; var $mDataKeys = array(); var $mDataDeep = 1; var $lSelAll = "All"; var $lSelNone = "None"; - function __construct($name,$value="") - { - $this->name = $name; - $this->value = $value; - } + function __construct($name, $value = '') { + $this->class = 'CheckboxGroup'; + $this->name = $name; + $this->value = $value; + } function setChecked($value) { $this->mChecked = $value; } function isChecked() { return $this->mChecked; } diff --git a/WEB-INF/lib/form/Combobox.class.php b/WEB-INF/lib/form/Combobox.class.php index ce667396..97c9c50e 100644 --- a/WEB-INF/lib/form/Combobox.class.php +++ b/WEB-INF/lib/form/Combobox.class.php @@ -44,13 +44,12 @@ class Combobox extends FormElement { var $mCompareOn = "key"; // or "value" var $mDataDeep = 1; var $mDataKeys = array(); - var $class = 'Combobox'; - function __construct($name,$value="") - { - $this->name = $name; - $this->value = $value; - } + function __construct($name, $value = '') { + $this->class = 'Combobox'; + $this->name = $name; + $this->value = $value; + } function setMultiple($value) { $this->mMultiple = $value; } function isMultiple() { return $this->mMultiple; } @@ -111,4 +110,3 @@ class Combobox extends FormElement { return $html; } } -?> \ No newline at end of file diff --git a/WEB-INF/lib/form/DateField.class.php b/WEB-INF/lib/form/DateField.class.php index 3906db6c..ecfdaf92 100644 --- a/WEB-INF/lib/form/DateField.class.php +++ b/WEB-INF/lib/form/DateField.class.php @@ -33,15 +33,14 @@ class DateField extends TextField { var $mWeekStartDay = 0; var $mDateFormat = "d/m/Y"; var $lToday = "Today"; - var $mDateObj; - var $class = 'DateField'; var $lCalendarButtons = array('today'=>'Today', 'close'=>'Close'); function __construct($name) { - $this->name = $name; - $this->mDateObj = new DateAndTime(); + $this->class = 'DateField'; + $this->name = $name; + $this->mDateObj = new DateAndTime(); if (isset($GLOBALS["I18N"])) { $this->localize($GLOBALS["I18N"]); diff --git a/WEB-INF/lib/form/FloatField.class.php b/WEB-INF/lib/form/FloatField.class.php index 6bbfd64c..b11f4a11 100644 --- a/WEB-INF/lib/form/FloatField.class.php +++ b/WEB-INF/lib/form/FloatField.class.php @@ -29,12 +29,11 @@ import('form.TextField'); class FloatField extends TextField { - var $mDelimiter = '.'; var $mFFormat; - var $class = 'FloatField'; - + function __construct($name) { + $this->class = 'FloatField'; $this->name = $name; } diff --git a/WEB-INF/lib/form/Form.class.php b/WEB-INF/lib/form/Form.class.php index 5f825451..704ce7e5 100644 --- a/WEB-INF/lib/form/Form.class.php +++ b/WEB-INF/lib/form/Form.class.php @@ -34,7 +34,6 @@ // +----------------------------------------------------------------------+ class Form { - var $name = ''; // Form name. var $elements = array(); // An array of input controls in form. diff --git a/WEB-INF/lib/form/Hidden.class.php b/WEB-INF/lib/form/Hidden.class.php index e06466e1..3693f84c 100644 --- a/WEB-INF/lib/form/Hidden.class.php +++ b/WEB-INF/lib/form/Hidden.class.php @@ -27,26 +27,20 @@ // +----------------------------------------------------------------------+ import('form.FormElement'); - + class Hidden extends FormElement { - var $class = 'Hidden'; - function __construct($name,$value="") - { - $this->name = $name; - $this->value = $value; - } + function __construct($name, $value = '') { + $this->class = 'Hidden'; + $this->name = $name; + $this->value = $value; + } + + function getHtml() { + if ($this->id == '') $this->id = $this->name; - function getHtml() { - - if ($this->id=="") $this->id = $this->name; - - $html = "\n\tname\" id=\"$this->id\""; - - $html .= " value=\"".$this->getValue()."\""; - $html .= ">"; - - return $html; - } + $html = "\n\tid\" name=\"$this->name\""; + $html.= ' value="'.$this->getValue().'">'; + return $html; + } } diff --git a/WEB-INF/lib/form/Submit.class.php b/WEB-INF/lib/form/Submit.class.php index 905b2695..91123c55 100644 --- a/WEB-INF/lib/form/Submit.class.php +++ b/WEB-INF/lib/form/Submit.class.php @@ -29,15 +29,15 @@ import('form.FormElement'); class Submit extends FormElement { - var $class = 'Submit'; - function __construct($name,$value="") - { - $this->name = $name; - $this->value = $value; - } + function __construct($name, $value = '') + { + $this->class = 'Submit'; + $this->name = $name; + $this->value = $value; + } - function getHtml() { + function getHtml() { if ($this->id=="") $this->id = $this->name; diff --git a/WEB-INF/lib/form/Table.class.php b/WEB-INF/lib/form/Table.class.php index 807e2c7c..ec3510c8 100644 --- a/WEB-INF/lib/form/Table.class.php +++ b/WEB-INF/lib/form/Table.class.php @@ -41,13 +41,13 @@ class Table extends FormElement { var $mBgColor = '#ffffff'; var $mBgColorOver = '#eeeeff'; var $mWidth = ''; - var $class = 'Table'; var $mTableOptions = array(); var $mRowOptions = array(); var $mHeaderOptions = array(); var $mProccessed = false; function __construct($name, $value='') { + $this->class = 'Table'; $this->name = $name; $this->value = $value; } diff --git a/WEB-INF/lib/form/TextArea.class.php b/WEB-INF/lib/form/TextArea.class.php index ea1009a8..66101b98 100644 --- a/WEB-INF/lib/form/TextArea.class.php +++ b/WEB-INF/lib/form/TextArea.class.php @@ -31,14 +31,14 @@ import('form.FormElement'); class TextArea extends FormElement { var $mColumns = ""; var $mRows = ""; - var $class = 'TextArea'; var $mOnKeyPress = ""; - function __construct($name,$value="") - { - $this->name = $name; - $this->value = $value; - } + function __construct($name, $value = '') + { + $this->class = 'TextArea'; + $this->name = $name; + $this->value = $value; + } function setColumns($value) { $this->mColumns = $value; } function getColumns() { return $this->mColumns; } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 9f064307..3945875a 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.10.38.3617 | Copyright © Anuko | +  Anuko Time Tracker 1.10.38.3618 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} -- 2.20.1