2014-05-08 07:33:39 +00:00
|
|
|
class FaqsController < ApplicationController
|
|
|
|
def index
|
2014-06-18 06:41:43 +00:00
|
|
|
faqs = Qa.can_display.order_by(:created_at=>'desc').filter_by_categories
|
|
|
|
f = faqs.collect do |qa|
|
2014-06-18 10:03:39 +00:00
|
|
|
statuses = qa.statuses_with_classname.collect do |status|
|
|
|
|
{
|
|
|
|
"status" => status["name"],
|
|
|
|
"status-class" => "status-#{status['classname']}"
|
|
|
|
}
|
|
|
|
end
|
2014-05-08 07:33:39 +00:00
|
|
|
{
|
|
|
|
"link_to_show" => OrbitHelper.url_to_show(qa.to_param),
|
2014-06-18 06:32:57 +00:00
|
|
|
"question" => qa.title,
|
|
|
|
"statuses" => statuses
|
2014-05-08 07:33:39 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
{
|
2014-06-18 07:15:14 +00:00
|
|
|
"faqs" => f,
|
2014-06-18 06:41:43 +00:00
|
|
|
"extras" => {"widget-title"=>"Faqs"},
|
2014-06-18 06:32:57 +00:00
|
|
|
"total_pages" => faqs.total_pages
|
2014-05-08 07:33:39 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
params = OrbitHelper.params
|
2014-06-18 06:32:57 +00:00
|
|
|
faq = Qa.can_display.find_by_param(params[:uid])
|
2014-05-08 07:33:39 +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
|
2014-06-18 06:32:57 +00:00
|
|
|
tags = faq.tags.map{|tag| { "tag" => tag.name } } rescue []
|
2014-05-08 07:33:39 +00:00
|
|
|
{
|
|
|
|
"extras" => {"question" => faq.title,"answer" => faq.answer},
|
|
|
|
"faqs_links" => faqs_links,
|
2014-06-18 06:32:57 +00:00
|
|
|
"faqs_files" => faqs_files,
|
|
|
|
"tags" => tags
|
2014-05-08 07:33:39 +00:00
|
|
|
}
|
|
|
|
end
|
2014-05-23 06:03:16 +00:00
|
|
|
|
|
|
|
def widget
|
|
|
|
faqs = Qa.filter_by_widget_categories.collect do |qa|
|
|
|
|
{
|
2014-05-24 11:37:57 +00:00
|
|
|
"link_to_show" => OrbitHelper.widget_item_url(qa.to_param),
|
2014-05-23 06:03:16 +00:00
|
|
|
"title" => qa.title,
|
|
|
|
"postdate" => qa.created_at.strftime('%Y-%m-%d %H:%M')
|
|
|
|
}
|
|
|
|
end
|
|
|
|
{
|
|
|
|
"faqs" => faqs,
|
2014-05-24 11:37:57 +00:00
|
|
|
"extras" => {"widget-title"=>"Faqs","more_url"=>OrbitHelper.widget_more_url}
|
2014-05-23 06:03:16 +00:00
|
|
|
}
|
|
|
|
end
|
2014-05-08 07:33:39 +00:00
|
|
|
end
|