1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: namespace Xoops\Form;
13:
14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26: class ThemeForm extends Form
27: {
28: 29: 30: 31: 32: 33: 34: 35:
36: public function insertBreak($extra = '', $class = '')
37: {
38: $class = ($class != '' ? " class=\"" . $class . "\"" : " class=\"break\"");
39:
40: if ($extra) {
41: $value = '<div' . $class . '>' . $extra . '</div>';
42: $ele = new Raw($value);
43: $this->addElement($ele);
44: } else {
45: $value = '<div' . $class . '> </div>';
46: $ele = new Raw($value);
47: $this->addElement($ele);
48: }
49: }
50:
51: 52: 53: 54: 55:
56: public function render()
57: {
58: $xoops = \Xoops::getInstance();
59: $xoops->theme()->addStylesheet('media/xoops/css/form.css');
60: switch ($this->getDisplay()) {
61: case '':
62: case 'horizontal':
63: default:
64: $xoops->tpl()->assign('type', 'horizontal');
65: break;
66:
67: case 'vertical':
68: $xoops->tpl()->assign('type', 'vertical');
69: break;
70:
71: case 'inline':
72: $xoops->tpl()->assign('type', 'inline');
73: break;
74:
75: case 'personalized':
76: $xoops->tpl()->assign('type', 'personalized');
77: break;
78: }
79: $xoops->tpl()->assign('title', $this->getTitle());
80: $xoops->tpl()->assign('name', $this->getName());
81: $xoops->tpl()->assign('action', $this->getAction());
82: $xoops->tpl()->assign('method', $this->getMethod());
83: $xoops->tpl()->assign('extra', $this->getExtra());
84: $hidden = '';
85: foreach ($this->getElements() as $ele) {
86:
87: if (!$ele->isHidden()) {
88: $input['name'] = $ele->getName();
89: $input['caption'] = $ele->getCaption();
90: $input['description'] = $ele->getDescription();
91: $input['ele'] = $ele->render();
92: $input['required'] = $ele->isRequired();
93: $input['pattern_description'] = $ele->getPatternDescription();
94: $input['datalist'] = $ele->renderDatalist();
95: $xoops->tpl()->appendByRef('xo_input', $input);
96: unset($input);
97: } else {
98: $hidden .= $ele->render(). "\n";
99: }
100:
101: }
102: $xoops->tpl()->assign('hidden', $hidden);
103: $xoops->tpl()->assign('validationJS', $this->renderValidationJS(true));
104: $ret = $xoops->tpl()->fetch('module:system/system_form.tpl');
105: $xoops->tpl()->clearAssign('xo_input');
106: return $ret;
107:
108: }
109: }
110: