1 |
cvsjoko |
1.1 |
<? |
2 |
|
|
|
3 |
|
|
// ================================================================ |
4 |
|
|
class HTMLWidgetFactory { |
5 |
|
|
|
6 |
|
|
// ------------------------------------------------------------------------------------------------------ |
7 |
|
|
function Textbox($name, $currentValue = "", $args = array()) { |
8 |
|
|
$retval = ''; |
9 |
|
|
|
10 |
|
|
// get args passed in |
11 |
|
|
$args_html = array(); if (isset($args['htmlargs'])) { $args_html = $args['htmlargs']; } |
12 |
|
|
|
13 |
|
|
// build local args |
14 |
|
|
$args_local = array('name' => $name, 'type' => 'text', 'value' => $currentValue); |
15 |
|
|
|
16 |
|
|
// merge two arg-arrays |
17 |
|
|
$args = array_merge($args_local, $args_html); |
18 |
|
|
|
19 |
|
|
// build html-tag |
20 |
|
|
$retval = getHtmlTag('input', $args); |
21 |
|
|
|
22 |
|
|
// return built tag |
23 |
|
|
return $retval; |
24 |
|
|
} |
25 |
|
|
|
26 |
|
|
// ------------------------------------------------------------------------------------------------------ |
27 |
|
|
function Hidden($name, $currentValue = "", $args = array()) { |
28 |
|
|
$retval = ''; |
29 |
|
|
|
30 |
|
|
// get args passed in |
31 |
|
|
$args_html = array(); if (isset($args['htmlargs'])) { $args_html = $args['htmlargs']; } |
32 |
|
|
|
33 |
|
|
// build local args |
34 |
|
|
$args_local = array('name' => $name, 'type' => 'hidden', 'value' => $currentValue); |
35 |
|
|
|
36 |
|
|
// merge two arg-arrays |
37 |
|
|
$args = array_merge($args_local, $args_html); |
38 |
|
|
|
39 |
|
|
// build html-tag |
40 |
|
|
$retval = getHtmlTag('input', $args); |
41 |
|
|
|
42 |
|
|
// return built tag |
43 |
|
|
return $retval; |
44 |
|
|
} |
45 |
|
|
|
46 |
|
|
// ------------------------------------------------------------------------------------------------------ |
47 |
|
|
function Checkbox($name, $currentValue = "", $args = array()) { |
48 |
|
|
$retval = ''; |
49 |
|
|
|
50 |
|
|
// get args passed in |
51 |
|
|
$args_html = array(); if (isset($args['htmlargs'])) { $args_html = $args['htmlargs']; } |
52 |
|
|
|
53 |
|
|
// build local args |
54 |
|
|
$args_local = array('name' => $name, 'type' => 'checkbox'); |
55 |
|
|
if ($currentValue) { |
56 |
|
|
$args_local['checked'] = 'on'; |
57 |
|
|
} |
58 |
|
|
|
59 |
|
|
// merge two arg-arrays |
60 |
|
|
$args = array_merge($args_local, $args_html); |
61 |
|
|
|
62 |
|
|
// build html-tag |
63 |
|
|
$retval = getHtmlTag('input', $args); |
64 |
|
|
|
65 |
|
|
// return built tag |
66 |
|
|
return $retval; |
67 |
|
|
} |
68 |
|
|
|
69 |
|
|
// ------------------------------------------------------------------------------------------------------ |
70 |
|
|
function Select($name, $optionHash, $currentValue = "", $args = array()) { |
71 |
|
|
|
72 |
|
|
if (!is_array($optionHash)) { return; } |
73 |
|
|
|
74 |
|
|
$retval = ''; |
75 |
|
|
|
76 |
|
|
// get args passed in |
77 |
|
|
$args_html = array(); if (isset($args['htmlargs'])) { $args_html = $args['htmlargs']; } |
78 |
|
|
|
79 |
|
|
// build local args |
80 |
|
|
$args_local = array('name' => $name); |
81 |
|
|
if ( isset($args['submitOnChange']) && ($args['submitOnChange']) ) { |
82 |
|
|
$args_local['onChange'] = 'javascript:document.forms[0].submit();'; |
83 |
|
|
} |
84 |
|
|
if ( isset($html_args['class']) && ($html_args['class']) ) { |
85 |
|
|
$args_local['class'] = $html_args['class']; |
86 |
|
|
} |
87 |
|
|
|
88 |
|
|
// merge two arg-arrays |
89 |
|
|
$args = array_merge($args_local, $args_html); |
90 |
|
|
|
91 |
|
|
// build html-tag |
92 |
|
|
$retval .= getHtmlTag('select', $args); |
93 |
|
|
reset($optionHash); |
94 |
|
|
while(list($key, $value) = each($optionHash)) { |
95 |
|
|
$html_selected = ''; |
96 |
|
|
$bool_selected = ($key == $currentValue); |
97 |
|
|
if ($bool_selected) { $html_selected = 'selected'; } |
98 |
|
|
$retval .= "<option value=\"$key\" $html_selected>$value</option>"; |
99 |
|
|
} |
100 |
|
|
$retval .= getHtmlTag('select', Null, 1); |
101 |
|
|
|
102 |
|
|
// return built tag |
103 |
|
|
return $retval; |
104 |
|
|
} |
105 |
|
|
|
106 |
|
|
// ------------------------------------------------------------------------------------------------------ |
107 |
|
|
function TreeView($args) { |
108 |
|
|
$treeview = new HTMLWidgetFactory_TreeView(); |
109 |
|
|
$treeview->Main($args); |
110 |
|
|
} |
111 |
|
|
|
112 |
|
|
// ------------------------------------------------------------------------------------------------------ |
113 |
|
|
function ListView($args) { |
114 |
|
|
$listview = new HTMLWidgetFactory_ListView(); |
115 |
|
|
$listview->Main($args); |
116 |
|
|
} |
117 |
|
|
|
118 |
|
|
} |
119 |
|
|
|
120 |
|
|
|
121 |
|
|
// ================================================================ |
122 |
|
|
class HTMLWidgets { |
123 |
|
|
|
124 |
|
|
var $name_formvar; |
125 |
|
|
|
126 |
|
|
function HTMLWidgets($name_formvar) { |
127 |
|
|
$this->name_formvar = $name_formvar; |
128 |
|
|
} |
129 |
|
|
|
130 |
|
|
function ui_getWidget($got_MetaItem) { |
131 |
|
|
|
132 |
|
|
$attribs = $got_MetaItem->getAttributes(); |
133 |
|
|
|
134 |
|
|
$name = $this->name_formvar . '[' . $attribs['name'] . ']'; |
135 |
|
|
|
136 |
|
|
$retval = "<input name=\"$name\" type=\"text\" value=\"{$attribs['value']}\" title=\"{$attribs['description']}\">"; |
137 |
|
|
return $retval; |
138 |
|
|
} |
139 |
|
|
|
140 |
|
|
} |
141 |
|
|
|
142 |
|
|
?> |