Commit dd83445f authored by Jean-Philippe Lang's avatar Jean-Philippe Lang

extended the search to wiki content

git-svn-id: http://redmine.rubyforge.org/svn/trunk@325 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 290485b1
......@@ -556,7 +556,7 @@ class ProjectsController < ApplicationController
@question = params[:q] || ""
@question.strip!
@all_words = params[:all_words] || (params[:submit] ? false : true)
@scope = params[:scope] || (params[:submit] ? [] : %w(issues news documents) )
@scope = params[:scope] || (params[:submit] ? [] : %w(issues news documents wiki) )
if !@question.empty?
# tokens must be at least 3 character long
@tokens = @question.split.uniq.select {|w| w.length > 2 }
......@@ -570,6 +570,7 @@ class ProjectsController < ApplicationController
@results += @project.issues.find(:all, :limit => limit, :include => :author, :conditions => [ (["(LOWER(issues.subject) like ? OR LOWER(issues.description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'issues'
@results += @project.news.find(:all, :limit => limit, :conditions => [ (["(LOWER(news.title) like ? OR LOWER(news.description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort], :include => :author ) if @scope.include? 'news'
@results += @project.documents.find(:all, :limit => limit, :conditions => [ (["(LOWER(title) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'documents'
@results += @project.wiki.pages.find(:all, :limit => limit, :include => :content, :conditions => [ (["(LOWER(wiki_pages.title) like ? OR LOWER(wiki_contents.text) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @project.wiki && @scope.include?('wiki')
@question = @tokens.join(" ")
end
end
......
......@@ -5,7 +5,11 @@
<p><%= text_field_tag 'q', @question, :size => 30 %>
<%= check_box_tag 'scope[]', 'issues', (@scope.include? 'issues') %> <label><%= l(:label_issue_plural) %></label>
<%= check_box_tag 'scope[]', 'news', (@scope.include? 'news') %> <label><%= l(:label_news_plural) %></label>
<%= check_box_tag 'scope[]', 'documents', (@scope.include? 'documents') %> <label><%= l(:label_document_plural) %></label><br />
<%= check_box_tag 'scope[]', 'documents', (@scope.include? 'documents') %> <label><%= l(:label_document_plural) %></label>
<% if @project.wiki %>
<%= check_box_tag 'scope[]', 'wiki', (@scope.include? 'wiki') %> <label><%= l(:label_wiki) %></label>
<% end %>
<br />
<%= check_box_tag 'all_words', 1, @all_words %> <%= l(:label_all_words) %></p>
<%= submit_tag l(:button_submit), :name => 'submit' %>
<% end %>
......@@ -28,6 +32,10 @@
<%=l(:label_document)%>: <%= link_to highlight_tokens(h(e.title), @tokens), :controller => 'documents', :action => 'show', :id => e %><br />
<%= highlight_tokens(e.description, @tokens) %><br />
<i><%= format_time(e.created_on) %></i>
<% elsif e.is_a? WikiPage %>
<%=l(:label_wiki)%>: <%= link_to highlight_tokens(h(e.pretty_title), @tokens), :controller => 'wiki', :action => 'index', :id => @project, :page => e.title %><br />
<%= highlight_tokens(e.content.text, @tokens) %><br />
<i><%= e.content.author ? e.content.author.name : "Anonymous" %>, <%= format_time(e.content.updated_on) %></i>
<% end %>
</p></li>
<% end %>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment