| 1 | <?php |
| 2 | /******************************************************************************** |
| 3 | * include/plugin_custheader.inc.php : The class for Custom Header Based Match |
| 4 | * --------------------------------- |
| 5 | * |
| 6 | * This file is part of the philter distribution |
| 7 | * Copyright: See COPYING files that comes with this distribution |
| 8 | ********************************************************************************/ |
| 9 | |
| 10 | class CustHdrPlugin extends MatchPlugin { |
| 11 | function HdrPlugin($glob) { $this->MatchPlugin(false); } |
| 12 | function rtti() { return 3; } |
| 13 | function name() { return _i18n('3_cust_hdr'); } |
| 14 | |
| 15 | function to_js() { |
| 16 | return |
| 17 | "function(Node, data) { |
| 18 | var i,j; |
| 19 | var sel = 0; |
| 20 | |
| 21 | Node.appendChild(document.createTextNode(' ')); |
| 22 | var txt_i = document.createElement('input'); |
| 23 | txt_i.setAttribute('type','text'); |
| 24 | txt_i.setAttribute('name', Node.name+'[1]'); |
| 25 | txt_i.setAttribute('value', (data[1] ? data[1] :'') ); |
| 26 | Node.appendChild(txt_i); |
| 27 | |
| 28 | Node.appendChild(document.createTextNode(' ')); |
| 29 | var op_s = document.createElement('select'); |
| 30 | op_s.setAttribute('name', Node.name+'[2]'); |
| 31 | Node.appendChild(op_s); |
| 32 | |
| 33 | op_s.options[0] = new Option('"._i18n('3_contains')."',0,false,data[2]==0); |
| 34 | op_s.options[1] = new Option('"._i18n('3_not_contains')."',1,false,data[2]==1); |
| 35 | op_s.options[2] = new Option(' = ',2,false,data[2]==2); |
| 36 | op_s.options[3] = new Option(' != ',3,false,data[2]==3); |
| 37 | op_s.selectIndex = data[2]; |
| 38 | |
| 39 | Node.appendChild(document.createTextNode(' ')); |
| 40 | var txt_i = document.createElement('input'); |
| 41 | txt_i.setAttribute('type','text'); |
| 42 | txt_i.setAttribute('name', Node.name+'[3]'); |
| 43 | txt_i.setAttribute('value', (data[3] ? data[3] : '') ); |
| 44 | Node.appendChild(txt_i); |
| 45 | }"; |
| 46 | } |
| 47 | |
| 48 | function to_string($_data) { |
| 49 | $res = trim($_data[1]).':'; |
| 50 | switch($_data[2]) { |
| 51 | case 0: $res = "(/^$res.*{$_data[3]}/:h)"; break; |
| 52 | case 1: $res = "!(/$res.*{$_data[3]}/:h)"; break; |
| 53 | case 2: $res = "(/$res {$_data[3]}$/:h)"; break; |
| 54 | case 3: $res = "!(/$res {$_data[3]}$/:h)"; break; |
| 55 | } |
| 56 | return $res; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | /******************************************************************************** |
| 61 | * $Id$ |
| 62 | * vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 textwidth=100: |
| 63 | ********************************************************************************/ |
| 64 | ?> |