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