Skip to content

Commit a4d1c56

Browse files
committed
Further refactoring of the FormElement class.
1 parent 1a0a677 commit a4d1c56

12 files changed

Lines changed: 43 additions & 37 deletions

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ function loadBean() {
186186
import('form.'.$ref_el["class"]);
187187
$class_name = $ref_el["class"];
188188
$el = new $class_name($ref_el["name"]);
189-
if (isset($GLOBALS["I18N"])) $el->setLocalization($GLOBALS["I18N"]);
189+
if (isset($GLOBALS["I18N"])) $el->localize($GLOBALS["I18N"]);
190190
$el->setValueSafe(@$_SESSION[$this->mSessionCell . "_" .$el->getName()]);
191191

192192
if ($this->mForm && !isset($this->mForm->elements[$ref_el["name"]])) {

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,10 @@ function setHighlight($highlight) {
5858
$this->highlight = $highlight;
5959
}
6060

61-
function setLocalization($i18n) {
61+
function localize($i18n) {
6262
global $user;
6363

64-
FormElement::setLocalization($i18n);
65-
$this->mMonthNames = $i18n->monthNames;
64+
$this->mMonthNames = $i18n->monthNames;
6665
$this->mWeekDayShortNames = $i18n->weekdayShortNames;
6766
if (is_array($i18n->holidays)) {
6867
foreach ($i18n->holidays as $fday) {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ function getLayout() { return $this->mLayout; }
6060
function setGroupIn($value) { $this->mGroupIn = $value; if ($this->mGroupIn<1) $this->mGroupIn = 1;}
6161
function getGroupIn() { return $this->mGroupIn; }
6262

63-
function setLocalization($i18n) {
64-
FormElement::setLocalization($i18n);
63+
function localize($i18n) {
6564
$this->lSelAll = $i18n->getKey('label.select_all');
6665
$this->lSelNone = $i18n->getKey('label.select_none');
6766
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,13 @@ function __construct($name) {
4444
$this->mDateObj = new DateAndTime();
4545

4646
if (isset($GLOBALS["I18N"])) {
47-
$this->setLocalization($GLOBALS["I18N"]);
47+
$this->localize($GLOBALS["I18N"]);
4848
}
4949
}
5050

51-
function setLocalization($i18n) {
52-
global $user;
51+
function localize($i18n) {
52+
global $user;
5353

54-
FormElement::setLocalization($i18n);
5554
$this->mDateObj->setFormat($user->date_format);
5655

5756
$this->mMonthNames = $i18n->monthNames;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ function __construct($name) {
3838
$this->name = $name;
3939
}
4040

41-
function setLocalization($i18n) {
42-
FormElement::setLocalization($i18n);
41+
function localize($i18n) {
4342
global $user;
4443
$this->mDelimiter = $user->decimal_mark;
4544
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ function addInput($arguments) {
141141
if ($el!=null) {
142142
$el->setFormName($this->name);
143143
if (isset($arguments["id"])) $el->setId($arguments["id"]);
144-
if (isset($GLOBALS["I18N"])) $el->setLocalization($GLOBALS["I18N"]);
144+
if (isset($GLOBALS["I18N"])) $el->localize($GLOBALS["I18N"]);
145145
if (isset($arguments["enable"])) $el->setEnabled($arguments["enable"]);
146146

147147
if (isset($arguments["style"])) $el->setStyle($arguments["style"]);
@@ -159,7 +159,7 @@ function addInput($arguments) {
159159

160160
function addInputElement(&$el) {
161161
if ($el && is_object($el)) {
162-
if (isset($GLOBALS["I18N"])) $el->setLocalization($GLOBALS["I18N"]);
162+
if (isset($GLOBALS["I18N"])) $el->localize($GLOBALS["I18N"]);
163163

164164
$el->setFormName($this->name);
165165
$this->elements[$el->name] = &$el;

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

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,30 +60,40 @@ function getValue() { return $this->value; }
6060
function setValueSafe($value) { $this->value = $value;}
6161
function getValueSafe() { return $this->value; }
6262

63+
function setId($id) { $this->id = $id; }
64+
function getId() { return $this->id; }
65+
66+
function setSize($value) { $this->size = $value; }
67+
function getSize() { return $this->size; }
68+
69+
function setLabel($label) { $this->label = $label; }
70+
function getLabel() { return $this->label; }
71+
72+
function setMaxLength($value) { $this->max_length = $value; }
73+
function getMaxLength() { return $this->max_length; }
74+
75+
function setStyle($value) { $this->style = $value; }
76+
function getStyle() { return $this->style; }
77+
78+
function setEnabled($flag) { $this->enabled = $flag; }
79+
function isEnabled() { return $this->enabled; }
80+
81+
function setOnChange($str) { $this->on_change = $str; }
82+
function setOnClick($str) { $this->on_click = $str; }
83+
84+
function localize($i18n) {} // Localization occurs in derived classes and is dependent on control type.
85+
// For example, in calendar control we need to localize day and month names.
86+
6387
// TODO: refactoring ongoing down from here.
64-
function setId($id) { $this->id = $id; }
65-
function getId() { return $this->id; }
66-
67-
function setSize($value) { $this->size = $value; }
68-
function getSize() { return $this->size; }
6988

70-
function setLabel($label) { $this->label = $label; }
71-
function getLabel() { return $this->label; }
72-
73-
function setMaxLength($value) { $this->max_length = $value; }
74-
function getMaxLength() { return $this->max_length; }
7589

76-
function setStyle($value) { $this->style = $value; }
77-
function getStyle() { return $this->style; }
7890

79-
function setEnabled($flag) { $this->enabled = $flag; }
80-
function isEnabled() { return $this->enabled; }
91+
92+
8193

82-
function setOnChange($str) { $this->on_change = $str; }
83-
function setOnClick($str) { $this->on_click = $str; }
8494

85-
function setLocalization($i18n) {
86-
}
95+
96+
8797

8898
function toStringControl() {
8999
return "";

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.3611 | 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.3612 | 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>

mobile/user_add.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function render(&$table, $value, $row, $column, $selected = false) {
107107
global $assigned_projects;
108108
$field = new FloatField('rate_'.$table->getValueAtName($row, 'id'));
109109
$field->setFormName($table->getFormName());
110-
$field->setLocalization($GLOBALS['I18N']);
110+
$field->localize($GLOBALS['I18N']);
111111
$field->setSize(5);
112112
$field->setFormat('.2');
113113
foreach ($assigned_projects as $p) {

mobile/user_edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ function render(&$table, $value, $row, $column, $selected = false) {
137137
global $assigned_projects;
138138
$field = new FloatField('rate_'.$table->getValueAtName($row,'id'));
139139
$field->setFormName($table->getFormName());
140-
$field->setLocalization($GLOBALS['I18N']);
140+
$field->localize($GLOBALS['I18N']);
141141
$field->setSize(5);
142142
$field->setFormat('.2');
143143
foreach ($assigned_projects as $p) {

0 commit comments

Comments
 (0)