Пример #1
0
    def form_passvars(self, ln=None):
        params = self.form.request.form_args(ln)
        if not params:
            return ''

        return Markup('<div class="hidden">%s</div>') % \
            Markup('').join(tags.hidden(*x) for x in params)
Пример #2
0
    def form_passvars(self, ln=None):
        params = self.form.request.form_args(ln)
        if not params:
            return ''

        return Markup('<div class="hidden">%s</div>') % \
            Markup('').join(tags.hidden(*x) for x in params)
Пример #3
0
def hidden_field(name, value=None, **options):
    """
    Creates a hidden field.

    Takes the same options as text_field
    """
    _update_fa(options, name)
    return tags.hidden(name, value=value, **options)
Пример #4
0
def hidden_field(name, value=None, **options):
    """
    Creates a hidden field.

    Takes the same options as text_field
    """
    _update_fa(options, name)
    return tags.hidden(name, value=value, **options)
Пример #5
0
 def hidden(self, name, value=None, id=None, **attrs):
     """
     Outputs hidden input.
     """
     id = id or name
     # uncomment below to enable unobtrusive validation for hidden fields
     # attrs.update(self.validation_attrs(name))
     return tags.hidden(name, self.value(name, value), id, **attrs)
Пример #6
0
def form(url, method="post", **attrs):
    """Like webhelpers.html.tags.form , but automatically adding
    session_csrf_secret_token for POST. The secret is thus never leaked in GET
    URLs.
    """
    form = insecure_form(url, method, **attrs)
    if method.lower() == 'get':
        return form
    return form + HTML.div(hidden(session_csrf_secret_name, session_csrf_secret_token()), style="display: none;")
Пример #7
0
    def hidden(self, name, value=None, id=NotGiven, **attrs):
        """
        Return a ``hidden`` input tag.
        """
        name = self._get_name(name)
        if value is None:
            value = self.value(name)

        return tags.hidden(name, value, self._get_id(id, name), **attrs)
Пример #8
0
    def hidden(self, name, value=None, id=NotGiven, **attrs):
        """
        Return a ``hidden`` input tag.
        """
        name = self._get_name(name)
        if value is None:
            value = self.value(name)

        return tags.hidden(name,
                           value,
                           self._get_id(id, name),
                           **attrs)
Пример #9
0
    def hidden(self, name, value=None, id=None, **attrs):
        """
        Outputs hidden input.
        """
        if value is None:
            value = self.value(name)

        return tags.hidden(
            name, 
            value, 
            self._get_id(id, name), 
            **attrs
        )
