-
Notifications
You must be signed in to change notification settings - Fork 8
/
get_form_content.php
114 lines (102 loc) · 3.51 KB
/
get_form_content.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
//include "chech_restricted.php";
require "settings/database.class.php";
if(isset($_POST['form_id'])){
$form_id = $_POST["form_id"];
$echo_data = "new";
$db = new Database("formbuilder");
$conn = $db->getConnection();
$sql = "SELECT * FROM form_content WHERE form_id='$form_id'";
if($result = $conn->query($sql)) {
$count = mysqli_num_rows($result);
if($count > 0){
while($row = mysqli_fetch_assoc($result)){
$echo_data = $row['form_form'] ;
}
}
}
if($echo_data != "new" && $echo_data != ""){
$submitBtnObj = new stdClass();
$submitBtnObj->type = "button";
$submitBtnObj->subtype = "submit";
$submitBtnObj->label = "Submit";
$submitBtnObj->className = "btn-primary btn";
$submitBtnObj->name = "button-submit-form";
$submitBtnObj->id = "button-submit-form";
$submitBtnObj->style = "primary";
/*
{
"type": "Buttons",
"label": "לחצנים",
"placeholder": "btn btn-primary",
"className": "buttons-container",
"name": "Buttons-1560116053064",
"submitBtnColor": "btn btn-primary",
"clearBtnColor": "btn btn-danger",
"btnsPos": "form-control-buttons-center",
"submitLabel": "שלח",
"cancelLabel": "נקה"
},
*/
$btnsObj = new stdClass();
$btnsObj->type = "Buttons";
$btnsObj->label = "";
$btnsObj->className = "buttons-container";
$btnsObj->name = "";
$btnsObj->submitBtnColor = "btn btn-primary";
$btnsObj->clearBtnColor = "btn btn-danger";
$btnsObj->btnsPos = "";
$btnsObj->submitLabel = "Submit";
$btnsObj->cancelLabel = "Clear";
$hiddenObj = new stdClass();
$hiddenObj->type = "hidden";
$hiddenObj->name = "hidden-form-id";
$hiddenObj->id = "hidden-form-id";
$hiddenObj->value = $form_id;
$form = json_decode($echo_data);
$frm_ary = array();
//remove button and hidden field if exists
$isButtons = false;
foreach($form as $fild){
if($fild->type != "button" && $fild->type != "hidden"){
$frm_ary[] = $fild;
}
if($fild->type == "Buttons"){
$isButtons = true;
}
}
array_push($frm_ary,$hiddenObj);
//array_push($frm_ary,$submitBtnObj);
if(!$isButtons){
array_push($frm_ary,$btnsObj);
}
$echo_data = json_encode($frm_ary);
}else{
$frm_ary = array();
$hiddenObj = new stdClass();
$hiddenObj->type = "hidden";
$hiddenObj->name = "hidden-form-id";
$hiddenObj->id = "hidden-form-id";
$hiddenObj->value = $form_id;
$btnsObj = new stdClass();
$btnsObj->type = "Buttons";
$btnsObj->label = "";
$btnsObj->className = "buttons-container";
$btnsObj->name = "";
$btnsObj->submitBtnColor = "btn btn-primary";
$btnsObj->clearBtnColor = "btn btn-danger";
$btnsObj->btnsPos = "";
$btnsObj->submitLabel = "Submit";
$btnsObj->cancelLabel = "Clear";
array_push($frm_ary,$hiddenObj);
array_push($frm_ary,$btnsObj);
$echo_data = json_encode($frm_ary);
}
echo $echo_data;
}else{
echo 'Error: missing form_id';
}
?>