<?xml version="1.0" encoding="utf-8"?>

<py:cocktail.html.Form
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:py="http://www.whads.com/ns/cocktail/templates"
    py:name_prefix="filter_"
    py:required_marks="${False}"
    py:generate_groups="${False}">
    
    <?py-class
    def create_language_display(self, obj, member):
        
        display = loader.new("cocktail.html.DropdownSelector")
        display.empty_option_displayed = not member.required
        display.empty_label = translations("cocktail.html.UserFilterEntry any language")

        @refine(display)
        def get_item_label(self, language):
            return translations("translated into", lang = language)

        return display

    def create_operator_display(self, obj, member):
        
        display = loader.new("cocktail.html.DropdownSelector")
        display.empty_option_displayed = False

        @refine(display)
        def get_item_label(self, item):
            return translations("cocktail.html.UserFilterEntry operator " + item)

        return display

    def get_member_supplied_display(self, user_filter, member):
        
        control = member.search_control
        
        if control is None and member.name in ("value", "values"):
            
            user_filter_member = getattr(user_filter, "member", None)
            
            if user_filter_member:
                control = user_filter_member.search_control

            if control is None:
                control = user_filter.search_control

        return control
    ?>

    <?py
    self.set_member_label("language", "")
    self.set_member_label("operator", "")
    self.set_member_label("value", "")
    ?>

</py:cocktail.html.Form>
