public static function getFrontComponentBody($formId, $componentId, $data, $value = array(), $invalid = false, $layoutName)
 {
     $mainframe = JFactory::getApplication();
     $doc = JFactory::getDocument();
     $formId = (int) $formId;
     $componentId = (int) $componentId;
     $db = JFactory::getDBO();
     // For legacy reasons...
     $r = array();
     $r['ComponentTypeId'] = $data['componentTypeId'];
     $r['Order'] = @$data['Order'];
     $out = '';
     // calculation handling
     $pricePattern = '#\\[p(.*?)\\]#is';
     $prices = array();
     //Trigger Event - rsfp_bk_onBeforeCreateFrontComponentBody
     $mainframe->triggerEvent('rsfp_bk_onBeforeCreateFrontComponentBody', array(array('out' => &$out, 'formId' => $formId, 'componentId' => $componentId, 'data' => &$data, 'value' => &$value)));
     switch ($data['ComponentTypeName']) {
         case 1:
         case 'textBox':
             if (isset($data['VALIDATIONRULE']) && $data['VALIDATIONRULE'] == 'password') {
                 $defaultValue = '';
             } else {
                 $defaultValue = RSFormProHelper::isCode($data['DEFAULTVALUE']);
             }
             $className = 'rsform-input-box';
             if ($invalid) {
                 $className .= ' rsform-error';
             }
             RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
             $out .= '<input type="text" value="' . (isset($value[$data['NAME']]) ? RSFormProHelper::htmlEscape($value[$data['NAME']]) : RSFormProHelper::htmlEscape($defaultValue)) . '" size="' . $data['SIZE'] . '" ' . ((int) $data['MAXSIZE'] > 0 ? 'maxlength="' . (int) $data['MAXSIZE'] . '"' : '') . ' name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES'] . '/>';
             break;
         case 2:
         case 'textArea':
             $defaultValue = RSFormProHelper::isCode($data['DEFAULTVALUE']);
             $className = 'rsform-text-box';
             if ($invalid) {
                 $className .= ' rsform-error';
             }
             RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
             if (isset($data['WYSIWYG']) && $data['WYSIWYG'] == 'YES') {
                 $out .= RSFormProHelper::WYSIWYG('form[' . $data['NAME'] . ']', isset($value[$data['NAME']]) ? RSFormProHelper::htmlEscape($value[$data['NAME']]) : RSFormProHelper::htmlEscape($defaultValue), 'id[' . $data['NAME'] . ']', $data['COLS'] * 10, $data['ROWS'] * 10, $data['COLS'], $data['ROWS']);
             } else {
                 $out .= '<textarea cols="' . (int) $data['COLS'] . '" rows="' . (int) $data['ROWS'] . '" name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES'] . '>' . (isset($value[$data['NAME']]) ? RSFormProHelper::htmlEscape($value[$data['NAME']]) : RSFormProHelper::htmlEscape($defaultValue)) . '</textarea>';
             }
             break;
         case 3:
         case 'selectList':
             $className = 'rsform-select-box';
             if ($invalid) {
                 $className .= ' rsform-error';
             }
             RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
             $out .= '<select ' . ($data['MULTIPLE'] == 'YES' ? 'multiple="multiple"' : '') . ' name="form[' . $data['NAME'] . '][]" ' . ((int) $data['SIZE'] > 0 ? 'size="' . (int) $data['SIZE'] . '"' : '') . ' id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES'] . ' >';
             $items = RSFormProHelper::explode(RSFormProHelper::isCode($data['ITEMS']));
             $special = array('[c]', '[g]', '[d]');
             foreach ($items as $item) {
                 $hasPrice = false;
                 if (preg_match($pricePattern, $item, $match)) {
                     $hasPrice = true;
                     $price = $match[1];
                 }
                 $item = preg_replace($pricePattern, '', $item);
                 @(list($val, $txt) = @explode('|', str_replace($special, '', $item), 2));
                 if (is_null($txt)) {
                     $txt = $val;
                 }
                 // <optgroup>
                 if (strpos($item, '[g]') !== false) {
                     $out .= '<optgroup label="' . RSFormProHelper::htmlEscape($val) . '">';
                     continue;
                 }
                 // </optgroup>
                 if (strpos($item, '[/g]') !== false) {
                     $out .= '</optgroup>';
                     continue;
                 }
                 $additional = '';
                 // selected
                 if (strpos($item, '[c]') !== false && empty($value) || isset($value[$data['NAME']]) && in_array($val, $value[$data['NAME']])) {
                     $additional .= 'selected="selected"';
                 }
                 // disabled
                 if (strpos($item, '[d]') !== false) {
                     $additional .= 'disabled="disabled"';
                 }
                 if ($hasPrice) {
                     $prices[$val] = $price;
                 }
                 $out .= '<option ' . $additional . ' value="' . RSFormProHelper::htmlEscape($val) . '">' . RSFormProHelper::htmlEscape($txt) . '</option>';
             }
             $out .= '</select>';
             $option = JRequest::getCmd('option');
             $view = JRequest::getCmd('view');
             $layout = JRequest::getCmd('layout');
             if ($option == 'com_rsevents' && $view == 'events' && $layout == 'subscribe' && $data['NAME'] == 'RSEventsTickets') {
                 $db->setQuery("SELECT ConfigValue FROM #__rsevents_config WHERE ConfigName = 'event.multiple.tickets' ");
                 $multipleTickets = $db->loadResult();
                 if ($multipleTickets) {
                     $lang = JFactory::getLanguage();
                     $lang->load('com_rsevents', JPATH_SITE);
                     $out .= ' <a onclick="add_ticket(1,\'' . JText::_('RSE_REMOVE_TICKET', true) . '\');" href="javascript:void(0)">' . JText::_('RSE_ADD_TICKET') . '</a> ';
                     $out .= '<br /><span id="tickets"></span>';
                     $out .= '<span id="rse_tickets_ids"></span>' . "\n";
                     $out .= '<span id="rse_tickets_no"></span>' . "\n";
                 }
             }
             break;
         case 4:
         case 'checkboxGroup':
             $i = 0;
             $items = RSFormProHelper::explode(RSFormProHelper::isCode($data['ITEMS']));
             $special = array('[c]', '[d]');
             foreach ($items as $item) {
                 $hasPrice = false;
                 if (preg_match($pricePattern, $item, $match)) {
                     $hasPrice = true;
                     $price = $match[1];
                 }
                 $item = preg_replace($pricePattern, '', $item);
                 @(list($val, $txt) = @explode('|', str_replace($special, '', $item), 2));
                 if (is_null($txt)) {
                     $txt = $val;
                 }
                 $additional = '';
                 // checked
                 if (strpos($item, '[c]') !== false && empty($value) || isset($value[$data['NAME']]) && in_array($val, $value[$data['NAME']])) {
                     $additional .= 'checked="checked"';
                 }
                 // disabled
                 if (strpos($item, '[d]') !== false) {
                     $additional .= 'disabled="disabled"';
                 }
                 if ($data['FLOW'] == 'VERTICAL' && $layoutName == 'responsive') {
                     $out .= '<p class="rsformVerticalClear">';
                 }
                 $out .= '<label class="checkbox' . ($data['FLOW'] == 'VERTICAL' ? '"' : ' inline"') . ' for="' . $data['NAME'] . $i . '"><input ' . $additional . ' name="form[' . $data['NAME'] . '][]" type="checkbox" value="' . RSFormProHelper::htmlEscape($val) . '" id="' . $data['NAME'] . $i . '" ' . $data['ADDITIONALATTRIBUTES'] . ' />' . $txt . '</label>';
                 if ($hasPrice) {
                     $prices[$val] = $price;
                 }
                 if ($data['FLOW'] == 'VERTICAL') {
                     if ($layoutName == 'responsive') {
                         $out .= '</p>';
                     }
                     //else
                     //$out .= '<br />';
                 }
                 $i++;
             }
             break;
         case 5:
         case 'radioGroup':
             $i = 0;
             $items = RSFormProHelper::explode(RSFormProHelper::isCode($data['ITEMS']));
             $special = array('[c]', '[d]');
             foreach ($items as $item) {
                 $hasPrice = false;
                 if (preg_match($pricePattern, $item, $match)) {
                     $hasPrice = true;
                     $price = $match[1];
                 }
                 $item = preg_replace($pricePattern, '', $item);
                 @(list($val, $txt) = @explode('|', str_replace($special, '', $item), 2));
                 if (is_null($txt)) {
                     $txt = $val;
                 }
                 $additional = '';
                 // checked
                 if (strpos($item, '[c]') !== false && empty($value) || isset($value[$data['NAME']]) && $val == $value[$data['NAME']]) {
                     $additional .= 'checked="checked"';
                 }
                 // disabled
                 if (strpos($item, '[d]') !== false) {
                     $additional .= 'disabled="disabled"';
                 }
                 if ($data['FLOW'] == 'VERTICAL' && $layoutName == 'responsive') {
                     $out .= '<p class="rsformVerticalClear">';
                 }
                 $out .= '<label class="radio' . ($data['FLOW'] == 'VERTICAL' ? '"' : ' inline"') . ' for="' . $data['NAME'] . $i . '"><input ' . $additional . ' name="form[' . $data['NAME'] . ']" type="radio" value="' . RSFormProHelper::htmlEscape($val) . '" id="' . $data['NAME'] . $i . '" ' . $data['ADDITIONALATTRIBUTES'] . ' />' . $txt . '</label>';
                 if ($hasPrice) {
                     $prices[$val] = $price;
                 }
                 if ($data['FLOW'] == 'VERTICAL') {
                     if ($layoutName == 'responsive') {
                         $out .= '</p>';
                     }
                     //else
                     //$out .= '<br />';
                 }
                 $i++;
             }
             break;
         case 6:
         case 'calendar':
             $calendars = RSFormProHelper::componentExists($formId, 6);
             $calendars = array_flip($calendars);
             $defaultValue = isset($value[$data['NAME']]) ? $value[$data['NAME']] : (isset($data['DEFAULTVALUE']) ? RSFormProHelper::isCode($data['DEFAULTVALUE']) : '');
             switch ($data['CALENDARLAYOUT']) {
                 case 'FLAT':
                     $className = 'rsform-calendar-box';
                     if ($invalid) {
                         $className .= ' rsform-error';
                     }
                     $out .= '<input id="txtcal' . $formId . '_' . $calendars[$componentId] . '" name="form[' . $data['NAME'] . ']" type="text" ' . ($data['READONLY'] == 'YES' ? 'readonly="readonly"' : '') . ' class="txtCal ' . $className . '" value="' . RSFormProHelper::htmlEscape($defaultValue) . '" ' . $data['ADDITIONALATTRIBUTES'] . '/><br />';
                     $out .= '<div id="cal' . $formId . '_' . $calendars[$componentId] . 'Container" style="z-index:' . (9999 - $data['Order']) . '"></div>';
                     break;
                 case 'POPUP':
                     $data['ADDITIONALATTRIBUTES2'] = $data['ADDITIONALATTRIBUTES'];
                     $className = 'rsform-calendar-box';
                     if ($invalid) {
                         $className .= ' rsform-error';
                     }
                     RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
                     $out .= '<div class="input-append">';
                     $out .= '<input id="txtcal' . $formId . '_' . $calendars[$componentId] . '" name="form[' . $data['NAME'] . ']" type="text" ' . ($data['READONLY'] == 'YES' ? 'readonly="readonly"' : '') . '  value="' . RSFormProHelper::htmlEscape($defaultValue) . '" ' . $data['ADDITIONALATTRIBUTES'] . '/>';
                     $className = 'btn rsform-calendar-button';
                     if ($invalid) {
                         $className .= ' rsform-error';
                     }
                     $out .= '<button id="btn' . $formId . '_' . $calendars[$componentId] . '" type="button" onclick="showHideCalendar(\'cal' . $formId . '_' . $calendars[$componentId] . 'Container\');" class="btnCal ' . $className . '" ' . $data['ADDITIONALATTRIBUTES2'] . '>' . RSFormProHelper::htmlEscape($data['POPUPLABEL']) . '</button>';
                     $out .= '</div>';
                     $out .= '<div id="cal' . $formId . '_' . $calendars[$componentId] . 'Container" style="clear:both;display:none;position:absolute;z-index:' . (9999 - $data['Order']) . '"></div>';
                     break;
             }
             $out .= '<input id="hiddencal' . $formId . '_' . $calendars[$componentId] . '" type="hidden" name="hidden[' . $data['NAME'] . ']" />';
             break;
         case 7:
         case 'button':
             $button_type = isset($data['BUTTONTYPE']) && $data['BUTTONTYPE'] == 'TYPEBUTTON' ? 'button' : 'input';
             $data['ADDITIONALATTRIBUTES2'] = $data['ADDITIONALATTRIBUTES'];
             $className = 'rsform-button';
             if ($invalid) {
                 $className .= ' rsform-error';
             }
             RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
             if ($button_type == 'button') {
                 $out .= '<button type="button" name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES'] . '>' . RSFormProHelper::htmlEscape($data['LABEL']) . '</button>';
             } else {
                 $out .= '<input type="button" value="' . RSFormProHelper::htmlEscape($data['LABEL']) . '" name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES'] . ' />';
             }
             if ($data['RESET'] == 'YES') {
                 $className = 'rsform-reset-button';
                 RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES2'], $className);
                 if ($button_type == 'button') {
                     $out .= '&nbsp;&nbsp;<button type="reset" name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES2'] . '>' . RSFormProHelper::htmlEscape($data['RESETLABEL']) . '</button>';
                 } else {
                     $out .= '&nbsp;&nbsp;<input type="reset" value="' . RSFormProHelper::htmlEscape($data['RESETLABEL']) . '" name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES2'] . ' />';
                 }
             }
             break;
         case 8:
         case 'captcha':
             switch (@$data['IMAGETYPE']) {
                 default:
                 case 'FREETYPE':
                 case 'NOFREETYPE':
                     $className = 'rsform-captcha-box';
                     if ($invalid) {
                         $className .= ' rsform-error';
                     }
                     RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
                     $out .= '<img src="' . JRoute::_('index.php?option=com_rsform&amp;task=captcha&amp;componentId=' . $componentId . '&amp;tmpl=component&amp;sid=' . mt_rand()) . '" id="captcha' . $componentId . '" alt="' . RSFormProHelper::htmlEscape($data['CAPTION']) . ' "/>';
                     //if ($data['FLOW'] == 'VERTICAL')
                     //$out .= '<br />';
                     $out .= '<input type="text" name="form[' . $data['NAME'] . ']" value="" id="captchaTxt' . $componentId . '" ' . $data['ADDITIONALATTRIBUTES'] . ' />';
                     if ($data['SHOWREFRESH'] == 'YES') {
                         $out .= '&nbsp;&nbsp;<a href="javascript:void(0)" onclick="refreshCaptcha(' . $componentId . ',\'' . JRoute::_('index.php?option=com_rsform&task=captcha&componentId=' . $componentId . '&tmpl=component') . '\'); return false;">' . $data['REFRESHTEXT'] . '</a>';
                     }
                     break;
                 case 'INVISIBLE':
                     // a list of words that spam bots might auto-complete
                     $words = RSFormProHelper::getInvisibleCaptchaWords();
                     $word = $words[array_rand($words, 1)];
                     // a list of styles so that the field is hidden
                     $styles = array('display: none !important', 'position: absolute !important; left: -4000px !important; top: -4000px !important;', 'position: absolute !important; left: -4000px !important; top: -4000px !important; display: none !important', 'position: absolute !important; display: none !important', 'display: none !important; position: absolute !important; left: -4000px !important; top: -4000px !important;');
                     $style = $styles[array_rand($styles, 1)];
                     // now we're going to shuffle the properties of the html tag
                     $properties = array('type="text"', 'name="' . $word . '"', 'value=""', 'style="' . $style . '"');
                     shuffle($properties);
                     $session = JFactory::getSession();
                     $session->set('com_rsform.captcha.' . $componentId, $word);
                     $out .= '<input ' . implode(' ', $properties) . ' />';
                     break;
             }
             break;
         case 9:
         case 'fileUpload':
             $className = 'rsform-upload-box';
             if ($invalid) {
                 $className .= ' rsform-error';
             }
             RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
             $out .= '<input type="hidden" name="MAX_FILE_SIZE" value="' . (int) $data['FILESIZE'] . '000" />';
             $out .= '<input type="file" name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES'] . ' />';
             break;
         case 10:
         case 'freeText':
             $out .= $data['TEXT'];
             break;
         case 11:
         case 'hidden':
             $defaultValue = RSFormProHelper::isCode($data['DEFAULTVALUE']);
             $out .= '<input type="hidden" name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" value="' . RSFormProHelper::htmlEscape($defaultValue) . '" ' . $data['ADDITIONALATTRIBUTES'] . ' />';
             break;
         case 12:
         case 'imageButton':
             $data['ADDITIONALATTRIBUTES2'] = $data['ADDITIONALATTRIBUTES'];
             $className = 'btn rsform-image-button';
             RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
             $data['ADDITIONALATTRIBUTES3'] = $data['ADDITIONALATTRIBUTES'];
             $pages = RSFormProHelper::componentExists($formId, 41);
             $pages = count($pages);
             if (!empty($pages)) {
                 if (empty($data['PREVBUTTON'])) {
                     $data['PREVBUTTON'] = JText::_('PREV');
                 }
                 $onclick = 'rsfp_changePage(' . $formId . ', ' . ($pages - 1) . ', ' . $pages . ')';
                 RSFormProHelper::addOnClick($data['ADDITIONALATTRIBUTES3'], $onclick);
                 $out .= '<input type="button" value="' . RSFormProHelper::htmlEscape($data['PREVBUTTON']) . '"  id="' . $data['NAME'] . 'Prev" ' . $data['ADDITIONALATTRIBUTES3'] . ' />';
             }
             $out .= '<input type="image" src="' . RSFormProHelper::htmlEscape($data['IMAGEBUTTON']) . '" name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES2'] . ' />';
             if ($data['RESET'] == 'YES') {
                 $className = 'btn rsform-reset-button';
                 RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES2'], $className);
                 $out .= '<input type="reset" name="" id="reset_' . $data['NAME'] . '" style="display: none !important" />&nbsp;&nbsp;<input onclick="document.getElementById(\'reset_' . $data['NAME'] . '\').click();return false;" type="image" src="' . RSFormProHelper::htmlEscape($data['IMAGERESET']) . '" name="form[' . $data['NAME'] . ']" ' . $data['ADDITIONALATTRIBUTES2'] . ' />';
             }
             break;
         case 13:
         case 'submitButton':
             $button_type = isset($data['BUTTONTYPE']) && $data['BUTTONTYPE'] == 'TYPEBUTTON' ? 'button' : 'input';
             $data['ADDITIONALATTRIBUTES2'] = $data['ADDITIONALATTRIBUTES'];
             $className = 'btn rsform-submit-button';
             RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
             $data['ADDITIONALATTRIBUTES3'] = $data['ADDITIONALATTRIBUTES'];
             $last_submit = $componentId == end($data['SUBMITS']);
             $pages = RSFormProHelper::componentExists($formId, 41);
             $pages = count($pages);
             if (!empty($pages) && $last_submit) {
                 if (empty($data['PREVBUTTON'])) {
                     $data['PREVBUTTON'] = JText::_('PREV');
                 }
                 $onclick = 'rsfp_changePage(' . $formId . ', ' . ($pages - 1) . ', ' . $pages . ')';
                 RSFormProHelper::addOnClick($data['ADDITIONALATTRIBUTES3'], $onclick);
                 if ($button_type == 'button') {
                     $out .= '<button type="button" id="' . $data['NAME'] . 'Prev" ' . $data['ADDITIONALATTRIBUTES3'] . '>' . RSFormProHelper::htmlEscape($data['PREVBUTTON']) . '</button>';
                 } else {
                     $out .= '<input type="button" value="' . RSFormProHelper::htmlEscape($data['PREVBUTTON']) . '"  id="' . $data['NAME'] . 'Prev" ' . $data['ADDITIONALATTRIBUTES3'] . ' />';
                 }
             }
             if ($button_type == 'button') {
                 $out .= '<button type="submit" name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES'] . '>' . RSFormProHelper::htmlEscape($data['LABEL']) . '</button>';
             } else {
                 $out .= '<input type="submit" value="' . RSFormProHelper::htmlEscape($data['LABEL']) . '" name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES'] . ' />';
             }
             if ($data['RESET'] == 'YES') {
                 $className = 'btn rsform-reset-button';
                 RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES2'], $className);
                 if ($button_type == 'button') {
                     $out .= '&nbsp;&nbsp;<button type="reset" name="form[' . $data['NAME'] . ']" ' . $data['ADDITIONALATTRIBUTES2'] . '>' . RSFormProHelper::htmlEscape($data['RESETLABEL']) . '</button>';
                 } else {
                     $out .= '&nbsp;&nbsp;<input type="reset" value="' . RSFormProHelper::htmlEscape($data['RESETLABEL']) . '" name="form[' . $data['NAME'] . ']" ' . $data['ADDITIONALATTRIBUTES2'] . ' />';
                 }
             }
             break;
         case 14:
         case 'password':
             $defaultValue = '';
             if (isset($data['VALIDATIONRULE']) && $data['VALIDATIONRULE'] != 'password') {
                 $defaultValue = $data['DEFAULTVALUE'];
             }
             $className = 'rsform-password-box';
             if ($invalid) {
                 $className .= ' rsform-error';
             }
             RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
             $out .= '<input type="password" value="' . RSFormProHelper::htmlEscape($defaultValue) . '" size="' . (int) $data['SIZE'] . '" name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" ' . ((int) $data['MAXSIZE'] > 0 ? 'maxlength="' . (int) $data['MAXSIZE'] . '"' : '') . ' ' . $data['ADDITIONALATTRIBUTES'] . ' />';
             break;
         case 15:
         case 'ticket':
             $out .= '<input type="hidden" name="form[' . $data['NAME'] . ']" value="' . RSFormProHelper::generateString($data['LENGTH'], $data['CHARACTERS']) . '" ' . $data['ADDITIONALATTRIBUTES'] . ' />';
             break;
         case 41:
         case 'pageBreak':
             $validate = 'false';
             if (isset($data['VALIDATENEXTPAGE']) && $data['VALIDATENEXTPAGE'] == 'YES') {
                 $validate = 'true';
             }
             $className = 'btn rsform-button';
             if ($invalid) {
                 $className .= ' rsform-error';
             }
             RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
             $data['ADDITIONALATTRIBUTES2'] = $data['ADDITIONALATTRIBUTES'];
             $num = count($data['PAGES']);
             $pos = array_search($componentId, $data['PAGES']);
             if ($pos) {
                 $onclick = 'rsfp_changePage(' . $formId . ', ' . ($pos - 1) . ', ' . $num . ')';
                 RSFormProHelper::addOnClick($data['ADDITIONALATTRIBUTES'], $onclick);
                 $out .= '<input type="button" value="' . RSFormProHelper::htmlEscape($data['PREVBUTTON']) . '" ' . $data['ADDITIONALATTRIBUTES'] . ' id="' . $data['NAME'] . 'Prev" />';
             }
             if ($pos < count($data['PAGES'])) {
                 $onclick = 'rsfp_changePage(' . $formId . ', ' . ($pos + 1) . ', ' . $num . ', ' . $validate . ')';
                 RSFormProHelper::addOnClick($data['ADDITIONALATTRIBUTES2'], $onclick);
                 $out .= '<input type="button" value="' . RSFormProHelper::htmlEscape($data['NEXTBUTTON']) . '" ' . $data['ADDITIONALATTRIBUTES2'] . ' id="' . $data['NAME'] . 'Next" />';
             }
             break;
         case 32:
         case 'rseprotickets':
             $html = '';
             if (JRequest::getCmd('option') == 'com_rseventspro') {
                 $cid = JRequest::getInt('cid');
                 $db->setQuery("SELECT COUNT(id) FROM #__rseventspro_tickets WHERE ide = " . $cid . "");
                 $eventtickets = $db->loadResult();
                 $html .= '<input type="text" id="numberinp" name="numberinp" value="1" size="3" style="display: none;" onkeyup="this.value=this.value.replace(/[^0-9\\.\\,]/g, \'\');" />';
                 $html .= '<select name="number" id="number"><option value="1">1</option></select> ';
                 $className = 'rsform-select-box';
                 if ($invalid) {
                     $className .= ' rsform-error';
                 }
                 RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
                 $html .= '<select name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES'] . ' >';
                 $items = RSFormProHelper::explode(RSFormProHelper::isCode($data['ITEMS']));
                 $special = array('[c]', '[g]', '[d]');
                 foreach ($items as $item) {
                     @(list($val, $txt) = @explode('|', str_replace($special, '', $item), 2));
                     if (is_null($txt)) {
                         $txt = $val;
                     }
                     // <optgroup>
                     if (strpos($item, '[g]') !== false) {
                         $out .= '<optgroup label="' . RSFormProHelper::htmlEscape($val) . '">';
                         continue;
                     }
                     // </optgroup>
                     if (strpos($item, '[/g]') !== false) {
                         $out .= '</optgroup>';
                         continue;
                     }
                     $additional = '';
                     // selected
                     if (strpos($item, '[c]') !== false && empty($value) || isset($value[$data['NAME']]) && $val == $value[$data['NAME']]) {
                         $additional .= 'selected="selected"';
                     }
                     // disabled
                     if (strpos($item, '[d]') !== false) {
                         $additional .= 'disabled="disabled"';
                     }
                     $html .= '<option ' . $additional . ' value="' . RSFormProHelper::htmlEscape($val) . '">' . RSFormProHelper::htmlEscape($txt) . '</option>';
                 }
                 $html .= '</select>';
                 if (JRequest::getCmd('option') == 'com_rseventspro' && JRequest::getCmd('layout') == 'subscribe') {
                     $db->setQuery("SELECT `value` FROM `#__rseventspro_config` WHERE `name` = 'multi_tickets'");
                     $multipleTickets = $db->loadResult();
                     if ($multipleTickets) {
                         $lang = JFactory::getLanguage();
                         $lang->load('com_rseventspro', JPATH_SITE);
                         $html .= ' <a href="javascript:void(0);" onclick="rs_add_ticket();">' . JText::_('RSEPRO_SUBSCRIBER_ADD_TICKET') . '</a> ';
                     }
                 }
                 $html .= ' <img id="rs_loader" src="' . JURI::root() . 'components/com_rseventspro/assets/images/loader.gif" alt="" style="vertical-align: middle; display: none;" />';
                 if (JRequest::getCmd('option') == 'com_rseventspro' && JRequest::getCmd('layout') == 'subscribe' && $multipleTickets) {
                     $html .= '<br /> <br /> <span id="tickets"></span>';
                     $html .= '<span id="hiddentickets"></span>';
                 }
                 $html .= ' <br /> <span id="tdescription"></span>';
                 $html .= '<input type="hidden" name="from" id="from" value="" />';
                 if (!empty($eventtickets)) {
                     $out .= $html;
                 }
             }
             break;
         case 211:
         case 'birthDay':
             $day = strpos($data['DATEORDERING'], 'D');
             $month = strpos($data['DATEORDERING'], 'M');
             $year = strpos($data['DATEORDERING'], 'Y');
             $items = array();
             $hasAllFields = $data['SHOWDAY'] == 'YES' && $data['SHOWMONTH'] == 'YES' && $data['SHOWYEAR'] == 'YES';
             if ($data['SHOWDAY'] == 'YES') {
                 $isInvalid = $invalid && empty($value[$data['NAME']]['d']);
                 $attr = $data['ADDITIONALATTRIBUTES'];
                 $className = 'rsform-select-box rsform-select-box-small';
                 if ($isInvalid) {
                     $className .= ' rsform-error';
                 }
                 RSFormProHelper::addClass($attr, $className);
                 $item = '<select name="form[' . $data['NAME'] . '][d]" id="' . $data['NAME'] . 'd" ' . $attr . ' >';
                 if (strlen($data['SHOWDAYPLEASE']) > 0) {
                     $item .= '<option value="">' . self::htmlEscape($data['SHOWDAYPLEASE']) . '</option>';
                 }
                 for ($i = 1; $i <= 31; $i++) {
                     switch ($data['SHOWDAYTYPE']) {
                         default:
                         case 'DAY_TYPE_1':
                             $val = $i;
                             break;
                         case 'DAY_TYPE_01':
                             $val = str_pad($i, 2, '0', STR_PAD_LEFT);
                             break;
                     }
                     // selected
                     $additional = '';
                     if (isset($value[$data['NAME']]['d']) && $value[$data['NAME']]['d'] == $i) {
                         $additional .= 'selected="selected"';
                     }
                     $item .= '<option value="' . $i . '" ' . $additional . '>' . $val . '</option>';
                 }
                 $item .= '</select>';
                 $items[$day] = $item;
             }
             if ($data['SHOWMONTH'] == 'YES') {
                 $isInvalid = $invalid && empty($value[$data['NAME']]['m']);
                 $attr = $data['ADDITIONALATTRIBUTES'];
                 $className = 'rsform-select-box rsform-select-box-small';
                 if ($isInvalid) {
                     $className .= ' rsform-error';
                 }
                 RSFormProHelper::addClass($attr, $className);
                 if ($hasAllFields && $data['VALIDATION_ALLOW_INCORRECT_DATE'] == 'NO') {
                     $attr .= ' onchange="rsfp_checkValidDate(\'' . $data['NAME'] . '\');"';
                 }
                 $item = '<select name="form[' . $data['NAME'] . '][m]" id="' . $data['NAME'] . 'm" ' . $attr . ' >';
                 if (strlen($data['SHOWMONTHPLEASE']) > 0) {
                     $item .= '<option value="">' . self::htmlEscape($data['SHOWMONTHPLEASE']) . '</option>';
                 }
                 for ($i = 1; $i <= 12; $i++) {
                     switch ($data['SHOWMONTHTYPE']) {
                         default:
                         case 'MONTH_TYPE_1':
                             $val = $i;
                             break;
                         case 'MONTH_TYPE_01':
                             $val = str_pad($i, 2, '0', STR_PAD_LEFT);
                             break;
                         case 'MONTH_TYPE_TEXT_SHORT':
                             $val = JText::_('RSFP_CALENDAR_MONTHS_SHORT_' . $i);
                             break;
                         case 'MONTH_TYPE_TEXT_LONG':
                             $val = JText::_('RSFP_CALENDAR_MONTHS_LONG_' . $i);
                             break;
                     }
                     // selected
                     $additional = '';
                     if (isset($value[$data['NAME']]['m']) && $value[$data['NAME']]['m'] == $i) {
                         $additional .= 'selected="selected"';
                     }
                     $item .= '<option value="' . $i . '" ' . $additional . '>' . $val . '</option>';
                 }
                 $item .= '</select>';
                 $items[$month] = $item;
             }
             if ($data['SHOWYEAR'] == 'YES') {
                 $isInvalid = $invalid && empty($value[$data['NAME']]['y']);
                 $attr = $data['ADDITIONALATTRIBUTES'];
                 $className = 'rsform-select-box rsform-select-box-small';
                 if ($isInvalid) {
                     $className .= ' rsform-error';
                 }
                 RSFormProHelper::addClass($attr, $className);
                 if ($hasAllFields && $data['VALIDATION_ALLOW_INCORRECT_DATE'] == 'NO') {
                     $attr .= ' onchange="rsfp_checkValidDate(\'' . $data['NAME'] . '\');"';
                 }
                 $item = '<select name="form[' . $data['NAME'] . '][y]" id="' . $data['NAME'] . 'y" ' . $attr . ' >';
                 if (strlen($data['SHOWYEARPLEASE']) > 0) {
                     $item .= '<option value="">' . self::htmlEscape($data['SHOWYEARPLEASE']) . '</option>';
                 }
                 $start = (int) $data['STARTYEAR'];
                 $end = (int) $data['ENDYEAR'];
                 if ($start < $end) {
                     for ($i = $start; $i <= $end; $i++) {
                         // selected
                         $additional = '';
                         if (isset($value[$data['NAME']]['y']) && $value[$data['NAME']]['y'] == $i) {
                             $additional .= 'selected="selected"';
                         }
                         $item .= '<option value="' . $i . '" ' . $additional . '>' . $i . '</option>';
                     }
                 } else {
                     for ($i = $start; $i >= $end; $i--) {
                         // selected
                         $additional = '';
                         if (isset($value[$data['NAME']]['y']) && $value[$data['NAME']]['y'] == $i) {
                             $additional .= 'selected="selected"';
                         }
                         $item .= '<option value="' . $i . '" ' . $additional . '>' . $i . '</option>';
                     }
                 }
                 $item .= '</select>';
                 $items[$year] = $item;
             }
             ksort($items);
             $out .= implode($data['DATESEPARATOR'], $items);
             break;
         case 212:
         case 'gmaps':
             $doc->addScript('https://maps.google.com/maps/api/js?sensor=false');
             $mapWidth = !empty($data['MAPWIDTH']) ? $data['MAPWIDTH'] : '450px';
             $mapHeight = !empty($data['MAPHEIGHT']) ? $data['MAPHEIGHT'] : '300px';
             $geolocation = isset($data['GEOLOCATION']) && $data['GEOLOCATION'] == 'YES';
             if (isset($data['VALIDATIONRULE'])) {
                 $defaultValue = '';
             } else {
                 $defaultValue = RSFormProHelper::isCode($data['DEFAULTVALUE']);
             }
             $className = 'rsform-input-box';
             if ($invalid) {
                 $className .= ' rsform-error';
             }
             RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
             $out .= '<div id="rsform-map' . $componentId . '" style="width: ' . $mapWidth . '; height: ' . $mapHeight . ';" class="rsformMaps"></div>';
             $out .= '<br />';
             if ($geolocation) {
                 $out .= '<span style="position:relative">';
             }
             $out .= '<input autocomplete="off" type="text" value="' . (isset($value[$data['NAME']]) ? RSFormProHelper::htmlEscape($value[$data['NAME']]) : RSFormProHelper::htmlEscape($defaultValue)) . '" size="' . $data['SIZE'] . '" name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES'] . '/>';
             if ($geolocation) {
                 $out .= '<ul class="rsform-map-geolocation" id="rsform_geolocation' . $componentId . '" style="display:none;"></ul>';
                 $out .= '</span>';
             }
             break;
     }
     if ($prices && RSFormProHelper::hasCalculations($formId)) {
         $jsPrices = array();
         foreach ($prices as $value => $price) {
             $jsPrices[] = "'" . addslashes($value) . "': '" . addslashes($price) . "'";
         }
         self::$prices[] = "RSFormProPrices['" . addslashes($formId . '_' . $data['NAME']) . "'] = {" . implode(', ', $jsPrices) . "};";
     }
     //Trigger Event - rsfp_bk_onAfterCreateFrontComponentBody
     $mainframe->triggerEvent('rsfp_bk_onAfterCreateFrontComponentBody', array(array('out' => &$out, 'formId' => $formId, 'componentId' => $componentId, 'data' => $data, 'value' => $value, 'r' => $r, 'invalid' => $invalid)));
     return $out;
 }
