diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-07-20 17:26:07 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-07-20 17:26:07 +0000 |
commit | be2b8a62f4d0d8bf413a5583fe644bd41a8ebf04 (patch) | |
tree | 95fe7f273935739e1ffa82be16cee93927a4c054 /app/helpers | |
parent | 83baccb71ac0e609ce72ebf322f73884548a9ba5 (diff) | |
download | redmine-be2b8a62f4d0d8bf413a5583fe644bd41a8ebf04.tar.gz redmine-be2b8a62f4d0d8bf413a5583fe644bd41a8ebf04.zip |
Search engine: display total results count (#906) and count by result type.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1681 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/search_helper.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index d6a2fb949..92f2da8a5 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -36,6 +36,10 @@ module SearchHelper result end + def type_label(t) + l("label_#{t.singularize}_plural") + end + def project_select_tag options = [[l(:label_project_all), 'all']] options << [l(:label_my_projects), 'my_projects'] unless User.current.memberships.empty? @@ -43,4 +47,16 @@ module SearchHelper options << [@project.name, ''] unless @project.nil? select_tag('scope', options_for_select(options, params[:scope].to_s)) if options.size > 1 end + + def render_results_by_type(results_by_type) + links = [] + # Sorts types by results count + results_by_type.keys.sort {|a, b| results_by_type[b] <=> results_by_type[a]}.each do |t| + c = results_by_type[t] + next if c == 0 + text = "#{type_label(t)} (#{c})" + links << link_to(text, :q => params[:q], :titles_only => params[:title_only], :all_words => params[:all_words], :scope => params[:scope], t => 1) + end + ('<ul>' + links.map {|link| content_tag('li', link)}.join(' ') + '</ul>') unless links.empty? + end end |