Exemple #1
0
function show_conditions()
{
    $form_id = JRequest::getVar('form_id');
    $row = JTable::getInstance('formmaker', 'Table');
    $row->load($form_id);
    $ids = array();
    $types = array();
    $labels = array();
    $paramss = array();
    $all_ids = array();
    $all_labels = array();
    $select_and_input = array("type_text", "type_password", "type_textarea", "type_name", "type_number", "type_phone", "type_submitter_mail", "type_country", "type_address", "type_spinner", "type_checkbox", "type_radio", "type_own_select", "type_paypal_price", "type_paypal_select", "type_paypal_checkbox", "type_paypal_radio", "type_paypal_shipping");
    $fields = explode('*:*new_field*:*', $row->form_fields);
    $fields = array_slice($fields, 0, count($fields) - 1);
    foreach ($fields as $field) {
        $temp = explode('*:*id*:*', $field);
        array_push($ids, $temp[0]);
        array_push($all_ids, $temp[0]);
        $temp = explode('*:*type*:*', $temp[1]);
        array_push($types, $temp[0]);
        $temp = explode('*:*w_field_label*:*', $temp[1]);
        array_push($labels, $temp[0]);
        array_push($all_labels, $temp[0]);
        array_push($paramss, $temp[1]);
    }
    foreach ($types as $key => $value) {
        if (!in_array($types[$key], $select_and_input)) {
            unset($ids[$key]);
            unset($labels[$key]);
            unset($types[$key]);
            unset($paramss[$key]);
        }
    }
    $ids = array_values($ids);
    $labels = array_values($labels);
    $types = array_values($types);
    $paramss = array_values($paramss);
    $show_hide = array();
    $field_label = array();
    $all_any = array();
    $condition_params = array();
    $count_of_conditions = 0;
    echo '<input type="hidden" id="condition" name="condition" value="' . $row->condition . '" />';
    if ($row->condition != "") {
        $conditions = explode('*:*new_condition*:*', $row->condition);
        $conditions = array_slice($conditions, 0, count($conditions) - 1);
        $count_of_conditions = count($conditions);
        foreach ($conditions as $condition) {
            $temp = explode('*:*show_hide*:*', $condition);
            array_push($show_hide, $temp[0]);
            $temp = explode('*:*field_label*:*', $temp[1]);
            array_push($field_label, $temp[0]);
            $temp = explode('*:*all_any*:*', $temp[1]);
            array_push($all_any, $temp[0]);
            array_push($condition_params, $temp[1]);
        }
        HTML_contact::show_conditions($ids, $all_ids, $types, $labels, $all_labels, $paramss, $count_of_conditions, $show_hide, $field_label, $all_any, $condition_params, $form_id);
    }
}