to_string basis
[old-projects.git] / philter / philter / include / plugin_header.inc.php
index 9771eaa..5112b9e 100644 (file)
@@ -13,8 +13,11 @@ class HdrPlugin extends MatchPlugin {
     function name() { return _i18n('2_hdr'); }
 
     function to_js() {
-        return
-"function(Node, data) {
+        $_2_dests = _i18n('2_dests');
+        $_2_contains = _i18n('2_contains');
+        $_2_not_contains = _i18n('2_not_contains');
+        return <<<EOF
+function(Node, data) {
     var i,j;
     var sel = 0;
     
@@ -24,7 +27,7 @@ class HdrPlugin extends MatchPlugin {
     hdr_s.setAttribute('name', Node.name+'[1]');
     Node.appendChild(hdr_s);
 
-    hdr_s.options[0] = new Option('<"._i18n('2_dests').">',0,false,data[1]==0);
+    hdr_s.options[0] = new Option('<$_2_dests>',0,false,data[1]==0);
     hdr_s.options[1] = new Option('Subject:',1,false,data[1]==1);
     hdr_s.options[2] = new Option('From:',2,false,data[1]==2);
     hdr_s.options[3] = new Option('To:',3,false,data[1]==3);
@@ -33,28 +36,48 @@ class HdrPlugin extends MatchPlugin {
     hdr_s.options[6] = new Option('Organization:',6,false,data[1]==6);
     hdr_s.options[7] = new Option('List-Id:',7,false,data[1]==7);
     hdr_s.options[8] = new Option('X-Mailing-List:',8,false,data[1]==8);
-    hdr_s.options[9] = new Option('<"._i18n('2_daemon').">',9,false,data[1]==9);
     hdr_s.selectIndex = data[1];
     
+    Node.appendChild(document.createTextNode(' '));
     var op_s = document.createElement('select');
     op_s.setAttribute('name', Node.name+'[2]');
     Node.appendChild(op_s);
 
-    op_s.options[0] = new Option('"._i18n('2_contains')."',0,false,data[2]==0);
-    op_s.options[1] = new Option('"._i18n('2_not_contains')."',1,false,data[2]==1);
+    op_s.options[0] = new Option('$_2_contains',0,false,data[2]==0);
+    op_s.options[1] = new Option('$_2_not_contains',1,false,data[2]==1);
     op_s.options[2] = new Option(' = ',2,false,data[2]==2);
     op_s.options[3] = new Option(' != ',3,false,data[2]==3);
-    op_s.options[4] = new Option(' >= ',4,false,data[2]==4);
-    op_s.options[5] = new Option(' > ',5,false,data[2]==5);
-    op_s.options[6] = new Option(' <= ',6,false,data[2]==6);
-    op_s.options[7] = new Option(' < ',7,false,data[2]==7);
     op_s.selectIndex = data[2];
 
+    Node.appendChild(document.createTextNode(' '));
     var txt_i = document.createElement('input');
     txt_i.setAttribute('type','text');
     txt_i.setAttribute('name', Node.name+'[3]');
+    txt_i.setAttribute('value', (data[3] ? data[3] : '') );
     Node.appendChild(txt_i);
-}";
+}
+EOF;
+    }
+    
+    function to_string($_data) {
+        switch($_data[1]) {
+            case 0: $res = '^TO';                 break;
+            case 1: $res = '^Subject:';           break;
+            case 2: $res = '^From:';              break;
+            case 3: $res = '^To:';                break;
+            case 4: $res = '^Cc:';                break;
+            case 5: $res = '^Reply-To:';          break;
+            case 6: $res = '^Organization:';      break;
+            case 7: $res = '^List-Id:';           break;
+            case 8: $res = '^X-Mailing-List:';    break;
+        }
+        switch($_data[2]) {
+            case 0: $res = "* $res.*{$_data[3]}\n";    break;
+            case 1: $res = "* !$res.*{$_data[3]}\n";   break;
+            case 2: $res = "* $res {$_data[3]}$\n";    break;
+            case 3: $res = "* !$res {$_data[3]}$\n";   break;
+        }
+        return $res;
     }
 }