This commit is contained in:
Ruling-Mac 2015-10-21 15:42:37 +08:00
parent 456c698d31
commit f8f86f7b57
1 changed files with 33 additions and 30 deletions

View File

@ -1,34 +1,35 @@
class DigitalArchivesController < ApplicationController
def index
if OrbitHelper.params[:item_date_low].nil?
@digital_content_archives = DigitalContentArchive.where(:title => /#{OrbitHelper.params[:title]}/ ,
:character => /#{OrbitHelper.params[:character]}/ ,
:location => /#{OrbitHelper.params[:location]}/,
:description =>/#{OrbitHelper.params[:description]}/)
elsif OrbitHelper.params[:item_date_low].empty? && OrbitHelper.params[:item_date_high].empty?
@digital_content_archives = DigitalContentArchive.where(:title => /#{OrbitHelper.params[:title]}/ ,
:character => /#{OrbitHelper.params[:character]}/ ,
:location => /#{OrbitHelper.params[:location]}/,
:description =>/#{OrbitHelper.params[:description]}/)
elsif OrbitHelper.params[:item_date_low].empty? && !OrbitHelper.params[:item_date_high].empty?
@digital_content_archives = DigitalContentArchive.where(:title => /#{OrbitHelper.params[:title]}/ ,
:character => /#{OrbitHelper.params[:character]}/ ,
:location => /#{OrbitHelper.params[:location]}/,
:description =>/#{OrbitHelper.params[:description]}/,
:item_date.lte => OrbitHelper.params[:item_date_high])
elsif !OrbitHelper.params[:item_date_low].empty? && OrbitHelper.params[:item_date_high].empty?
@digital_content_archives = DigitalContentArchive.where(:title => /#{OrbitHelper.params[:title]}/ ,
:character => /#{OrbitHelper.params[:character]}/ ,
:location => /#{OrbitHelper.params[:location]}/,
:description =>/#{OrbitHelper.params[:description]}/,
:item_date.gte => OrbitHelper.params[:item_date_low])
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 => /#{OrbitHelper.params[:title]}/ ,
:character => /#{OrbitHelper.params[:character]}/ ,
:location => /#{OrbitHelper.params[:location]}/,
:description =>/#{OrbitHelper.params[:description]}/,
:item_date.gte => OrbitHelper.params[:item_date_low],
:item_date.lte => OrbitHelper.params[:item_date_high])
@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|
@ -48,9 +49,11 @@ class DigitalArchivesController < ApplicationController
"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
"digital_content_archives" => dcas,
"page_url" => url
}
end