|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* You may not change or alter any portion of this comment or credits |
|
4
|
|
|
* of supporting developers from this source code or any supporting source code |
|
5
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
6
|
|
|
* This program is distributed in the hope that it will be useful, |
|
7
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
8
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Bootstrap5 style form renderer |
|
13
|
|
|
* |
|
14
|
|
|
* @category XoopsForm |
|
15
|
|
|
* @package XoopsFormRendererBootstrap5 |
|
16
|
|
|
* @author Tad <[email protected]> |
|
17
|
|
|
* @author Richard Griffith <[email protected]> |
|
18
|
|
|
* @copyright 2018-2021 XOOPS Project (https://xoops.org) |
|
19
|
|
|
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
|
20
|
|
|
*/ |
|
21
|
|
|
class XoopsFormRendererBootstrap5 implements XoopsFormRendererInterface |
|
22
|
|
|
{ |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Render support for XoopsFormButton |
|
26
|
|
|
* |
|
27
|
|
|
* @param XoopsFormButton $element form element |
|
28
|
|
|
* |
|
29
|
|
|
* @return string rendered form element |
|
30
|
|
|
*/ |
|
31
|
|
|
public function renderFormButton(XoopsFormButton $element) |
|
32
|
|
|
{ |
|
33
|
|
|
return '<button type="' . $element->getType() . '"' |
|
34
|
|
|
. ' class="btn btn-secondary" name="' . $element->getName() . '"' |
|
35
|
|
|
. ' id="' . $element->getName() . '" title="' . $element->getValue() . '"' |
|
36
|
|
|
. ' value="' . $element->getValue() . '"' |
|
37
|
|
|
. $element->getExtra() . '>' . $element->getValue() . '</button>'; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Render support for XoopsFormButtonTray |
|
42
|
|
|
* |
|
43
|
|
|
* @param XoopsFormButtonTray $element form element |
|
44
|
|
|
* |
|
45
|
|
|
* @return string rendered form element |
|
46
|
|
|
*/ |
|
47
|
|
|
public function renderFormButtonTray(XoopsFormButtonTray $element) |
|
48
|
|
|
{ |
|
49
|
|
|
$ret = ''; |
|
50
|
|
|
if ($element->_showDelete) { |
|
51
|
|
|
$ret .= '<button type="submit" class="btn btn-danger mr-1" name="delete" id="delete" onclick="this.form.elements.op.value=\'delete\'">' . _DELETE |
|
52
|
|
|
. '</button>'; |
|
53
|
|
|
} |
|
54
|
|
|
$ret .= '<button class="btn btn-danger mr-1" onClick="history.go(-1);return true;">' |
|
55
|
|
|
. _CANCEL . '</button>' |
|
56
|
|
|
. '<button type="reset" class="btn btn-warning mr-1" name="reset" id="reset">' . _RESET . '</button>' |
|
57
|
|
|
. '<button type="' . $element->getType() . '" class="btn btn-success" name="' . $element->getName() |
|
58
|
|
|
. '" id="' . $element->getName() . '" ' . $element->getExtra() |
|
59
|
|
|
. '>' . $element->getValue() . '</button>'; |
|
60
|
|
|
|
|
61
|
|
|
return $ret; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Render support for XoopsFormCheckBox |
|
66
|
|
|
* |
|
67
|
|
|
* @param XoopsFormCheckBox $element form element |
|
68
|
|
|
* |
|
69
|
|
|
* @return string rendered form element |
|
70
|
|
|
*/ |
|
71
|
|
|
public function renderFormCheckBox(XoopsFormCheckBox $element) |
|
72
|
|
|
{ |
|
73
|
|
|
$elementName = $element->getName(); |
|
74
|
|
|
$elementId = $elementName; |
|
75
|
|
|
$elementOptions = $element->getOptions(); |
|
76
|
|
|
if (count($elementOptions) > 1 && substr($elementName, -2, 2) !== '[]') { |
|
77
|
|
|
$elementName .= '[]'; |
|
78
|
|
|
$element->setName($elementName); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
switch ((int) ($element->columns)) { |
|
82
|
|
|
case 0: |
|
83
|
|
|
return $this->renderCheckedInline($element, 'checkbox', $elementId, $elementName); |
|
84
|
|
|
case 1: |
|
85
|
|
|
return $this->renderCheckedOneColumn($element, 'checkbox', $elementId, $elementName); |
|
86
|
|
|
default: |
|
87
|
|
|
return $this->renderCheckedColumnar($element, 'checkbox', $elementId, $elementName); |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Render a inline checkbox or radio element |
|
93
|
|
|
* |
|
94
|
|
|
* @param XoopsFormCheckBox|XoopsFormRadio $element element being rendered |
|
95
|
|
|
* @param string $type 'checkbox' or 'radio; |
|
96
|
|
|
* @param string $elementId input 'id' attribute of element |
|
97
|
|
|
* @param string $elementName input 'name' attribute of element |
|
98
|
|
|
* @return string |
|
99
|
|
|
*/ |
|
100
|
|
|
protected function renderCheckedInline($element, $type, $elementId, $elementName) |
|
101
|
|
|
{ |
|
102
|
|
|
$class = $type . '-inline'; |
|
|
|
|
|
|
103
|
|
|
$ret = ''; |
|
104
|
|
|
|
|
105
|
|
|
$idSuffix = 0; |
|
106
|
|
|
$elementValue = $element->getValue(); |
|
107
|
|
|
$elementOptions = $element->getOptions(); |
|
108
|
|
|
foreach ($elementOptions as $value => $name) { |
|
109
|
|
|
++$idSuffix; |
|
110
|
|
|
|
|
111
|
|
|
$ret .= '<div class="form-check form-check-inline m-2">'; |
|
112
|
|
|
$ret .= "<input class='form-check-input' type='" . $type . "' name='{$elementName}' id='{$elementId}{$idSuffix}' title='" |
|
113
|
|
|
. htmlspecialchars(strip_tags($name), ENT_QUOTES) . "' value='" |
|
114
|
|
|
. htmlspecialchars($value, ENT_QUOTES) . "'"; |
|
115
|
|
|
|
|
116
|
|
|
if (is_array($elementValue) ? in_array($value, $elementValue): $value == $elementValue) { |
|
117
|
|
|
$ret .= ' checked'; |
|
118
|
|
|
} |
|
119
|
|
|
$ret .= $element->getExtra() . '>'; |
|
120
|
|
|
$ret .= '<label class="form-check-label" for="'.$elementId.$idSuffix.'">' . $name . $element->getDelimeter().'</label>'; |
|
121
|
|
|
$ret .= '</div>'; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
return $ret; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* Render a single column checkbox or radio element |
|
129
|
|
|
* |
|
130
|
|
|
* @param XoopsFormCheckBox|XoopsFormRadio $element element being rendered |
|
131
|
|
|
* @param string $type 'checkbox' or 'radio; |
|
132
|
|
|
* @param string $elementId input 'id' attribute of element |
|
133
|
|
|
* @param string $elementName input 'name' attribute of element |
|
134
|
|
|
* @return string |
|
135
|
|
|
*/ |
|
136
|
|
|
protected function renderCheckedOneColumn($element, $type, $elementId, $elementName) |
|
137
|
|
|
{ |
|
138
|
|
|
$class = $type; |
|
139
|
|
|
$ret = ''; |
|
140
|
|
|
|
|
141
|
|
|
$idSuffix = 0; |
|
142
|
|
|
$elementValue = $element->getValue(); |
|
143
|
|
|
$elementOptions = $element->getOptions(); |
|
144
|
|
|
foreach ($elementOptions as $value => $name) { |
|
145
|
|
|
++$idSuffix; |
|
146
|
|
|
$ret .= '<div class="' . $class . '">'; |
|
147
|
|
|
$ret .= '<label>'; |
|
148
|
|
|
$ret .= "<input type='" . $type . "' name='{$elementName}' id='{$elementId}{$idSuffix}' title='" |
|
149
|
|
|
. htmlspecialchars(strip_tags($name), ENT_QUOTES) . "' value='" |
|
150
|
|
|
. htmlspecialchars($value, ENT_QUOTES) . "'"; |
|
151
|
|
|
|
|
152
|
|
|
if (is_array($elementValue) ? in_array($value, $elementValue): $value == $elementValue) { |
|
153
|
|
|
$ret .= ' checked'; |
|
154
|
|
|
} |
|
155
|
|
|
$ret .= $element->getExtra() . '>' . $name . $element->getDelimeter(); |
|
156
|
|
|
$ret .= '</label>'; |
|
157
|
|
|
$ret .= '</div>'; |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
return $ret; |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* Render a multicolumn checkbox or radio element |
|
165
|
|
|
* |
|
166
|
|
|
* @param XoopsFormCheckBox|XoopsFormRadio $element element being rendered |
|
167
|
|
|
* @param string $type 'checkbox' or 'radio; |
|
168
|
|
|
* @param string $elementId input 'id' attribute of element |
|
169
|
|
|
* @param string $elementName input 'name' attribute of element |
|
170
|
|
|
* @return string |
|
171
|
|
|
*/ |
|
172
|
|
|
protected function renderCheckedColumnar($element, $type, $elementId, $elementName) |
|
173
|
|
|
{ |
|
174
|
|
|
$class = $type; |
|
|
|
|
|
|
175
|
|
|
$ret = ''; |
|
176
|
|
|
|
|
177
|
|
|
$idSuffix = 0; |
|
178
|
|
|
$elementValue = $element->getValue(); |
|
179
|
|
|
$elementOptions = $element->getOptions(); |
|
180
|
|
|
foreach ($elementOptions as $value => $name) { |
|
181
|
|
|
++$idSuffix; |
|
182
|
|
|
|
|
183
|
|
|
$ret .= '<div class="form-check m-2">'; |
|
184
|
|
|
$ret .= "<input class='form-check-input' type='" . $type . "' name='{$elementName}' id='{$elementId}{$idSuffix}' title='" |
|
185
|
|
|
. htmlspecialchars(strip_tags($name), ENT_QUOTES) . "' value='" |
|
186
|
|
|
. htmlspecialchars($value, ENT_QUOTES) . "'"; |
|
187
|
|
|
|
|
188
|
|
|
if (is_array($elementValue) ? in_array($value, $elementValue): $value == $elementValue) { |
|
189
|
|
|
$ret .= ' checked'; |
|
190
|
|
|
} |
|
191
|
|
|
$ret .= $element->getExtra() . '>'; |
|
192
|
|
|
$ret .= '<label class="form-check-label" for="'.$elementId.$idSuffix.'">'. $name . $element->getDelimeter().'</label>'; |
|
193
|
|
|
$ret .= '</div>'; |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
return $ret; |
|
197
|
|
|
} |
|
198
|
|
|
/** |
|
199
|
|
|
* Render support for XoopsFormColorPicker |
|
200
|
|
|
* |
|
201
|
|
|
* @param XoopsFormColorPicker $element form element |
|
202
|
|
|
* |
|
203
|
|
|
* @return string rendered form element |
|
204
|
|
|
*/ |
|
205
|
|
|
public function renderFormColorPicker(XoopsFormColorPicker $element) |
|
206
|
|
|
{ |
|
207
|
|
|
if (isset($GLOBALS['xoTheme'])) { |
|
208
|
|
|
$GLOBALS['xoTheme']->addScript('include/spectrum.js'); |
|
209
|
|
|
$GLOBALS['xoTheme']->addStylesheet('include/spectrum.css'); |
|
210
|
|
|
} else { |
|
211
|
|
|
echo '<script type="text/javascript" src="' . XOOPS_URL . '/include/spectrum.js"></script>'; |
|
212
|
|
|
echo '<link rel="stylesheet" type="text/css" href="' . XOOPS_URL . '/include/spectrum.css">'; |
|
213
|
|
|
} |
|
214
|
|
|
return '<input class="form-control" style="width: 25%;" type="color" name="' . $element->getName() |
|
215
|
|
|
. "' title='" . $element->getTitle() . "' id='" . $element->getName() |
|
216
|
|
|
. '" size="7" maxlength="7" value="' . $element->getValue() . '"' . $element->getExtra() . '>'; |
|
217
|
|
|
} |
|
218
|
|
|
|
|
219
|
|
|
/** |
|
220
|
|
|
* Render support for XoopsFormDhtmlTextArea |
|
221
|
|
|
* |
|
222
|
|
|
* @param XoopsFormDhtmlTextArea $element form element |
|
223
|
|
|
* |
|
224
|
|
|
* @return string rendered form element |
|
225
|
|
|
*/ |
|
226
|
|
|
public function renderFormDhtmlTextArea(XoopsFormDhtmlTextArea $element) |
|
227
|
|
|
{ |
|
228
|
|
|
xoops_loadLanguage('formdhtmltextarea'); |
|
229
|
|
|
$ret = ''; |
|
230
|
|
|
// actions |
|
231
|
|
|
$ret .= $this->renderFormDhtmlTAXoopsCode($element) . "<br>\n"; |
|
232
|
|
|
// fonts |
|
233
|
|
|
$ret .= $this->renderFormDhtmlTATypography($element); |
|
234
|
|
|
// length checker |
|
235
|
|
|
|
|
236
|
|
|
$ret .= "<br>\n"; |
|
237
|
|
|
// the textarea box |
|
238
|
|
|
$ret .= "<textarea class='form-control' id='" . $element->getName() . "' name='" . $element->getName() |
|
239
|
|
|
. "' title='" . $element->getTitle() . "' onselect=\"xoopsSavePosition('" . $element->getName() |
|
240
|
|
|
. "');\" onclick=\"xoopsSavePosition('" . $element->getName() |
|
241
|
|
|
. "');\" onkeyup=\"xoopsSavePosition('" . $element->getName() . "');\" cols='" |
|
242
|
|
|
. $element->getCols() . "' rows='" . $element->getRows() . "'" . $element->getExtra() |
|
243
|
|
|
. '>' . $element->getValue() . "</textarea>\n"; |
|
244
|
|
|
|
|
245
|
|
|
if (empty($element->skipPreview)) { |
|
246
|
|
|
if (empty($GLOBALS['xoTheme'])) { |
|
247
|
|
|
$element->js .= implode('', file(XOOPS_ROOT_PATH . '/class/textsanitizer/image/image.js')); |
|
248
|
|
|
} else { |
|
249
|
|
|
$GLOBALS['xoTheme']->addScript( |
|
250
|
|
|
'/class/textsanitizer/image/image.js', |
|
251
|
|
|
array('type' => 'text/javascript') |
|
252
|
|
|
); |
|
253
|
|
|
} |
|
254
|
|
|
$button = "<button type='button' class='btn btn-primary' onclick=\"form_instantPreview('" . XOOPS_URL |
|
255
|
|
|
. "', '" . $element->getName() . "','" . XOOPS_URL . "/images', " . (int)$element->doHtml . ", '" |
|
256
|
|
|
. $GLOBALS['xoopsSecurity']->createToken() . "')\" title='" . _PREVIEW . "'>" . _PREVIEW . "</button>"; |
|
257
|
|
|
|
|
258
|
|
|
$ret .= '<br>' . "<div id='" . $element->getName() . "_hidden' style='display: block;'> " |
|
259
|
|
|
. ' <fieldset>' . ' <legend>' . $button . '</legend>' |
|
260
|
|
|
. " <div id='" . $element->getName() . "_hidden_data'>" . _XOOPS_FORM_PREVIEW_CONTENT |
|
261
|
|
|
. '</div>' . ' </fieldset>' . '</div>'; |
|
262
|
|
|
} |
|
263
|
|
|
// Load javascript |
|
264
|
|
|
$javascript_file = XOOPS_URL . '/include/formdhtmltextarea.js'; |
|
265
|
|
|
$javascript_file_element = 'include_formdhtmltextarea_js'; |
|
266
|
|
|
$javascript = ($element->js ? '<script type="text/javascript">' . $element->js . '</script>' : ''); |
|
267
|
|
|
$javascript .= <<<EOJS |
|
268
|
|
|
<script> |
|
269
|
|
|
var el = document.getElementById('{$javascript_file_element}'); |
|
270
|
|
|
if (el === null) { |
|
271
|
|
|
var xformtag = document.createElement('script'); |
|
272
|
|
|
xformtag.id = '{$javascript_file_element}'; |
|
273
|
|
|
xformtag.type = 'text/javascript'; |
|
274
|
|
|
xformtag.src = '{$javascript_file}'; |
|
275
|
|
|
document.body.appendChild(xformtag); |
|
276
|
|
|
} |
|
277
|
|
|
</script> |
|
278
|
|
|
EOJS; |
|
279
|
|
|
|
|
280
|
|
|
return $javascript . $ret; |
|
281
|
|
|
} |
|
282
|
|
|
|
|
283
|
|
|
/** |
|
284
|
|
|
* Render xoopscode buttons for editor, include calling text sanitizer extensions |
|
285
|
|
|
* |
|
286
|
|
|
* @param XoopsFormDhtmlTextArea $element form element |
|
287
|
|
|
* |
|
288
|
|
|
* @return string rendered buttons for xoopscode assistance |
|
289
|
|
|
*/ |
|
290
|
|
|
protected function renderFormDhtmlTAXoopsCode(XoopsFormDhtmlTextArea $element) |
|
291
|
|
|
{ |
|
292
|
|
|
$textarea_id = $element->getName(); |
|
293
|
|
|
$code = ''; |
|
294
|
|
|
$code .= "<div class='row'><div class='col-lg-12'>"; |
|
295
|
|
|
$code .= "<button type='button' class='btn btn-secondary btn-sm' onclick='xoopsCodeUrl(\"{$textarea_id}\", \"" . htmlspecialchars(_ENTERURL, ENT_QUOTES) . "\", \"" . htmlspecialchars(_ENTERWEBTITLE, ENT_QUOTES) . "\");' onmouseover='style.cursor=\"hand\"' title='" . _XOOPS_FORM_ALT_URL . "'><span class='fa fa-fw fa-link' aria-hidden='true'></span></button>"; |
|
296
|
|
|
$code .= "<button type='button' class='btn btn-secondary btn-sm' onclick='xoopsCodeEmail(\"{$textarea_id}\", \"" . htmlspecialchars(_ENTEREMAIL, ENT_QUOTES) . "\", \"" . htmlspecialchars(_ENTERWEBTITLE, ENT_QUOTES) . "\");' onmouseover='style.cursor=\"hand\"' title='" . _XOOPS_FORM_ALT_EMAIL . "'><span class='fa fa-fw fa-envelope-o' aria-hidden='true'></span></button>"; |
|
297
|
|
|
$code .= "<button type='button' class='btn btn-secondary btn-sm' onclick='xoopsCodeImg(\"{$textarea_id}\", \"" . htmlspecialchars(_ENTERIMGURL, ENT_QUOTES) . "\", \"" . htmlspecialchars(_ENTERIMGPOS, ENT_QUOTES) . "\", \"" . htmlspecialchars(_IMGPOSRORL, ENT_QUOTES) . "\", \"" . htmlspecialchars(_ERRORIMGPOS, ENT_QUOTES) . "\", \"" . htmlspecialchars(_XOOPS_FORM_ALT_ENTERWIDTH, ENT_QUOTES) . "\");' onmouseover='style.cursor=\"hand\"' title='" . _XOOPS_FORM_ALT_IMG . "'><span class='fa fa-fw fa-file-image-o' aria-hidden='true'></span></button>"; |
|
298
|
|
|
$code .= "<button type='button' class='btn btn-secondary btn-sm' onclick='openWithSelfMain(\"" . XOOPS_URL . "/imagemanager.php?target={$textarea_id}\",\"imgmanager\",400,430);' onmouseover='style.cursor=\"hand\"' title='" . _XOOPS_FORM_ALT_IMAGE . "'><span class='fa fa-file-image-o' aria-hidden='true'></span><small> Manager</small></button>"; |
|
299
|
|
|
$code .= "<button type='button' class='btn btn-secondary btn-sm' onclick='openWithSelfMain(\"" . XOOPS_URL . "/misc.php?action=showpopups&type=smilies&target={$textarea_id}\",\"smilies\",300,475);' onmouseover='style.cursor=\"hand\"' title='" . _XOOPS_FORM_ALT_SMILEY . "'><span class='fa fa-fw fa-smile-o' aria-hidden='true'></span></button>"; |
|
300
|
|
|
|
|
301
|
|
|
$myts = MyTextSanitizer::getInstance(); |
|
302
|
|
|
|
|
303
|
|
|
$extensions = array_filter($myts->config['extensions']); |
|
304
|
|
|
foreach (array_keys($extensions) as $key) { |
|
305
|
|
|
$extension = $myts->loadExtension($key); |
|
306
|
|
|
@list($encode, $js) = $extension->encode($textarea_id); |
|
307
|
|
|
if (empty($encode)) { |
|
308
|
|
|
continue; |
|
309
|
|
|
} |
|
310
|
|
|
// TODO - MyTextSanitizer button rendering should go through XoopsFormRenderer |
|
311
|
|
|
$encode = str_replace('btn-default', 'btn-secondary', $encode); |
|
312
|
|
|
|
|
313
|
|
|
$code .= $encode; |
|
314
|
|
|
if (!empty($js)) { |
|
315
|
|
|
$element->js .= $js; |
|
316
|
|
|
} |
|
317
|
|
|
} |
|
318
|
|
|
$code .= "<button type='button' class='btn btn-secondary btn-sm' onclick='xoopsCodeCode(\"{$textarea_id}\", \"" . htmlspecialchars(_ENTERCODE, ENT_QUOTES) . "\");' onmouseover='style.cursor=\"hand\"' title='" . _XOOPS_FORM_ALT_CODE . "'><span class='fa fa-fw fa-code' aria-hidden='true'></span></button>"; |
|
319
|
|
|
$code .= "<button type='button' class='btn btn-secondary btn-sm' onclick='xoopsCodeQuote(\"{$textarea_id}\", \"" . htmlspecialchars(_ENTERQUOTE, ENT_QUOTES) . "\");' onmouseover='style.cursor=\"hand\"' title='" . _XOOPS_FORM_ALT_QUOTE . "'><span class='fa fa-fw fa-quote-right' aria-hidden='true'></span></button>"; |
|
320
|
|
|
$code .= "</div></div>"; |
|
321
|
|
|
|
|
322
|
|
|
$xoopsPreload = XoopsPreload::getInstance(); |
|
323
|
|
|
$xoopsPreload->triggerEvent('core.class.xoopsform.formdhtmltextarea.codeicon', array(&$code)); |
|
324
|
|
|
|
|
325
|
|
|
return $code; |
|
326
|
|
|
} |
|
327
|
|
|
|
|
328
|
|
|
/** |
|
329
|
|
|
* Render typography controls for editor (font, size, color) |
|
330
|
|
|
* |
|
331
|
|
|
* @param XoopsFormDhtmlTextArea $element form element |
|
332
|
|
|
* |
|
333
|
|
|
* @return string rendered typography controls |
|
334
|
|
|
*/ |
|
335
|
|
|
protected function renderFormDhtmlTATypography(XoopsFormDhtmlTextArea $element) |
|
336
|
|
|
{ |
|
337
|
|
|
$textarea_id = $element->getName(); |
|
338
|
|
|
$hiddentext = $element->_hiddenText; |
|
339
|
|
|
|
|
340
|
|
|
$fontarray = !empty($GLOBALS['formtextdhtml_fonts']) ? $GLOBALS['formtextdhtml_fonts'] : array( |
|
341
|
|
|
'Arial', |
|
342
|
|
|
'Courier', |
|
343
|
|
|
'Georgia', |
|
344
|
|
|
'Helvetica', |
|
345
|
|
|
'Impact', |
|
346
|
|
|
'Verdana', |
|
347
|
|
|
'Haettenschweiler'); |
|
348
|
|
|
|
|
349
|
|
|
$colorArray = array( |
|
350
|
|
|
'Black' => '000000', |
|
351
|
|
|
'Blue' => '38AAFF', |
|
352
|
|
|
'Brown' => '987857', |
|
353
|
|
|
'Green' => '79D271', |
|
354
|
|
|
'Grey' => '888888', |
|
355
|
|
|
'Orange' => 'FFA700', |
|
356
|
|
|
'Paper' => 'E0E0E0', |
|
357
|
|
|
'Purple' => '363E98', |
|
358
|
|
|
'Red' => 'FF211E', |
|
359
|
|
|
'White' => 'FEFEFE', |
|
360
|
|
|
'Yellow' => 'FFD628', |
|
361
|
|
|
); |
|
362
|
|
|
|
|
363
|
|
|
$fontStr = '<div class="row"><div class="col-lg-12"><div class="btn-group" role="toolbar">'; |
|
364
|
|
|
$fontStr .= '<div class="btn-group">' |
|
365
|
|
|
. '<button type="button" class="btn btn-secondary btn-sm dropdown-toggle" title="'. _SIZE .'"' |
|
366
|
|
|
. ' data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' |
|
367
|
|
|
. '<span class = "fa fa-text-height"></span><span class="caret"></span></button>' |
|
368
|
|
|
. '<ul class="dropdown-menu">'; |
|
369
|
|
|
//. _SIZE . ' <span class="caret"></span></button><ul class="dropdown-menu">'; |
|
370
|
|
|
foreach ($GLOBALS['formtextdhtml_sizes'] as $value => $name) { |
|
371
|
|
|
$fontStr .= '<li class="dropdown-item"><a href="javascript:xoopsSetElementAttribute(\'size\', \'' . $value . '\', \'' |
|
372
|
|
|
. $textarea_id . '\', \'' . $hiddentext . '\');">' . $name . '</a></li>'; |
|
373
|
|
|
} |
|
374
|
|
|
$fontStr .= '</ul></div>'; |
|
375
|
|
|
|
|
376
|
|
|
$fontStr .= '<div class="btn-group">' |
|
377
|
|
|
. '<button type="button" class="btn btn-secondary btn-sm dropdown-toggle" title="'. _FONT .'"' |
|
378
|
|
|
. ' data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' |
|
379
|
|
|
. '<span class = "fa fa-font"></span><span class="caret"></span></button>' |
|
380
|
|
|
. '<ul class="dropdown-menu">'; |
|
381
|
|
|
//. _FONT . ' <span class="caret"></span></button><ul class="dropdown-menu">'; |
|
382
|
|
|
foreach ($fontarray as $font) { |
|
383
|
|
|
$fontStr .= '<li class="dropdown-item"><a href="javascript:xoopsSetElementAttribute(\'font\', \'' . $font . '\', \'' |
|
384
|
|
|
. $textarea_id . '\', \'' . $hiddentext . '\');">' . $font . '</a></li>'; |
|
385
|
|
|
} |
|
386
|
|
|
$fontStr .= '</ul></div>'; |
|
387
|
|
|
|
|
388
|
|
|
$fontStr .= '<div class="btn-group">' |
|
389
|
|
|
. '<button type="button" class="btn btn-secondary btn-sm dropdown-toggle" title="'. _COLOR .'"' |
|
390
|
|
|
. ' data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' |
|
391
|
|
|
. '<span class = "fa fa-tint"></span><span class="caret"></span></button>' |
|
392
|
|
|
. '<ul class="dropdown-menu">'; |
|
393
|
|
|
//. _COLOR . ' <span class="caret"></span></button><ul class="dropdown-menu">'; |
|
394
|
|
|
foreach ($colorArray as $color => $hex) { |
|
395
|
|
|
$fontStr .= '<li class="dropdown-item"><a href="javascript:xoopsSetElementAttribute(\'color\', \'' . $hex . '\', \'' |
|
396
|
|
|
. $textarea_id . '\', \'' . $hiddentext . '\');">' |
|
397
|
|
|
. '<span style="color:#' . $hex . ';">' . $color .'</span></a></li>'; |
|
398
|
|
|
} |
|
399
|
|
|
$fontStr .= '</ul></div>'; |
|
400
|
|
|
$fontStr .= '</div>'; |
|
401
|
|
|
|
|
402
|
|
|
//$styleStr = "<div class='row'><div class='col-lg-12'>"; |
|
403
|
|
|
$styleStr = "<div class='btn-group' role='group'>"; |
|
404
|
|
|
$styleStr .= "<button type='button' class='btn btn-secondary btn-sm' onclick='xoopsMakeBold(\"{$hiddentext}\", \"{$textarea_id}\");' title='" . _XOOPS_FORM_ALT_BOLD . "' aria-label='Left Align'><span class='fa fa-bold' aria-hidden='true'></span></button>"; |
|
405
|
|
|
$styleStr .= "<button type='button' class='btn btn-secondary btn-sm' onclick='xoopsMakeItalic(\"{$hiddentext}\", \"{$textarea_id}\");' title='" . _XOOPS_FORM_ALT_ITALIC . "' aria-label='Left Align'><span class='fa fa-italic' aria-hidden='true'></span></button>"; |
|
406
|
|
|
$styleStr .= "<button type='button' class='btn btn-secondary btn-sm' onclick='xoopsMakeUnderline(\"{$hiddentext}\", \"{$textarea_id}\");' title='" . _XOOPS_FORM_ALT_UNDERLINE . "' aria-label='Left Align'>" . '<span class="fa fa-underline"></span></button>'; |
|
407
|
|
|
$styleStr .= "<button type='button' class='btn btn-secondary btn-sm' onclick='xoopsMakeLineThrough(\"{$hiddentext}\", \"{$textarea_id}\");' title='" . _XOOPS_FORM_ALT_LINETHROUGH . "' aria-label='Left Align'>" . '<span class="fa fa-strikethrough"></span></button>'; |
|
408
|
|
|
$styleStr .= "</div>"; |
|
409
|
|
|
|
|
410
|
|
|
$alignStr = "<div class='btn-group' role='group'>"; |
|
411
|
|
|
$alignStr .= "<button type='button' class='btn btn-secondary btn-sm' onclick='xoopsMakeLeft(\"{$hiddentext}\", \"{$textarea_id}\");' title='" . _XOOPS_FORM_ALT_LEFT . "' aria-label='Left Align'><span class='fa fa-align-left' aria-hidden='true'></span></button>"; |
|
412
|
|
|
$alignStr .= "<button type='button' class='btn btn-secondary btn-sm' onclick='xoopsMakeCenter(\"{$hiddentext}\", \"{$textarea_id}\");' title='" . _XOOPS_FORM_ALT_CENTER . "' aria-label='Left Align'><span class='fa fa-align-center' aria-hidden='true'></span></button>"; |
|
413
|
|
|
$alignStr .= "<button type='button' class='btn btn-secondary btn-sm' onclick='xoopsMakeRight(\"{$hiddentext}\", \"{$textarea_id}\");' title='" . _XOOPS_FORM_ALT_RIGHT . "' aria-label='Left Align'><span class='fa fa-align-right' aria-hidden='true'></span></button>"; |
|
414
|
|
|
$alignStr .= "</div>"; |
|
415
|
|
|
|
|
416
|
|
|
$fontStr .= " {$styleStr} {$alignStr} \n"; |
|
417
|
|
|
|
|
418
|
|
|
$fontStr .= "<button type='button' class='btn btn-secondary btn-sm' onclick=\"XoopsCheckLength('" |
|
419
|
|
|
. $element->getName() . "', '" . @$element->configs['maxlength'] . "', '" |
|
|
|
|
|
|
420
|
|
|
. _XOOPS_FORM_ALT_LENGTH . "', '" . _XOOPS_FORM_ALT_LENGTH_MAX . "');\" title='" |
|
421
|
|
|
. _XOOPS_FORM_ALT_CHECKLENGTH . "'><span class='fa fa-check-square-o' aria-hidden='true'></span></button>"; |
|
422
|
|
|
$fontStr .= "</div></div>"; |
|
423
|
|
|
|
|
424
|
|
|
return $fontStr; |
|
425
|
|
|
} |
|
426
|
|
|
|
|
427
|
|
|
/** |
|
428
|
|
|
* Render support for XoopsFormElementTray |
|
429
|
|
|
* |
|
430
|
|
|
* @param XoopsFormElementTray $element form element |
|
431
|
|
|
* |
|
432
|
|
|
* @return string rendered form element |
|
433
|
|
|
*/ |
|
434
|
|
|
public function renderFormElementTray(XoopsFormElementTray $element) |
|
435
|
|
|
{ |
|
436
|
|
|
$count = 0; |
|
437
|
|
|
$inline = (\XoopsFormElementTray::ORIENTATION_VERTICAL === $element->getOrientation()); |
|
438
|
|
|
$ret = ''; |
|
439
|
|
|
foreach ($element->getElements() as $ele) { |
|
440
|
|
|
if ($count > 0 && !$inline) { |
|
441
|
|
|
$ret .= $element->getDelimeter(); |
|
442
|
|
|
} |
|
443
|
|
|
if ($inline) { |
|
444
|
|
|
$ret .= '<span class="form-inline">'; |
|
445
|
|
|
} |
|
446
|
|
|
if ($ele->getCaption() != '') { |
|
447
|
|
|
$ret .= '<label for="' . $ele->getName() . '" class="form-label text-sm-right">' |
|
448
|
|
|
. $ele->getCaption() |
|
449
|
|
|
. ($ele->isRequired() ? '<span class="caption-required">*</span>' : '') |
|
450
|
|
|
. '</label> '; |
|
451
|
|
|
|
|
452
|
|
|
} |
|
453
|
|
|
$ret .= $ele->render() . NWLINE; |
|
|
|
|
|
|
454
|
|
|
if ($inline) { |
|
455
|
|
|
$ret .= '</span>'; |
|
456
|
|
|
} |
|
457
|
|
|
if (!$ele->isHidden()) { |
|
458
|
|
|
++$count; |
|
459
|
|
|
} |
|
460
|
|
|
} |
|
461
|
|
|
|
|
462
|
|
|
return $ret; |
|
463
|
|
|
} |
|
464
|
|
|
|
|
465
|
|
|
/** |
|
466
|
|
|
* Render support for XoopsFormFile |
|
467
|
|
|
* |
|
468
|
|
|
* @param XoopsFormFile $element form element |
|
469
|
|
|
* |
|
470
|
|
|
* @return string rendered form element |
|
471
|
|
|
*/ |
|
472
|
|
|
public function renderFormFile(XoopsFormFile $element) |
|
473
|
|
|
{ |
|
474
|
|
|
return '<input type="file" class="form-control" name="' . $element->getName() |
|
475
|
|
|
. '" id="' . $element->getName() |
|
476
|
|
|
. '" title="' . $element->getTitle() . '" ' . $element->getExtra() . '>' |
|
477
|
|
|
. '<input type="hidden" name="MAX_FILE_SIZE" value="' . $element->getMaxFileSize() . '">' |
|
478
|
|
|
. '<input type="hidden" name="xoops_upload_file[]" id="xoops_upload_file[]" value="' |
|
479
|
|
|
. $element->getName() . '">'; |
|
480
|
|
|
} |
|
481
|
|
|
|
|
482
|
|
|
/** |
|
483
|
|
|
* Render support for XoopsFormLabel |
|
484
|
|
|
* |
|
485
|
|
|
* @param XoopsFormLabel $element form element |
|
486
|
|
|
* |
|
487
|
|
|
* @return string rendered form element |
|
488
|
|
|
*/ |
|
489
|
|
|
public function renderFormLabel(XoopsFormLabel $element) |
|
490
|
|
|
{ |
|
491
|
|
|
return '<label class="col-form-label" id="' . $element->getName() . '">' . $element->getValue(); |
|
492
|
|
|
} |
|
493
|
|
|
|
|
494
|
|
|
/** |
|
495
|
|
|
* Render support for XoopsFormPassword |
|
496
|
|
|
* |
|
497
|
|
|
* @param XoopsFormPassword $element form element |
|
498
|
|
|
* |
|
499
|
|
|
* @return string rendered form element |
|
500
|
|
|
*/ |
|
501
|
|
|
public function renderFormPassword(XoopsFormPassword $element) |
|
502
|
|
|
{ |
|
503
|
|
|
return '<input class="form-control" type="password" name="' |
|
504
|
|
|
. $element->getName() . '" id="' . $element->getName() . '" size="' . $element->getSize() |
|
505
|
|
|
. '" maxlength="' . $element->getMaxlength() . '" value="' . $element->getValue() . '"' |
|
506
|
|
|
. $element->getExtra() . ' ' . ($element->autoComplete ? '' : 'autocomplete="off" ') . '/>'; |
|
507
|
|
|
} |
|
508
|
|
|
|
|
509
|
|
|
/** |
|
510
|
|
|
* Render support for XoopsFormRadio |
|
511
|
|
|
* |
|
512
|
|
|
* @param XoopsFormRadio $element form element |
|
513
|
|
|
* |
|
514
|
|
|
* @return string rendered form element |
|
515
|
|
|
*/ |
|
516
|
|
|
public function renderFormRadio(XoopsFormRadio $element) |
|
517
|
|
|
{ |
|
518
|
|
|
|
|
519
|
|
|
$elementName = $element->getName(); |
|
520
|
|
|
$elementId = $elementName; |
|
521
|
|
|
|
|
522
|
|
|
switch ((int) ($element->columns)) { |
|
523
|
|
|
case 0: |
|
524
|
|
|
return $this->renderCheckedInline($element, 'radio', $elementId, $elementName); |
|
525
|
|
|
case 1: |
|
526
|
|
|
return $this->renderCheckedOneColumn($element, 'radio', $elementId, $elementName); |
|
527
|
|
|
default: |
|
528
|
|
|
return $this->renderCheckedColumnar($element, 'radio', $elementId, $elementName); |
|
529
|
|
|
} |
|
530
|
|
|
} |
|
531
|
|
|
|
|
532
|
|
|
/** |
|
533
|
|
|
* Render support for XoopsFormSelect |
|
534
|
|
|
* |
|
535
|
|
|
* @param XoopsFormSelect $element form element |
|
536
|
|
|
* |
|
537
|
|
|
* @return string rendered form element |
|
538
|
|
|
*/ |
|
539
|
|
|
public function renderFormSelect(XoopsFormSelect $element) |
|
540
|
|
|
{ |
|
541
|
|
|
$ele_name = $element->getName(); |
|
542
|
|
|
$ele_title = $element->getTitle(); |
|
543
|
|
|
$ele_value = $element->getValue(); |
|
544
|
|
|
$ele_options = $element->getOptions(); |
|
545
|
|
|
$ret = '<select class="form-control" size="' |
|
546
|
|
|
. $element->getSize() . '"' . $element->getExtra(); |
|
547
|
|
|
if ($element->isMultiple() != false) { |
|
|
|
|
|
|
548
|
|
|
$ret .= ' name="' . $ele_name . '[]" id="' . $ele_name . '" title="' . $ele_title |
|
549
|
|
|
. '" multiple="multiple">'; |
|
550
|
|
|
} else { |
|
551
|
|
|
$ret .= ' name="' . $ele_name . '" id="' . $ele_name . '" title="' . $ele_title . '">'; |
|
552
|
|
|
} |
|
553
|
|
|
foreach ($ele_options as $value => $name) { |
|
554
|
|
|
$ret .= '<option value="' . htmlspecialchars($value, ENT_QUOTES) . '"'; |
|
555
|
|
|
if (count($ele_value) > 0 && in_array($value, $ele_value)) { |
|
556
|
|
|
$ret .= ' selected'; |
|
557
|
|
|
} |
|
558
|
|
|
$ret .= '>' . $name . '</option>'; |
|
559
|
|
|
} |
|
560
|
|
|
$ret .= '</select>'; |
|
561
|
|
|
|
|
562
|
|
|
return $ret; |
|
563
|
|
|
} |
|
564
|
|
|
|
|
565
|
|
|
/** |
|
566
|
|
|
* Render support for XoopsFormText |
|
567
|
|
|
* |
|
568
|
|
|
* @param XoopsFormText $element form element |
|
569
|
|
|
* |
|
570
|
|
|
* @return string rendered form element |
|
571
|
|
|
*/ |
|
572
|
|
|
public function renderFormText(XoopsFormText $element) |
|
573
|
|
|
{ |
|
574
|
|
|
return "<input class='form-control' type='text' name='" |
|
575
|
|
|
. $element->getName() . "' title='" . $element->getTitle() . "' id='" . $element->getName() |
|
576
|
|
|
. "' size='" . $element->getSize() . "' maxlength='" . $element->getMaxlength() |
|
577
|
|
|
. "' value='" . $element->getValue() . "'" . $element->getExtra() . '>'; |
|
578
|
|
|
} |
|
579
|
|
|
|
|
580
|
|
|
/** |
|
581
|
|
|
* Render support for XoopsFormTextArea |
|
582
|
|
|
* |
|
583
|
|
|
* @param XoopsFormTextArea $element form element |
|
584
|
|
|
* |
|
585
|
|
|
* @return string rendered form element |
|
586
|
|
|
*/ |
|
587
|
|
|
public function renderFormTextArea(XoopsFormTextArea $element) |
|
588
|
|
|
{ |
|
589
|
|
|
return "<textarea class='form-control' name='" |
|
590
|
|
|
. $element->getName() . "' id='" . $element->getName() . "' title='" . $element->getTitle() |
|
591
|
|
|
. "' rows='" . $element->getRows() . "' cols='" . $element->getCols() . "'" |
|
592
|
|
|
. $element->getExtra() . '>' . $element->getValue() . '</textarea>'; |
|
593
|
|
|
} |
|
594
|
|
|
|
|
595
|
|
|
/** |
|
596
|
|
|
* Render support for XoopsFormTextDateSelect |
|
597
|
|
|
* |
|
598
|
|
|
* @param XoopsFormTextDateSelect $element form element |
|
599
|
|
|
* |
|
600
|
|
|
* @return string rendered form element |
|
601
|
|
|
*/ |
|
602
|
|
|
public function renderFormTextDateSelect(XoopsFormTextDateSelect $element) |
|
603
|
|
|
{ |
|
604
|
|
|
static $included = false; |
|
605
|
|
|
if (file_exists(XOOPS_ROOT_PATH . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/calendar.php')) { |
|
606
|
|
|
include_once XOOPS_ROOT_PATH . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/calendar.php'; |
|
607
|
|
|
} else { |
|
608
|
|
|
include_once XOOPS_ROOT_PATH . '/language/english/calendar.php'; |
|
609
|
|
|
} |
|
610
|
|
|
|
|
611
|
|
|
$ele_name = $element->getName(); |
|
612
|
|
|
$ele_value = $element->getValue(false); |
|
613
|
|
|
if (is_string($ele_value)) { |
|
|
|
|
|
|
614
|
|
|
$display_value = $ele_value; |
|
615
|
|
|
$ele_value = time(); |
|
616
|
|
|
} else { |
|
617
|
|
|
$display_value = date(_SHORTDATESTRING, $ele_value); |
|
618
|
|
|
} |
|
619
|
|
|
|
|
620
|
|
|
$jstime = formatTimestamp($ele_value, 'm/d/Y'); |
|
621
|
|
|
if (isset($GLOBALS['xoTheme']) && is_object($GLOBALS['xoTheme'])) { |
|
622
|
|
|
$GLOBALS['xoTheme']->addScript('include/calendar.js'); |
|
623
|
|
|
$GLOBALS['xoTheme']->addStylesheet('include/calendar-blue.css'); |
|
624
|
|
|
if (!$included) { |
|
625
|
|
|
$included = true; |
|
626
|
|
|
$GLOBALS['xoTheme']->addScript('', '', ' |
|
627
|
|
|
var calendar = null; |
|
628
|
|
|
|
|
629
|
|
|
function selected(cal, date) |
|
630
|
|
|
{ |
|
631
|
|
|
cal.sel.value = date; |
|
632
|
|
|
} |
|
633
|
|
|
|
|
634
|
|
|
function closeHandler(cal) |
|
635
|
|
|
{ |
|
636
|
|
|
cal.hide(); |
|
637
|
|
|
Calendar.removeEvent(document, "mousedown", checkCalendar); |
|
638
|
|
|
} |
|
639
|
|
|
|
|
640
|
|
|
function checkCalendar(ev) |
|
641
|
|
|
{ |
|
642
|
|
|
var el = Calendar.is_ie ? Calendar.getElement(ev) : Calendar.getTargetElement(ev); |
|
643
|
|
|
for (; el != null; el = el.parentNode) |
|
644
|
|
|
if (el == calendar.element || el.tagName == "A") break; |
|
645
|
|
|
if (el == null) { |
|
646
|
|
|
calendar.callCloseHandler(); Calendar.stopEvent(ev); |
|
647
|
|
|
} |
|
648
|
|
|
} |
|
649
|
|
|
function showCalendar(id) |
|
650
|
|
|
{ |
|
651
|
|
|
var el = xoopsGetElementById(id); |
|
652
|
|
|
if (calendar != null) { |
|
653
|
|
|
calendar.hide(); |
|
654
|
|
|
} else { |
|
655
|
|
|
var cal = new Calendar(true, "' . $jstime . '", selected, closeHandler); |
|
656
|
|
|
calendar = cal; |
|
657
|
|
|
cal.setRange(1900, 2100); |
|
658
|
|
|
calendar.create(); |
|
659
|
|
|
} |
|
660
|
|
|
calendar.sel = el; |
|
661
|
|
|
calendar.parseDate(el.value); |
|
662
|
|
|
calendar.showAtElement(el); |
|
663
|
|
|
Calendar.addEvent(document, "mousedown", checkCalendar); |
|
664
|
|
|
|
|
665
|
|
|
return false; |
|
666
|
|
|
} |
|
667
|
|
|
|
|
668
|
|
|
Calendar._DN = new Array |
|
669
|
|
|
("' . _CAL_SUNDAY . '", |
|
670
|
|
|
"' . _CAL_MONDAY . '", |
|
671
|
|
|
"' . _CAL_TUESDAY . '", |
|
672
|
|
|
"' . _CAL_WEDNESDAY . '", |
|
673
|
|
|
"' . _CAL_THURSDAY . '", |
|
674
|
|
|
"' . _CAL_FRIDAY . '", |
|
675
|
|
|
"' . _CAL_SATURDAY . '", |
|
676
|
|
|
"' . _CAL_SUNDAY . '"); |
|
677
|
|
|
Calendar._MN = new Array |
|
678
|
|
|
("' . _CAL_JANUARY . '", |
|
679
|
|
|
"' . _CAL_FEBRUARY . '", |
|
680
|
|
|
"' . _CAL_MARCH . '", |
|
681
|
|
|
"' . _CAL_APRIL . '", |
|
682
|
|
|
"' . _CAL_MAY . '", |
|
683
|
|
|
"' . _CAL_JUNE . '", |
|
684
|
|
|
"' . _CAL_JULY . '", |
|
685
|
|
|
"' . _CAL_AUGUST . '", |
|
686
|
|
|
"' . _CAL_SEPTEMBER . '", |
|
687
|
|
|
"' . _CAL_OCTOBER . '", |
|
688
|
|
|
"' . _CAL_NOVEMBER . '", |
|
689
|
|
|
"' . _CAL_DECEMBER . '"); |
|
690
|
|
|
|
|
691
|
|
|
Calendar._TT = {}; |
|
692
|
|
|
Calendar._TT["TOGGLE"] = "' . _CAL_TGL1STD . '"; |
|
693
|
|
|
Calendar._TT["PREV_YEAR"] = "' . _CAL_PREVYR . '"; |
|
694
|
|
|
Calendar._TT["PREV_MONTH"] = "' . _CAL_PREVMNTH . '"; |
|
695
|
|
|
Calendar._TT["GO_TODAY"] = "' . _CAL_GOTODAY . '"; |
|
696
|
|
|
Calendar._TT["NEXT_MONTH"] = "' . _CAL_NXTMNTH . '"; |
|
697
|
|
|
Calendar._TT["NEXT_YEAR"] = "' . _CAL_NEXTYR . '"; |
|
698
|
|
|
Calendar._TT["SEL_DATE"] = "' . _CAL_SELDATE . '"; |
|
699
|
|
|
Calendar._TT["DRAG_TO_MOVE"] = "' . _CAL_DRAGMOVE . '"; |
|
700
|
|
|
Calendar._TT["PART_TODAY"] = "(' . _CAL_TODAY . ')"; |
|
701
|
|
|
Calendar._TT["MON_FIRST"] = "' . _CAL_DISPM1ST . '"; |
|
702
|
|
|
Calendar._TT["SUN_FIRST"] = "' . _CAL_DISPS1ST . '"; |
|
703
|
|
|
Calendar._TT["CLOSE"] = "' . _CLOSE . '"; |
|
704
|
|
|
Calendar._TT["TODAY"] = "' . _CAL_TODAY . '"; |
|
705
|
|
|
|
|
706
|
|
|
// date formats |
|
707
|
|
|
Calendar._TT["DEF_DATE_FORMAT"] = "' . _SHORTDATESTRING . '"; |
|
708
|
|
|
Calendar._TT["TT_DATE_FORMAT"] = "' . _SHORTDATESTRING . '"; |
|
709
|
|
|
|
|
710
|
|
|
Calendar._TT["WK"] = ""; |
|
711
|
|
|
'); |
|
712
|
|
|
} |
|
713
|
|
|
} |
|
714
|
|
|
return '<div class="input-group">' |
|
715
|
|
|
. '<input class="form-control" type="text" name="' . $ele_name . '" id="' . $ele_name |
|
716
|
|
|
. '" size="' . $element->getSize() . '" maxlength="' . $element->getMaxlength() |
|
717
|
|
|
. '" value="' . $display_value . '"' . $element->getExtra() . '>' |
|
718
|
|
|
. '<div class="input-group-append"><button class="btn btn-secondary" type="button"' |
|
719
|
|
|
. ' onclick="return showCalendar(\'' . $ele_name . '\');">' |
|
720
|
|
|
. '<i class="fa fa-calendar" aria-hidden="true"></i></button>' |
|
721
|
|
|
. '</div>' |
|
722
|
|
|
. '</div>'; |
|
723
|
|
|
} |
|
724
|
|
|
|
|
725
|
|
|
/** |
|
726
|
|
|
* Render support for XoopsThemeForm |
|
727
|
|
|
* |
|
728
|
|
|
* @param XoopsThemeForm $form form to render |
|
729
|
|
|
* |
|
730
|
|
|
* @return string rendered form |
|
731
|
|
|
*/ |
|
732
|
|
|
public function renderThemeForm(XoopsThemeForm $form) |
|
733
|
|
|
{ |
|
734
|
|
|
$ele_name = $form->getName(); |
|
735
|
|
|
|
|
736
|
|
|
$ret = '<div>'; |
|
737
|
|
|
$ret .= '<form name="' . $ele_name . '" id="' . $ele_name . '" action="' |
|
738
|
|
|
. $form->getAction() . '" method="' . $form->getMethod() |
|
739
|
|
|
. '" onsubmit="return xoopsFormValidate_' . $ele_name . '();"' . $form->getExtra() . '>' |
|
740
|
|
|
. '<h3>' . $form->getTitle() . '</h3>'; |
|
741
|
|
|
$hidden = ''; |
|
742
|
|
|
|
|
743
|
|
|
foreach ($form->getElements() as $element) { |
|
744
|
|
|
if (!is_object($element)) { // see $form->addBreak() |
|
745
|
|
|
$ret .= $element; |
|
746
|
|
|
continue; |
|
747
|
|
|
} |
|
748
|
|
|
if ($element->isHidden()) { |
|
749
|
|
|
$hidden .= $element->render(); |
|
|
|
|
|
|
750
|
|
|
continue; |
|
751
|
|
|
} |
|
752
|
|
|
|
|
753
|
|
|
$ret .= '<div class="form-group row">'; |
|
754
|
|
|
if (($caption = $element->getCaption()) != '') { |
|
|
|
|
|
|
755
|
|
|
$ret .= '<label for="' . $element->getName() . '" class="col-xs-12 col-sm-2 col-form-label text-sm-right">' |
|
756
|
|
|
. $element->getCaption() |
|
757
|
|
|
. ($element->isRequired() ? '<span class="caption-required">*</span>' : '') |
|
758
|
|
|
. '</label>'; |
|
759
|
|
|
} else { |
|
760
|
|
|
$ret .= '<div class="col-xs-12 col-sm-2"> </div>'; |
|
761
|
|
|
} |
|
762
|
|
|
$ret .= '<div class="col-xs-12 col-sm-10">'; |
|
763
|
|
|
$ret .= $element->render(); |
|
|
|
|
|
|
764
|
|
|
if (($desc = $element->getDescription()) != '') { |
|
765
|
|
|
$ret .= '<p class="form-text text-muted">' . $desc . '</p>'; |
|
766
|
|
|
} |
|
767
|
|
|
$ret .= '</div>'; |
|
768
|
|
|
$ret .= '</div>'; |
|
769
|
|
|
} |
|
770
|
|
|
$ret .= $hidden; |
|
771
|
|
|
$ret .= '</form></div>'; |
|
772
|
|
|
$ret .= $form->renderValidationJS(true); |
|
773
|
|
|
|
|
774
|
|
|
return $ret; |
|
775
|
|
|
} |
|
776
|
|
|
|
|
777
|
|
|
/** |
|
778
|
|
|
* Support for themed addBreak |
|
779
|
|
|
* |
|
780
|
|
|
* @param XoopsThemeForm $form |
|
781
|
|
|
* @param string $extra pre-rendered content for break row |
|
782
|
|
|
* @param string $class class for row |
|
783
|
|
|
* |
|
784
|
|
|
* @return void |
|
785
|
|
|
*/ |
|
786
|
|
|
public function addThemeFormBreak(XoopsThemeForm $form, $extra, $class) |
|
787
|
|
|
{ |
|
788
|
|
|
$class = ($class != '') ? preg_replace('/[^A-Za-z0-9\s\s_-]/i', '', $class) : ''; |
|
789
|
|
|
$form->addElement('<div class="col-md-12 ' . $class .'">'. $extra . '</div>'); |
|
790
|
|
|
} |
|
791
|
|
|
} |
|
792
|
|
|
|