eb01b42010-10-26Martin Stjernholm #pike __REAL_VERSION__
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  {
ce807f2016-02-02Martin Nilsson  if( !filter->contenttypes ) continue; 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 }
c63b802016-02-02Martin Nilsson //! @decl Search.Filer.Base get_filter(string mime_type) //! //! Returns the appropriate filter object for the given mime //! type. This will be one of the objects in @[Search.Filter].
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  return filter_mimetypes[mime_type];
5f4e122000-05-15Martin Nilsson }
c63b802016-02-02Martin Nilsson //! @decl mapping(string:Search.Filter.Base) get_filter_mime_types() //! //! Returns a mapping from mime-type to filter objects. The filter //! objects are from @[Search.Filter].
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 }
c63b802016-02-02Martin Nilsson //! Returns an array of field types supported by the available set of //! media plugins.
9ad9b72001-06-23Johan Schön array(string) get_filter_fields() { if(!filter_fields) get_filters(); return indices(filter_fields);
6b3def2000-10-27Martin Nilsson }