-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig-form.php
More file actions
457 lines (438 loc) · 22.3 KB
/
Copy pathconfig-form.php
File metadata and controls
457 lines (438 loc) · 22.3 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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
<div class="field">
<div id="alertbox">
<p class="explanation"><?php echo __('* Required Fields'); ?></p>
</div>
<div class="two columns alpha">
<label id="logo_label" for="per_page"><?php echo __('Logo*'); ?></label>
</div>
<div class="inputs five columns omega">
<p class="explanation"><?php echo __('Upload your logo here (We only accept .png format images)'); ?>.</p>
<p class="explanation"><?php echo __('Your current logo'); ?>.</p>
<img src="<?php echo getFullOmekaUrl(); ?>../plugins/Incite/views/shared/images/customized_logo.png" height="100" width="400">
<br>
<br>
<div class="input-block">
<input type="file" class="textinput" name="logo" accept=".png" id="logo" />
</div>
</div>
<div class="two columns alpha">
<label id="title_label" for="per_page"><?php echo __('Homepage Tagline*'); ?></label>
</div>
<div class="inputs five columns omega">
<p class="explanation"><?php echo __('Write your homepage tagline here'); ?>.</p>
<div class="input-block">
<?php $tmp = get_option('title'); ?>
<?php if (empty($tmp)): ?>
<input style="width: 358px;" type="text" class="textinput" name="title" value="Your project title/description here" id="title" />
<?php else: ?>
<input style="width: 358px;" type="text" class="textinput" name="title" value="<?php echo get_option('title'); ?>" id="title" />
<?php endif; ?>
</div>
</div>
<div class="two columns alpha">
<label id="intro_label" for="per_page"><?php echo __('HomePage Introduction*'); ?></label>
</div>
<div class="inputs five columns omega">
<p class="explanation"><?php echo __('Write your homepage introduction here'); ?>.</p>
<div class="input-block">
<?php $tmp = get_option('intro'); ?>
<?php if (empty($tmp)): ?>
<textarea placeholder=""rows="15" cols="50" name="intro" id="intro">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla maximus velit sed felis gravida, et pellentesque libero posuere. Nullam augue mi, lacinia eu mauris iaculis, suscipit hendrerit elit. Ut consectetur nunc eget lorem venenatis, et vehicula nisl vestibulum. Vivamus vel aliquam lectus. Aliquam pulvinar dictum tellus a feugiat. Praesent a eros sed velit suscipit semper eu et orci. Donec elementum tempor sagittis. Duis orci nisl, semper ut erat ac, aliquet commodo purus. Morbi erat massa, dictum quis eleifend at, ornare vitae risus. </textarea>
<?php else: ?>
<textarea placeholder=""rows="15" cols="50" name="intro" id="intro"><?php echo get_option('intro'); ?></textarea>
<?php endif; ?>
</div>
</div>
<div class="two columns alpha">
<label for="per_page"><?php echo __('Social Feeds'); ?></label>
</div>
<div class="inputs five columns omega">
<p class="explanation"><?php echo __('Provide your social feeds here'); ?>.</p>
<div class="input-block">
<div id="twitter_feeds">
<p class="explanation"><?php echo __('<strong>Twitter (You can go to <a target="_blank" href="https://twitter.com/login?lang=en">here</a> -> Settings and privacy -> Widgets -> Create new)</strong>'); ?></p>
<label style="clear: both;margin-right:-45px;">Timeline:</label>
<?php $tmp = get_option('twitter_timeline'); ?>
<?php if (empty($tmp)): ?>
<textarea placeholder=""rows="10" cols="50" name="twitter_timeline"><?php echo '<a class="twitter-timeline" data-width="100%" data-height="220" data-theme="light" data-link-color="#2B7BB9 " href="https://twitter.com/July4CivilWar">Tweets by July4CivilWar</a> <script async src="//platform.twitter.com/widget s.js" charset="utf-8"></script>'; ?> </textarea>
<?php else: ?>
<textarea placeholder=""rows="10" cols="50" name="twitter_timeline"><?php echo get_option('twitter_timeline'); ?></textarea>
<?php endif; ?>
<br>
<label style="clear: both;margin-right:-45px;">Buttons:</label>
<?php $tmp = get_option('twitter_button'); ?>
<?php if (empty($tmp)): ?>
<textarea placeholder=""rows="10" cols="50" name="twitter_button"><?php echo '<a href="https://twitter.com/July4CivilWar" class="twitter-follow-button" data-show-count="false">Follow @July4CivilWar</a><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>'; ?> </textarea>
<?php else: ?>
<textarea placeholder=""rows="10" cols="50" name="twitter_button"><?php echo get_option('twitter_button'); ?></textarea>
<?php endif; ?>
</div>
<div id="fb_feeds">
<br>
<p class="explanation"><?php echo __('<strong>FaceBook (You can go to <a target="_blank" href="https://developers.facebook.com/docs/plugins">here</a> for help)</strong>'); ?></p>
<label style="clear: both;margin-right:-45px;">Facebook:</label>
<?php $tmp = get_option('fb'); ?>
<?php if (empty($tmp)): ?>
<textarea placeholder=""rows="12" cols="50" name="fb"><?php echo '<div class="fb-page" data-href="https://www.facebook.com/July4CivilWar/" data-tabs="timeline" data-width="500" data-height="220" data-small-header="true" data-adapt-container-width="true" data-hide-cover="false" data-show-facepile="false"><blockquote cite="https://www.facebook.com/July4CivilWar/" class="fb-xfbml-parse-ignore"><a href="https://www.facebook.com/July4CivilWar/">Mapping the Fourth of July: Exploring Independence in the Civil War Era</a></blockquote></div>'; ?> </textarea>
<?php else: ?>
<textarea placeholder=""rows="12" cols="50" name="fb"><?php echo get_option('fb'); ?></textarea>
<?php endif; ?>
</div>
</div>
</div>
<div class="two columns alpha">
<label for="per_page"><?php echo __('Introduction Page'); ?></label>
</div>
<div class="inputs five columns omega">
<div class="input-block">
<p class="explanation"><?php echo __('Choose to show or not show the about page by check or uncheck'); ?></p>
<input type="checkbox" name="active" id="active" value="no">
<span class="explanation"> Active</span>
</div>
</div>
<div class="two columns alpha">
<label id="theme_label" for="per_page"><?php echo __('Themes*'); ?></label>
</div>
<div class="inputs five columns omega">
<div id="connect">
<p class="explanation"><?php echo __('We need at least <b>one</b> theme to make sure the connect task working'); ?>.</p>
<label style="clear: both;margin-right:-45px;">Subject :</label>
<input style="width: auto;" type="text" class="textinput" name="concept_place" />
<label style="clear: both;margin-right:-45px;">Definition :</label>
<input style="width: auto;" type="text" class="textinput" name="def_place" />
<input type="button" id="add_button" value="add" />
<input type="hidden" name="encoded_concept" id="encoded_concept"/>
<input type="hidden" name="encoded_def" id="encoded_def"/>
</div>
<br>
<div id="c_table">
<?php $tmp = get_option('encoded_concept'); ?>
<?php if(!empty($tmp)): ?>
<table style="width:300px">
<tr>
<th>Concepts</th>
<th></th>
</tr>
</table>
<?php endif; ?>
</div>
</div>
<!-- First sponsor -->
<div class="two columns alpha">
<label for="per_page"><?php echo __('Sponsor1'); ?></label>
</div>
<div class="inputs five columns omega">
<p class="explanation"><?php echo __('Upload your sponsor here (Please use the full url including http)'); ?>.</p>
<?php $tmp = get_option('delete_sponsor1'); ?>
<?php if (empty($tmp) || $tmp == "no"): ?>
<div id="spon1">
<p class="explanation"><?php echo __('Your current sponsor 1'); ?>.</p>
<img src="<?php echo getFullOmekaUrl(); ?>../plugins/Incite/views/shared/images/customized_sponsors1.png" height="100" width="400">
<input type="button" id="delete_button1" value="delete" />
<br>
<br>
</div>
<?php endif; ?>
<?php $tmp = get_option('delete_sponsor1'); ?>
<input type="hidden" name="delete_sponsor1" id="delete_sponsor1" value="<?php echo (empty($tmp) || $tmp == 'no')? 'no' : 'yes' ?>"/>
<div class="input-block">
<label style="clear: both;margin-right:-75px;">Link: </label>
<input style="width: auto;" type="text" class="textinput" name="sponsorlink1" value="<?php echo get_option('sponsorlink1'); ?>" id="sponsorlink1" />
<input type="file" class="textinput" name="sponsor1" accept=".png" id="sponsor1" />
</div>
</div>
<!-- Second sponsor -->
<div class="two columns alpha">
<label for="per_page"><?php echo __('Sponsor2'); ?></label>
</div>
<div class="inputs five columns omega">
<p class="explanation"><?php echo __('Upload your sponsor here (Please use the full url including http)'); ?>.</p>
<?php $tmp = get_option('delete_sponsor2'); ?>
<?php if (empty($tmp) || $tmp == "no"): ?>
<div id="spon2">
<p class="explanation"><?php echo __('Your current sponsor 2'); ?>.</p>
<img src="<?php echo getFullOmekaUrl(); ?>../plugins/Incite/views/shared/images/customized_sponsors1.png" height="100" width="400">
<input type="button" id="delete_button2" value="delete" />
<br>
<br>
</div>
<?php endif; ?>
<?php $tmp = get_option('delete_sponsor2') ; ?>
<input type="hidden" name="delete_sponsor2" id="delete_sponsor2" value="<?php echo (empty($tmp) || $tmp == 'no')? 'no' : 'yes' ?>"/>
<div class="input-block">
<label style="clear: both;margin-right:-75px;">Link: </label>
<input style="width: auto;" type="text" class="textinput" name="sponsorlink2" value="<?php echo get_option('sponsorlink2'); ?>" id="sponsorlink2" />
<input type="file" class="textinput" name="sponsor2" accept=".png" id="sponsor2" />
</div>
</div>
<!-- Third sponsor -->
<div class="two columns alpha">
<label for="per_page"><?php echo __('Sponsor3'); ?></label>
</div>
<div class="inputs five columns omega">
<p class="explanation"><?php echo __('Upload your sponsor here (Please use the full url including http)'); ?>.</p>
<?php $tmp = get_option('delete_sponsor3'); ?>
<?php if (empty($tmp) || $tmp == "no"): ?>
<div id="spon3">
<p class="explanation"><?php echo __('Your current sponsor 3'); ?>.</p>
<img src="<?php echo getFullOmekaUrl(); ?>../plugins/Incite/views/shared/images/customized_sponsors1.png" height="100" width="400">
<input type="button" id="delete_button3" value="delete" />
<br>
<br>
</div>
<?php endif; ?>
<?php $tmp = get_option('delete_sponsor3'); ?>
<input type="hidden" name="delete_sponsor3" id="delete_sponsor3" value="<?php echo (empty($tmp) || $tmp == 'no')? 'no' : 'yes' ?>"/>
<div class="input-block">
<label style="clear: both;margin-right:-75px;">Link: </label>
<input style="width: auto;" type="text" class="textinput" name="sponsorlink3" value="<?php echo get_option('sponsorlink3'); ?>" id="sponsorlink3" />
<input type="file" class="textinput" name="sponsor3" accept=".png" id="sponsor3" />
</div>
</div>
<!-- Fourth sponsor -->
<div class="two columns alpha">
<label for="per_page"><?php echo __('Sponsor4'); ?></label>
</div>
<div class="inputs five columns omega">
<p class="explanation"><?php echo __('Upload your sponsor here (Please use the full url including http)'); ?>.</p>
<?php $tmp = get_option('delete_sponsor4'); ?>
<?php if (empty($tmp) || $tmp == "no"): ?>
<div id="spon4">
<p class="explanation"><?php echo __('Your current sponsor 4'); ?>.</p>
<img src="<?php echo getFullOmekaUrl(); ?>../plugins/Incite/views/shared/images/customized_sponsors1.png" height="100" width="400">
<input type="button" id="delete_button4" value="delete" />
<br>
<br>
</div>
<?php endif; ?>
<?php $tmp = get_option('delete_sponsor4'); ?>
<input type="hidden" name="delete_sponsor4" id="delete_sponsor4" value="<?php echo (empty($tmp) || $tmp == 'no')? 'no' : 'yes' ?>"/>
<div class="input-block">
<label style="clear: both;margin-right:-75px;">Link: </label>
<input style="width: auto;" type="text" class="textinput" name="sponsorlink4" value="<?php echo get_option('sponsorlink4'); ?>" id="sponsorlink4" />
<input type="file" class="textinput" name="sponsor4" accept=".png" id="sponsor4" />
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script>
var concept_arr= [];
<?php $tmp = get_option('encoded_concept'); ?>
<?php if(!empty($tmp)): ?>
concept_arr = <?php echo get_option('encoded_concept'); ?>;
$("#encoded_concept").val(JSON.stringify(concept_arr));
<?php endif; ?>
var def_arr = [];
<?php $tmp = get_option('encoded_concept'); ?>
<?php if(!empty($tmp)): ?>
def_arr = <?php echo get_option('encoded_def'); ?>;
$("#encoded_def").val(JSON.stringify(def_arr));
<?php endif; ?>
$(document ).ready(function() {
//set up the input length
$("input[type = 'text']").width($("textarea").width());
activeCheck();
getConcept();
$('[data-toggle="popover"]').popover();
$("#install_plugin").click(function(event){
if ($("#sponsor1").val() != "") {
$("#delete_sponsor1").val('no');
}
if ($("#sponsor2").val() != "") {
$("#delete_sponsor2").val('no');
}
if ($("#sponsor3").val() != "") {
$("#delete_sponsor3").val('no');
}
if ($("#sponsor4").val() != "") {
$("#delete_sponsor4").val('no');
}
var num_of_delete = 0;
jQuery.each($(".delete_button"), function() {
num_of_delete += (($(this).val() == "undo") ? 1 : 0);
});
if ($("#title").val() != "" && $("#intro").val() != "" && ($("#c_table td").length != 0 && num_of_delete < $("#c_table tr").length - 1) && ($("#logo").val() != "" || <?php echo json_encode(get_option('logo_set')); ?> == "true")) {
//submit button working fine
}
else {
event.preventDefault();
var error_message = "";
if ($("#logo").val() == "" && (<?php echo json_encode(get_option('logo_set')); ?> == "false" || <?php echo json_encode(get_option('logo_set')); ?> == null)) {
error_message += "*You have not set the logo</br>";
$("#logo_label").css("color", "red");
}
if ($("#title").val() == "") {
error_message += "*Tagline cannot empty </br>";
$("#title_label").css("color", "red");
}
if ($("#intro").val() == "") {
error_message += "*Introduction cannot be empty</br>";
$("#intro_label").css("color", "red");
}
if ($("#c_table td").length == 0 || num_of_delete == $("#c_table tr").length - 1) {
error_message += "*We need at least one theme</br>";
$("#theme_label").css("color", "red");
}
if ($("#alert").length == 0)
$("#alertbox").append('<p id="alert" style = "border-style: solid; color: red;">' + error_message + '</div>');
else {
$("#alert").remove();
$("#alertbox").append('<p id="alert" style = "border-style: solid; color: red;">' + error_message + '</div>');
}
window.scrollTo(0, 0);
}
});
del_sponsor_check();
$("#add_button").prop("disabled",true);
$("#active").click(function(){
if ($('#active:checkbox:checked').length > 0) {
$("#active").val("yes");
}
else {
$("#active").val("no");
}
});
$("input[name = 'concept_place']").change(function() {
if ($("input[name = 'concept_place']").val() != "" && $("input[name = 'def_place']").val() != "") {
$("#add_button").prop("disabled",false);
}
if ($("input[name = 'concept_place']").val() == "" || $("input[name = 'def_place']").val() == "") {
$("#add_button").prop("disabled",true);
}
});
$("input[name = 'def_place']").change(function() {
if ($("input[name = 'concept_place']").val() != "" && $("input[name = 'def_place']").val() != "") {
$("#add_button").prop("disabled",false);
}
if ($("input[name = 'concept_place']").val() == "" || $("input[name = 'def_place']").val() == "") {
$("#add_button").prop("disabled",true);
}
});
$("#add_button" ).click(function() {
if ($("#c_table table").length == 0) {
$("#c_table").append('<table style="width:300px"><tr><th>Concepts</th><th></th></tr></table>');
}
var concept = $("input[name = 'concept_place']").val();
var def = $("input[name = 'def_place']").val();
concept_arr.push(concept);
def_arr.push(def);
$("input[name = 'concept_place']").val("");
$("input[name = 'def_place']").val("");
var concept_element = "<input type='hidden' value='" + concept + "' name='concept[]' />";
var def_element = "<input type='hidden' value='" + def + "' name='def[]' />";
var trash_button = '<td><input type="button" class="delete_button" value="delete" /></td>';
var popover = '<td><a tabindex="0" data-toggle="popover" data-trigger="focus" data-placement="left" title="Defination" data-content="' + def + '">' + concept + '</a>'
$("#c_table table").append("<tr>" + popover + concept_element + def_element + "</td>" + trash_button + "</tr>");
$("#encoded_concept").val(JSON.stringify(concept_arr));
$("#encoded_def").val(JSON.stringify(def_arr));
$("#add_button").prop("disabled",true);
$('[data-toggle="popover"]').popover();
});
$("#c_table").on("mouseover", "td", function(){
$($(this).find(".defs")).css("display", "inline");
$($(this).find(".defs")).css("background", "#fffAF0");
});
$("#c_table").on("mouseleave", "td", function(){
$($(this).find(".defs")).css("display", "none");
$($(this).find(".defs")).css("background", "#fff");
});
$(document).on("click", ".delete_button", function(){
if ($(this).val() == "delete") {
var first_td = $($($($($(this).parent()).parent()).children().first())[0]);
var subject = first_td.text();
var definition = first_td.find('a').attr('data-content');
removeConcept(subject);
var delete_subject_element = "<input type='hidden' value='" + subject + "' name='del_concept[]' />";
var delete_definition_element = "<input type='hidden' value='" + definition + "' name='del_def[]' />";
first_td.find('a').wrap("<strike></strike>");
first_td.append(delete_subject_element).append(delete_definition_element);
$(this).val("undo");
}
else {
var first_td = $($($($($(this).parent()).parent()).children().first())[0]);
var subject = first_td.text();
var definition = first_td.find('a').attr('data-content');
concept_arr.push(subject);
def_arr.push(definition);
first_td.find('a').unwrap();
first_td.find('input').remove();
$(this).val("delete");
}
$("#encoded_concept").val(JSON.stringify(concept_arr));
$("#encoded_def").val(JSON.stringify(def_arr));
});
});
function getConcept() {
var con_arr;
<?php $tmp = get_option('encoded_concept'); ?>
<?php if(!empty($tmp)): ?>
con_arr = <?php echo get_option('encoded_concept'); ?>;
<?php endif; ?>
var def_arr;
<?php $tmp = get_option('encoded_def'); ?>
<?php if(!empty($tmp)): ?>
def_arr = <?php echo get_option('encoded_def'); ?>;
<?php endif; ?>
<?php $tmp = get_option('encoded_concept'); ?>
<?php if(!empty($tmp)): ?>
for (var i = 0; i < con_arr.length; i++) {
if (con_arr[i] != null) {
var trash_button = '<td><input type="button" class="delete_button" value="delete" /></td>';
var popover = '<td><a tabindex="0" data-toggle="popover" title="Definition" data-trigger="focus" data-placement="left" data-content="' + def_arr[i] + '">' + con_arr[i] + '</a></td>'
$("#c_table table").append("<tr>" + popover + trash_button + "</tr>");
}
}
<?php endif; ?>
}
function removeConcept(concept) {
var index = -1;
for (var i = 0; i < concept_arr.length; i++) {
if (concept_arr[i] == concept){
delete concept_arr[i];
index = i;
}
}
if (index != -1) {
delete def_arr[index];
}
}
function activeCheck () {
var checked = <?php echo json_encode(get_option('active')); ?>;
if (checked == "yes")
$('#active').prop('checked', true);
else
$('#active').prop('checked', false);
}
function del_sponsor_check() {
$("#delete_button1").click(function(){
$("#delete_sponsor1").val("yes");
$("#spon1").remove();
$("#sponsorlink1").val("");
});
$("#delete_button2").click(function(){
$("#delete_sponsor2").val("yes");
$("#spon2").remove();
$("#sponsorlink2").val("");
});
$("#delete_button3").click(function(){
$("#delete_sponsor3").val("yes");
$("#spon3").remove();
$("#sponsorlink3").val("");
});
$("#delete_button4").click(function(){
$("#delete_sponsor4").val("yes");
$("#spon4").remove();
$("#sponsorlink4").val("");
});
}
</script>
<style>
.popover-content {
word-break: break-all;
}
table tr td {
padding: 5px 5px;
}
</style>