diff --git a/app/controllers/digital_archives_controller.rb b/app/controllers/digital_archives_controller.rb index f1ffa5d..8643722 100644 --- a/app/controllers/digital_archives_controller.rb +++ b/app/controllers/digital_archives_controller.rb @@ -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