Class: Widgets::Search::Base

Inherits:
ErpApp::Widgets::Base
  • Object
show all
Includes:
ActionDispatch::Routing::UrlFor, WillPaginate::ActionView
Defined in:
app/widgets/search/base.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.base_layoutObject



63
64
65
66
67
68
69
70
# File 'app/widgets/search/base.rb', line 63

def base_layout
  begin
    file = File.join(File.dirname(__FILE__),"/views/layouts/base.html.erb")
    IO.read(file)
  rescue
    return nil
  end
end

.titleObject



55
56
57
# File 'app/widgets/search/base.rb', line 55

def title
  "Search"
end

.widget_nameObject



59
60
61
# File 'app/widgets/search/base.rb', line 59

def widget_name
  File.basename(File.dirname(__FILE__))
end

Instance Method Details

#indexObject



22
23
24
25
# File 'app/widgets/search/base.rb', line 22

def index
  set_variables
  render
end

#locateObject

should not be modified modify at your own risk



50
51
52
# File 'app/widgets/search/base.rb', line 50

def locate
  File.dirname(__FILE__)
end

#newObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/widgets/search/base.rb', line 27

def new
  set_variables
  @website = Website.find_by_host(request.host_with_port)

  options = {
    :website_id => @website.id,
    :query => params[:query],
    :content_type => params[:content_type],
    :section_permalink => params[:section_permalink],
    :page => (params[:page] || 1),
    :per_page => (params[:per_page] || 20)
  }
  @results = Content.do_search(options)

  if @ajax_results
    render :update => {:id => "#{@uuid}_result", :view => :show}
  else
    render :view => :show
  end
end

#set_variablesObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/widgets/search/base.rb', line 8

def set_variables
  @results_permalink = params[:results_permalink]
  @section_permalink = params[:section_permalink]
  @content_type = params[:content_type]
  @per_page = params[:per_page]
  @css_class = params[:class]

  if @results_permalink.nil? or @results_permalink.blank?
    @ajax_results = true
  else
    @ajax_results = false
  end
end