Пример #10
0
    def __call__(self, search_form, **kwargs):
        if not self.template_values:
            return ""

        request = self.request

        _ = lambda x: gettext(x, request)

        passvars = request.passvars
        use_cic = request.dboptions.UseCIC
        search_info = self.search_info
        topic_searches = self.topic_searches
        quick_searches = self.quick_searches
        user = request.user
        cic_user = user and user.cic
        viewdata = request.viewdata.cic
        makeLink = passvars.makeLink

        browse_row_tmpl = """<tr><th class="RevTitleBox" colspan="2">%s</th></tr>
                            <tr><td align="center" colspan="2">%s</td></tr>"""

        browse = []
        browse_org_items = []
        browse_subject_items = []
        browse_org_title = ""
        if search_info.BSrchBrowseByOrg:
            browse_org_title = viewdata.BrowseByOrg or _(
                "Browse by Organization")
            browse.append(browse_row_tmpl % (
                browse_org_title,
                makeAlphaList(True, "browsebyorg.asp", "MenuText", request),
            ))
            browse_org_items = makeAlphaListItems(True, "browsebyorg.asp",
                                                  request)

        if use_cic and viewdata.UseThesaurusView:
            browse.append(browse_row_tmpl % (
                _("Browse by Subject"),
                makeAlphaList(False, "browsebysubj.asp", "MenuText", request),
            ))
            browse_subject_items = makeAlphaListItems(False,
                                                      "browsebysubj.asp",
                                                      request)

        if browse:
            browse = "".join(browse)
        else:
            browse = None

        service_category = None
        service_category_list = None
        if use_cic and viewdata.UseTaxonomyView:
            if cic_user:
                service_category = [
                    (
                        makeLink("servcat.asp"),
                        '<span class="glyphicon glyphicon-th" aria-hidden="true"></span> '
                        + _("Browse by Service Category"),
                    ),
                    (
                        makeLink("tax.asp"),
                        '<span class="glyphicon glyphicon-sort-by-attributes" aria-hidden="true"></span> '
                        + _("Basic Taxonomy Search"),
                    ),
                    (
                        makeLink("taxsrch.asp"),
                        '<span class="glyphicon glyphicon-filter" aria-hidden="true"></span> '
                        + _("Advanced Taxonomy Search"),
                    ),
                ]

                serv_cat_item_tmpl = '<li><a href="%s">%s</a></li>'

                service_category = (
                    '<ul id="service-category-staff" class="nav nav-pills nav-stacked">%s</ul>'
                    % "".join(serv_cat_item_tmpl % x
                              for x in service_category))

                service_category_list = service_category
            else:
                service_category = '{} <a href="{}">{}</a>'.format(
                    viewdata.FindAnOrgBy or
                    _("Find an Organization or Program by type of service:"),
                    makeLink("servcat.asp"),
                    _("Browse by Service Category"),
                )

                serv_cat_link_tmpl = makeLink("servcat.asp",
                                              "TC=TCTC").replace(
                                                  "TCTC", "{1}")
                serv_cat_icon_tmpl = '<i class="fa fa-{}" aria-hidden="true"></i> '
                serv_cat_item_tmpl = ('<li><a href="%s">{0}{2}</a></li>' %
                                      serv_cat_link_tmpl)

                with request.connmgr.get_connection() as conn:
                    service_category_list = conn.execute(
                        "EXEC dbo.sp_TAX_Term_l_CdLvl1").fetchall()

                service_category_list = (
                    '<ul id="service-category-list" class="nav nav-pills nav-stacked">%s</ul>'
                    % "".join(
                        serv_cat_item_tmpl.format(
                            "" if not x.IconFA else serv_cat_icon_tmpl.
                            format(x.IconFA), *x[:-1])
                        for x in service_category_list))

        menu_groups = {}
        for key, group in itertools.groupby(self.menu_items_custom,
                                            lambda x: x.MenuGroup):
            menu_groups[key] = list(group)

        menu_items_custom = [
            encode_link_values(x) for x in menu_groups.get(None, [])
        ]

        Culture = request.language.Culture
        # main menu:
        other_langs = []
        if user or self.menu_items_custom:
            for key, val in viewdata.Cultures.items():
                if key == Culture:
                    continue
                httpvals = {}
                if key != passvars.DefaultCulture:
                    httpvals["Ln"] = key
                other_langs.append(
                    dict(Link=makeLink("~/", httpvals, ("Ln", )), Display=val))

        vol_link = None
        vol_link_text = None
        if (user and request.dboptions.UseVOL and viewdata.VolunteerLink
                and Culture in request.viewdata.vol.Cultures):
            vol_link = makeLink("~/volunteer/")
            vol_link_text = _("Volunteer Menu")

        search_menu_items = []
        change_view = None
        dboptions = request.dboptions

        if user:
            if dboptions.UseCIC and cic_user and user.SavedSearchQuota:
                icon = '<span class="glyphicon glyphicon-floppy-save" aria-hidden="true"></span> '
                search_menu_items.append(
                    (makeLink("savedsearch.asp"), icon + _("Saved Search")))

            if cic_user and not cic_user.LimitedView and dboptions.UseCIC:
                icon = '<span class="glyphicon glyphicon-print" aria-hidden="true"></span> '
                search_menu_items.append(
                    (makeLink("printlist.asp"), icon + _("Print Records")))

            if dboptions.UseCIC and (
                (cic_user.ExportPermission and viewdata.HasExportProfile)
                    or viewdata.HasExcelProfile):
                icon = '<span class="glyphicon glyphicon-export" aria-hidden="true"></span> '
                search_menu_items.append(
                    (makeLink("export.asp"), icon + _("Export")))

            if cic_user.ImportPermission:
                icon = '<span class="glyphicon glyphicon-import" aria-hidden="true"></span> '
                search_menu_items.append((
                    makeLink("import/import.asp", {"DM": const.DM_CIC}),
                    icon + _("Import"),
                ))

            if cic_user.CanUpdatePubs == const.UPDATE_ALL and dboptions.UseCIC:
                icon = (
                    '<span class="glyphicon glyphicon-book" aria-hidden="true"></span> '
                )
                if cic_user.LimitedView:
                    search_menu_items.append((
                        makeLink("publication/edit",
                                 {"PB_ID": cic_user.PB_ID}),
                        icon + _("Publications"),
                    ))
                else:
                    search_menu_items.append(
                        (makeLink("publication"), icon + _("Publications")))

            if cic_user.CanDeleteRecord:
                icon = '<span class="glyphicon glyphicon-remove" aria-hidden="true"></span> '
                search_menu_items.append((makeLink("delete_manage.asp"),
                                          icon + _("Deleted Records")))

            if cic_user.CanViewStats and dboptions.UseCIC:
                icon = '<span class="glyphicon glyphicon-stats" aria-hidden="true"></span> '
                search_menu_items.append(
                    (makeLink("stats.asp"), icon + _("Statistics")))

            makeLinkAdmin = passvars.makeLinkAdmin

            if cic_user.CanManageUsers:
                icon = (
                    '<span class="glyphicon glyphicon-lock" aria-hidden="true"></span> '
                )
                search_menu_items.append(
                    (makeLinkAdmin("users.asp"), icon + _("Manage Users")))

            if cic_user.SuperUser:
                icon = '<span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span> '
                search_menu_items.append((
                    makeLinkAdmin("download.asp", dict(DM=const.DM_CIC)),
                    icon + _("Download"),
                ))
                icon = '<span class="glyphicon glyphicon-wrench" aria-hidden="true"></span> '
                search_menu_items.append(
                    (makeLinkAdmin("setup.asp"), icon + _("Setup")))

            if cic_user.WebDeveloper:
                icon = '<span class="glyphicon glyphicon-wrench" aria-hidden="true"></span> '
                search_menu_items.append(
                    (makeLinkAdmin("setup_webdev.asp"), icon + _("Setup")))

            icon = '<span class="glyphicon glyphicon-user" aria-hidden="true"></span> '
            search_menu_items.append(
                (makeLinkAdmin("account.asp"), icon + _("My Account")))

            icon = (
                '<span class="glyphicon glyphicon-log-out" aria-hidden="true"></span> '
            )
            search_menu_items.append(
                (makeLink("logout.asp"), icon + _("Logout")))

            search_menu_items = [
                dict(Link=l, Display=d) for l, d in search_menu_items
            ]

            if self.viewslist:
                cv_select = tags.select(
                    "UseCICVw",
                    None,
                    convert_options([("", "")] +
                                    list(map(tuple, self.viewslist))),
                    class_="form-control",
                )

                cv_params = "".join(
                    tags.hidden(n, value=v) for n, v in request.params.items()
                    if n != "UseCICVw")

                cv_submit = tags.submit(None, value=_("Change View"))

                cv_namespace = dict(
                    action=request.path,
                    params=cv_params,
                    title=_("Change View:"),
                    select=cv_select,
                    submit=cv_submit,
                )
                change_view = ("""
                <form action="%(action)s">
                <div style="display:none;">
                %(params)s
                </div>
                %(select)s %(submit)s
                </form>""" % cv_namespace)

        show_cic_search_form = any(
            getattr(search_info, x) for x in [
                "BSrchAges",
                "BSrchLanguage",
                "BSrchNUM",
                "BSrchOCG",
                "BSrchKeywords",
                "BSrchVacancy",
                "BSrchVOL",
                "BSrchWWW",
            ])

        if not show_cic_search_form and request.dboptions.UseCIC:
            if self.quicklist:
                show_cic_search_form = True

        quick_searches = [{
            "URL":
            makeLink("~/" + qs.PageName, qs.QueryParameters),
            "NAME":
            qs.Name,
            "PROMOTE":
            qs.PromoteToTab,
        } for qs in quick_searches]

        quick_searches_tab = [qs for qs in quick_searches if qs["PROMOTE"]]
        quick_searches_notab = [
            qs for qs in quick_searches if not qs["PROMOTE"]
        ]
        log.debug(
            "quick_searches: %s, %s, %s",
            quick_searches,
            quick_searches_tab,
            quick_searches_notab,
        )

        has_centre_section = (show_cic_search_form or bool(topic_searches)
                              or bool(quick_searches) or service_category
                              or (use_cic and search_info.CSrch)
                              or (use_cic and viewdata.UseNAICSView) or browse
                              or search_info.SearchCentreMessage)

        if viewdata.QuickListWrapAt < 2:
            quicklist_col_class = "col-sm-12"
            quicklist_clear_at = []
        elif viewdata.QuickListWrapAt == 2:
            quicklist_col_class = "col-sm-6"
            quicklist_clear_at = [(2, ["sm", "md", "lg"])]
        elif viewdata.QuickListWrapAt == 3:
            quicklist_col_class = "col-md-6 col-lg-4"
            quicklist_clear_at = [(2, ["sm", "md"]), (3, ["lg"])]
        else:
            quicklist_col_class = "col-sm-6 col-md-4 col-lg-3"
            quicklist_clear_at = [(2, ["sm"]), (3, ["md"]), (4, ["lg"])]

        quick_list_clear_visible = lambda index: " ".join(
            "visible-" + y + "-block"
            for condition, sizes in quicklist_clear_at for y in sizes
            if (index + 1) % condition == 0)
        if viewdata.LimitedView or viewdata.QuickListPubHeadings:
            quicklist_split = []
            for key, group in itertools.groupby(self.quicklist,
                                                lambda x: x.Group):
                group_row = len(quicklist_split)
                if key is None:
                    quicklist_split.extend([{
                        "IDTYPE":
                        "GHID",
                        "ID":
                        row.GH_ID,
                        "NAME":
                        row.GeneralHeading,
                        "ICON":
                        make_icon_html(None, row.IconNameFull, False,
                                       "heading-icon"),
                        "HEADINGS":
                        None,
                        "CLEAR_CLASS":
                        quick_list_clear_visible(i),
                    } for i, row in enumerate(group, group_row)])
                else:
                    group = list(group)
                    sub_heading = [{
                        "IDTYPE":
                        "GHID",
                        "ID":
                        row.GH_ID,
                        "NAME":
                        row.GeneralHeading,
                        "ICON":
                        make_icon_html(None, row.IconNameFull, False,
                                       "sub-heading-icon"),
                    } for row in group]
                    row = group[0]
                    quicklist_split.append({
                        "IDTYPE":
                        "GHID",
                        "ID":
                        row.GroupID,
                        "IDLIST":
                        ",".join(str(row.GH_ID) for row in group),
                        "NAME":
                        row.Group,
                        "ICON":
                        make_icon_html(None, row.IconNameFullGroup, False,
                                       "heading-icon"),
                        "HEADINGS":
                        sub_heading,
                        "CLEAR_CLASS":
                        quick_list_clear_visible(group_row),
                    })
        else:
            quicklist_split = [{
                "IDTYPE": "PBID",
                "ID": row.PB_ID,
                "NAME": row.PubName or row.PubCode,
                "ICON": None,
                "HEADINGS": None,
                "CLEAR_CLASS": quick_list_clear_visible(i),
            } for i, row in enumerate(self.quicklist or [])]

        namespace = {
            "TOGGLE_NAV_TITLE":
            gettext("Toggle navigation", request),
            "MENU_TITLE":
            search_info.MenuTitle
            or (_("Main Menu") if not not user else None),
            "MENU_MESSAGE":
            search_info.MenuMessage,
            "MENU_GLYPH":
            search_info.MenuGlyph,
            "BASIC_SEARCH":
            search_form() if show_cic_search_form else None,
            "BASIC_SEARCH_SECTION":
            show_cic_search_form,
            "BROWSE":
            browse,
            "BROWSE_BY_INDUSTRY_URL":
            makeLink("browsebyindustry.asp")
            if use_cic and viewdata.UseNAICSView else None,
            "NAICS_INTRO":
            gettext("Browse for a Business / Organization using the ",
                    request),
            "NAICS_LINK_TEXT":
            gettext("North American Industry Classification System (NAICS)",
                    request),
            "NAICS_TITLE":
            gettext("Industry Search", request),
            "BROWSE_TITLE":
            gettext("Browse", request),
            "BROWSE_ORG_ITEMS":
            browse_org_items,
            "BROWSE_ORG_TITLE":
            browse_org_title,
            "BROWSE_SUBJ_ITEMS":
            browse_subject_items,
            "BROWSE_SUBJ_TITLE": (_("Browse by Subject")),
            "CHANGE_VIEW":
            change_view,
            "CHILDCARE_SEARCH_TITLE":
            gettext("Child Care Search", request),
            "CHILDCARE_SEARCH_TEXT":
            search_info.CSrchText,
            "CHILDCARE_LINK_TEXT":
            gettext("Search for Child Care Resources", request),
            "CHILDCARE_SEARCH_URL":
            makeLink("csrch") if use_cic and search_info.CSrch else None,
            "CHILDCARE_SEARCH_FORM":
            self.csearchform,
            "CUSTOM_MENU_ITEMS":
            menu_items_custom,
            "CUSTOM_MENU_ITEMS_GROUP_1":
            [encode_link_values(x) for x in menu_groups.get(1, [])],
            "CUSTOM_MENU_ITEMS_GROUP_2":
            [encode_link_values(x) for x in menu_groups.get(2, [])],
            "CUSTOM_MENU_ITEMS_GROUP_3":
            [encode_link_values(x) for x in menu_groups.get(3, [])],
            "TOPIC_SEARCHES": [{
                "TAG":
                g,
                "TITLE":
                t,
                "DESC":
                d,
                "LINK":
                request.passvars.route_path("cic_topicsearch", tag=g),
            } for g, t, d in topic_searches],
            "SEARCH_LEAD":
            gettext("Search ", request),
            "QUICK_SEARCHES":
            quick_searches,
            "QUICK_SEARCHES_TAB":
            quick_searches_tab,
            "QUICK_SEARCHES_NOTAB":
            quick_searches_notab,
            "LOGGED_IN":
            not not user,
            "NOT_LOGGED_IN":
            not user,
            "OTHER_LANGS":
            other_langs,
            "QUICK_SEARCH_TITLE":
            search_info.QuickSearchTitle or gettext("Quick Search", request),
            "QUICK_SEARCH_GLYPH":
            search_info.QuickSearchGlyph,
            "SEARCH":
            gettext("Search", request),
            "SEARCH_ALERT_TITLE":
            search_info.SearchAlertTitle,
            "SEARCH_ALERT_GLYPH":
            search_info.SearchAlertGlyph,
            "SEARCH_ALERT":
            search_info.SearchAlertMessage,
            "SEARCH_LEFT_TITLE":
            search_info.SearchLeftTitle,
            "SEARCH_LEFT_GLYPH":
            search_info.SearchLeftGlyph,
            "SEARCH_LEFT_CONTENT":
            search_info.SearchLeftMessage,
            "SEARCH_CENTRE_TITLE":
            search_info.SearchCentreTitle,
            "SEARCH_CENTRE_GLYPH":
            search_info.SearchCentreGlyph,
            "SEARCH_CENTRE_CONTENT":
            search_info.SearchCentreMessage,
            "SEARCH_RIGHT_TITLE":
            search_info.SearchRightTitle,
            "SEARCH_RIGHT_GLYPH":
            search_info.SearchRightGlyph,
            "SEARCH_RIGHT_CONTENT":
            search_info.SearchRightMessage,
            "SEARCH_KEYWORD_TITLE":
            search_info.KeywordSearchTitle or gettext("New Search", request),
            "SEARCH_KEYWORD_GLYPH":
            search_info.KeywordSearchGlyph or "search",
            "SEARCH_OTHER_TITLE":
            search_info.OtherSearchTitle or gettext("Explore", request),
            "SEARCH_OTHER_GLYPH":
            search_info.OtherSearchGlyph or "hand-right",
            "SEARCH_OTHER_MESSAGE":
            search_info.OtherSearchMessage,
            "SEARCH_MENU":
            not not (search_info.MenuMessage or user
                     or self.menu_items_custom),
            "SEARCH_MENU_ITEMS":
            search_menu_items,
            "SERVICE_CATEGORY_TITLE":
            gettext("Service Categories", request),
            "SERVICE_CATEGORY":
            service_category,
            "SERVICE_CATEGORY_LIST":
            service_category_list,
            "SERVICE_CATEGORY_URL":
            makeLink("servcat.asp")
            if use_cic and viewdata.UseTaxonomyView and not cic_user else None,
            "VOL_LINK":
            vol_link,
            "VOL_LINK_TEXT":
            vol_link_text,
            "SEARCH_FORM_START":
            kwargs["searchform_start"],
            "HAS_KEYWORD_SEARCH":
            not not search_info.BSrchKeywords,
            "KEYWORD_SEARCH_BOX":
            kwargs["searchform_keyword"],
            "KEYWORD_SEARCH_IN":
            kwargs["searchform_in_values"],
            "COMMUNITY_SEARCH":
            kwargs["searchform_community"],
            "LANGUAGES_SEARCH":
            kwargs["searchform_languages"],
            "HAS_LANGUAGES_SEARCH":
            self.languages,
            "HAS_COMMUNITY_SEARCH":
            self.communities or (request.viewdata.cic.QuickListDropDown
                                 and request.viewdata.cic.OtherCommunity),
            "QUICKLIST":
            quicklist_split,
            "QUICKLIST_COL_CLASS":
            quicklist_col_class,
            "QUICKLIST_SEARCH":
            kwargs["searchform_quicklist"] if self.quicklist else None,
            "QUICKLIST_SEARCH_GROUPS":
            request.viewdata.cic.QuickListSearchGroups,
            "SEARCH_ALL_TITLE":
            gettext("Search all in this Category", request),
            "NUM_SEARCH":
            kwargs["searchform_num"] if search_info.BSrchNUM else None,
            "RECORD_NUMBER":
            gettext("Record #", request),
            "VOLUNTEER_ORG_URL":
            makeLink("results.asp", "HasVol=on")
            if search_info.BSrchVOL else None,
            "VOLUNTEER_OPPORTUNITIES":
            gettext("Volunteer Opportunities", request),
            "ORGS_WITH_OPS":
            request.viewdata.cic.OrganizationsWithVolOps
            or _("Organizations with Volunteer Opportunities"),
            "MAKE_LINK":
            template.make_linkify_fn(request),
            "VIEWS_LIST": [{
                "VIEWTYPE": str(x.ViewType),
                "VIEWNAME": x.ViewName
            } for x in self.viewslist] if self.viewslist else [],
            "CHANGE_VIEW_TITLE":
            _("Change View"),
            "HAS_CENTRE_SECTION":
            has_centre_section,
        }

        namespace["HAS_LEFT_CONTENT"] = any(
            namespace[x]
            for x in ["SEARCH_ALERT", "SEARCH_MENU", "SEARCH_LEFT_CONTENT"])
        namespace["HAS_RIGHT_OR_SERVCAT"] = any(
            namespace[x] for x in ["SEARCH_RIGHT_CONTENT", "SERVICE_CATEGORY"])

        return template.apply_html_values(
            self.template_values.SearchLayoutHTML or "", namespace)
