diff --git a/app/helpers/admin/journal_papers_helper.rb b/app/helpers/admin/journal_papers_helper.rb index cfe0bb6..fc889ef 100644 --- a/app/helpers/admin/journal_papers_helper.rb +++ b/app/helpers/admin/journal_papers_helper.rb @@ -3,14 +3,48 @@ module Admin::JournalPapersHelper (journal.authors.to_s.blank? ? get_member(journal).collect(&:name).join('/') : Nokogiri::HTML(journal.authors.to_s).text rescue "") end def get_authors_show(journal) - member_names = get_member_show(journal) - (journal.authors.to_s.blank? ? get_member_show(journal) : (member_names.blank? ? journal.authors.to_s : (member_names + "、" + journal.authors.to_s.gsub(",","、").gsub(",","、")) ) rescue "") + begin + if journal.authors.to_s.blank? + get_member_show(journal) + else + members = get_member(journal) + if members.blank? + journal.authors.to_s + else + authors = journal.authors.to_s.split(/,|,/).collect{|v| v.strip} + authors_tp = authors.clone + locales = Site.first.enable_locales rescue I18n.available_locales + members_tp = members.select do |member| + flag = true + locales.each do |locale| + name_tp = I18n.with_locale(locale) do + member.name.strip + end + author_index = authors.index(name_tp) + if !author_index.nil? + author = authors[author_index] + authors_tp[author_index] = "#{author}" + flag = false + break + end + end + flag + end + (get_a_tag_from_members(members_tp) + authors_tp).join('、') + end + end + rescue => e + "" + end end def get_member(journal) Array(MemberProfile.find(Array(journal).collect(&:member_profile_id))) rescue [] end + def get_a_tag_from_members(members) + members.collect{|member| "#{member.name}"} + end def get_member_show(journal) - get_member(journal).collect{|member| "#{member.name}"}.join('、') + get_a_tag_from_members(get_member(journal)).join('、') end def get_level_type(journal) !journal.journal_levels.blank? ? "(#{journal.journal_levels.collect(&:title).join(', ')})" : nil