87e9262001-06-22Martin Nilsson // This file is part of Roxen Search // Copyright © 2000,2001 Roxen IS. All rights reserved.
5f4e122000-05-15Martin Nilsson //
55928b2003-01-15Anders Johansson // $Id: module.pmod,v 1.17 2003/01/15 13:09:24 anders Exp $
5f4e122000-05-15Martin Nilsson 
9ad9b72001-06-23Johan Schön private mapping filter_mimetypes; private multiset filter_fields;
ca4c382001-05-17Johan Schön 
55928b2003-01-15Anders Johansson program search_filter;
ca4c382001-05-17Johan Schön private void get_filters()
7ec58b2000-10-26Johan Schön {
55928b2003-01-15Anders Johansson  if (!search_filter) search_filter = master()->resolv("Search.Filter");
9ad9b72001-06-23Johan Schön  filter_mimetypes=([]); filter_fields=(<>);
55928b2003-01-15Anders Johansson  foreach(values(search_filter), object filter)
9ad9b72001-06-23Johan Schön  {
ca4c382001-05-17Johan Schön  foreach(filter->contenttypes || ({ }), string mime)
9ad9b72001-06-23Johan Schön  filter_mimetypes[mime]=filter; foreach(filter->fields || ({ }), string field) filter_fields[field]=1; }
5f4e122000-05-15Martin Nilsson }
55928b2003-01-15Anders Johansson object get_filter(string mime_type)
7ec58b2000-10-26Johan Schön {
9ad9b72001-06-23Johan Schön  if(!filter_mimetypes)
ca4c382001-05-17Johan Schön  get_filters();
9ad9b72001-06-23Johan Schön  if(!filter_mimetypes[mime_type]) return 0; return filter_mimetypes[mime_type];
5f4e122000-05-15Martin Nilsson }
55928b2003-01-15Anders Johansson mapping(string:object) get_filter_mime_types()
7ec58b2000-10-26Johan Schön {
9ad9b72001-06-23Johan Schön  if(!filter_mimetypes)
ca4c382001-05-17Johan Schön  get_filters();
9ad9b72001-06-23Johan Schön  return filter_mimetypes;
5f4e122000-05-15Martin Nilsson }
9ad9b72001-06-23Johan Schön array(string) get_filter_fields() { if(!filter_fields) get_filters(); return indices(filter_fields);
6b3def2000-10-27Martin Nilsson }