2013-01-03 11:38:14 +00:00
|
|
|
class DefaultWidgetController< OrbitWidgetController
|
|
|
|
|
|
|
|
def front_end_available(var)
|
2013-01-21 08:56:37 +00:00
|
|
|
@page_part = case params[:item_type]
|
|
|
|
when "page"
|
|
|
|
Page.find params[:page_id]
|
|
|
|
when "page_part"
|
|
|
|
PagePart.find params[:part_id]
|
|
|
|
end
|
2013-01-03 11:38:14 +00:00
|
|
|
@page_part.module_app.enable_frontend?
|
|
|
|
end
|
|
|
|
|
|
|
|
def default_widget
|
|
|
|
@tag_class = nil
|
|
|
|
|
|
|
|
@default_widget = @page_part.module_app.get_default_widget
|
2013-01-21 08:56:37 +00:00
|
|
|
@widget_image_field = @default_widget["image"] || @default_widget[:image]
|
|
|
|
data_limit = case @page_part
|
|
|
|
when Page
|
|
|
|
@fields = @page_part.frontend_field
|
|
|
|
@page_part.frontend_data_count.is_a?(Fixnum) ? @page_part.frontend_data_count : (@page_part.frontend_data_count.to_i rescue 3)
|
|
|
|
when PagePart
|
|
|
|
@fields = @page_part.widget_field
|
|
|
|
@page_part.widget_data_count.is_a?(Fixnum) ? @page_part.widget_data_count : (@page_part.widget_data_count.to_i rescue 3)
|
|
|
|
end
|
2013-01-04 10:42:25 +00:00
|
|
|
@data = eval(@default_widget["query"]).limit(data_limit).includes(@widget_image_field)
|
2013-01-21 08:56:37 +00:00
|
|
|
|
2013-01-03 11:38:14 +00:00
|
|
|
|
|
|
|
case params[:type]
|
|
|
|
when "typeA"
|
2013-01-10 01:40:52 +00:00
|
|
|
@tag_class = 'default_widget_typeA'
|
2013-01-03 11:38:14 +00:00
|
|
|
render "typeA"
|
|
|
|
when /typeB_/
|
2013-01-10 01:40:52 +00:00
|
|
|
@tag_class = "default_widget_#{params[:type]}"
|
2013-01-03 11:38:14 +00:00
|
|
|
render "typeB"
|
|
|
|
when "typeC"
|
2013-01-10 01:40:52 +00:00
|
|
|
@tag_class = 'default_widget_typeC'
|
2013-01-03 11:38:14 +00:00
|
|
|
render "typeC"
|
|
|
|
end
|
|
|
|
|
|
|
|
# {"inner"=>"true",
|
|
|
|
# "category_id"=>"false",
|
|
|
|
# "tag_id"=>"",
|
|
|
|
# "page"=>"",
|
|
|
|
# "search_query"=>"",
|
|
|
|
# "part_title"=>"",
|
|
|
|
# "part_id"=>"50ac426f83e75219d20000a7",
|
|
|
|
# "controller"=>"default_widget",
|
|
|
|
# "action"=>"default_widget",
|
|
|
|
# "type"=>"typeA"}
|
|
|
|
end
|
|
|
|
end
|