Initial repo created
[timetracker.git] / WEB-INF / lib / form / FormElement.class.php
1 <?php
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.
10 // |
11 // | There are only two ways to violate the license:
12 // |
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).
16 // |
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).
20 // |
21 // | This license applies to this document only, not any other software
22 // | that it may be combined with.
23 // |
24 // +----------------------------------------------------------------------+
25 // | Contributors:
26 // | https://www.anuko.com/time_tracker/credits.htm
27 // +----------------------------------------------------------------------+
28
29 class FormElement {
30         var $mId                        = "";
31         var $mName;
32         var $mFormName          = "";
33         var $mValue                     = "";
34         var $mSize                      = "";
35         var $mMaxLength         = "";
36         var $mTabindex          = "";
37         var $mAccesskey     = "";
38         var $mOnBlur            = "";
39         var $mOnSelect          = "";
40         var $mOnChange          = "";
41         var $mOnClick           = "";
42         var $mOnKeyPress        = "";
43         var $mOnFocus           = "";
44         var $mLabel         = "";
45         var $mStyle         = "";
46         var $mRenderable    = true;
47         var $mEnabled           = true;
48         var $cClassName         = "FormElement";
49         var $mI18n                      = null;
50
51         function FormElement() {
52         }
53
54         function getClass()     { return $this->cClassName; }
55         
56         function setName($name) { $this->mName = $name; }
57         function getName()      { return $this->mName; }
58         
59         function setFormName($name)     { $this->mFormName = $name;     }
60         function getFormName()  { return $this->mFormName; }
61         
62         function setValue($value)       { $this->mValue = $value;}
63         function getValue() { return $this->mValue; }
64         
65         function setValueSafe($value)   { $this->mValue = $value;}
66         function getValueSafe() { return $this->mValue; }
67
68         function setId($id)     { $this->mId = $id;     }
69         function getId() { return $this->mId; }
70         
71         function setSize($value)        { $this->mSize = $value; }
72         function getSize() { return $this->mSize; }
73
74         function setLabel($label)       { $this->mLabel = $label; }
75         function getLabel() { return $this->mLabel; }
76         
77         function setMaxLength($value)   { $this->mMaxLength = $value; }
78         function getMaxLength() { return $this->mMaxLength; }
79         
80         function setTabindex($value)    { $this->mTabindex = $value; }
81         function getTabindex() { return $this->mTabindex; }
82         
83         function setAccesskey($value)   { $this->mAccesskey = $value; }
84         function getAccesskey() { return $this->mAccesskey; }
85
86         function setStyle($value)       { $this->mStyle = $value; }
87         function getStyle() { return $this->mStyle; }
88         
89         function setRenderable($flag)   { $this->mRenderable = $flag;   }
90         function isRenderable() { return $this->mRenderable; }
91         
92         function setEnable($flag)       { $this->mEnabled = $flag;      }
93         function isEnable()     { return $this->mEnabled; }
94         
95         function setOnChange($str)      { $this->mOnChange = $str; }
96         function setOnClick($str)       { $this->mOnClick = $str; }
97         function setOnSelect($str)      { $this->mOnSelect = $str; }
98         function setOnBlue($str)        { $this->mOnBlur = $str; }
99         function setOnKeyPress($str){ $this->mOnKeyPress = $str; }
100         
101         function setLocalization($i18n) {
102                 $this->mI18n = $i18n;
103         }
104         
105         function toStringControl()      {
106                 return "";
107         }
108         
109         function toStringLabel() {
110             return "<label for=\"" . $this->mId . "\">" . $this->mLabel . "</label>";
111         }
112         
113         function toArray() {
114             return array(
115                      "label"=>$this->toStringLabel(),
116                      "control"=>$this->toStringControl()
117                    );
118         }
119
120 }
121 ?>