Soem refactoring to keep things a bit more consistent.
[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 $mOnSelect          = "";
39         var $mOnChange          = "";
40         var $mOnClick           = "";
41         var $mOnKeyPress        = "";
42         var $mOnFocus           = "";
43         var $mLabel         = "";
44         var $mStyle         = "";
45         var $mRenderable    = true;
46         var $mEnabled           = true;
47         var $cClassName         = "FormElement";
48         var $mI18n                      = null;
49
50         function __construct() {
51         }
52
53         function getClass()     { return $this->cClassName; }
54         
55         function setName($name) { $this->mName = $name; }
56         function getName()      { return $this->mName; }
57         
58         function setFormName($name)     { $this->mFormName = $name;     }
59         function getFormName()  { return $this->mFormName; }
60         
61         function setValue($value)       { $this->mValue = $value;}
62         function getValue() { return $this->mValue; }
63         
64         function setValueSafe($value)   { $this->mValue = $value;}
65         function getValueSafe() { return $this->mValue; }
66
67         function setId($id)     { $this->mId = $id;     }
68         function getId() { return $this->mId; }
69         
70         function setSize($value)        { $this->mSize = $value; }
71         function getSize() { return $this->mSize; }
72
73         function setLabel($label)       { $this->mLabel = $label; }
74         function getLabel() { return $this->mLabel; }
75         
76         function setMaxLength($value)   { $this->mMaxLength = $value; }
77         function getMaxLength() { return $this->mMaxLength; }
78         
79         function setTabindex($value)    { $this->mTabindex = $value; }
80         function getTabindex() { return $this->mTabindex; }
81         
82         function setAccesskey($value)   { $this->mAccesskey = $value; }
83         function getAccesskey() { return $this->mAccesskey; }
84
85         function setStyle($value)       { $this->mStyle = $value; }
86         function getStyle() { return $this->mStyle; }
87         
88         function setRenderable($flag)   { $this->mRenderable = $flag;   }
89         function isRenderable() { return $this->mRenderable; }
90         
91         function setEnable($flag)       { $this->mEnabled = $flag;      }
92         function isEnable()     { return $this->mEnabled; }
93         
94         function setOnChange($str)      { $this->mOnChange = $str; }
95         function setOnClick($str)       { $this->mOnClick = $str; }
96         function setOnSelect($str)      { $this->mOnSelect = $str; }
97
98         function setLocalization($i18n) {
99                 $this->mI18n = $i18n;
100         }
101         
102         function toStringControl()      {
103                 return "";
104         }
105         
106         function toStringLabel() {
107             return "<label for=\"" . $this->mId . "\">" . $this->mLabel . "</label>";
108         }
109         
110         function toArray() {
111             return array(
112                      "label"=>$this->toStringLabel(),
113                      "control"=>$this->toStringControl()
114                    );
115         }
116
117 }