default.php
8.03 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
<?php
/**
* Joomla! component Creative Contact Form
*
* @version $Id: 2012-04-05 14:30:25 svn $
* @author creative-solutions.net
* @package Creative Contact Form
* @subpackage com_creativecontactform
* @license GNU/GPL
*
*/
// no direct access
defined('_JEXEC') or die('Restircted access');
$db = JFactory::getDBO();
error_reporting(0);
//header('Content-type: application/json');
$id = (int)$_POST['menu_id'];
$type = $_POST['type'];
if($type == 'get_data') {
//get form configuration
$query = "
SELECT
spo.`name`,
spo.`value`,
spo.`selected`
FROM
`#__creative_form_options` spo
WHERE spo.id = '$id'";
$db->setQuery($query);
$option_data = $db->loadAssoc();
$option_name = htmlspecialchars($option_data['name'],ENT_QUOTES);
$option_value = htmlspecialchars($option_data['value'],ENT_QUOTES);
$option_selected = $option_data['selected'];
?>
<form method="post" action="" enctype="multipart/form-data" id="menu_edit_form">
<div id=menus_info_tabs>
<ul>
<li><a href="#tabs-1">Option data</a></li>
</ul>
<div id="tabs-1" style="background-color: #fff3d6">
<table border="0" cellpadding="2" cellspacing="1" style="margin: 8px 2px 3px 2px;padding: 0;width:100%">
<tr>
<td style="width: 100px;">
Name
</td>
<td>
<input type="text" id="new_title" name="new_title" value="<?php echo $option_name;?>"/>
</td>
</tr>
<tr>
<td style="width: 100px;">
Value
</td>
<td>
<input type="text" id="new_value" name="new_value" value="<?php echo $option_value;?>"/>
</td>
</tr>
<tr>
<td style="width: 100px;">
Selected
</td>
<td valign="middle">
<input type="radio" value="0" <?php if($option_selected == 0) echo 'checked="checked"';?> name="option_selected" id="check_option_0"/> <label style="display: inline-block;" for="check_option_0">No</label>
<input type="radio" value="1" <?php if($option_selected == 1) echo 'checked="checked"';?> name="option_selected" id="check_option_1"/> <label style="display: inline-block;" for="check_option_1" >Yes</label>
</td>
</tr>
<tr>
<td colspan="2" align="right" style="margin-top: 10px;">
<button id="submit_options_form" class="btn btn-small btn-success"><i class="icon-apply icon-white"></i>Save</button>
</td>
</tr>
</table>
</div>
</div>
</form>
<?php
}
elseif($type == 'new_option_data') {
//get form configuration
?>
<form method="post" action="" enctype="multipart/form-data" id="menu_edit_form">
<div id=menus_info_tabs>
<ul>
<li><a href="#tabs-1">Option data</a></li>
</ul>
<div id="tabs-1" style="background-color: #fff3d6">
<table border="0" cellpadding="2" cellspacing="1" style="margin: 8px 2px 3px 2px;padding: 0;width:100%">
<tr>
<td style="width: 100px;">
Name
</td>
<td>
<input type="text" id="new_title" name="new_title" value="" placeholder="Option name"/>
</td>
</tr>
<tr>
<td style="width: 100px;">
Selected
</td>
<td valign="middle">
<input type="radio" value="0" checked="checked" name="option_selected" id="check_option_0"/> <label style="display: inline-block;" for="check_option_0">No</label>
<input type="radio" value="1" name="option_selected" id="check_option_1"/> <label style="display: inline-block;" for="check_option_1" >Yes</label>
</td>
</tr>
<tr>
<td colspan="2" align="right" style="margin-top: 10px;">
<button id="submit_new_option_form" class="btn btn-small btn-success"><i class="icon-apply icon-white"></i>Add</button>
</td>
</tr>
</table>
</div>
</div>
</form>
<?php
}
elseif($type == 'save_data') {
$name = JRequest::getVar('name');
$value = JRequest::getVar('value');
$selected = (int)$_POST['selected'];
//get form configuration
$query = "
UPDATE
`#__creative_form_options`
SET
`name` = '$name',
`value` = '$value',
`selected` = '$selected'
WHERE id = '$id'";
$db->setQuery($query);
$db->query();
}
elseif($type == 'save_new_option_data') {
$name = JRequest::getVar('name');
$value = $name;
$selected = (int)$_POST['selected'];
//get ordering
$query = "SELECT MAX(`ordering`) maxorder FROM `#__creative_form_options` WHERE `id_parent` = '$id'";
$db->setQuery($query);
$ordering = $db->loadResult();
$ordering ++;
$ordering = (int)$ordering;
$query = "
INSERT INTO
`#__creative_form_options` (`name`,`value`,`selected`,`ordering`,`id_parent`)
VALUES
('$name','$value','$selected','$ordering','$id')";
$db->setQuery($query);
$db->query();
$insertid = $db->insertid();
?>
<li class=" ui-state-default text" id="option_li_<?php echo $insertid;?>">
<div class="option_item" id="option_<?php echo $insertid;?>"><?php echo htmlspecialchars($name, ENT_QUOTES);?></div>
<div class="menu_moove" title="Move option" > </div>
<div id="edit_<?php echo $insertid;?>" menu_id="<?php echo $insertid;?>" class="edit" title="Edit option" > </div>
<div id="showrow_<?php echo $insertid;?>" menu_id="<?php echo $insertid;?>" class="hide" title="Unpublish option" > </div>
<div id="remove_<?php echo $insertid;?>" menu_id="<?php echo $insertid;?>" class="delete" title="Delete option" > </div>
</li>
<?php
}
elseif($type == 'show_unpublish_wrapper') {
//get form configuration
?>
<div style="background-color: #fff3d6;padding: 15px;">
<div style="margin: 5px 5px 15px 5px;text-align: center">Unpublish option?</div>
<button id="submit_hide_option" class="btn btn-small btn-success"><i class="icon-apply icon-white"></i>Unpublish</button>
</div>
<?php
}
elseif($type == 'show_publish_wrapper') {
//get form configuration
?>
<div style="background-color: #fff3d6;padding: 15px;">
<div style="margin: 5px 5px 15px 5px;text-align: center">Publish option?</div>
<button id="submit_show_option" class="btn btn-small btn-success"><i class="icon-apply icon-white"></i>Publish</button>
</div>
<?php
}
elseif($type == 'show_delete_wrapper') {
//get form configuration
?>
<div style="background-color: #fff3d6;padding: 15px;">
<div style="margin: 5px 5px 15px 5px;text-align: center">Delete option?</div>
<button id="submit_delete_option" class="btn btn-small btn-success"><i class="icon-apply icon-white"></i>Delete</button>
</div>
<?php
}
elseif($type == 'unpublish_data') {
//get form configuration
$query = "
UPDATE
`#__creative_form_options`
SET
`showrow` = '0'
WHERE id = '$id'";
$db->setQuery($query);
$db->query();
}
elseif($type == 'delete_data') {
//get form configuration
$query = "
DELETE FROM
`#__creative_form_options`
WHERE id = '$id'";
$db->setQuery($query);
$db->query();
}
elseif($type == 'publish_data') {
//get form configuration
$query = "
UPDATE
`#__creative_form_options`
SET
`showrow` = '1'
WHERE id = '$id'";
$db->setQuery($query);
$db->query();
}
elseif($type == 'reorder') {
//get form configuration
$order = str_replace('option_li_','',$_POST[order]);
$order_array = explode(',',$order);
$query ="UPDATE `#__creative_form_options` SET `ordering` = CASE `id`";
foreach ($order_array as $key => $val)
{
$ord = $key+1;
$query .= "WHEN ".$val." THEN '".$ord."'";
}
$query .= " END WHERE `id` IN (".$order.")";
$db->setQuery($query);
$db->query();
}
elseif($type=="update_star") {
$sub_id = (int)$_POST["sub_id"];
$star_index = (int)$_POST["star_index"];
$query = "
UPDATE
`#__creative_submissions`
SET
`star_index` = $star_index
WHERE id = '$sub_id'";
$db->setQuery($query);
$db->query();
}
elseif($type=="update_imp") {
$sub_id = (int)$_POST["sub_id"];
$imp_index = (int)$_POST["imp_index"];
$query = "
UPDATE
`#__creative_submissions`
SET
`imp_index` = $imp_index
WHERE id = '$sub_id'";
$db->setQuery($query);
$db->query();
}
elseif($type=="set_viewed") {
$sub_id = (int)$_POST["sub_id"];
$viewed_index = (int)$_POST["viewed_index"];
echo $query = "
UPDATE
`#__creative_submissions`
SET
`viewed` = \"$viewed_index\"
WHERE id = '$sub_id'";
$db->setQuery($query);
$db->query();
}
exit();
?>