form_name))."_";
$sections = AFormsTomM8::get_results("a_form_sections", "*", "form_id='".$atts["id"]."'", array("section_order ASC"));
if (isset($_POST["send_a_form_section"])) {
$section_index = ($_POST["send_a_form_section"]);
} else {
$section_index = 0;
}
if(!(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')) {
// If not a ajax request.
$ajax_class = "";
if ($form->enable_ajax == "1") {
$ajax_class = "ajaxified";
}
$return_content .= "
";
}
return $return_content;
}
function render_a_form_one_section_per_page($atts, $form, $form_name, $section, $return_content) {
// We only want to display one section per page.
$return_content .= "";
}
function render_a_form_section_html($form, $form_name, $section, $return_content) {
$fields = AFormsTomM8::get_results("a_form_fields", "*", "section_id='".$section->ID."'", array("field_order ASC"));
// Render form fields.
if ($form->show_section_names) {
$return_content .= "";
}
foreach ($fields as $field) {
$field_name = str_replace(" ", "_", strtolower($field->field_label));
$value_options = array();
if ($field->value_options != "") {
$options = explode(",", $field->value_options);
foreach($options as $option_with_label) {
$temp_array = explode(":", $option_with_label);
$option = $temp_array[1];
$value = $temp_array[0];
if ($option == "") {
$option = $value;
}
$value_options[$option] = $value;
}
}
$field_label = $field->field_label;
if (preg_match("/required/",$field->validation)) {
$field_label .= "*";
}
ob_start();
if ($field->field_type == "file" && $field->file_ext_allowed != "") {
echo("");
}
$error_class = "";
if (isset($_SESSION[$form_name.$field_name."_error"])) {
$error_class = "error";
}
AFormsTomM8::add_form_field(null, $field->field_type, $field_label, $form_name.$field_name, $form_name.$field_name, array("class" => $field->field_type." ".$field->validation), "div", array("class" => $error_class), $value_options);
if ($field->field_type == "file" && $field->file_ext_allowed != "") {
$extensions_allowed = $field->file_ext_allowed;
$extensions_allowed = preg_replace('/(\s)+/',' ', $extensions_allowed);
$extensions_allowed = preg_replace('/(\s)+$/', '', $extensions_allowed);
$extensions_allowed = preg_replace('/(\s)/', ', ', $extensions_allowed);
$extensions_allowed = preg_replace('/ \.([a-z|A-Z])*$/', ' and $0', $extensions_allowed);
$extensions_allowed = preg_replace('/,(\s)+and/', ' and', $extensions_allowed);
echo("Can only accept: ".$extensions_allowed."");
echo("
");
}
$return_content .= ob_get_contents();
ob_end_clean();
}
return $return_content;
}
function render_a_form_submit_html($form, $form_name) {
$return_content = "";
if ($form->include_captcha) {
$error_class = "";
if (isset($_SESSION[$form_name."captcha_error"])) {
$error_class = "error";
}
ob_start();
if ($form->captcha_type == "1") {
AFormsTomM8::add_form_field(null, "captcha", "Captcha", AFormPage::aform_field_name($form, "captcha"), AFormPage::aform_field_name($form, "captcha"), array(), "div", array("class" => "captcha $error_class"));
} else if ($form->captcha_type == "2") {
$first_number = $_POST[AFormPage::aform_field_name($form, "captcha_first_number")] = rand(1, 20);
$second_number = $_POST[AFormPage::aform_field_name($form, "captcha_second_number")] = rand(1, 20);
AFormsTomM8::add_form_field(null, "hidden", "First number", AFormPage::aform_field_name($form, "captcha_first_number"),
AFormPage::aform_field_name($form, "captcha_first_number")
, array(), "div", array());
AFormsTomM8::add_form_field(null, "hidden", "Second number", AFormPage::aform_field_name($form, "captcha_second_number"), AFormPage::aform_field_name($form, "captcha_second_number"), array(), "div", array());
AFormsTomM8::add_form_field(null, "text", "What is ".$first_number." + ".$second_number, AFormPage::aform_field_name($form, "captcha"), AFormPage::aform_field_name($form, "captcha"), array(), "div", array("class" => "captcha $error_class"));
}
$return_content .= ob_get_contents();
ob_end_clean();
}
$return_content .= "";
return $return_content;
}
function aform_field_name($form, $field_name) {
return "a_form_".str_replace(" ", "_", strtolower($form->form_name))."_".$field_name;
}
}
?>