1: <?php
2: /**
3: * XOOPS table form
4: *
5: * You may not change or alter any portion of this comment or credits
6: * of supporting developers from this source code or any supporting source code
7: * which is considered copyrighted (c) material of the original comment or credit authors.
8: * This program is distributed in the hope that it will be useful,
9: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11: *
12: * @copyright (c) 2000-2016 XOOPS Project (www.xoops.org)
13: * @license GNU GPL 2 (http://www.gnu.org/licenses/gpl-2.0.html)
14: * @package kernel
15: * @subpackage form
16: * @since 2.0.0
17: */
18:
19: defined('XOOPS_ROOT_PATH') || exit('Restricted access');
20:
21: xoops_load('XoopsForm');
22:
23: /**
24: * Form that will output formatted as a HTML table
25: *
26: * No styles and no JavaScript to check for required fields.
27: */
28: class XoopsTableForm extends XoopsForm
29: {
30: /**
31: * create HTML to output the form as a table
32: *
33: * YOU SHOULD AVOID TO USE THE FOLLOWING Nocolspan METHOD, IT WILL BE REMOVED
34: *
35: * To use the noColspan simply use the following example:
36: *
37: * $colspan = new XoopsFormDhtmlTextArea( '', 'key', $value, '100%', '100%' );
38: * $colspan->setNocolspan();
39: * $form->addElement( $colspan );
40: *
41: * @return string
42: */
43: public function render()
44: {
45: $ret = $this->getTitle() . NWLINE . '<form name="' . $this->getName() . '" id="' . $this->getName() . '" action="' . $this->getAction() . '" method="' . $this->getMethod() . '"' . $this->getExtra() . '>' . NWLINE . '<table border="0" width="100%">' . NWLINE;
46: $hidden = '';
47: foreach ($this->getElements() as $ele) {
48: if (!$ele->isHidden()) {
49: if (!$ele->getNocolspan()) {
50: $ret .= '<tr valign="top" align="left"><td>' . $ele->getCaption();
51: if ($ele_desc = $ele->getDescription()) {
52: $ret .= '<br><br><span style="font-weight: normal;">' . $ele_desc . '</span>';
53: }
54: $ret .= '</td><td>' . $ele->render() . '</td></tr>';
55: } else {
56: $ret .= '<tr valign="top" align="left"><td colspan="2">' . $ele->getCaption();
57: $ret .= '</td></tr><tr valign="top" align="left"><td>' . $ele->render() . '</td></tr>';
58: }
59: } else {
60: $hidden .= $ele->render() . NWLINE;
61: }
62: }
63: $ret .= '</table>' . NWLINE . ' ' . $hidden . '</form>' . NWLINE;
64:
65: return $ret;
66: }
67: }
68: