2014-05-14 11:52:06 +00:00
|
|
|
class ArchivesController < ApplicationController
|
|
|
|
def index
|
|
|
|
categories = OrbitHelper.page_categories
|
|
|
|
@categories = []
|
|
|
|
if categories.first == "all"
|
|
|
|
module_app = OrbitHelper.this_module_app
|
|
|
|
@categories = module_app.categories.collect do |cat|
|
|
|
|
{
|
2014-07-16 09:11:29 +00:00
|
|
|
"title" => cat.title || "",
|
2014-05-14 11:52:06 +00:00
|
|
|
"id" => cat.id.to_s
|
|
|
|
}
|
|
|
|
end
|
|
|
|
else
|
|
|
|
categories.each do |cat|
|
|
|
|
c = Category.find(cat)
|
2014-07-16 09:11:29 +00:00
|
|
|
@categories << {"title" => c.title || "", "id" => c.id.to_s}
|
2014-05-14 11:52:06 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
cats = @categories.collect do |cat|
|
2014-06-30 07:31:10 +00:00
|
|
|
archives = ArchiveFile.where(:category_id => cat["id"]).order_by(:sort_number=>'asc').collect do |archive|
|
2014-06-18 10:07:10 +00:00
|
|
|
statuses = archive.statuses_with_classname.collect do |status|
|
|
|
|
{
|
2014-07-16 09:11:29 +00:00
|
|
|
"status" => status["name"] || "",
|
2014-06-18 10:07:10 +00:00
|
|
|
"status-class" => "status-#{status['classname']}"
|
|
|
|
}
|
|
|
|
end
|
2014-06-30 07:31:10 +00:00
|
|
|
files = archive.archive_file_multiples.order_by(:sort_number=>'asc').collect do |file|
|
2014-07-10 07:48:38 +00:00
|
|
|
title = (file.file_title.blank? ? File.basename(file.file.path) : file.file_title)
|
2014-05-14 11:52:06 +00:00
|
|
|
{
|
2014-07-16 09:11:29 +00:00
|
|
|
"file-name" => title || "",
|
|
|
|
"file-type" => file.file.file.extension.downcase || "",
|
|
|
|
"file-url" => file.file.url || ""
|
2014-05-14 11:52:06 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
{
|
2014-07-16 09:11:29 +00:00
|
|
|
"archive-title" => archive.title || "",
|
|
|
|
"statuses" => statuses || [],
|
2014-05-14 11:52:06 +00:00
|
|
|
"files" => files
|
|
|
|
}
|
|
|
|
end
|
|
|
|
{
|
2014-07-16 09:11:29 +00:00
|
|
|
"category-title" => cat["title"] || "",
|
2014-05-14 11:52:06 +00:00
|
|
|
"archives" => archives
|
|
|
|
}
|
|
|
|
end
|
|
|
|
{
|
2014-07-16 09:11:29 +00:00
|
|
|
"categories" => cats
|
2014-05-14 11:52:06 +00:00
|
|
|
}
|
|
|
|
end
|
2014-05-23 06:00:49 +00:00
|
|
|
|
|
|
|
def widget
|
|
|
|
categories = OrbitHelper.widget_categories
|
|
|
|
@categories = []
|
|
|
|
if categories.first == "all"
|
|
|
|
module_app = OrbitHelper.widget_module_app
|
|
|
|
@categories = module_app.categories.collect do |cat|
|
|
|
|
{
|
|
|
|
"title" => cat.title,
|
|
|
|
"id" => cat.id.to_s
|
|
|
|
}
|
|
|
|
end
|
|
|
|
else
|
|
|
|
categories.each do |cat|
|
|
|
|
c = Category.find(cat)
|
|
|
|
@categories << {"title" => c.title, "id" => c.id.to_s}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
cats = @categories.collect do |cat|
|
2014-06-09 02:01:53 +00:00
|
|
|
archives = ArchiveFile.can_display.where(:category_id => cat["id"]).collect do |archive|
|
2014-05-23 06:00:49 +00:00
|
|
|
{
|
2014-05-24 11:37:07 +00:00
|
|
|
"archive-title" => archive.title,
|
|
|
|
"archive_url" => OrbitHelper.widget_more_url
|
2014-05-23 06:00:49 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
{
|
|
|
|
"category-title" => cat["title"],
|
|
|
|
"archives" => archives
|
|
|
|
}
|
|
|
|
end
|
|
|
|
{
|
|
|
|
"categories" => cats,
|
2014-05-24 11:37:07 +00:00
|
|
|
"extras" => {"widget-title" => "Archives","more_url"=>OrbitHelper.widget_more_url}
|
2014-05-23 06:00:49 +00:00
|
|
|
}
|
|
|
|
end
|
2014-05-14 11:52:06 +00:00
|
|
|
end
|