Makes search providers extensible (#3936).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3444 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2010-02-17 20:05:51 +00:00
parent b733accfe3
commit c11d30ebc9
3 changed files with 29 additions and 1 deletions

View File

@ -48,7 +48,7 @@ class SearchController < ApplicationController
return
end
@object_types = %w(issues news documents changesets wiki_pages messages projects)
@object_types = Redmine::Search.available_search_types.dup
if projects_to_search.is_a? Project
# don't search projects
@object_types.delete('projects')

View File

@ -1,6 +1,7 @@
require 'redmine/access_control'
require 'redmine/menu_manager'
require 'redmine/activity'
require 'redmine/search'
require 'redmine/mime_type'
require 'redmine/core_ext'
require 'redmine/themes'
@ -178,6 +179,16 @@ Redmine::Activity.map do |activity|
activity.register :time_entries, :default => false
end
Redmine::Search.map do |search|
search.register :issues
search.register :news
search.register :documents
search.register :changesets
search.register :wiki_pages
search.register :messages
search.register :projects
end
Redmine::WikiFormatting.map do |format|
format.register :textile, Redmine::WikiFormatting::Textile::Formatter, Redmine::WikiFormatting::Textile::Helper
end

View File

@ -17,6 +17,23 @@
module Redmine
module Search
mattr_accessor :available_search_types
@@available_search_types = []
class << self
def map(&block)
yield self
end
# Registers a search provider
def register(search_type, options={})
search_type = search_type.to_s
@@available_search_types << search_type unless @@available_search_types.include?(search_type)
end
end
module Controller
def self.included(base)
base.extend(ClassMethods)