2015-08-11 08:39:31 +00:00
|
|
|
class DigitalArchivesController < ApplicationController
|
|
|
|
def index
|
2015-10-21 07:42:37 +00:00
|
|
|
params = OrbitHelper.params
|
|
|
|
if params[:item_date_low].nil?
|
|
|
|
@digital_content_archives = DigitalContentArchive.where(:title => /#{params[:title]}/ ,
|
|
|
|
:character => /#{params[:character]}/ ,
|
|
|
|
:location => /#{params[:location]}/,
|
|
|
|
:description =>/#{params[:description]}/)
|
|
|
|
elsif params[:item_date_low].empty? && params[:item_date_high].empty?
|
|
|
|
@digital_content_archives = DigitalContentArchive.where(:title => /#{params[:title]}/ ,
|
|
|
|
:character => /#{params[:character]}/ ,
|
|
|
|
:location => /#{params[:location]}/,
|
|
|
|
:description =>/#{params[:description]}/)
|
|
|
|
elsif params[:item_date_low].empty? && !params[:item_date_high].empty?
|
|
|
|
@digital_content_archives = DigitalContentArchive.where(:title => /#{params[:title]}/ ,
|
|
|
|
:character => /#{params[:character]}/ ,
|
|
|
|
:location => /#{params[:location]}/,
|
|
|
|
:description =>/#{params[:description]}/,
|
|
|
|
:item_date.lte => params[:item_date_high])
|
|
|
|
elsif !params[:item_date_low].empty? && params[:item_date_high].empty?
|
|
|
|
@digital_content_archives = DigitalContentArchive.where(:title => /#{params[:title]}/ ,
|
|
|
|
:character => /#{params[:character]}/ ,
|
|
|
|
:location => /#{params[:location]}/,
|
|
|
|
:description =>/#{params[:description]}/,
|
|
|
|
:item_date.gte => params[:item_date_low])
|
2015-08-11 08:39:31 +00:00
|
|
|
else
|
2015-10-21 07:42:37 +00:00
|
|
|
@digital_content_archives = DigitalContentArchive.where(:title => /#{params[:title]}/ ,
|
|
|
|
:character => /#{params[:character]}/ ,
|
|
|
|
:location => /#{params[:location]}/,
|
|
|
|
:description =>/#{params[:description]}/,
|
|
|
|
:item_date.gte => params[:item_date_low],
|
|
|
|
:item_date.lte => params[:item_date_high])
|
2015-08-11 08:39:31 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
dcas = @digital_content_archives.collect do |dca|
|
|
|
|
dcafs = dca.digital_content_archive_files.collect do |file|
|
|
|
|
if file.choose_lang.include?(I18n.locale.to_s)
|
|
|
|
title = (file.file_title.blank? ? File.basename(file.file.path) : file.file_title) rescue ""
|
|
|
|
extension = file.file.file.extension.downcase rescue ""
|
|
|
|
# url = file.file.url rescue ""
|
|
|
|
{
|
|
|
|
"file-name" => title
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
{
|
2015-10-21 10:32:10 +00:00
|
|
|
"link_to_show" => OrbitHelper.url_to_show(dca.to_param),
|
2015-08-11 08:39:31 +00:00
|
|
|
"title" => (dca.title rescue ""),
|
|
|
|
"item-date" => (dca.item_date rescue ""),
|
2015-10-21 07:52:22 +00:00
|
|
|
"location" => (dca.location rescue ""),
|
|
|
|
"department" => (dca.department rescue ""),
|
|
|
|
"character" => (dca.character rescue ""),
|
|
|
|
"description" => (dca.description rescue ""),
|
2015-10-21 09:34:28 +00:00
|
|
|
"detail-description" => (dca.detail_description rescue ""),
|
2015-10-21 07:52:22 +00:00
|
|
|
"material" => (dca.material rescue ""),
|
|
|
|
"size" => (dca.size rescue ""),
|
2015-10-21 09:34:28 +00:00
|
|
|
"item-id" => (dca.item_id rescue ""),
|
|
|
|
"item-from" => (dca.item_from rescue ""),
|
|
|
|
"item-status" => (dca.item_status rescue ""),
|
|
|
|
"album-content" => (dca.album_content rescue ""),
|
2015-08-11 08:39:31 +00:00
|
|
|
"files" => dcafs
|
|
|
|
}
|
|
|
|
end
|
2015-10-21 07:42:37 +00:00
|
|
|
page = Page.where(:page_id => params[:page_id]).first rescue nil
|
2015-10-21 07:52:22 +00:00
|
|
|
url = page.nil? ? "#" : "/#{I18n.locale.to_s}#{page.url}"
|
2015-08-11 08:39:31 +00:00
|
|
|
{
|
2015-10-21 07:42:37 +00:00
|
|
|
"digital_content_archives" => dcas,
|
2015-10-21 07:46:04 +00:00
|
|
|
"extras" => {
|
2015-10-21 09:34:28 +00:00
|
|
|
"page_url" => url,
|
|
|
|
"th_title" => t('title'),
|
2015-10-21 10:09:15 +00:00
|
|
|
"th_location" => t("digital_archive.location"),
|
|
|
|
"th_department" => t('digital_archive.department'),
|
|
|
|
"th_character" => t('digital_archive.character'),
|
|
|
|
"th_description" => t('digital_archive.description'),
|
|
|
|
"th_detaildes" => t('digital_archive.detail_description'),
|
|
|
|
"th_material" => t('digital_archive.material'),
|
|
|
|
"th_size" => t('digital_archive.size'),
|
|
|
|
"th_item_date" => t('digital_archive.item_date'),
|
|
|
|
"th_item_id" => t('digital_archive.item_id'),
|
|
|
|
"th_item_from" => t('digital_archive.item_from'),
|
|
|
|
"th_item_status" => t('digital_archive.item_status')
|
2015-10-21 07:46:04 +00:00
|
|
|
}
|
2015-08-11 08:39:31 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
2015-10-21 10:32:10 +00:00
|
|
|
params = OrbitHelper.params
|
|
|
|
dca = DigitalContentArchive.find_by_param(params[:uid])
|
|
|
|
|
|
|
|
dcafs = dca.digital_content_archive_files.collect do |file|
|
|
|
|
if file.choose_lang.include?(I18n.locale.to_s)
|
|
|
|
title = (file.file_title.blank? ? File.basename(file.file.path) : file.file_title) rescue ""
|
|
|
|
extension = file.file.file.extension.downcase rescue ""
|
|
|
|
# url = file.file.url rescue ""
|
|
|
|
{
|
|
|
|
"file-name" => title
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
url = page.nil? ? "#" : "/#{I18n.locale.to_s}#{page.url}"
|
|
|
|
dca = {
|
|
|
|
"title" => (dca.title rescue ""),
|
|
|
|
"item-date" => (dca.item_date rescue ""),
|
|
|
|
"location" => (dca.location rescue ""),
|
|
|
|
"department" => (dca.department rescue ""),
|
|
|
|
"character" => (dca.character rescue ""),
|
|
|
|
"description" => (dca.description rescue ""),
|
|
|
|
"detail-description" => (dca.detail_description rescue ""),
|
|
|
|
"material" => (dca.material rescue ""),
|
|
|
|
"size" => (dca.size rescue ""),
|
|
|
|
"item-id" => (dca.item_id rescue ""),
|
|
|
|
"item-from" => (dca.item_from rescue ""),
|
|
|
|
"item-status" => (dca.item_status rescue ""),
|
|
|
|
"album-content" => (dca.album_content rescue ""),
|
|
|
|
"files" => dcafs
|
|
|
|
}
|
|
|
|
dcas =
|
|
|
|
{
|
|
|
|
"digital_content_archives" => dca,
|
|
|
|
"extras" => {
|
|
|
|
"th_title" => t('title'),
|
|
|
|
"th_location" => t("digital_archive.location"),
|
|
|
|
"th_department" => t('digital_archive.department'),
|
|
|
|
"th_character" => t('digital_archive.character'),
|
|
|
|
"th_description" => t('digital_archive.description'),
|
|
|
|
"th_detaildes" => t('digital_archive.detail_description'),
|
|
|
|
"th_material" => t('digital_archive.material'),
|
|
|
|
"th_size" => t('digital_archive.size'),
|
|
|
|
"th_item_date" => t('digital_archive.item_date'),
|
|
|
|
"th_item_id" => t('digital_archive.item_id'),
|
|
|
|
"th_item_from" => t('digital_archive.item_from'),
|
|
|
|
"th_item_status" => t('digital_archive.item_status')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-08-11 08:39:31 +00:00
|
|
|
end
|
|
|
|
end
|