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