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: * SimpleForm - Form that outputs as simple HTML, with minimum formatting
16: *
17: * @category Xoops\Form\SimpleForm
18: * @package Xoops\Form
19: * @author Kazumi Ono <onokazu@xoops.org>
20: * @copyright 2001-2015 XOOPS Project (http://xoops.org)
21: * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
22: * @link http://xoops.org
23: */
24: class SimpleForm extends Form
25: {
26: /**
27: * Insert an empty row in the table to serve as a separator.
28: *
29: * @param string $extra not in use.
30: * @param string $class not in use
31: *
32: * @return void
33: */
34: public function insertBreak($extra = '', $class = '')
35: {
36: $class = empty($class) ? '' : ' class="' . $class . '"';
37: $value = '<br' . $class . ' />' . $extra;
38: $ele = new Raw($value);
39: $this->addElement($ele);
40: }
41:
42: /**
43: * create HTML to output the form with minimal formatting
44: *
45: * @return string
46: */
47: public function render()
48: {
49: $ret = $this->getTitle() . "\n<form name=\"" . $this->getName() . "\" id=\""
50: . $this->getName() . "\" action=\"" . $this->getAction() . "\" method=\""
51: . $this->getMethod() . "\"" . $this->getExtra() . ">\n";
52: foreach ($this->getElements() as $ele) {
53: /* @var $ele Element */
54: if (!$ele->isHidden()) {
55: if (!$ele instanceof Raw) {
56: $ret .= "<strong>" . $ele->getCaption() . "</strong><br />" . $ele->render() . "<br />\n";
57: } else {
58: $ret .= $ele->render();
59: }
60: } else {
61: $ret .= $ele->render() . "\n";
62: }
63: }
64: $ret .= "</form>\n";
65: return $ret;
66: }
67: }
68: