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:
7: This program is distributed in the hope that it will be useful,
8: but WITHOUT ANY WARRANTY; without even the implied warranty of
9: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: */
11:
12: namespace Xoops\Form;
13:
14: /**
15: * TableForm - Form that will output formatted as a HTML table
16: *
17: * No styles and no JavaScript to check for required fields.
18: *
19: * @category Xoops\Form\SimpleForm
20: * @package Xoops\Form
21: * @author Xoops Team
22: * @copyright 2001-2015 XOOPS Project (http://xoops.org)
23: * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
24: * @link http://xoops.org
25: */
26: class TableForm extends Form
27: {
28: /**
29: * Insert an empty row in the table to serve as a separator.
30: *
31: * @return void
32: */
33: public function insertBreak()
34: {
35: $value = '<tr valign="top" align="left"><td></td></tr>';
36: $ele = new Raw($value);
37: $this->addElement($ele);
38: }
39:
40: /**
41: * create HTML to output the form as a table
42: *
43: * @return string
44: */
45: public function render()
46: {
47: $ret = $this->getTitle() . "\n" . '<form name="' . $this->getName() . '" id="'
48: . $this->getName() . '" action="' . $this->getAction() . '" method="' . $this->getMethod()
49: . '"' . $this->getExtra() . '>' . "\n" . '<table border="0" width="100%">' . "\n";
50: $hidden = "";
51: foreach ($this->getElements() as $ele) {
52: /* @var $ele Element */
53: if (!$ele->isHidden()) {
54: if (!$ele instanceof Raw) {
55: $ret .= '<tr valign="top" align="left"><td>' . $ele->getCaption();
56: if ($ele_desc = $ele->getDescription()) {
57: $ret .= '<br /><br /><span style="font-weight: normal;">' . $ele_desc . '</span>';
58: }
59: $ret .= '</td><td>' . $ele->render() . '</td></tr>';
60: } else {
61: $ret .= $ele->render();
62: }
63: } else {
64: $hidden .= $ele->render() . "\n";
65: }
66: }
67: $ret .= '</table>' . "\n" . ' ' . $hidden . '</form>' . "\n";
68: return $ret;
69: }
70: }
71: