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