From 6e59f47d1baf9e3d420b4a368dcc005d54b6e599 Mon Sep 17 00:00:00 2001 From: anuko Date: Sun, 19 Feb 2017 21:33:27 +0000 Subject: [PATCH] Ongoing refactoring of form controls. --- WEB-INF/lib/form/ActionForm.class.php | 4 ++-- WEB-INF/lib/form/Checkbox.class.php | 6 +++--- WEB-INF/lib/form/CheckboxGroup.class.php | 12 ++++++------ WEB-INF/lib/form/Combobox.class.php | 6 +++--- WEB-INF/lib/form/DateField.class.php | 10 +++++----- WEB-INF/lib/form/FloatField.class.php | 2 +- WEB-INF/lib/form/FormElement.class.php | 21 +++++++++++---------- WEB-INF/lib/form/Hidden.class.php | 6 +++--- WEB-INF/lib/form/Submit.class.php | 6 +++--- WEB-INF/lib/form/Table.class.php | 2 +- WEB-INF/lib/form/TextArea.class.php | 10 +++++----- WEB-INF/lib/form/TextField.class.php | 8 ++++---- WEB-INF/lib/form/UploadFile.class.php | 19 +++++-------------- WEB-INF/templates/footer.tpl | 2 +- 14 files changed, 53 insertions(+), 61 deletions(-) diff --git a/WEB-INF/lib/form/ActionForm.class.php b/WEB-INF/lib/form/ActionForm.class.php index fa70e15f..dcd3811c 100644 --- a/WEB-INF/lib/form/ActionForm.class.php +++ b/WEB-INF/lib/form/ActionForm.class.php @@ -62,8 +62,8 @@ class ActionForm { } function setName($name) { - $this->mName = $name; - $this->mSessionCell = "formbean_".$this->mName; + $this->name = $name; + $this->mSessionCell = "formbean_".$this->name; } /** diff --git a/WEB-INF/lib/form/Checkbox.class.php b/WEB-INF/lib/form/Checkbox.class.php index 5ba79165..8ee4fea0 100644 --- a/WEB-INF/lib/form/Checkbox.class.php +++ b/WEB-INF/lib/form/Checkbox.class.php @@ -35,7 +35,7 @@ class Checkbox extends FormElement { function __construct($name,$value="") { - $this->mName = $name; + $this->name = $name; $this->mValue = $value; } @@ -48,10 +48,10 @@ class Checkbox extends FormElement { function toStringControl() { if (!$this->isRenderable()) return ""; - if ($this->mId=="") $this->mId = $this->mName; + if ($this->id=="") $this->id = $this->name; $html = "\n\tmName\" id=\"$this->mId\""; + $html .= " name=\"$this->name\" id=\"$this->id\""; if ($this->mTabindex!="") $html .= " tabindex=\"$this->mTabindex\""; diff --git a/WEB-INF/lib/form/CheckboxGroup.class.php b/WEB-INF/lib/form/CheckboxGroup.class.php index f9d850fc..759a0767 100644 --- a/WEB-INF/lib/form/CheckboxGroup.class.php +++ b/WEB-INF/lib/form/CheckboxGroup.class.php @@ -41,7 +41,7 @@ class CheckboxGroup extends FormElement { function __construct($name,$value="") { - $this->mName = $name; + $this->name = $name; $this->mValue = $value; } @@ -69,7 +69,7 @@ class CheckboxGroup extends FormElement { function toStringControl() { if (!$this->isRenderable()) return ""; - if ($this->mId=="") $this->mId = $this->mName; + if ($this->id=="") $this->id = $this->name; $renderArray = array(); $renderCols = 0; @@ -86,14 +86,14 @@ class CheckboxGroup extends FormElement { $optkey = $optval[$this->mDataKeys[0]]; $optval = $optval[$this->mDataKeys[1]]; } - $html = "mName[]\" id=\"$this->mId"."_".$i."\""; + $html = "name[]\" id=\"$this->id"."_".$i."\""; if (is_array($this->mValue)) { foreach ($this->mValue as $value) { if (($value == $optkey) && ($value != null)) $html .= " checked=\"true\""; } } - $html .= " value=\"".htmlspecialchars($optkey)."\"> "; + $html .= " value=\"".htmlspecialchars($optkey)."\"> "; $renderArray[$col][$row] = $html; $col++; @@ -114,14 +114,14 @@ class CheckboxGroup extends FormElement { $optkey = $optval[$this->mDataKeys[0]]; $optval = $optval[$this->mDataKeys[1]]; } - $html = "mName[]\" id=\"$this->mId"."_".$i."\""; + $html = "name[]\" id=\"$this->id"."_".$i."\""; if (is_array($this->mValue)) { foreach ($this->mValue as $value) { if (($value == $optkey) && ($value != null)) $html .= " checked=\"true\""; } } - $html .= " value=\"".htmlspecialchars($optkey)."\"> "; + $html .= " value=\"".htmlspecialchars($optkey)."\"> "; $renderArray[$col][$row] = $html; $row++; diff --git a/WEB-INF/lib/form/Combobox.class.php b/WEB-INF/lib/form/Combobox.class.php index dcb84a24..0e8ec06c 100644 --- a/WEB-INF/lib/form/Combobox.class.php +++ b/WEB-INF/lib/form/Combobox.class.php @@ -48,7 +48,7 @@ class Combobox extends FormElement { function __construct($name,$value="") { - $this->mName = $name; + $this->name = $name; $this->mValue = $value; } @@ -68,10 +68,10 @@ class Combobox extends FormElement { function toStringControl() { if (!$this->isRenderable()) return ""; - if ($this->mId=="") $this->mId = $this->mName; + if ($this->id=="") $this->id = $this->name; $html = "\n\tmName\" id=\"$this->mId\""; + $html .= " name=\"$this->name\" id=\"$this->id\""; if ($this->mSize!="") $html .= " size=\"$this->mSize\""; diff --git a/WEB-INF/lib/form/DateField.class.php b/WEB-INF/lib/form/DateField.class.php index db59a3b2..24266a39 100644 --- a/WEB-INF/lib/form/DateField.class.php +++ b/WEB-INF/lib/form/DateField.class.php @@ -40,7 +40,7 @@ class DateField extends TextField { var $lCalendarButtons = array('today'=>'Today', 'close'=>'Close'); function __construct($name) { - $this->mName = $name; + $this->name = $name; $this->mDateObj = new DateAndTime(); if (isset($GLOBALS["I18N"])) { @@ -86,10 +86,10 @@ class DateField extends TextField { if (!$this->isEnable()) { $html = htmlspecialchars($this->getValue()). - "mName\" value=\"".htmlspecialchars($this->getValue())."\">\n"; + "name\" value=\"".htmlspecialchars($this->getValue())."\">\n"; } else { - if ($this->mId=="") $this->mId = $this->mName; + if ($this->id=="") $this->id = $this->name; $html = ""; @@ -393,7 +393,7 @@ class DateField extends TextField { $html .= "\n"; $html .= "\n\tmName\" id=\"$this->mId\""; + $html .= " name=\"$this->name\" id=\"$this->id\""; if ($this->mSize!="") $html .= " size=\"$this->mSize\""; @@ -418,7 +418,7 @@ class DateField extends TextField { if (APP_NAME) $app_root = '/'.APP_NAME; - $html .= " mName."');\">\n"; + $html .= " name."');\">\n"; } return $html; diff --git a/WEB-INF/lib/form/FloatField.class.php b/WEB-INF/lib/form/FloatField.class.php index 9cd38bfd..298e09bb 100644 --- a/WEB-INF/lib/form/FloatField.class.php +++ b/WEB-INF/lib/form/FloatField.class.php @@ -35,7 +35,7 @@ class FloatField extends TextField { var $cClassName = 'FloatField'; function __construct($name) { - $this->mName = $name; + $this->name = $name; } function setLocalization($i18n) { diff --git a/WEB-INF/lib/form/FormElement.class.php b/WEB-INF/lib/form/FormElement.class.php index e7ea9ccb..f46e3bf2 100644 --- a/WEB-INF/lib/form/FormElement.class.php +++ b/WEB-INF/lib/form/FormElement.class.php @@ -26,10 +26,11 @@ // | https://www.anuko.com/time_tracker/credits.htm // +----------------------------------------------------------------------+ +// FromElement is the base class for controls on forms. class FormElement { - var $mId = ""; - var $mName; - var $mFormName = ""; + var $id = ""; + var $name; + var $form_name = ""; var $mValue = ""; var $mSize = ""; var $mMaxLength = ""; @@ -52,11 +53,11 @@ class FormElement { function getClass() { return $this->cClassName; } - function setName($name) { $this->mName = $name; } - function getName() { return $this->mName; } + function setName($name) { $this->name = $name; } + function getName() { return $this->name; } - function setFormName($name) { $this->mFormName = $name; } - function getFormName() { return $this->mFormName; } + function setFormName($name) { $this->form_name = $name; } + function getFormName() { return $this->form_name; } function setValue($value) { $this->mValue = $value;} function getValue() { return $this->mValue; } @@ -64,8 +65,8 @@ class FormElement { function setValueSafe($value) { $this->mValue = $value;} function getValueSafe() { return $this->mValue; } - function setId($id) { $this->mId = $id; } - function getId() { return $this->mId; } + function setId($id) { $this->id = $id; } + function getId() { return $this->id; } function setSize($value) { $this->mSize = $value; } function getSize() { return $this->mSize; } @@ -104,7 +105,7 @@ class FormElement { } function toStringLabel() { - return ""; + return ""; } function toArray() { diff --git a/WEB-INF/lib/form/Hidden.class.php b/WEB-INF/lib/form/Hidden.class.php index 84837467..0105de15 100644 --- a/WEB-INF/lib/form/Hidden.class.php +++ b/WEB-INF/lib/form/Hidden.class.php @@ -34,16 +34,16 @@ class Hidden extends FormElement { function __construct($name,$value="") { - $this->mName = $name; + $this->name = $name; $this->mValue = $value; } function toStringControl() { - if ($this->mId=="") $this->mId = $this->mName; + if ($this->id=="") $this->id = $this->name; $html = "\n\tmName\" id=\"$this->mId\""; + $html .= " type=\"hidden\" name=\"$this->name\" id=\"$this->id\""; $html .= " value=\"".$this->getValue()."\""; $html .= ">"; diff --git a/WEB-INF/lib/form/Submit.class.php b/WEB-INF/lib/form/Submit.class.php index facfffc8..bcfe3be2 100644 --- a/WEB-INF/lib/form/Submit.class.php +++ b/WEB-INF/lib/form/Submit.class.php @@ -33,17 +33,17 @@ class Submit extends FormElement { function __construct($name,$value="") { - $this->mName = $name; + $this->name = $name; $this->mValue = $value; } function toStringControl() { if (!$this->isRenderable()) return ""; - if ($this->mId=="") $this->mId = $this->mName; + if ($this->id=="") $this->id = $this->name; $html = "\n\tmName\" id=\"$this->mId\""; + $html .= " type=\"submit\" name=\"$this->name\" id=\"$this->id\""; if (!$this->isEnable()) { $html .= " disabled=\"true\""; diff --git a/WEB-INF/lib/form/Table.class.php b/WEB-INF/lib/form/Table.class.php index b41a1f12..833bffac 100644 --- a/WEB-INF/lib/form/Table.class.php +++ b/WEB-INF/lib/form/Table.class.php @@ -48,7 +48,7 @@ class Table extends FormElement { var $mProccessed = false; function __construct($name, $value='') { - $this->mName = $name; + $this->name = $name; $this->mValue = $value; } diff --git a/WEB-INF/lib/form/TextArea.class.php b/WEB-INF/lib/form/TextArea.class.php index be0c8caa..ecc2010b 100644 --- a/WEB-INF/lib/form/TextArea.class.php +++ b/WEB-INF/lib/form/TextArea.class.php @@ -37,7 +37,7 @@ class TextArea extends FormElement { function __construct($name,$value="") { - $this->mName = $name; + $this->name = $name; $this->mValue = $value; } @@ -50,12 +50,12 @@ class TextArea extends FormElement { function toStringControl() { if (!$this->isRenderable()) return ""; - if ($this->mId=="") $this->mId = $this->mName; + if ($this->id=="") $this->id = $this->mName; $js_maxlen = ""; $html = "\n\tmName\" id=\"$this->mId\""; + $html .= " name=\"$this->name\" id=\"$this->id\""; if ($this->mColumns!="") $html .= " cols=\"$this->mColumns\""; @@ -65,7 +65,7 @@ class TextArea extends FormElement { if ($this->mMaxLength!="") { if ($this->mOnKeyPress) $this->mOnKeyPress .= ";"; - $this->mOnKeyPress .= "return validateMaxLenght_".$this->mName."(this, event);"; + $this->mOnKeyPress .= "return validateMaxLenght_".$this->name."(this, event);"; $js_maxlen = $this->getExtraScript(); $html .= " maxlength=\"$this->mMaxLength\""; } @@ -86,7 +86,7 @@ class TextArea extends FormElement { function getExtraScript() { $s = "