diff --git a/app/controllers/personal_journals_controller.rb b/app/controllers/personal_journals_controller.rb index 38f2bf2..dc2ea81 100644 --- a/app/controllers/personal_journals_controller.rb +++ b/app/controllers/personal_journals_controller.rb @@ -1,12 +1,8 @@ class PersonalJournalsController < ApplicationController - def search_all_words(target,word) - target=target.upcase - words=word.upcase.split(' ') - return words.select{|value| target.include? value}==words - end def index params = OrbitHelper.params - journal_papers = JournalPaper.where(:is_hidden=>false).sort_for_frontend.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count) + page_data_count = OrbitHelper.page_data_count + journal_papers = JournalPaper.where(:is_hidden=>false).sort_for_frontend.page(OrbitHelper.params[:page_no]).per(page_data_count) page = Page.where(:page_id => params[:page_id]).first rescue nil if page.custom_string_field == "table" fields_to_show = page.custom_array_field rescue [] @@ -40,6 +36,8 @@ class PersonalJournalsController < ApplicationController journal_papers_show = journal_papers_temp.select {|value| search_all_words((value.send("publication_date").strftime("%Y/%m/%d") rescue ""), params[:keywords])} when "author_type" journal_papers_show = journal_papers_temp.select {|value| search_all_words(value.journal_paper_author_types.collect{|jat| jat.title}.join(", "), params[:keywords])} + when "paper_types" + journal_papers_show = journal_papers_temp.select {|value| search_all_words(value.journal_paper_type.collect{|x| x.title}.join(", "), params[:keywords])} when "language" journal_papers_show = journal_papers_temp.select {|value| search_all_words((!value.language.nil? ? t("#{value.language}") : ""), params[:keywords])} else @@ -50,8 +48,8 @@ class PersonalJournalsController < ApplicationController else page_to_show = params[:page_no].to_i end - journal_papers = journal_papers_show[(page_to_show-1)*OrbitHelper.page_data_count...page_to_show*OrbitHelper.page_data_count] - journal_papers_total_pages = (journal_papers_show.length/OrbitHelper.page_data_count.to_f).ceil + journal_papers = journal_papers_show[(page_to_show-1)*page_data_count...page_to_show*page_data_count] + journal_papers_total_pages = (journal_papers_show.length/page_data_count.to_f).ceil else journal_papers_total_pages = journal_papers.total_pages end @@ -73,7 +71,7 @@ class PersonalJournalsController < ApplicationController when "author_type" t << {"value" => (journal_paper.journal_paper_author_types.collect{|jat| jat.title}.join(", ") rescue "")} when "paper_types" - t << {"value" => ( !journal_paper.paper_types.blank? ? "(#{journal_paper.paper_types.collect{|x| x.title}.join(', ')})" : nil)} + t << {"value" => ( !journal_paper.journal_paper_type.blank? ? "(#{journal_paper.journal_paper_type.collect{|x| x.title}.join(', ')})" : nil)} when "language" t << {"value" => (!journal_paper.language.nil? ? t("#{journal_paper.language}") : "")} else @@ -185,4 +183,10 @@ class PersonalJournalsController < ApplicationController page.save render :json => {"success" => true}.to_json end +private + def search_all_words(target,word) + target=target.upcase + words=word.upcase.split(' ') + return words.select{|value| target.include? value}==words + end end