-
Notifications
You must be signed in to change notification settings - Fork 1
/
editfilter.inc.php
103 lines (87 loc) · 3.74 KB
/
editfilter.inc.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
<?php
include "includes/form-messages.inc.php";
/*
* If this page is rendered without an result variable
* available, just create one ourselves.
*/
if (!isset($result)) {
$result = new Dto_FormResult('notsubmitted');
} # if
if ((isset($lastformaction) && ($lastformaction == 'exportfilters'))) {
$this->sendContentTypeHeader('xml');
Header('Content-Disposition: attachment; filename="spotwebfilters.xml"');
echo $result->getData('filters');
return ;
} # if
if ((isset($lastformaction) && ($lastformaction == 'importfilters'))) {
if ($result->isSuccess()) {
$tplHelper->redirect($http_referer);
} # if
} # if
/*
* Render the JSON or the form
*/
if (showResults($result)) {
return ;
} # if
/*
* Retrieve a list of icons available
*/
$filterIcons = $tplHelper->getFilterIcons();
/*
* If the user did not submit the form yet, make
* sure we add some data to the template
*/
if (!$result->isSubmitted()) {
# Determine whether this an edit of an existing filter or adding a new one
$isNew = (isset($data['isnew']));
# Retrieve the requested filter
if ((!$isNew) && (isset($data['filterid']))) {
$filter = $tplHelper->getUserFilter($data['filterid']);
} else {
$filter = array('id' => 9999, 'title' => '', 'icon' => '');
} # if
?>
<!-- Naam van filter wijzigen of nieuwe filter toevoegen -->
<fieldset>
<form class="editfilterform" name="editfilterform" action="<?php echo $tplHelper->makeEditFilterAction(); ?>" method="post">
<input type="hidden" name="editfilterform[xsrfid]" value="<?php echo $tplHelper->generateXsrfCookie('editfilterform'); ?>">
<?php if (!$isNew) { ?>
<input type="hidden" name="filterid" value="<?php echo (int) $filter['id']; ?>">
<?php } else { ?>
<input type="hidden" name="filterid" value="9999">
<input type="hidden" name="editfilterform[tree]" value="<?php echo (isset($search['tree']) ? htmlspecialchars($search['tree'], ENT_QUOTES, "UTF-8") : ""); ?>" />
<input type="hidden" name="editfilterform[valuelist]" value="<?php echo htmlspecialchars(implode('&', array_map('urlencode', (isset($search['value']) ?$search['value'] : array()) )), ENT_QUOTES, "UTF-8"); ?>" />
<input type="hidden" name="editfilterform[sorton]" value="<?php echo htmlspecialchars($sortby, ENT_QUOTES, "UTF-8"); ?>" />
<input type="hidden" name="editfilterform[sortorder]" value="<?php echo htmlspecialchars($sortdir, ENT_QUOTES, "UTF-8"); ?>" />
<?php } ?>
<dt><label for="editfilterform[title]"><?php echo _('Name'); ?></label></dt>
<dd>
<input type="text" name="editfilterform[title]" value="<?php echo htmlspecialchars($filter['title']); ?>" />
</dd>
<dt><label for="editfilterform[icon]"><?php echo _('Icon'); ?></label></dt>
<dd>
<select name="editfilterform[icon]">
<?php
foreach($filterIcons as $icon => $desc) {
echo "<option " . ($filter['icon'] == $icon ? 'selected="selected"' : '') . "value='" . $icon . "'>" . $desc . "</option>";
} # foreach
?>
</select>
</dd>
<dt><label for="editfilterform[enablenotify]"><?php echo _('Notify me when this filter has new spots?'); ?></label></dt>
<dd>
<input type="checkbox" name="editfilterform[enablenotify]" <?php if ((isset($filter['enablenotify'])) && ($filter['enablenotify'])) { echo 'checked="checked" '; } ?> />
</dd>
<dd>
<?php if ($isNew) { ?>
<input class="smallGreyButton" type="submit" name="editfilterform[submitaddfilter]" value="<?php echo _('Add'); ?>">
<?php } else { ?>
<input class="smallGreyButton" type="submit" name="editfilterform[submitchangefilter]" value="<?php echo _('Change'); ?>">
<input class="smallGreyButton" type="submit" name="editfilterform[submitremovefilter]" value="<?php echo _('Delete'); ?>">
<?php } ?>
</dd>
</form>
</fieldset>
<?php
} # if not only xml