XOOPS  2.6.0
ThemeForm.php
Go to the documentation of this file.
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 
27 class ThemeForm extends Form
28 {
37  public function insertBreak($extra = '', $class = '')
38  {
39  $class = ($class != '' ? " class=\"" . $class . "\"" : " class=\"break\"");
40  // Fix for $extra tag not showing
41  if ($extra) {
42  $value = '<div' . $class . '>' . $extra . '</div>';
43  $ele = new Raw($value);
44  $this->addElement($ele);
45  } else {
46  $value = '<div' . $class . '>&nbsp;</div>';
47  $ele = new Raw($value);
48  $this->addElement($ele);
49  }
50  }
51 
57  public function render()
58  {
60  $xoops->theme()->addStylesheet('media/xoops/css/form.css');
61  switch ($this->getDisplay()) {
62  case '':
63  case 'horizontal':
64  default:
65  $xoops->tpl()->assign('type', 'horizontal');
66  break;
67 
68  case 'vertical':
69  $xoops->tpl()->assign('type', 'vertical');
70  break;
71 
72  case 'inline':
73  $xoops->tpl()->assign('type', 'inline');
74  break;
75 
76  case 'personalized':
77  $xoops->tpl()->assign('type', 'personalized');
78  break;
79  }
80  $xoops->tpl()->assign('title', $this->getTitle());
81  $xoops->tpl()->assign('name', $this->getName());
82  $xoops->tpl()->assign('action', $this->getAction());
83  $xoops->tpl()->assign('method', $this->getMethod());
84  $xoops->tpl()->assign('extra', $this->getExtra());
85  $hidden = '';
86  foreach ($this->getElements() as $ele) {
87  /* @var $ele Element */
88  if (!$ele->isHidden()) {
89  $input['name'] = $ele->getName();
90  $input['caption'] = $ele->getCaption();
91  $input['description'] = $ele->getDescription();
92  $input['ele'] = $ele->render();
93  $input['required'] = $ele->isRequired();
94  $input['pattern_description'] = $ele->getPatternDescription();
95  $input['datalist'] = $ele->getDatalist();
96  $xoops->tpl()->appendByRef('xo_input', $input);
97  unset($input);
98  } else {
99  $hidden .= $ele->render(). NWLINE;
100  }
101 
102  }
103  $xoops->tpl()->assign('hidden', $hidden);
104  $xoops->tpl()->assign('validationJS', $this->renderValidationJS(true));
105  $ret = $xoops->tpl()->fetch('module:system/system_form.tpl');
106  $xoops->tpl()->clearAssign('xo_input');
107  return $ret;
108 
109  }
110 }
static getInstance()
Definition: Xoops.php:160
addElement(Element $formElement, $required=false)
Definition: Form.php:206
getAction($encode=true)
Definition: Form.php:182
getDisplay($encode=false)
Definition: Form.php:120
$xoops
Definition: admin.php:25
getName($encode=true)
Definition: Form.php:158
getTitle($encode=false)
Definition: Form.php:132
insertBreak($extra= '', $class= '')
Definition: ThemeForm.php:37
getElements($recurse=false)
Definition: Form.php:232
renderValidationJS($withtags=true)
Definition: Form.php:471