88 lines
3.6 KiB
Ruby
88 lines
3.6 KiB
Ruby
class DigitalArchivesController < ApplicationController
|
|
def index
|
|
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])
|
|
else
|
|
@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])
|
|
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
|
|
{
|
|
"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
|
|
}
|
|
end
|
|
page = Page.where(:page_id => params[:page_id]).first rescue nil
|
|
url = page.nil? ? "#" : "/#{I18n.locale.to_s}#{page.url}"
|
|
{
|
|
"digital_content_archives" => dcas,
|
|
"extras" => {
|
|
"page_url" => url,
|
|
"th_title" => t('title'),
|
|
"th_location" => t('location'),
|
|
"th_department" => t('department'),
|
|
"th_character" => t('character')
|
|
"th_location" => t('location'),
|
|
"th_description" => t('description'),
|
|
"th_detaildes" => t('detail_description'),
|
|
"th_material" => t('material'),
|
|
"th_size" => t('size'),
|
|
"th_item_date" => t('item_date'),
|
|
"th_item_id" => t('item_id'),
|
|
"th_item_from" => t('item_from'),
|
|
"th_item_status" => t('item_status')
|
|
}
|
|
}
|
|
end
|
|
|
|
def show
|
|
end
|
|
end |