Пример #11
0
 def marker_end(self):
     if self._marker_type is not None:
         return tags.hidden('__end__', '{}:{}'.format(self.name or '_ziggurat_form_field_',
                                                      self._marker_type), id=None)
     return ''
Пример #12
0
    def __call__(self, search_form, search_menu, **kwargs):
        if not self.template_values:
            return ""

        request = self.request
        search_info = self.search_info
        _ = lambda x: gettext(x, request)

        browse_by_org = ""
        browse_by_org_items = []
        if search_info.BSrchBrowseByOrg:
            browse_by_org = """<tr><th class="RevTitleBox" colspan="2">{}</th></tr>
                        <tr><td align="center" colspan="2">{}</td></tr>""".format(
                _("Browse Organizations with Opportunities"),
                makeAlphaList(True, "browsebyorg.asp", "MenuText", request),
            )
            browse_by_org_items = makeAlphaListItems(True, "browsebyorg.asp",
                                                     request)

        browse_by_interest = ""
        browse_op_items = []
        if search_info.BSrchBrowseByInterest:
            browse_op_items = makeAlphaListItems(False, "browsebyinterest.asp",
                                                 request)
            browse_by_interest = """
                <tr><th class="RevTitleBox" colspan="2">{}</th></tr>
                <tr><td align="center" colspan="2">{}</td></tr>
                """.format(
                _("Browse by Area of Interest"),
                makeAlphaList(False, "browsebyinterest.asp", "MenuText",
                              request),
            )

        browse = browse_by_org + browse_by_interest

        viewdata = request.viewdata.vol

        # main menu:
        Culture = request.language.Culture
        user = request.user
        passvars = request.passvars
        makeLink = passvars.makeLink
        vol_user = user and user.vol

        menu_groups = {}
        for key, group in itertools.groupby(self.menu_items_custom,
                                            lambda x: x.MenuGroup):
            menu_groups[key] = list(group)

        menu_items_custom = [
            encode_link_values(x) for x in menu_groups.get(None, [])
        ]

        other_langs = []
        if user or self.menu_items_custom:
            for key, val in viewdata.Cultures.items():
                if key == Culture:
                    continue
                httpvals = {}
                if key != passvars.DefaultCulture:
                    httpvals["Ln"] = key
                other_langs.append(
                    dict(Link=makeLink("~/volunteer/", httpvals, ("Ln", )),
                         Display=val))

        cic_link = None
        cic_link_text = None
        if user and Culture in request.viewdata.cic.Cultures:
            cic_link = makeLink("~/")
            cic_link_text = _("CIC Menu")

        search_menu_items = []
        change_view = None

        if user:
            if vol_user and user.SavedSearchQuota:
                icon = '<span class="glyphicon glyphicon-floppy-save" aria-hidden="true"></span> '
                search_menu_items.append(
                    (makeLink("savedsearch.asp"), icon + _("Saved Search")))

            if vol_user.CanDeleteRecord:
                icon = '<span class="glyphicon glyphicon-remove" aria-hidden="true"></span> '
                search_menu_items.append((makeLink("delete_manage.asp"),
                                          icon + _("Deleted Records")))

            if vol_user.CanManageReferrals:
                icon = (
                    '<span class="glyphicon glyphicon-send" aria-hidden="true"></span> '
                )
                search_menu_items.append(
                    (makeLink("referral.asp"), icon + _("Referrals")))

            if vol_user.CanManageMembers:
                icon = '<span class="glyphicon glyphicon-certificate" aria-hidden="true"></span> '
                search_menu_items.append(
                    (makeLink("member.asp"), icon + _("Members")))

            if request.dboptions.UseVolunteerProfiles and vol_user.CanAccessProfiles:
                icon = '<span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span> '
                search_menu_items.append(
                    (makeLink("profiles.asp"), icon + _("Volunteer Profiles")))

            if vol_user.CanViewStats:
                icon = '<span class="glyphicon glyphicon-stats" aria-hidden="true"></span> '
                search_menu_items.append(
                    (makeLink("stats.asp"), icon + _("Statistics")))

            makeLinkAdmin = passvars.makeLinkAdmin

            if vol_user.CanManageUsers:
                icon = (
                    '<span class="glyphicon glyphicon-lock" aria-hidden="true"></span> '
                )
                search_menu_items.append(
                    (makeLinkAdmin("users.asp"), icon + _("Manage Users")))

            if vol_user.SuperUser:
                icon = '<span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span> '
                search_menu_items.append((
                    makeLinkAdmin("download.asp", dict(DM=const.DM_VOL)),
                    icon + _("Download"),
                ))
                icon = '<span class="glyphicon glyphicon-wrench" aria-hidden="true"></span> '
                search_menu_items.append(
                    (makeLinkAdmin("setup.asp"), icon + _("Setup")))

            if vol_user.WebDeveloper:
                icon = '<span class="glyphicon glyphicon-wrench" aria-hidden="true"></span> '
                search_menu_items.append(
                    (makeLinkAdmin("setup_webdev.asp"), icon + _("Setup")))

            icon = '<span class="glyphicon glyphicon-user" aria-hidden="true"></span> '
            search_menu_items.append(
                (makeLinkAdmin("account.asp"), icon + _("My Account")))

            icon = (
                '<span class="glyphicon glyphicon-log-out" aria-hidden="true"></span> '
            )
            search_menu_items.append(
                (makeLink("~/logout.asp"), icon + _("Logout")))

            search_menu_items = [
                dict(Link=l, Display=d) for l, d in search_menu_items
            ]

            if self.viewslist:
                cv_select = tags.select(
                    "UseVOLVw",
                    None,
                    convert_options([("", "")] +
                                    list(map(tuple, self.viewslist))),
                )

                cv_params = "".join(
                    tags.hidden(n, value=v) for n, v in request.params.items()
                    if n != "UseVOLVw")

                cv_submit = tags.submit(None, value=_("Change View"))

                cv_namespace = dict(
                    action=request.path,
                    params=cv_params,
                    title=_("Change View:"),
                    select=cv_select,
                    submit=cv_submit,
                )
                change_view = ("""
                <form action="%(action)s">
                <div style="display:none;">
                %(params)s
                </div>
                %(title)s
                <br>%(select)s %(submit)s
                </form>""" % cv_namespace)

        vol_search_menu = search_menu().strip()
        spotlight = None
        if search_info.HighlightOpportunity:
            spotlight = SpotlightFeed(request)

        namespace = {
            "BASIC_SEARCH":
            search_form if search_info.BSrchKeywords else None,
            "BASIC_SEARCH_SECTION":
            vol_search_menu and search_info.BSrchKeywords,
            "BROWSE":
            browse,
            "BROWSE_OP_ITEMS":
            browse_op_items,
            "BROWSE_OP_URL":
            makeLink("browsebyinterest.asp"),
            "BROWSE_ORG_ITEMS":
            browse_by_org_items,
            "BROWSE_ORG_URL":
            makeLink("browsebyorg.asp"),
            "CHANGE_VIEW":
            change_view,
            "CIC_LINK":
            cic_link,
            "CIC_LINK_TEXT":
            cic_link_text,
            "CUSTOM_MENU_ITEMS":
            menu_items_custom,
            "CUSTOM_MENU_ITEMS_GROUP_1":
            [encode_link_values(x) for x in menu_groups.get(1, [])],
            "CUSTOM_MENU_ITEMS_GROUP_2":
            [encode_link_values(x) for x in menu_groups.get(2, [])],
            "CUSTOM_MENU_ITEMS_GROUP_3":
            [encode_link_values(x) for x in menu_groups.get(3, [])],
            "WHATS_NEW_FEED":
            make_whats_new_feed(request) if search_info.BSrchWhatsNew else "",
            "WHATS_NEW_URL":
            makeLink("whatsnew.asp"),
            "POPULAR_INTEREST_FEED":
            make_popular_interest_feed(request)
            if search_info.BSrchBrowseByInterest else "",
            "POPULAR_ORG_FEED":
            make_popular_org_feed(request)
            if search_info.BSrchBrowseByOrg else "",
            "DURATION_OPTIONS":
            make_commitmentlength_option_list(request)
            if search_info.BSrchCommitmentLength else "",
            "COMMUNITY_OPTIONS":
            make_community_option_list(request) if search_info.BSrchCommunity
            or not search_info.BSrchCommitmentLength
            or not search_info.BSrchBrowseByOrg else "",
            "SUITABILITY_OPTIONS":
            make_suitability_option_list(request)
            if search_info.BSrchSuitableFor else "",
            "SPOTLIGHT_FEED":
            spotlight and spotlight.spotlight_content,
            "SPOTLIGHT_LINK":
            spotlight and spotlight.spotlight_details_link,
            "LOGGED_IN":
            not not user,
            "MENU_MESSAGE":
            search_info.MenuMessage,
            "MENU_TITLE":
            _("Main Menu"),
            "NOT_LOGGED_IN":
            not user,
            "OTHER_LANGS":
            other_langs,
            "SEARCH":
            gettext("Search", request),
            "SEARCH_ALERT_TITLE":
            search_info.SearchAlertTitle,
            "SEARCH_ALERT_GLYPH":
            search_info.SearchAlertGlyph,
            "SEARCH_ALERT":
            search_info.SearchAlertMessage,
            "SEARCH_LEFT_TITLE":
            search_info.SearchLeftTitle,
            "SEARCH_LEFT_GLYPH":
            search_info.SearchLeftGlyph,
            "SEARCH_LEFT_CONTENT":
            search_info.SearchLeftMessage,
            "SEARCH_CENTRE_TITLE":
            search_info.SearchCentreTitle,
            "SEARCH_CENTRE_GLYPH":
            search_info.SearchCentreGlyph,
            "SEARCH_CENTRE_CONTENT":
            search_info.SearchCentreMessage,
            "SEARCH_RIGHT_TITLE":
            search_info.SearchRightTitle,
            "SEARCH_RIGHT_GLYPH":
            search_info.SearchRightGlyph,
            "SEARCH_RIGHT_CONTENT":
            search_info.SearchRightMessage,
            "SEARCH_MENU":
            not not (search_info.MenuMessage or user
                     or self.menu_items_custom),
            "SEARCH_MENU_ITEMS":
            search_menu_items,
            "SEARCH_PROMPT":
            (search_info.SearchPromptOverride
             or (_("Looking for Volunteer Opportunities%s?") %
                 "[IN_COMMUNITY]")).replace(
                     "[IN_COMMUNITY]",
                     ("" if not viewdata.AreaServed else " ".join(
                         ("", _("in"), viewdata.AreaServed))),
                 ),
            "SEARCH_KEYWORD_TITLE":
            search_info.KeywordSearchTitle
            or gettext("Keyword Search", request),
            "SEARCH_KEYWORD_GLYPH":
            search_info.KeywordSearchGlyph or "search",
            "SEARCH_OTHER_TITLE":
            search_info.OtherSearchTitle or gettext("Explore", request),
            "SEARCH_OTHER_GLYPH":
            search_info.OtherSearchGlyph or "hand-right",
            "SEARCH_OTHER_MESSAGE":
            search_info.OtherSearchMessage,
            "VOL_SEARCH_MENU":
            vol_search_menu,
            "WHATS_NEW_ENABLED":
            search_info.BSrchWhatsNew,
            "BROWSE_INTERESTS_ENABLED":
            search_info.BSrchBrowseByInterest,
            "BROWSE_ORGS_ENABLED":
            search_info.BSrchBrowseByOrg,
            "HAS_SEARCH_AREA":
            search_info.BSrchKeywords or vol_search_menu or browse,
            "SEARCH_FORM_START":
            kwargs["searchform_start"],
            "HAS_KEYWORD_SEARCH":
            not not search_info.BSrchKeywords,
            "KEYWORD_SEARCH_BOX":
            kwargs["searchform_keyword"],
            "KEYWORD_SEARCH_IN":
            kwargs["searchform_in_values"],
            "USE_VOL_PROFILES_VIEW":
            not not (user and viewdata.UseProfilesView),
            "PROFILE_LINKS":
            kwargs["searchform_profilelinks"],
            "MAKE_LINK":
            template.make_linkify_fn(request),
            "VIEWS_LIST": [{
                "VIEWTYPE": str(x.ViewType),
                "VIEWNAME": x.ViewName
            } for x in self.viewslist] if self.viewslist else [],
            "CHANGE_VIEW_TITLE":
            _("Change View"),
        }
        namespace["HAS_LEFT_CONTENT"] = any(
            namespace[x]
            for x in ["SEARCH_ALERT", "SEARCH_MENU", "SEARCH_LEFT_CONTENT"])

        return template.apply_html_values(
            self.template_values.SearchLayoutHTML or "", namespace)