Beispiel #2
0
 function getFrontComponentBody($formId, $componentId, $data, $value = '', $invalid = false)
 {
     $mainframe =& JFactory::getApplication();
     $formId = (int) $formId;
     $componentId = (int) $componentId;
     $db = JFactory::getDBO();
     // Optimized, don't need this anymore
     //$db->setQuery("SELECT `ComponentTypeId`, `Order` FROM #__rsform_components WHERE ComponentId='".$componentId."' LIMIT 1");
     //$r = $db->loadAssoc();
     // For legacy reasons...
     $r = array();
     $r['ComponentTypeId'] = $data['componentTypeId'];
     $r['Order'] = @$data['Order'];
     $out = '';
     //Trigger Event - rsfp_bk_onBeforeCreateFrontComponentBody
     $mainframe->triggerEvent('rsfp_bk_onBeforeCreateFrontComponentBody', array(array('out' => &$out, 'formId' => $formId, 'componentId' => $componentId, 'data' => $data, 'value' => $value)));
     switch ($data['ComponentTypeName']) {
         case 1:
         case 'textBox':
             $defaultValue = RSFormProHelper::isCode($data['DEFAULTVALUE']);
             $className = 'rsform-input-box';
             if ($invalid) {
                 $className .= ' rsform-error';
             }
             RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
             $out .= '<input type="text" value="' . (isset($value[$data['NAME']]) ? RSFormProHelper::htmlEscape($value[$data['NAME']]) : RSFormProHelper::htmlEscape($defaultValue)) . '" size="' . $data['SIZE'] . '" ' . ((int) $data['MAXSIZE'] > 0 ? 'maxlength="' . (int) $data['MAXSIZE'] . '"' : '') . ' name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES'] . '/>';
             break;
         case 2:
         case 'textArea':
             $defaultValue = RSFormProHelper::isCode($data['DEFAULTVALUE']);
             $className = 'rsform-text-box';
             if ($invalid) {
                 $className .= ' rsform-error';
             }
             RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
             if (isset($data['WYSIWYG']) && $data['WYSIWYG'] == 'YES') {
                 $out .= RSFormProHelper::WYSIWYG('form[' . $data['NAME'] . ']', isset($value[$data['NAME']]) ? RSFormProHelper::htmlEscape($value[$data['NAME']]) : RSFormProHelper::htmlEscape($defaultValue), 'id[' . $data['NAME'] . ']', $data['COLS'] * 10, $data['ROWS'] * 10, $data['COLS'], $data['ROWS']);
             } else {
                 $out .= '<textarea cols="' . (int) $data['COLS'] . '" rows="' . (int) $data['ROWS'] . '" name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES'] . '>' . (isset($value[$data['NAME']]) ? RSFormProHelper::htmlEscape($value[$data['NAME']]) : RSFormProHelper::htmlEscape($defaultValue)) . '</textarea>';
             }
             break;
         case 3:
         case 'selectList':
             $className = 'rsform-select-box';
             if ($invalid) {
                 $className .= ' rsform-error';
             }
             RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
             $out .= '<select ' . ($data['MULTIPLE'] == 'YES' ? 'multiple="multiple"' : '') . ' name="form[' . $data['NAME'] . '][]" ' . ((int) $data['SIZE'] > 0 ? 'size="' . (int) $data['SIZE'] . '"' : '') . ' id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES'] . ' >';
             $items = RSFormProHelper::isCode($data['ITEMS']);
             $items = str_replace("\r", "", $items);
             $items = explode("\n", $items);
             foreach ($items as $item) {
                 $buf = explode('|', $item, 2);
                 if (preg_match('/\\[g\\]/', $item)) {
                     $out .= '<optgroup label="' . RSFormProHelper::htmlEscape(str_replace('[g]', '', $item)) . '">';
                     continue;
                 }
                 if (preg_match('/\\[\\/g\\]/', $item)) {
                     $out .= '</optgroup>';
                     continue;
                 }
                 $option_value = $buf[0];
                 $option_value_trimmed = str_replace('[c]', '', $option_value);
                 $option_shown = count($buf) == 1 ? $buf[0] : $buf[1];
                 $option_shown_trimmed = str_replace('[c]', '', $option_shown);
                 $option_checked = false;
                 if (empty($value) && preg_match('/\\[c\\]/', $option_shown)) {
                     $option_checked = true;
                 }
                 if (isset($value[$data['NAME']]) && in_array($option_value_trimmed, $value[$data['NAME']])) {
                     $option_checked = true;
                 }
                 $out .= '<option ' . ($option_checked ? 'selected="selected"' : '') . ' value="' . RSFormProHelper::htmlEscape($option_value_trimmed) . '">' . RSFormProHelper::htmlEscape($option_shown_trimmed) . '</option>';
             }
             $out .= '</select>';
             $option = JRequest::getCmd('option');
             $view = JRequest::getCmd('view');
             $layout = JRequest::getCmd('layout');
             if ($option == 'com_rsevents' && $view == 'events' && $layout == 'subscribe' && $data['NAME'] == 'RSEventsTickets') {
                 $db->setQuery("SELECT ConfigValue FROM #__rsevents_config WHERE ConfigName = 'event.multiple.tickets' ");
                 $multipleTickets = $db->loadResult();
                 if ($multipleTickets) {
                     $lang =& JFactory::getLanguage();
                     $lang->load('com_rsevents', JPATH_SITE);
                     $out .= ' <a onclick="add_ticket(1,\'' . JText::_('RSE_REMOVE_TICKET', true) . '\');" href="javascript:void(0)">' . JText::_('RSE_ADD_TICKET') . '</a> ';
                     $out .= '<br /><span id="tickets"></span>';
                     $out .= '<span id="rse_tickets_ids"></span>' . "\n";
                     $out .= '<span id="rse_tickets_no"></span>' . "\n";
                 }
             }
             break;
         case 4:
         case 'checkboxGroup':
             $i = 0;
             $items = RSFormProHelper::isCode($data['ITEMS']);
             $items = str_replace("\r", "", $items);
             $items = explode("\n", $items);
             foreach ($items as $item) {
                 $buf = explode('|', $item, 2);
                 $option_value = $buf[0];
                 $option_value_trimmed = str_replace('[c]', '', $option_value);
                 $option_shown = count($buf) == 1 ? $buf[0] : $buf[1];
                 $option_shown_trimmed = str_replace('[c]', '', $option_shown);
                 $option_checked = false;
                 if (empty($value) && preg_match('/\\[c\\]/', $option_shown)) {
                     $option_checked = true;
                 }
                 if (isset($value[$data['NAME']]) && in_array($option_value_trimmed, $value[$data['NAME']])) {
                     $option_checked = true;
                 }
                 $out .= '<input ' . ($option_checked ? 'checked="checked"' : '') . ' name="form[' . $data['NAME'] . '][]" type="checkbox" value="' . RSFormProHelper::htmlEscape($option_value_trimmed) . '" id="' . $data['NAME'] . $i . '" ' . $data['ADDITIONALATTRIBUTES'] . ' /><label for="' . $data['NAME'] . $i . '">' . $option_shown_trimmed . '</label>';
                 if ($data['FLOW'] == 'VERTICAL') {
                     $out .= '<br/>';
                 }
                 $i++;
             }
             break;
         case 5:
         case 'radioGroup':
             $i = 0;
             $items = RSFormProHelper::isCode($data['ITEMS']);
             $items = str_replace("\r", "", $items);
             $items = explode("\n", $items);
             foreach ($items as $item) {
                 $buf = explode('|', $item, 2);
                 $option_value = $buf[0];
                 $option_value_trimmed = str_replace('[c]', '', $option_value);
                 $option_shown = count($buf) == 1 ? $buf[0] : $buf[1];
                 $option_shown_trimmed = str_replace('[c]', '', $option_shown);
                 $option_checked = false;
                 if (empty($value) && preg_match('/\\[c\\]/', $option_shown)) {
                     $option_checked = true;
                 }
                 if (isset($value[$data['NAME']]) && $value[$data['NAME']] == $option_value_trimmed) {
                     $option_checked = true;
                 }
                 $out .= '<input ' . ($option_checked ? 'checked="checked"' : '') . ' name="form[' . $data['NAME'] . ']" type="radio" value="' . RSFormProHelper::htmlEscape($option_value_trimmed) . '" id="' . $data['NAME'] . $i . '" ' . $data['ADDITIONALATTRIBUTES'] . ' /><label for="' . $data['NAME'] . $i . '">' . $option_shown_trimmed . '</label>';
                 if ($data['FLOW'] == 'VERTICAL') {
                     $out .= '<br/>';
                 }
                 $i++;
             }
             break;
         case 6:
         case 'calendar':
             $calendars = RSFormProHelper::componentExists($formId, 6);
             $calendars = array_flip($calendars);
             $defaultValue = isset($value[$data['NAME']]) ? $value[$data['NAME']] : (isset($data['DEFAULTVALUE']) ? RSFormProHelper::isCode($data['DEFAULTVALUE']) : '');
             switch ($data['CALENDARLAYOUT']) {
                 case 'FLAT':
                     $className = 'rsform-calendar-box';
                     if ($invalid) {
                         $className .= ' rsform-error';
                     }
                     $out .= '<input id="txtcal' . $formId . '_' . $calendars[$componentId] . '" name="form[' . $data['NAME'] . ']" type="text" ' . ($data['READONLY'] == 'YES' ? 'readonly="readonly"' : '') . ' class="txtCal ' . $className . '" value="' . RSFormProHelper::htmlEscape($defaultValue) . '" ' . $data['ADDITIONALATTRIBUTES'] . '/><br />';
                     $out .= '<div id="cal' . $formId . '_' . $calendars[$componentId] . 'Container" style="z-index:' . (9999 - $data['Order']) . '"></div>';
                     break;
                 case 'POPUP':
                     $data['ADDITIONALATTRIBUTES2'] = $data['ADDITIONALATTRIBUTES'];
                     $className = 'rsform-calendar-box';
                     if ($invalid) {
                         $className .= ' rsform-error';
                     }
                     RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
                     $out .= '<input id="txtcal' . $formId . '_' . $calendars[$componentId] . '" name="form[' . $data['NAME'] . ']" type="text" ' . ($data['READONLY'] == 'YES' ? 'readonly="readonly"' : '') . '  value="' . RSFormProHelper::htmlEscape($defaultValue) . '" ' . $data['ADDITIONALATTRIBUTES'] . '/>';
                     $className = 'rsform-calendar-button';
                     if ($invalid) {
                         $className .= ' rsform-error';
                     }
                     $out .= '<input id="btn' . $formId . '_' . $calendars[$componentId] . '" type="button" value="' . RSFormProHelper::htmlEscape($data['POPUPLABEL']) . '" onclick="showHideCalendar(\'cal' . $formId . '_' . $calendars[$componentId] . 'Container\');" class="btnCal ' . $className . '" ' . $data['ADDITIONALATTRIBUTES2'] . ' />';
                     $out .= '<div id="cal' . $formId . '_' . $calendars[$componentId] . 'Container" style="clear:both;display:none;position:absolute;z-index:' . (9999 - $data['Order']) . '"></div>';
                     break;
             }
             $out .= '<input id="hiddencal' . $formId . '_' . $calendars[$componentId] . '" type="hidden" name="hidden[' . $data['NAME'] . ']" />';
             break;
         case 7:
         case 'button':
             $data['ADDITIONALATTRIBUTES2'] = $data['ADDITIONALATTRIBUTES'];
             $className = 'rsform-button';
             if ($invalid) {
                 $className .= ' rsform-error';
             }
             RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
             $out .= '<input type="button" value="' . RSFormProHelper::htmlEscape($data['LABEL']) . '" name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES'] . ' />';
             if ($data['RESET'] == 'YES') {
                 $className = 'rsform-reset-button';
                 RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES2'], $className);
                 $out .= '&nbsp;&nbsp;<input type="reset" value="' . RSFormProHelper::htmlEscape($data['RESETLABEL']) . '" name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES2'] . ' />';
             }
             break;
         case 8:
         case 'captcha':
             switch (@$data['IMAGETYPE']) {
                 default:
                 case 'FREETYPE':
                 case 'NOFREETYPE':
                     $className = 'rsform-captcha-box';
                     if ($invalid) {
                         $className .= ' rsform-error';
                     }
                     RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
                     $out .= '<img src="' . JRoute::_('index.php?option=com_rsform&amp;task=captcha&amp;componentId=' . $componentId . '&amp;tmpl=component&amp;sid=' . mt_rand()) . '" id="captcha' . $componentId . '" alt="' . RSFormProHelper::htmlEscape($data['CAPTION']) . ' "/>';
                     if ($data['FLOW'] == 'VERTICAL') {
                         $out .= '<br />';
                     }
                     $out .= '<input type="text" name="form[' . $data['NAME'] . ']" value="" id="captchaTxt' . $componentId . '" ' . $data['ADDITIONALATTRIBUTES'] . ' />';
                     if ($data['SHOWREFRESH'] == 'YES') {
                         $out .= '&nbsp;&nbsp;<a href="javascript:void(0)" onclick="refreshCaptcha(' . $componentId . ',\'' . JRoute::_('index.php?option=com_rsform&task=captcha&componentId=' . $componentId . '&tmpl=component') . '\'); return false;">' . $data['REFRESHTEXT'] . '</a>';
                     }
                     break;
                 case 'INVISIBLE':
                     // a list of words that spam bots might auto-complete
                     $words = RSFormProHelper::getInvisibleCaptchaWords();
                     $word = $words[array_rand($words, 1)];
                     // a list of styles so that the field is hidden
                     $styles = array('display: none !important', 'position: absolute !important; left: -4000px !important; top: -4000px !important;', 'position: absolute !important; left: -4000px !important; top: -4000px !important; display: none !important', 'position: absolute !important; display: none !important', 'display: none !important; position: absolute !important; left: -4000px !important; top: -4000px !important;');
                     $style = $styles[array_rand($styles, 1)];
                     // now we're going to shuffle the properties of the html tag
                     $properties = array('type="text"', 'name="' . $word . '"', 'value=""', 'style="' . $style . '"');
                     shuffle($properties);
                     $session =& JFactory::getSession();
                     $session->set('com_rsform.captcha.' . $componentId, $word);
                     $out .= '<input ' . implode(' ', $properties) . ' />';
                     break;
             }
             break;
         case 9:
         case 'fileUpload':
             $className = 'rsform-upload-box';
             if ($invalid) {
                 $className .= ' rsform-error';
             }
             RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
             $out .= '<input type="hidden" name="MAX_FILE_SIZE" value="' . (int) $data['FILESIZE'] . '000" />';
             $out .= '<input type="file" name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES'] . ' />';
             break;
         case 10:
         case 'freeText':
             $out .= $data['TEXT'];
             break;
         case 11:
         case 'hidden':
             $defaultValue = RSFormProHelper::isCode($data['DEFAULTVALUE']);
             $out .= '<input type="hidden" name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" value="' . RSFormProHelper::htmlEscape($defaultValue) . '" ' . $data['ADDITIONALATTRIBUTES'] . ' />';
             break;
         case 12:
         case 'imageButton':
             $data['ADDITIONALATTRIBUTES2'] = $data['ADDITIONALATTRIBUTES'];
             $className = 'rsform-image-button';
             RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
             $data['ADDITIONALATTRIBUTES3'] = $data['ADDITIONALATTRIBUTES'];
             $pages = RSFormProHelper::componentExists($formId, 41);
             $pages = count($pages);
             if (!empty($pages)) {
                 if (empty($data['PREVBUTTON'])) {
                     $data['PREVBUTTON'] = JText::_('PREV');
                 }
                 $onclick = 'rsfp_changePage(' . $formId . ', ' . ($pages - 1) . ', ' . $pages . ')';
                 RSFormProHelper::addOnClick($data['ADDITIONALATTRIBUTES3'], $onclick);
                 $out .= '<input type="button" value="' . RSFormProHelper::htmlEscape($data['PREVBUTTON']) . '"  id="' . $data['NAME'] . 'Prev" ' . $data['ADDITIONALATTRIBUTES3'] . ' />';
             }
             $out .= '<input type="image" src="' . RSFormProHelper::htmlEscape($data['IMAGEBUTTON']) . '" name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES2'] . ' />';
             if ($data['RESET'] == 'YES') {
                 $className = 'rsform-reset-button';
                 RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES2'], $className);
                 $out .= '<input type="reset" name="" id="reset_' . $data['NAME'] . '" style="display: none !important" />&nbsp;&nbsp;<input onclick="document.getElementById(\'reset_' . $data['NAME'] . '\').click();return false;" type="image" src="' . RSFormProHelper::htmlEscape($data['IMAGERESET']) . '" name="form[' . $data['NAME'] . ']" ' . $data['ADDITIONALATTRIBUTES2'] . ' />';
             }
             break;
         case 13:
         case 'submitButton':
             $data['ADDITIONALATTRIBUTES2'] = $data['ADDITIONALATTRIBUTES'];
             $className = 'rsform-submit-button';
             RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
             $data['ADDITIONALATTRIBUTES3'] = $data['ADDITIONALATTRIBUTES'];
             $last_submit = $componentId == end($data['SUBMITS']);
             $pages = RSFormProHelper::componentExists($formId, 41);
             $pages = count($pages);
             if (!empty($pages) && $last_submit) {
                 if (empty($data['PREVBUTTON'])) {
                     $data['PREVBUTTON'] = JText::_('PREV');
                 }
                 $onclick = 'rsfp_changePage(' . $formId . ', ' . ($pages - 1) . ', ' . $pages . ')';
                 RSFormProHelper::addOnClick($data['ADDITIONALATTRIBUTES3'], $onclick);
                 $out .= '<input type="button" value="' . RSFormProHelper::htmlEscape($data['PREVBUTTON']) . '"  id="' . $data['NAME'] . 'Prev" ' . $data['ADDITIONALATTRIBUTES3'] . ' />';
             }
             $out .= '<input type="submit" value="' . RSFormProHelper::htmlEscape($data['LABEL']) . '" name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES'] . ' />';
             if ($data['RESET'] == 'YES') {
                 $className = 'rsform-reset-button';
                 RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES2'], $className);
                 $out .= '&nbsp;&nbsp;<input type="reset" value="' . RSFormProHelper::htmlEscape($data['RESETLABEL']) . '" name="form[' . $data['NAME'] . ']" ' . $data['ADDITIONALATTRIBUTES2'] . ' />';
             }
             break;
         case 14:
         case 'password':
             $defaultValue = '';
             if ($data['VALIDATIONRULE'] != 'password') {
                 $defaultValue = $data['DEFAULTVALUE'];
             }
             $className = 'rsform-password-box';
             if ($invalid) {
                 $className .= ' rsform-error';
             }
             RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
             $out .= '<input type="password" value="' . RSFormProHelper::htmlEscape($defaultValue) . '" size="' . (int) $data['SIZE'] . '" name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" ' . ((int) $data['MAXSIZE'] > 0 ? 'maxlength="' . (int) $data['MAXSIZE'] . '"' : '') . ' ' . $data['ADDITIONALATTRIBUTES'] . ' />';
             break;
         case 15:
         case 'ticket':
             $out .= '<input type="hidden" name="form[' . $data['NAME'] . ']" value="' . RSFormProHelper::generateString($data['LENGTH'], $data['CHARACTERS']) . '" ' . $data['ADDITIONALATTRIBUTES'] . ' />';
             break;
         case 41:
         case 'pageBreak':
             $validate = 'false';
             if (isset($data['VALIDATENEXTPAGE']) && $data['VALIDATENEXTPAGE'] == 'YES') {
                 $validate = 'true';
             }
             $className = 'rsform-button';
             if ($invalid) {
                 $className .= ' rsform-error';
             }
             RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
             $data['ADDITIONALATTRIBUTES2'] = $data['ADDITIONALATTRIBUTES'];
             $num = count($data['PAGES']);
             $pos = array_search($componentId, $data['PAGES']);
             if ($pos) {
                 $onclick = 'rsfp_changePage(' . $formId . ', ' . ($pos - 1) . ', ' . $num . ')';
                 RSFormProHelper::addOnClick($data['ADDITIONALATTRIBUTES'], $onclick);
                 $out .= '<input type="button" value="' . RSFormProHelper::htmlEscape($data['PREVBUTTON']) . '" ' . $data['ADDITIONALATTRIBUTES'] . ' id="' . $data['NAME'] . 'Prev" />';
             }
             if ($pos < count($data['PAGES'])) {
                 $onclick = 'rsfp_changePage(' . $formId . ', ' . ($pos + 1) . ', ' . $num . ', ' . $validate . ')';
                 RSFormProHelper::addOnClick($data['ADDITIONALATTRIBUTES2'], $onclick);
                 $out .= '<input type="button" value="' . RSFormProHelper::htmlEscape($data['NEXTBUTTON']) . '" ' . $data['ADDITIONALATTRIBUTES2'] . ' id="' . $data['NAME'] . 'Next" />';
             }
             break;
     }
     //Trigger Event - rsfp_bk_onAfterCreateFrontComponentBody
     $mainframe->triggerEvent('rsfp_bk_onAfterCreateFrontComponentBody', array(array('out' => &$out, 'formId' => $formId, 'componentId' => $componentId, 'data' => $data, 'value' => $value, 'r' => $r, 'invalid' => $invalid)));
     return $out;
 }