protected function showConfigurationScreen() { ob_start(); ?> <div id="page-recaptchav2"> <p><a href="https://www.google.com/recaptcha/" target="_blank"><?php echo JText::_('RSFP_RECAPTCHAV2_GET_RECAPTCHA_HERE'); ?> </a></p> <table class="admintable"> <tr> <td width="200" style="width: 200px;" align="right" class="key"><label for="recaptchav2sitekey"><?php echo JText::_('RSFP_RECAPTCHAV2_SITE_KEY'); ?> </label></td> <td><input type="text" name="rsformConfig[recaptchav2.site.key]" id="recaptchav2sitekey" value="<?php echo RSFormProHelper::htmlEscape(RSFormProHelper::getConfig('recaptchav2.site.key')); ?> " size="100" maxlength="100" /></td> </tr> <tr> <td width="200" style="width: 200px;" align="right" class="key"><label for="recaptchav2secretkey"><?php echo JText::_('RSFP_RECAPTCHAV2_SECRET_KEY'); ?> </label></td> <td><input type="text" name="rsformConfig[recaptchav2.secret.key]" id="recaptchav2secretkey" value="<?php echo RSFormProHelper::htmlEscape(RSFormProHelper::getConfig('recaptchav2.secret.key')); ?> " size="100" maxlength="100" /></td> </tr> <tr> <td width="200" style="width: 200px;" align="right" class="key"><label for="recaptchav2language"><?php echo JText::_('RSFP_RECAPTCHAV2_LANGUAGE'); ?> </label></td> <td> <select name="rsformConfig[recaptchav2.language]" id="recaptchav2language"> <?php echo JHtml::_('select.options', array(JHtml::_('select.option', 'auto', JText::_('RSFP_RECAPTCHAV2_LANGUAGE_AUTO')), JHtml::_('select.option', 'site', JText::_('RSFP_RECAPTCHAV2_LANGUAGE_SITE'))), 'value', 'text', RSFormProHelper::getConfig('recaptchav2.language')); ?> </select> </td> </tr> </table> </div> <?php $contents = ob_get_contents(); ob_end_clean(); return $contents; }
function getComponentFields() { $db = JFactory::getDBO(); $lang = JFactory::getLanguage(); $return = array(); $data = $this->getComponentData(); $formId = JRequest::getInt('formId'); $general = array('NAME', 'CAPTION', 'LABEL', 'DEFAULTVALUE', 'ITEMS', 'TEXT', 'DESCRIPTION', 'COMPONENTTYPE'); $validations = array('REQUIRED', 'VALIDATIONRULE', 'VALIDATIONMESSAGE', 'VALIDATIONEXTRA'); $componentId = $this->getComponentId(); $componentType = $this->getComponentType(); $results = $this->_getList("SELECT * FROM #__rsform_component_type_fields WHERE ComponentTypeId='" . $componentType . "' ORDER BY Ordering ASC"); $translatable = RSFormProHelper::getTranslatableProperties(); foreach ($results as $i => $result) { if ($result->FieldName == 'ADDITIONALATTRIBUTES') { $results[$i]->Ordering = 1001; } } usort($results, array('RSFormModelFormAjax', 'sortFields')); foreach ($results as $result) { $field = new stdClass(); $field->name = $result->FieldName; $field->body = ''; switch ($result->FieldType) { case 'textbox': if ($lang->hasKey('RSFP_COMP_FIELD_' . $field->name)) { $field->body = JText::_('RSFP_COMP_FIELD_' . $field->name); } else { $field->body = $field->name; } $field->body = '<span id="caption' . $field->name . '">' . $field->body . '</span>'; $field->body .= '<br/>'; if ($componentId > 0) { $value = isset($data[$field->name]) ? $data[$field->name] : ''; } else { $values = RSFormProHelper::isCode($result->FieldValues); if ($lang->hasKey('RSFP_COMP_FVALUE_' . $values)) { $value = JText::_('RSFP_COMP_FVALUE_' . $values); } else { $value = $values; } } $additional = ''; if ($result->FieldName == 'FILESIZE') { $additional = 'onkeyup="javascript:this.value=this.value.replace(/[^0-9]/g, \'\');"'; } $field->body .= '<input type="text" id="' . $field->name . '" name="param[' . $field->name . ']" value="' . RSFormProHelper::htmlEscape($value) . '" ' . $additional . ' class="rsform_inp" />'; break; case 'textarea': if ($lang->hasKey('RSFP_COMP_FIELD_' . $field->name)) { $field->body = JText::_('RSFP_COMP_FIELD_' . $field->name); } else { $field->body = $field->name; } $field->body = '<span id="caption' . $field->name . '">' . $field->body . '</span>'; $field->body .= '<br />'; if ($componentId > 0) { if (!isset($data[$field->name])) { $data[$field->name] = ''; } if ($lang->hasKey('RSFP_COMP_FVALUE_' . $data[$field->name])) { $value = JText::_('RSFP_COMP_FVALUE_' . $data[$field->name]); } else { $value = $data[$field->name]; } } else { $values = RSFormProHelper::isCode($result->FieldValues); if ($lang->hasKey('RSFP_COMP_FVALUE_' . $values)) { $value = JText::_('RSFP_COMP_FVALUE_' . $values); } else { $value = $values; } } $field->body .= '<textarea id="' . $field->name . '" name="param[' . $field->name . ']" rows="5" cols="20" class="rsform_txtarea">' . RSFormProHelper::htmlEscape($value) . '</textarea></td>'; break; case 'select': if ($lang->hasKey('RSFP_COMP_FIELD_' . $field->name)) { $field->body = JText::_('RSFP_COMP_FIELD_' . $field->name); } else { $field->body = $field->name; } $field->body = '<span id="caption' . $field->name . '">' . $field->body . '</span>'; $field->body .= '<br />'; $field->body .= '<select name="param[' . $field->name . ']" id="' . $field->name . '" onchange="changeValidation(this);">'; if (!isset($data[$field->name])) { $data[$field->name] = ''; } $result->FieldValues = str_replace("\r", '', $result->FieldValues); $items = RSFormProHelper::isCode($result->FieldValues); $items = explode("\n", $items); foreach ($items as $item) { $buf = explode('|', $item); $option_value = $buf[0]; $option_shown = count($buf) == 1 ? $buf[0] : $buf[1]; if ($lang->hasKey('RSFP_COMP_FVALUE_' . $option_shown)) { $label = JText::_('RSFP_COMP_FVALUE_' . $option_shown); } else { $label = $option_shown; } $field->body .= '<option ' . ($componentId > 0 && $data[$field->name] == $option_value ? 'selected="selected"' : '') . ' value="' . $option_value . '">' . RSFormProHelper::htmlEscape($label) . '</option>'; } $field->body .= '</select>'; break; case 'hidden': $values = $result->FieldValues; if (defined('RSFP_COMP_FVALUE_' . $values)) { $value = constant('RSFP_COMP_FVALUE_' . $values); } else { $value = $values; } $field->body = '<input type="hidden" id="' . $field->name . '" name="' . $field->name . '" value="' . RSFormProHelper::htmlEscape($value) . '" />'; break; case 'hiddenparam': $field->body = '<input type="hidden" id="' . $field->name . '" name="param[' . $field->name . ']" value="' . RSFormProHelper::htmlEscape($result->FieldValues) . '" />'; break; case 'emailattach': if ($lang->hasKey('RSFP_COMP_FIELD_' . $field->name)) { $field->body = JText::_('RSFP_COMP_FIELD_' . $field->name); } else { $field->body = $field->name; } $field->body .= '<br />'; if (!isset($data[$field->name])) { $data[$field->name] = ''; } $values = trim($data[$field->name]) != '' ? explode(',', $data[$field->name]) : array(); $db->setQuery("SELECT id, subject FROM #__rsform_emails WHERE `type` = 'additional' AND formId = " . $formId . " "); $emails = $db->loadObjectList(); $field->body .= '<select name="param[' . $field->name . '][]" id="' . $field->name . '" onchange="changeValidation(this);" multiple="multiple" size="5" style="width:414px">'; $field->body .= '<option ' . ($componentId > 0 && in_array('useremail', $values) ? 'selected="selected"' : '') . ' value="useremail">' . RSFormProHelper::htmlEscape(JText::_('RSFP_COMP_ATTACH_UEMAIL')) . '</option>'; $field->body .= '<option ' . ($componentId > 0 && in_array('adminemail', $values) ? 'selected="selected"' : '') . ' value="adminemail">' . RSFormProHelper::htmlEscape(JText::_('RSFP_COMP_ATTACH_AEMAIL')) . '</option>'; $field->body .= '<optgroup label="' . RSFormProHelper::htmlEscape(JText::_('RSFP_COMP_ATTACH_ADEMAIL')) . '">'; if (!empty($emails)) { foreach ($emails as $email) { $field->body .= '<option ' . ($componentId > 0 && in_array($email->id, $values) ? 'selected="selected"' : '') . ' value="' . $email->id . '">' . RSFormProHelper::htmlEscape($email->subject) . '</option>'; } } $field->body .= '</optgroup>'; $field->body .= '</select>'; break; } if (in_array($result->FieldName, $translatable) && $result->FieldType != 'hiddenparam' && $result->FieldType != 'hidden') { $field->body = RSFormProHelper::translateIcon() . ' ' . $field->body; } if (in_array($field->name, $general) || $result->FieldType == 'hidden' || $result->FieldType == 'hiddenparam') { $return['general'][] = $field; } elseif (in_array($field->name, $validations) || strpos($field->name, 'VALIDATION') !== false) { $return['validations'][] = $field; } else { $return['attributes'][] = $field; } } return $return; }
function getEditFields() { $isPDF = JRequest::getVar('format') == 'pdf'; $cid = $this->getSubmissionId(); $return = array(); $this->_db->setQuery("SELECT * FROM #__rsform_submissions WHERE SubmissionId='" . $cid . "'"); $submission = $this->_db->loadObject(); if (empty($submission)) { $mainframe = JFactory::getApplication(); $mainframe->redirect('index.php?option=com_rsform&task=submissions.manage'); return $return; } if ($isPDF) { $this->_db->setQuery("SELECT MultipleSeparator, TextareaNewLines FROM #__rsform_forms WHERE FormId='" . $submission->FormId . "'"); $form = $this->_db->loadObject(); $form->MultipleSeparator = str_replace(array('\\n', '\\r', '\\t'), array("\n", "\r", "\t"), $form->MultipleSeparator); } $this->_db->setQuery("SELECT FieldName, FieldValue FROM #__rsform_submission_values WHERE SubmissionId='" . $cid . "'"); $fields = $this->_db->loadObjectList(); foreach ($fields as $field) { $submission->values[$field->FieldName] = $field->FieldValue; } unset($fields); $this->_db->setQuery("SELECT p.PropertyValue, ct.ComponentTypeName, c.ComponentId FROM #__rsform_components c LEFT JOIN #__rsform_properties p ON (p.ComponentId=c.ComponentId) LEFT JOIN #__rsform_component_types ct ON (c.ComponentTypeId=ct.ComponentTypeId) WHERE c.FormId='" . $submission->FormId . "' AND c.Published='1' AND p.PropertyName='NAME' ORDER BY `Order`"); $fields = $this->_db->loadObjectList(); if (empty($fields)) { return $return; } $componentIds = array(); foreach ($fields as $field) { $componentIds[] = $field->ComponentId; } $properties = RSFormProHelper::getComponentProperties($componentIds); foreach ($fields as $field) { $data = $properties[$field->ComponentId]; $new_field = array(); $new_field[0] = $field->PropertyValue; $name = $field->PropertyValue; $value = isset($submission->values[$field->PropertyValue]) ? $submission->values[$field->PropertyValue] : ''; if ($data['NAME'] == 'RSEProPayment') { $field->ComponentTypeName = 'rsepropayment'; } switch ($field->ComponentTypeName) { // skip this field for now, no need to edit it case 'freeText': continue 2; break; default: if ($isPDF) { $new_field[1] = RSFormProHelper::htmlEscape($value); } else { if (strpos($value, "\n") !== false || strpos($value, "\r") !== false) { $new_field[1] = '<textarea style="width: 95%" class="rs_textarea" rows="10" cols="60" name="form[' . $name . ']">' . RSFormProHelper::htmlEscape($value) . '</textarea>'; } else { $new_field[1] = '<input class="rs_inp rs_80"" size="105" type="text" name="form[' . $name . ']" value="' . RSFormProHelper::htmlEscape($value) . '" />'; } } break; case 'textArea': if ($isPDF) { if (isset($data['WYSIWYG']) && $data['WYSIWYG'] == 'YES') { $value = $value; } elseif ($form->TextareaNewLines) { $value = nl2br(RSFormProHelper::htmlEscape($value)); } $new_field[1] = $value; } elseif (isset($data['WYSIWYG']) && $data['WYSIWYG'] == 'YES') { $new_field[1] = RSFormProHelper::WYSIWYG('form[' . $name . ']', RSFormProHelper::htmlEscape($value), '', 600, 100, 60, 10); } else { $new_field[1] = '<textarea style="width: 95%" class="rs_textarea" rows="10" cols="60" name="form[' . $name . ']">' . RSFormProHelper::htmlEscape($value) . '</textarea>'; } break; case 'radioGroup': case 'checkboxGroup': case 'selectList': if ($isPDF) { $new_field[1] = str_replace("\n", $form->MultipleSeparator, $value); break; } if ($field->ComponentTypeName == 'radioGroup') { $data['SIZE'] = 0; $data['MULTIPLE'] = 'NO'; } elseif ($field->ComponentTypeName == 'checkboxGroup') { $data['SIZE'] = 5; $data['MULTIPLE'] = 'YES'; } $value = RSFormProHelper::explode($value); $items = RSFormProHelper::isCode($data['ITEMS']); $items = RSFormProHelper::explode($items); $options = array(); foreach ($items as $item) { // <OPTGROUP> if (preg_match('/\\[g\\]/', $item)) { $item = str_replace('[g]', '', $item); $optgroup = new stdClass(); $optgroup->value = '<OPTGROUP>'; $optgroup->text = $item; $options[] = $optgroup; continue; } // </OPTGROUP> if (preg_match('/\\[\\/g\\]/', $item)) { $optgroup = new stdClass(); $optgroup->value = '</OPTGROUP>'; $optgroup->text = ''; $options[] = $optgroup; continue; } $buf = explode('|', $item); $val = str_replace('[c]', '', $buf[0]); $item = str_replace('[c]', '', count($buf) == 1 ? $buf[0] : $buf[1]); $options[] = JHTML::_('select.option', $val, $item); } $attribs = array(); if ((int) $data['SIZE'] > 0) { $attribs[] = 'size="' . (int) $data['SIZE'] . '"'; } if ($data['MULTIPLE'] == 'YES') { $attribs[] = 'multiple="multiple"'; } $attribs = implode(' ', $attribs); $new_field[1] = JHTML::_('select.genericlist', $options, 'form[' . $name . '][]', $attribs, 'value', 'text', $value); break; case 'fileUpload': if ($isPDF) { $new_field[1] = $value; break; } $new_field[1] = '<input class="rs_inp rs_80" size="105" type="text" name="form[' . $name . ']" value="' . RSFormProHelper::htmlEscape($value) . '" />'; $new_field[1] .= '<br /><input size="45" type="file" name="upload[' . $name . ']" />'; break; } $return[] = $new_field; } // PayPal if (isset($submission->values['_STATUS'])) { $name = '_STATUS'; $value = $submission->values['_STATUS']; $new_field[0] = JText::_('RSFP_PAYPAL_STATUS'); if ($isPDF) { $new_field[1] = JText::_('RSFP_PAYPAL_STATUS_' . $value); } else { $options = array(JHTML::_('select.option', -1, JText::_('RSFP_PAYPAL_STATUS_-1')), JHTML::_('select.option', 0, JText::_('RSFP_PAYPAL_STATUS_0')), JHTML::_('select.option', 1, JText::_('RSFP_PAYPAL_STATUS_1'))); $new_field[1] = JHTML::_('select.genericlist', $options, 'form[' . $name . '][]', null, 'value', 'text', $value); } $return[] = $new_field; } // ANZ if (isset($submission->values['_ANZ_STATUS'])) { $name = '_ANZ_STATUS'; $value = $submission->values['_ANZ_STATUS']; $new_field[0] = JText::_('RSFP_ANZ_STATUS'); if ($isPDF) { $new_field[1] = JText::_('RSFP_ANZ_STATUS_' . $value); } else { $options = array(JHTML::_('select.option', -1, JText::_('RSFP_ANZ_STATUS_-1')), JHTML::_('select.option', 0, JText::_('RSFP_ANZ_STATUS_0')), JHTML::_('select.option', 1, JText::_('RSFP_ANZ_STATUS_1'))); $new_field[1] = JHTML::_('select.genericlist', $options, 'form[' . $name . '][]', null, 'value', 'text', $value); } $return[] = $new_field; } return $return; }
public static function getEditFields($cid) { $db = JFactory::getDbo(); $return = array(); $values = JFactory::getApplication()->input->get('form', array(), 'array'); $pattern = '#\\[p(.*?)\\]#is'; $db->setQuery("SELECT * FROM #__rsform_submissions WHERE SubmissionId='" . (int) $cid . "'"); $submission = $db->loadObject(); if (empty($submission)) { $mainframe = JFactory::getApplication(); $mainframe->redirect(JURI::root()); return $return; } $validation = !empty($values) ? RSFormProHelper::validateForm($submission->FormId, 'directory') : array(); $formFields = RSFormProHelper::getDirectoryFields($submission->FormId); $editable = array(); foreach ($formFields as $formField) { if ($formField->editable) { $editable[] = $formField->FieldName; } } $db->setQuery("SELECT FieldName, FieldValue FROM #__rsform_submission_values WHERE SubmissionId='" . (int) $cid . "'"); $fields = $db->loadObjectList(); foreach ($fields as $field) { $submission->values[$field->FieldName] = $field->FieldValue; } unset($fields); $db->setQuery("SELECT p.PropertyValue, ct.ComponentTypeName, c.ComponentId FROM #__rsform_components c LEFT JOIN #__rsform_properties p ON (p.ComponentId=c.ComponentId) LEFT JOIN #__rsform_component_types ct ON (c.ComponentTypeId=ct.ComponentTypeId) WHERE c.FormId='" . $submission->FormId . "' AND c.Published='1' AND p.PropertyName='NAME' ORDER BY `Order`"); $fields = $db->loadObjectList(); if (empty($fields)) { return $return; } $componentIds = array(); foreach ($fields as $field) { $componentIds[] = $field->ComponentId; } $properties = RSFormProHelper::getComponentProperties($componentIds); $fields = RSFormProHelper::sortFields($fields, $editable); foreach ($fields as $field) { if (!in_array($field->PropertyValue, $editable)) { continue; } $invalid = !empty($validation) && in_array($field->ComponentId, $validation) ? ' rsform-error' : ''; $data = $properties[$field->ComponentId]; $new_field = array(); $new_field[0] = !empty($data['CAPTION']) ? $data['CAPTION'] : $field->PropertyValue; $new_field[2] = isset($data['REQUIRED']) && $data['REQUIRED'] == 'YES' ? '<strong class="formRequired">(*)</strong>' : ''; $new_field[3] = $field->PropertyValue; $name = $field->PropertyValue; if (isset($values[$field->PropertyValue])) { $value = $values[$field->PropertyValue]; } else { $value = isset($submission->values[$field->PropertyValue]) ? $submission->values[$field->PropertyValue] : ''; } if ($data['NAME'] == 'RSEProPayment') { $field->ComponentTypeName = 'rsepropayment'; } switch ($field->ComponentTypeName) { // skip this field for now, no need to edit it case 'freeText': continue 2; break; default: if (strpos($value, "\n") !== false || strpos($value, "\r") !== false) { $new_field[1] = '<textarea style="width: 95%" class="rs_textarea' . $invalid . '" rows="10" cols="60" name="form[' . $name . ']">' . RSFormProHelper::htmlEscape($value) . '</textarea>'; } else { $new_field[1] = '<input class="rs_inp rs_80' . $invalid . '" type="text" name="form[' . $name . ']" value="' . RSFormProHelper::htmlEscape($value) . '" />'; } break; case 'textArea': if (isset($data['WYSIWYG']) && $data['WYSIWYG'] == 'YES') { $new_field[1] = RSFormProHelper::WYSIWYG('form[' . $name . ']', RSFormProHelper::htmlEscape($value), '', 600, 100, 60, 10); } else { $new_field[1] = '<textarea style="width: 95%" class="rs_textarea' . $invalid . '" rows="10" cols="60" name="form[' . $name . ']">' . RSFormProHelper::htmlEscape($value) . '</textarea>'; } break; case 'radioGroup': case 'checkboxGroup': case 'selectList': if ($field->ComponentTypeName == 'radioGroup') { $data['SIZE'] = 0; $data['MULTIPLE'] = 'NO'; } elseif ($field->ComponentTypeName == 'checkboxGroup') { $data['SIZE'] = 5; $data['MULTIPLE'] = 'YES'; } $value = !empty($values) ? $value : RSFormProHelper::explode($value); $items = RSFormProHelper::isCode($data['ITEMS']); $items = RSFormProHelper::explode($items); $options = array(); foreach ($items as $item) { if (preg_match($pattern, $item, $match)) { $item = preg_replace($pattern, '', $item); } // <OPTGROUP> if (preg_match('/\\[g\\]/', $item)) { $item = str_replace('[g]', '', $item); $optgroup = new stdClass(); $optgroup->value = '<OPTGROUP>'; $optgroup->text = $item; $options[] = $optgroup; continue; } // </OPTGROUP> if (preg_match('/\\[\\/g\\]/', $item)) { $optgroup = new stdClass(); $optgroup->value = '</OPTGROUP>'; $optgroup->text = ''; $options[] = $optgroup; continue; } $buf = explode('|', $item); $val = str_replace('[c]', '', $buf[0]); $item = str_replace('[c]', '', count($buf) == 1 ? $buf[0] : $buf[1]); $options[] = JHTML::_('select.option', $val, $item); } $attribs = array(); if ((int) $data['SIZE'] > 0) { $attribs[] = 'size="' . (int) $data['SIZE'] . '"'; } if ($data['MULTIPLE'] == 'YES') { $attribs[] = 'multiple="multiple"'; } if ($invalid) { $attribs[] = 'class="rsform-error"'; } $attribs = implode(' ', $attribs); $new_field[1] = JHTML::_('select.genericlist', $options, 'form[' . $name . '][]', $attribs, 'value', 'text', $value); break; case 'fileUpload': $new_field[1] = '<span class="' . $invalid . '">' . RSFormProHelper::htmlEscape(basename($value)) . '</span>'; $new_field[1] .= '<br /><input size="45" type="file" name="form[' . $name . ']" />'; break; } $return[] = $new_field; } /* // PayPal if (isset($submission->values['_STATUS'])) { $name = '_STATUS'; $value = $submission->values['_STATUS']; $new_field[0] = JText::_('RSFP_PAYPAL_STATUS'); $options = array( JHTML::_('select.option', -1, JText::_('RSFP_PAYPAL_STATUS_-1')), JHTML::_('select.option', 0, JText::_('RSFP_PAYPAL_STATUS_0')), JHTML::_('select.option', 1, JText::_('RSFP_PAYPAL_STATUS_1')) ); $new_field[1] = JHTML::_('select.genericlist', $options, 'form['.$name.'][]', null, 'value', 'text', $value); $return[] = $new_field; } // ANZ if (isset($submission->values['_ANZ_STATUS'])) { $name = '_ANZ_STATUS'; $value = $submission->values['_ANZ_STATUS']; $new_field[0] = JText::_('RSFP_ANZ_STATUS'); $options = array( JHTML::_('select.option', -1, JText::_('RSFP_ANZ_STATUS_-1')), JHTML::_('select.option', 0, JText::_('RSFP_ANZ_STATUS_0')), JHTML::_('select.option', 1, JText::_('RSFP_ANZ_STATUS_1')) ); $new_field[1] = JHTML::_('select.genericlist', $options, 'form['.$name.'][]', null, 'value', 'text', $value); $return[] = $new_field; } */ return $return; }
<span class="rsform_clear_both"></span> <fieldset> <legend><?php echo JText::_('RSFP_EDITING_TEXT'); ?> </legend> <?php if ($this->noEditor) { ?> <textarea cols="70" rows="10" style="width: 500px; height: 320px;" class="rs_textarea" name="<?php echo $this->editorName; ?> "><?php echo RSFormProHelper::htmlEscape($this->editorText); ?> </textarea> <?php } else { ?> <?php echo $this->editor->display($this->editorName, htmlentities($this->editorText, ENT_COMPAT, 'UTF-8'), 500, 320, 70, 10); ?> <?php } ?> </fieldset> <input type="hidden" name="option" value="com_rsform" /> <input type="hidden" name="opener" value="<?php
public static function getEditFields($cid) { $db = JFactory::getDbo(); $return = array(); $values = JFactory::getApplication()->input->get('form', array(), 'array'); $pattern = '#\\[p(.*?)\\]#is'; // Load submission $query = $db->getQuery(true); $query->select('*')->from($db->qn('#__rsform_submissions'))->where($db->qn('SubmissionId') . '=' . $db->q($cid)); $submission = $db->setQuery($query)->loadObject(); if (empty($submission)) { return $return; } $submission->DateSubmitted = JHtml::_('date', $submission->DateSubmitted, 'Y-m-d H:i:s'); // Get submission values $submission->values = array(); $query->clear()->select($db->qn('FieldName'))->select($db->qn('FieldValue'))->from($db->qn('#__rsform_submission_values'))->where($db->qn('SubmissionId') . '=' . $db->q($cid)); if ($values = $db->setQuery($query)->loadObjectList()) { foreach ($values as $value) { $submission->values[$value->FieldName] = $value->FieldValue; } unset($values); } $validation = !empty($values) ? RSFormProHelper::validateForm($submission->FormId, 'directory') : array(); $formFields = self::getDirectoryFields($submission->FormId); $headers = self::getDirectoryStaticHeaders(); $query = $db->getQuery(true); $query->select($db->qn('ct.ComponentTypeName', 'type'))->select($db->qn('c.ComponentId'))->from($db->qn('#__rsform_components', 'c'))->join('left', $db->qn('#__rsform_component_types', 'ct') . ' ON (' . $db->qn('c.ComponentTypeId') . '=' . $db->qn('ct.ComponentTypeId') . ')')->where($db->qn('c.FormId') . '=' . $db->q($submission->FormId))->where($db->qn('c.Published') . '=' . $db->q(1)); $componentTypes = $db->setQuery($query)->loadObjectList('ComponentId'); $componentIds = array(); foreach ($formFields as $formField) { if ($formField->FieldId > 0) { $componentIds[] = $formField->FieldId; } // Assign the type $formField->type = ''; if ($formField->FieldId < 0) { $formField->type = 'static'; } elseif (isset($componentTypes[$formField->FieldId])) { $formField->type = $componentTypes[$formField->FieldId]->type; } // For convenience... $formField->id = $formField->FieldId; $formField->name = $formField->FieldName; } $properties = RSFormProHelper::getComponentProperties($componentIds); foreach ($formFields as $field) { if (!$field->editable) { continue; } $invalid = !empty($validation) && in_array($field->id, $validation) ? ' rsform-error' : ''; $data = $field->id > 0 ? $properties[$field->id] : array('NAME' => $field->name); $new_field = array(); $new_field[0] = !empty($data['CAPTION']) ? $data['CAPTION'] : $field->name; $new_field[2] = isset($data['REQUIRED']) && $data['REQUIRED'] == 'YES' ? '<strong class="formRequired">(*)</strong>' : ''; $new_field[3] = $field->name; $name = $field->name; if ($field->type != 'static') { if (isset($values[$field->name])) { $value = $values[$field->name]; } else { $value = isset($submission->values[$field->name]) ? $submission->values[$field->name] : ''; } } else { $value = isset($submission->{$field->name}) ? $submission->{$field->name} : ''; } if ($data['NAME'] == 'RSEProPayment') { $field->type = 'rsepropayment'; } switch ($field->type) { case 'static': $new_field[0] = JText::_('RSFP_' . $field->name); // Show a dropdown for yes/no if ($field->name == 'confirmed') { $options = array(JHtml::_('select.option', 0, JText::_('RSFP_NO')), JHtml::_('select.option', 1, JText::_('RSFP_YES'))); $new_field[1] = JHTML::_('select.genericlist', $options, 'formStatic[confirmed]', null, 'value', 'text', $value); } else { $new_field[1] = '<input class="rs_inp rs_80" type="text" name="formStatic[' . $name . ']" value="' . RSFormProHelper::htmlEscape($value) . '" />'; } break; // skip this field for now, no need to edit it // skip this field for now, no need to edit it case 'freeText': continue 2; break; default: if (strpos($value, "\n") !== false || strpos($value, "\r") !== false) { $new_field[1] = '<textarea style="width: 95%" class="rs_textarea' . $invalid . '" rows="10" cols="60" name="form[' . $name . ']">' . RSFormProHelper::htmlEscape($value) . '</textarea>'; } else { $new_field[1] = '<input class="rs_inp rs_80' . $invalid . '" type="text" name="form[' . $name . ']" value="' . RSFormProHelper::htmlEscape($value) . '" />'; } break; case 'textArea': if (isset($data['WYSIWYG']) && $data['WYSIWYG'] == 'YES') { $new_field[1] = RSFormProHelper::WYSIWYG('form[' . $name . ']', RSFormProHelper::htmlEscape($value), '', 600, 100, 60, 10); } else { $new_field[1] = '<textarea style="width: 95%" class="rs_textarea' . $invalid . '" rows="10" cols="60" name="form[' . $name . ']">' . RSFormProHelper::htmlEscape($value) . '</textarea>'; } break; case 'radioGroup': case 'checkboxGroup': case 'selectList': if ($field->type == 'radioGroup') { $data['SIZE'] = 0; $data['MULTIPLE'] = 'NO'; } elseif ($field->type == 'checkboxGroup') { $data['SIZE'] = 5; $data['MULTIPLE'] = 'YES'; } $value = !empty($values) ? $value : RSFormProHelper::explode($value); $items = RSFormProHelper::isCode($data['ITEMS']); $items = RSFormProHelper::explode($items); $options = array(); foreach ($items as $item) { if (preg_match($pattern, $item, $match)) { $item = preg_replace($pattern, '', $item); } // <OPTGROUP> if (preg_match('/\\[g\\]/', $item)) { $item = str_replace('[g]', '', $item); $optgroup = new stdClass(); $optgroup->value = '<OPTGROUP>'; $optgroup->text = $item; $options[] = $optgroup; continue; } // </OPTGROUP> if (preg_match('/\\[\\/g\\]/', $item)) { $optgroup = new stdClass(); $optgroup->value = '</OPTGROUP>'; $optgroup->text = ''; $options[] = $optgroup; continue; } $buf = explode('|', $item); $val = str_replace('[c]', '', $buf[0]); $item = str_replace('[c]', '', count($buf) == 1 ? $buf[0] : $buf[1]); $options[] = JHTML::_('select.option', $val, $item); } $attribs = array(); if ((int) $data['SIZE'] > 0) { $attribs[] = 'size="' . (int) $data['SIZE'] . '"'; } if ($data['MULTIPLE'] == 'YES') { $attribs[] = 'multiple="multiple"'; } if ($invalid) { $attribs[] = 'class="rsform-error"'; } $attribs = implode(' ', $attribs); $new_field[1] = JHTML::_('select.genericlist', $options, 'form[' . $name . '][]', $attribs, 'value', 'text', $value); break; case 'fileUpload': $new_field[1] = '<span class="' . $invalid . '">' . RSFormProHelper::htmlEscape(basename($value)) . '</span>'; $new_field[1] .= '<br /><input size="45" type="file" name="form[' . $name . ']" />'; break; } $return[] = $new_field; } return $return; }
public function paypalConfigurationScreen() { ob_start(); ?> <div id="page-paypal" class="com-rsform-css-fix"> <table class="admintable"> <tr> <td width="200" style="width: 200px;" align="right" class="key"><label for="currency"><?php echo JText::_('RSFP_PAYPAL_EMAIL'); ?> </label></td> <td><input type="text" name="rsformConfig[paypal.email]" value="<?php echo RSFormProHelper::htmlEscape(RSFormProHelper::getConfig('paypal.email')); ?> " size="100" maxlength="64"></td> </tr> <tr> <td width="200" style="width: 200px;" align="right" class="key"><label for="return"><?php echo JText::_('RSFP_PAYPAL_RETURN'); ?> </label></td> <td><input type="text" name="rsformConfig[paypal.return]" value="<?php echo RSFormProHelper::htmlEscape(RSFormProHelper::getConfig('paypal.return')); ?> " size="100"></td> </tr> <tr> <td width="200" style="width: 200px;" align="right" class="key"><label for="cancel"><?php echo JText::_('RSFP_PAYPAL_CANCEL'); ?> </label></td> <td><input type="text" name="rsformConfig[paypal.cancel]" value="<?php echo RSFormProHelper::htmlEscape(RSFormProHelper::getConfig('paypal.cancel')); ?> " size="100"></td> </tr> <tr> <td width="200" style="width: 200px;" align="right" class="key"><label for="currency"><?php echo JText::_('RSFP_PAYPAL_TEST'); ?> </label></td> <td><?php echo JHTML::_('select.booleanlist', 'rsformConfig[paypal.test]', '', RSFormProHelper::htmlEscape(RSFormProHelper::getConfig('paypal.test'))); ?> </td> </tr> <tr> <td width="200" style="width: 200px;" align="right" class="key"><label for="tax.type"><?php echo JText::_('RSFP_PAYPAL_TAX_TYPE'); ?> </label></td> <td><?php echo JHTML::_('select.booleanlist', 'rsformConfig[paypal.tax.type]', '', RSFormProHelper::htmlEscape(RSFormProHelper::getConfig('paypal.tax.type')), JText::_('RSFP_PAYPAL_TAX_TYPE_FIXED'), JText::_('RSFP_PAYPAL_TAX_TYPE_PERCENT')); ?> </td> </tr> <tr> <td width="200" style="width: 200px;" align="right" class="key"><label for="tax.value"><?php echo JText::_('RSFP_PAYPAL_TAX_VALUE'); ?> </label></td> <td><input type="text" name="rsformConfig[paypal.tax.value]" value="<?php echo RSFormProHelper::htmlEscape(RSFormProHelper::getConfig('paypal.tax.value')); ?> " size="4" maxlength="5"></td> </tr> <tr> <td width="200" style="width: 200px;" align="right" class="key"><label for="language"><?php echo JText::_('RSFP_PAYPAL_LANGUAGE'); ?> </label></td> <td> <input type="text" name="rsformConfig[paypal.language]" value="<?php echo RSFormProHelper::htmlEscape(RSFormProHelper::getConfig('paypal.language')); ?> " size="4" maxlength="2"> <?php echo JText::_('PAYPAL_LANGUAGES_CODES'); ?> </td> </tr> </table> </div> <?php $contents = ob_get_contents(); ob_end_clean(); return $contents; }
function recaptchaConfigurationScreen() { ob_start(); $themes[] = JHTML::_('select.option', 'red', JText::_('RSFP_RED_THEME')); $themes[] = JHTML::_('select.option', 'white', JText::_('RSFP_WHITE_THEME')); $themes[] = JHTML::_('select.option', 'clean', JText::_('RSFP_CLEAN_THEME')); $themes[] = JHTML::_('select.option', 'blackglass', JText::_('RSFP_BLACKGLASS_THEME')); $theme = JHTML::_('select.genericlist', $themes, 'rsformConfig[recaptcha.theme]', 'size="1" class="inputbox"', 'value', 'text', RSFormProHelper::getConfig('recaptcha.theme')); ?> <div id="page-recaptcha"> <table class="admintable"> <tr> <td width="200" style="width: 200px;" align="right" class="key"><label for="public"><?php echo JText::_('RSFP_RECAPTCHA_PBKEY'); ?> </label></td> <td><input type="text" name="rsformConfig[recaptcha.public.key]" value="<?php echo RSFormProHelper::htmlEscape(RSFormProHelper::getConfig('recaptcha.public.key')); ?> " size="100" maxlength="100"></td> </tr> <tr> <td width="200" style="width: 200px;" align="right" class="key"><label for="private"><?php echo JText::_('RSFP_RECAPTCHA_PRKEY'); ?> </label></td> <td><input type="text" name="rsformConfig[recaptcha.private.key]" value="<?php echo RSFormProHelper::htmlEscape(RSFormProHelper::getConfig('recaptcha.private.key')); ?> " size="100" maxlength="100"></td> </tr> <tr> <td width="200" style="width: 200px;" align="right" class="key"><label for="theme"><?php echo JText::_('RSFP_RECAPTCHA_THEME'); ?> </label></td> <td><?php echo $theme; ?> </td> </tr> </table> </div> <?php $contents = ob_get_contents(); ob_end_clean(); return $contents; }
public static function mappingsColumns($config, $method, $row = null) { jimport('joomla.application.component.model'); if (RSFormProHelper::isJ('3.0')) { JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_rsform/models'); $model = JModelLegacy::getInstance('mappings', 'RSFormModel'); } else { JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_rsform/models'); $model = JModel::getInstance('mappings', 'RSFormModel'); } $columns = $model->getColumns($config); $data = @unserialize($row->data); if ($data === false) { $data = array(); } $where = @unserialize($row->wheredata); if ($where === false) { $where = array(); } $extra = @unserialize($row->extra); if ($extra === false) { $extra = array(); } $andor = @unserialize($row->andor); if ($andor === false) { $andor = array(); } $operators = array(JHTML::_('select.option', '=', JText::_('RSFP_OPERATOR_EQUALS')), JHTML::_('select.option', '!=', JText::_('RSFP_OPERATOR_NOTEQUAL')), JHTML::_('select.option', '>', JText::_('RSFP_OPERATOR_GREATER_THAN')), JHTML::_('select.option', '<', JText::_('RSFP_OPERATOR_LESS_THAN')), JHTML::_('select.option', '>=', JText::_('RSFP_OPERATOR_EQUALS_GREATHER_THAN')), JHTML::_('select.option', '<=', JText::_('RSFP_OPERATOR_EQUALS_LESS_THAN')), JHTML::_('select.option', '%..%', JText::_('RSFP_OPERATOR_LIKE')), JHTML::_('select.option', '%..', JText::_('RSFP_OPERATOR_STARTS_WITH')), JHTML::_('select.option', '..%', JText::_('RSFP_OPERATOR_ENDS_WITH'))); $html = ''; $html .= $method == 'set' ? JText::_('RSFP_SET') . '<hr />' : JText::_('RSFP_WHERE') . '<hr />'; $html .= '<table class="admintable">'; if (!empty($columns)) { $html .= '<tr>'; $html .= '<td> </td>'; if ($method == 'where') { $html .= '<td> </td>'; $html .= '<td> </td>'; } $html .= '<td align="right"><button class="rs_button" type="submit">' . JText::_('SAVE') . '</button></td>'; $html .= '</tr>'; } if (!empty($columns)) { foreach ($columns as $column => $type) { if ($method == 'set') { $value = isset($data[$column]) ? $data[$column] : ''; $name = 'f_' . $column; } else { $value = isset($where[$column]) ? $where[$column] : ''; $name = 'w_' . $column; $op = isset($extra[$column]) ? $extra[$column] : '='; $op2 = isset($andor[$column]) ? $andor[$column] : 0; } $html .= '<tr>'; $html .= '<td width="80" nowrap="nowrap" align="right" class="key">' . $column . ' (' . $type . ')</td>'; if ($method == 'where') { $html .= '<td>' . JHTML::_('select.genericlist', $operators, 'o_' . $column, 'class="inputbox"', 'value', 'text', $op) . '</td>'; } if (strpos($type, 'text') !== false) { $html .= '<td><textarea class="rs_textarea" onclick="toggleDropdown(this,returnMappingsExtra());" onkeydown="closeAllDropdowns();" style="width:300px; height: 200px;" id="' . RSFormProHelper::htmlEscape($name) . '" name="' . RSFormProHelper::htmlEscape($name) . '">' . RSFormProHelper::htmlEscape($value) . '</textarea></td>'; } else { $html .= '<td><input type="text" class="rs_inp rs_80" onclick="toggleDropdown(this,returnMappingsExtra());" onkeydown="closeAllDropdowns();" size="35" value="' . RSFormProHelper::htmlEscape($value) . '" id="' . RSFormProHelper::htmlEscape($name) . '" name="' . RSFormProHelper::htmlEscape($name) . '"></td>'; } if ($method == 'where') { $html .= '<td>' . JHTML::_('select.booleanlist', 'c_' . $column, 'class="inputbox"', $op2, 'RSFP_OR', 'RSFP_AND') . '</td>'; } $html .= '</tr>'; } } if (!empty($columns)) { $html .= '<tr>'; $html .= '<td> </td>'; if ($method == 'where') { $html .= '<td> </td>'; $html .= '<td> </td>'; } $html .= '<td align="right"><button class="rs_button" type="submit">' . JText::_('SAVE') . '</button></td>'; $html .= '</tr>'; } $html .= '</table>'; return $html; }
protected function _escape($string) { return RSFormProHelper::htmlEscape($string); }