From: anuko Date: Wed, 1 Mar 2017 20:40:18 +0000 (+0000) Subject: Finished refactoring of the FormElement class. X-Git-Tag: timetracker_1.19-1~1539 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=61efd9d023ae34c1290ef2e1ae25829c509caaee;p=timetracker.git Finished refactoring of the FormElement class. --- diff --git a/WEB-INF/lib/form/Calendar.class.php b/WEB-INF/lib/form/Calendar.class.php index f4a50a81..dbe29981 100644 --- a/WEB-INF/lib/form/Calendar.class.php +++ b/WEB-INF/lib/form/Calendar.class.php @@ -222,7 +222,7 @@ class Calendar extends FormElement { return $str; } - function toStringControl() { + function getHtml() { return $this->toString(); } diff --git a/WEB-INF/lib/form/Checkbox.class.php b/WEB-INF/lib/form/Checkbox.class.php index 8c20288a..4c6a9fd7 100644 --- a/WEB-INF/lib/form/Checkbox.class.php +++ b/WEB-INF/lib/form/Checkbox.class.php @@ -45,7 +45,7 @@ class Checkbox extends FormElement { function setData($value) { $this->mOptions = $value; } function getData() { return $this->mOptions; } - function toStringControl() { + function getHtml() { if ($this->id=="") $this->id = $this->name; diff --git a/WEB-INF/lib/form/CheckboxGroup.class.php b/WEB-INF/lib/form/CheckboxGroup.class.php index 136cc069..cb7c9f1f 100644 --- a/WEB-INF/lib/form/CheckboxGroup.class.php +++ b/WEB-INF/lib/form/CheckboxGroup.class.php @@ -65,7 +65,7 @@ class CheckboxGroup extends FormElement { $this->lSelNone = $i18n->getKey('label.select_none'); } - function toStringControl() { + function getHtml() { if ($this->id=="") $this->id = $this->name; diff --git a/WEB-INF/lib/form/Combobox.class.php b/WEB-INF/lib/form/Combobox.class.php index 314f4b74..ce667396 100644 --- a/WEB-INF/lib/form/Combobox.class.php +++ b/WEB-INF/lib/form/Combobox.class.php @@ -65,7 +65,7 @@ class Combobox extends FormElement { function getDataKeys() { return $this->mDataKeys; } - function toStringControl() { + function getHtml() { if ($this->id=="") $this->id = $this->name; diff --git a/WEB-INF/lib/form/DateField.class.php b/WEB-INF/lib/form/DateField.class.php index 320d5240..3906db6c 100644 --- a/WEB-INF/lib/form/DateField.class.php +++ b/WEB-INF/lib/form/DateField.class.php @@ -80,7 +80,7 @@ class DateField extends TextField { } } - function toStringControl() { + function getHtml() { if (!$this->isEnabled()) { $html = htmlspecialchars($this->getValue()). diff --git a/WEB-INF/lib/form/Form.class.php b/WEB-INF/lib/form/Form.class.php index cd506aed..f8a32ec5 100644 --- a/WEB-INF/lib/form/Form.class.php +++ b/WEB-INF/lib/form/Form.class.php @@ -188,7 +188,7 @@ class Form { $html = "\n"; foreach ($this->elements as $elname=>$el) { if (strtolower(get_class($this->elements[$elname]))=="hidden") { - $html .= $this->elements[$elname]->toStringControl()."\n"; + $html .= $this->elements[$elname]->getHtml()."\n"; } } $html .= ""; diff --git a/WEB-INF/lib/form/FormElement.class.php b/WEB-INF/lib/form/FormElement.class.php index f3d26a4d..799abf7b 100644 --- a/WEB-INF/lib/form/FormElement.class.php +++ b/WEB-INF/lib/form/FormElement.class.php @@ -84,30 +84,15 @@ class FormElement { function localize($i18n) {} // Localization occurs in derived classes and is dependent on control type. // For example, in calendar control we need to localize day and month names. - // TODO: refactoring ongoing down from here. + // getHtml returns HTML for the element. + function getHtml() { return ''; } + // getLabelHtml returns HTML code for element label. + function getLabelHtml() { return ''; } - - - - - - - - - function toStringControl() { - return ""; - } - - function toStringLabel() { - return ""; - } - - function toArray() { - return array( - "label"=>$this->toStringLabel(), - "control"=>$this->toStringControl() - ); - } - + function toArray() { + return array( + 'label'=>$this->getLabelHtml(), + 'control'=>$this->getHtml()); + } } diff --git a/WEB-INF/lib/form/Hidden.class.php b/WEB-INF/lib/form/Hidden.class.php index 57ed9aa2..e06466e1 100644 --- a/WEB-INF/lib/form/Hidden.class.php +++ b/WEB-INF/lib/form/Hidden.class.php @@ -37,7 +37,7 @@ class Hidden extends FormElement { $this->value = $value; } - function toStringControl() { + function getHtml() { if ($this->id=="") $this->id = $this->name; diff --git a/WEB-INF/lib/form/Submit.class.php b/WEB-INF/lib/form/Submit.class.php index 947b368d..905b2695 100644 --- a/WEB-INF/lib/form/Submit.class.php +++ b/WEB-INF/lib/form/Submit.class.php @@ -37,7 +37,7 @@ class Submit extends FormElement { $this->value = $value; } - function toStringControl() { + 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 ea0d28e8..807e2c7c 100644 --- a/WEB-INF/lib/form/Table.class.php +++ b/WEB-INF/lib/form/Table.class.php @@ -114,7 +114,7 @@ class Table extends FormElement { } } - function toStringControl() { + function getHtml() { if (!$this->mProccessed) $this->_process(); $html = ""; diff --git a/WEB-INF/lib/form/TextArea.class.php b/WEB-INF/lib/form/TextArea.class.php index 9c779179..728f4629 100644 --- a/WEB-INF/lib/form/TextArea.class.php +++ b/WEB-INF/lib/form/TextArea.class.php @@ -47,7 +47,7 @@ class TextArea extends FormElement { function setRows($value) { $this->mRows = $value; } function getRows() { return $this->mRows; } - function toStringControl() { + function getHtml() { if ($this->id=="") $this->id = $this->mName; diff --git a/WEB-INF/lib/form/TextField.class.php b/WEB-INF/lib/form/TextField.class.php index d7e38aef..c9ffaaed 100644 --- a/WEB-INF/lib/form/TextField.class.php +++ b/WEB-INF/lib/form/TextField.class.php @@ -41,7 +41,7 @@ class TextField extends FormElement { function setAsPassword($name) { $this->mPassword = $name; } function getAsPassword() { return $this->mPassword; } - function toStringControl() { + function getHtml() { if (!$this->isEnabled()) { $html = "name\" value=\"".htmlspecialchars($this->getValue())."\" readonly>\n"; } else { diff --git a/WEB-INF/lib/form/UploadFile.class.php b/WEB-INF/lib/form/UploadFile.class.php index 7e76d64c..eb24259e 100644 --- a/WEB-INF/lib/form/UploadFile.class.php +++ b/WEB-INF/lib/form/UploadFile.class.php @@ -41,7 +41,7 @@ class UploadFile extends FormElement { function setMaxSize($value) { $this->mMaxSize = $value; } function getMaxSize() { return $this->mMaxSize; } - function toStringControl() { + function getHtml() { if ($this->id=="") $this->id = $this->name; diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 14dadd5a..635abc3a 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.10.38.3612 | Copyright © Anuko | +  Anuko Time Tracker 1.10.38.3613 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/mobile/user_add.php b/mobile/user_add.php index eec9662d..681ddd5c 100644 --- a/mobile/user_add.php +++ b/mobile/user_add.php @@ -113,7 +113,7 @@ class RateCellRenderer extends DefaultCellRenderer { foreach ($assigned_projects as $p) { if ($p['id'] == $table->getValueAtName($row,'id')) $field->setValue($p['rate']); } - $this->setValue($field->toStringControl()); + $this->setValue($field->getHtml()); return $this->toString(); } } diff --git a/mobile/user_edit.php b/mobile/user_edit.php index 96532d90..06cfdf95 100644 --- a/mobile/user_edit.php +++ b/mobile/user_edit.php @@ -143,7 +143,7 @@ class RateCellRenderer extends DefaultCellRenderer { foreach ($assigned_projects as $p) { if ($p['id'] == $table->getValueAtName($row,'id')) $field->setValue($p['rate']); } - $this->setValue($field->toStringControl()); + $this->setValue($field->getHtml()); return $this->toString(); } } diff --git a/user_add.php b/user_add.php index 6b5befe9..82e55cf1 100644 --- a/user_add.php +++ b/user_add.php @@ -113,7 +113,7 @@ class RateCellRenderer extends DefaultCellRenderer { foreach ($assigned_projects as $p) { if ($p['id'] == $table->getValueAtName($row,'id')) $field->setValue($p['rate']); } - $this->setValue($field->toStringControl()); + $this->setValue($field->getHtml()); return $this->toString(); } } diff --git a/user_edit.php b/user_edit.php index b3f41116..5fd3b7ec 100644 --- a/user_edit.php +++ b/user_edit.php @@ -143,7 +143,7 @@ class RateCellRenderer extends DefaultCellRenderer { foreach ($assigned_projects as $p) { if ($p['id'] == $table->getValueAtName($row,'id')) $field->setValue($p['rate']); } - $this->setValue($field->toStringControl()); + $this->setValue($field->getHtml()); return $this->toString(); } }