instructions misplacing
[old-projects.git] / philter / philter / include / form_filter.inc.php
CommitLineData
772509f3 1<?php
98b878f3
PH
2if(count($_POST)) { // a FORM has been submitted
3 if(!empty($_POST['order']['action'])) // FORM order
4 if($_POST['order']['action']=='submit') {
5 foreach($filter->rules as $id=>$rule)
6 if(isset($_POST['order'][$id]))
7 $filter->rules[$id]->move_to($_POST['order'][$id], $filter->uid, $id);
8 uasort($filter->rules, 'rule_cmp');
9 } elseif($_POST['order']['action']=='delete' && !empty($_POST['order']['select'])) {
10 $filter->delete_rule($_POST['order']['select']);
11 $_POST['order']['select'] = min(count($filter->rules),$_POST['order']['select']);
12 }
13 if(!empty($_POST['rule']))
14 if(!$filter->handle_form())
15 echo "<p style=\"color:red;\">".$philter->error()."</p>\n";
16}
772509f3
PH
17
18require("include/js_factory.inc.php");
19?>
edb68514
PH
20<div class="rubrique"><?php i18n('filter_sync'); ?></div>
21<?php i18n('filter_sync_txt') ?>
22<form action="<?php echo $_SERVER['REQUEST_URI'] ?>" method="post">
23<center>
24 <input type="submit" value='<?php i18n('filter_valid') ?>' name="filter_valid" />
25 <input type="submit" value='<?php i18n('filter_cancel') ?>' name="filter_cancel" />
26</center>
27</form>
28<br />
b19786ca
PH
29<div class="rubrique"><?php i18n('filter_title'); ?></div>
30<?php
31i18n('filter_help');
32?>
33<table width="95%" cellspacing="0" cellpadding="2" align="center">
34<tr><td width="25%" valign="top">
35 <form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post" id="order" name="order" onsubmit="return false;">
36 <table class="bicol" width="100%" cellpadding="1" cellspacing="1">
37 <tr><th><?php i18n('filter_list_title');?></th></tr>
38 <tr><td>
39<?php
40 foreach($filter->rules as $id=>$rule)
41 if($id)
42 echo "<input type=\"hidden\" id=\"order$id\" name=\"order[$id]\" value=\"{$rule->rank}\" />\n";
43
44 $presel = (isset($_POST['rule']['id']) ? $_POST['rule']['id']
45 : (isset($_POST['order']['select']) ? $_POST['order']['select'] : 0));
46
47 echo "<select size=\"16\" style=\"width:100%;\" id=\"orderSelect\" name=\"order[select]\" onchange=\"createRuleForm()\">\n";
48 echo "<option value=\"0\" ".($presel ? "" : " selected=\"selected\"").">";
49 i18n('new_rule');
50 echo "</option>\n";
51
52 foreach($filter->rules as $id=>$rule)
53 if($id)
54 echo "<option value=\"$id\""
55 .($presel==$id ? " selected=\"selected\"":"")
56 .">{$rule->name}</option>\n";
57?>
58 </select>
59 </td></tr><tr><td>
60 <input type="submit" value="<?php i18n('up');?>" name="order[up]" onclick="order_up();" />
61 <input type="submit" value="<?php i18n('dn');?>" name="order[dn]" onclick="order_dn();" /><br />
62 <input type="submit" value="<?php i18n('del');?>" name="order[delete]" onclick="order_submit(this)" />
63 <input type="submit" value="<?php i18n('submit');?>" name="order[submit]" onclick="order_submit(this)" />
64 <input type="hidden" value="" name="order[action]" />
65 </td></tr>
66 </table>
67 </form>
68 </td>
69 <td valign="top">
70 <form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post" id="rule" name="rule" onsubmit="return false;">
71 <table width="100%" class="bicol" cellspacing="1" cellpadding="1">
72 <tr><th><?php i18n('rule_name'); ?>
73 </th></tr><tr><td>
74 <input type="text" value="" id="ruleName" name="rule[name]" style="width: 100%;"
75 onfocus="text_onfocus(this,'<?php i18n('new_rule');?>')"
76 onblur="text_onblur(this,'<?php i18n('new_rule');?>')" />
77 </td></tr>
78 <tr class="impair"><th><?php i18n('filter_rule_conf');?>
79 </th></tr><tr class="impair"><td>
80 <input type="radio" value="1" id="ruleAll1" name="rule[all]" /><?php i18n('all_matches');?>
81 <input type="radio" value="0" id="ruleAll0" name="rule[all]" /><?php i18n('one_match');?>
82 <br />
83 <input type="checkbox" checked="checked" id="ruleBlock" name="rule[block]" />
84 <?php i18n('blocking_rule');?>
85 </td></tr><tr class="impair"><th><?php i18n('filter_matches_list');?>
86 </th></tr><tr class="impair"><td id="matchesRow">
87 </td></tr><tr class="impair"><th><?php i18n('filter_actions_list');?>
88 </th></tr><tr class="impair"><td id="actionsRow">
89 </td></tr><tr class="impair"><td>
90 <input type="hidden" value="0" id="ruleId" name="rule[id]" />
91 <input type="submit" value="<?php i18n('new_match');?>" name="rule[new_match]" onclick="newMatch() "/>
92 <input type="submit" value="<?php i18n('new_action');?>" name="rule[new_action]" onclick="newAction()" />
93 <input type="submit" value="<?php i18n('submit');?>" name="rule[submit]" onclick="this.form.submit()" />
94 </td></tr>
95 </table>
96 </form>
97 </td>
98</tr>
99</table>
61783204
PH
100<?php
101i18n('filter_help2');
102?>
103
b19786ca
PH
104<script type="text/javascript">
105 createRuleForm();
106</script>