bsw/jbe@19: local search_for = param.get("search_for", atom.string) or "global" bsw@1045: local search_string = param.get("q", atom.string) bsw/jbe@0: bsw@480: if search_string then bsw@1045: ui.title ( _("Search results for: '#{search}'", { search = search_string } ) ) bsw@480: else bsw@1045: ui.title ( _"Search" ) bsw/jbe@0: end bsw/jbe@0: bsw@480: ui.form{ bsw@480: method = "get", module = "index", view = "search", bsw@480: routing = { default = { mode = "redirect", bsw@1045: module = "index", view = "search", search_for = search_for, q = search_string bsw@480: } }, bsw@1045: attr = { class = "vertical section" }, bsw@480: content = function() bsw@1045: bsw@1045: ui.sectionHead( function() bsw@1045: ui.heading { level = 1, content = _"Search" } bsw@1045: end) bsw@1045: bsw@1045: ui.sectionRow( function() bsw@1045: ui.tag { content = _"Search term (only complete words)" } bsw@1045: ui.tag { bsw@1045: tag = "input", bsw@1045: attr = { bsw@1045: name = "q", bsw@1045: value = search_string bsw@1045: } bsw@725: } bsw@1045: ui.tag{ bsw@1045: tag = "input", bsw@1045: attr = { bsw@1045: class = "btn btn-search", bsw@1045: type = "submit", bsw@1045: value = _"search" bsw@1045: } bsw@1045: } bsw@1045: end ) bsw@480: end bsw@480: } bsw@480: bsw@480: bsw@1045: if not search_string then bsw@1045: return bsw@1045: end bsw@1045: bsw/jbe@19: bsw@1045: local members_selector = Member:get_search_selector(search_string) bsw@1045: local count = members_selector:count() bsw@1045: local text bsw@1045: if count == 0 then bsw@1045: text = _"No matching members found" bsw@1045: elseif count == 1 then bsw@1045: text = _"1 matching member found" bsw@1045: else bsw@1045: text = _"#{count} matching members found" bsw@1045: end bsw@1045: if app.session:has_access("everything") then bsw@1045: ui.section( function() bsw@1045: ui.sectionHead( function() bsw@1045: ui.heading { level = 1, content = _(text, { count = count }) } bsw@1045: end ) bsw@1045: if count > 0 then bsw@725: execute.view{ bsw@725: module = "member", bsw@725: view = "_list", bsw@1045: params = { bsw@1045: members_selector = members_selector, bsw@1045: no_filter = true bsw@1045: }, bsw@725: } bsw@725: end bsw@1045: end ) bsw@1045: end bsw@1045: bsw@1045: slot.put("
") bsw@1045: bsw@1045: local issues_selector = Issue:get_search_selector(search_string) bsw@1045: local count = issues_selector:count() bsw@1045: local text bsw@1045: if count == 0 then bsw@1045: text = _"No matching issues found" bsw@1045: elseif count == 1 then bsw@1045: text = _"1 matching issue found" bsw@1045: else bsw@1045: text = _"#{count} matching issues found" bsw@1045: end bsw@725: bsw@1045: ui.section( function() bsw@1045: ui.sectionHead( function() bsw@1045: ui.heading { level = 1, content = _(text, { count = count }) } bsw@1045: end ) bsw@1045: if count > 0 then bsw@480: execute.view{ bsw@480: module = "issue", bsw@1045: view = "_list2", bsw@480: params = { bsw@1045: search = search_string, bsw@480: no_filter = true bsw@480: }, bsw@480: } bsw@480: end bsw@1045: end)