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