2014-05-08 07:33:39 +00:00
|
|
|
class FaqsController < ApplicationController
|
2014-08-05 06:39:47 +00:00
|
|
|
def index
|
2016-05-09 17:12:43 +00:00
|
|
|
faqs = Qa.can_display.order_by(:order_position => "asc").filter_by_categories
|
2014-08-05 06:39:47 +00:00
|
|
|
f = faqs.collect do |qa|
|
|
|
|
statuses = qa.statuses_with_classname.collect do |status|
|
2014-06-18 10:03:39 +00:00
|
|
|
{
|
|
|
|
"status" => status["name"],
|
|
|
|
"status-class" => "status-#{status['classname']}"
|
|
|
|
}
|
|
|
|
end
|
2014-08-05 06:39:47 +00:00
|
|
|
{
|
|
|
|
"link_to_show" => OrbitHelper.url_to_show(qa.to_param),
|
|
|
|
"question" => qa.title,
|
2014-11-07 11:00:48 +00:00
|
|
|
"answer" => qa.answer,
|
2014-08-05 06:39:47 +00:00
|
|
|
"statuses" => statuses
|
|
|
|
}
|
|
|
|
end
|
|
|
|
{
|
|
|
|
"faqs" => f,
|
|
|
|
"extras" => {"widget-title"=>"Faqs"},
|
|
|
|
"total_pages" => faqs.total_pages
|
|
|
|
}
|
|
|
|
end
|
2014-05-08 07:33:39 +00:00
|
|
|
|
2014-08-05 06:39:47 +00:00
|
|
|
def show
|
|
|
|
params = OrbitHelper.params
|
|
|
|
faq = Qa.can_display.find_by_param(params[:uid])
|
2014-05-23 06:03:16 +00:00
|
|
|
|
2014-08-05 06:39:47 +00:00
|
|
|
url_to_edit = OrbitHelper.user_can_edit?(faq) ? "/admin/faqs/#{faq.id.to_s}/edit" : ""
|
2014-12-11 09:48:10 +00:00
|
|
|
|
|
|
|
return {} if (faq.category.disable rescue false)
|
2014-08-05 06:39:47 +00:00
|
|
|
|
|
|
|
faqs_files = faq.qa_files.collect do |f|
|
|
|
|
{
|
|
|
|
"file_url" => f.file.url,
|
|
|
|
"file_title" => f.title
|
|
|
|
}
|
|
|
|
end
|
|
|
|
faqs_links = faq.qa_links.collect do |f|
|
|
|
|
{
|
|
|
|
"link_url" => f.url,
|
|
|
|
"link_title" => f.title
|
|
|
|
}
|
|
|
|
end
|
|
|
|
tags = faq.tags.map{|tag| { "tag" => tag.name } } rescue []
|
|
|
|
{
|
|
|
|
"extras" => {"question" => faq.title,"answer" => faq.answer},
|
|
|
|
"faqs_links" => faqs_links,
|
|
|
|
"faqs_files" => faqs_files,
|
|
|
|
"tags" => tags,
|
|
|
|
"url_to_edit" => url_to_edit
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def widget
|
|
|
|
faqs = Qa.filter_by_widget_categories.collect do |qa|
|
|
|
|
statuses = qa.statuses_with_classname.collect do |status|
|
|
|
|
{
|
|
|
|
"status" => status["name"],
|
|
|
|
"status-class" => "status-#{status['classname']}"
|
|
|
|
}
|
|
|
|
end
|
|
|
|
{
|
|
|
|
"link_to_show" => OrbitHelper.widget_item_url(qa.to_param),
|
|
|
|
"title" => qa.title,
|
|
|
|
"postdate" => qa.created_at.strftime('%Y-%m-%d %H:%M'),
|
|
|
|
"statuses" => statuses
|
|
|
|
}
|
|
|
|
end
|
|
|
|
{
|
|
|
|
"faqs" => faqs,
|
|
|
|
"extras" => {"widget-title"=>"Faqs","more_url"=>OrbitHelper.widget_more_url}
|
|
|
|
}
|
|
|
|
end
|
2014-05-08 07:33:39 +00:00
|
|
|
end
|