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