2 // +----------------------------------------------------------------------+
3 // | Anuko Time Tracker
4 // +----------------------------------------------------------------------+
5 // | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
6 // +----------------------------------------------------------------------+
7 // | LIBERAL FREEWARE LICENSE: This source code document may be used
8 // | by anyone for any purpose, and freely redistributed alone or in
9 // | combination with other software, provided that the license is obeyed.
11 // | There are only two ways to violate the license:
13 // | 1. To redistribute this code in source form, with the copyright
14 // | notice or license removed or altered. (Distributing in compiled
15 // | forms without embedded copyright notices is permitted).
17 // | 2. To redistribute modified versions of this code in *any* form
18 // | that bears insufficient indications that the modifications are
19 // | not the work of the original author(s).
21 // | This license applies to this document only, not any other software
22 // | that it may be combined with.
24 // +----------------------------------------------------------------------+
26 // | https://www.anuko.com/time_tracker/credits.htm
27 // +----------------------------------------------------------------------+
29 // FromElement is the base class for controls on forms.
31 var $id = ''; // Control id.
32 var $name; // Control name.
33 var $form_name = ''; // Form name the control is in.
34 var $value = ''; // Value of the control.
35 var $size = ''; // Control size.
36 var $max_length = ''; // Max length of text in control.
37 var $on_change = ''; // What happens when value of control changes.
38 var $on_click = ''; // What happens when the control is clicked.
39 var $label = ''; // Optional label for control.
40 var $style = ''; // Control style.
42 // TODO: refactoring ongoing down from here.
43 var $mRenderable = true;
45 var $cClassName = "FormElement";
48 function __construct() {
51 function getClass() { return $this->cClassName; }
53 function setName($name) { $this->name = $name; }
54 function getName() { return $this->name; }
56 function setFormName($name) { $this->form_name = $name; }
57 function getFormName() { return $this->form_name; }
59 function setValue($value) { $this->value = $value;}
60 function getValue() { return $this->value; }
62 function setValueSafe($value) { $this->value = $value;}
63 function getValueSafe() { return $this->value; }
65 function setId($id) { $this->id = $id; }
66 function getId() { return $this->id; }
68 function setSize($value) { $this->size = $value; }
69 function getSize() { return $this->size; }
71 function setLabel($label) { $this->label = $label; }
72 function getLabel() { return $this->label; }
74 function setMaxLength($value) { $this->max_length = $value; }
75 function getMaxLength() { return $this->max_length; }
77 function setStyle($value) { $this->style = $value; }
78 function getStyle() { return $this->style; }
80 function setRenderable($flag) { $this->mRenderable = $flag; }
81 function isRenderable() { return $this->mRenderable; }
83 function setEnable($flag) { $this->mEnabled = $flag; }
84 function isEnable() { return $this->mEnabled; }
86 function setOnChange($str) { $this->on_change = $str; }
87 function setOnClick($str) { $this->on_click = $str; }
89 function setLocalization($i18n) {
93 function toStringControl() {
97 function toStringLabel() {
98 return "<label for=\"" . $this->id . "\">" . $this->label . "</label>";
103 "label"=>$this->toStringLabel(),
104 "control"=>$this->toStringControl()