XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
themeform.php
Go to the documentation of this file.
1 <?php
20 defined('XOOPS_ROOT_PATH') or die('Restricted access');
21 
23 
29 class XoopsThemeForm extends XoopsForm
30 {
37  function insertBreak($extra = '', $class = '')
38  {
39  $class = ($class != '') ? " class='" . preg_replace('/[^A-Za-z0-9\s\s_-]/i', '', $class) . "'" : '';
40  // Fix for $extra tag not showing
41  if ($extra) {
42  $extra = '<tr><td colspan="2" ' . $class . '>' . $extra . '</td></tr>';
43  $this->addElement($extra);
44  } else {
45  $extra = '<tr><td colspan="2" ' . $class . '>&nbsp;</td></tr>';
46  $this->addElement($extra);
47  }
48  }
49 
63  function render()
64  {
65  $ele_name = $this->getName();
66  $ret = '<form name="' . $ele_name . '" id="' . $ele_name . '" action="' . $this->getAction() . '" method="' . $this->getMethod() . '" onsubmit="return xoopsFormValidate_' . $ele_name . '();"' . $this->getExtra() . '>
67  <table width="100%" class="outer" cellspacing="1">
68  <tr><th colspan="2">' . $this->getTitle() . '</th></tr>
69  ';
70  $hidden = '';
71  $class = 'even';
72  foreach ($this->getElements() as $ele) {
73  if (!is_object($ele)) {
74  $ret .= $ele;
75  } else if (!$ele->isHidden()) {
76  if (!$ele->getNocolspan()) {
77  $ret .= '<tr valign="top" align="left"><td class="head">';
78  if (($caption = $ele->getCaption()) != '') {
79  $ret .= '<div class="xoops-form-element-caption' . ($ele->isRequired() ? '-required' : '') . '">';
80  $ret .= '<span class="caption-text">' . $caption . '</span>';
81  $ret .= '<span class="caption-marker">*</span>';
82  $ret .= '</div>';
83  }
84  if (($desc = $ele->getDescription()) != '') {
85  $ret .= '<div class="xoops-form-element-help">' . $desc . '</div>';
86  }
87  $ret .= '</td><td class="' . $class . '">' . $ele->render() . '</td></tr>' . NWLINE;
88  } else {
89  $ret .= '<tr valign="top" align="left"><td class="head" colspan="2">';
90  if (($caption = $ele->getCaption()) != '') {
91  $ret .= '<div class="xoops-form-element-caption' . ($ele->isRequired() ? '-required' : '') . '">';
92  $ret .= '<span class="caption-text">' . $caption . '</span>';
93  $ret .= '<span class="caption-marker">*</span>';
94  $ret .= '</div>';
95  }
96  $ret .= '</td></tr><tr valign="top" align="left"><td class="' . $class . '" colspan="2">' . $ele->render() . '</td></tr>';
97  }
98  } else {
99  $hidden .= $ele->render();
100  }
101  }
102  $ret .= '</table>' . NWLINE . ' ' . $hidden . '</form>' . NWLINE;
103  $ret .= $this->renderValidationJS(true);
104  return $ret;
105  }
106 }
107 
108 ?>