Fix authors display.

This commit is contained in:
BoHung Chiu 2021-12-16 15:23:06 +08:00
parent 689e08ea1a
commit a18c1d0618
2 changed files with 28 additions and 7 deletions

View File

@ -1,12 +1,33 @@
module Admin::PersonalConferencesHelper
def get_authors_text(writing_conference)
(writing_conference.authors.to_s.blank? ? get_member(writing_conference).collect(&:name).join('/') : Nokogiri::HTML(writing_conference.authors.to_s).text rescue '')
authors_text = Nokogiri::HTML(writing_conference.authors.to_s).text
split_text = authors_text.match(/[、,,\/]/)
split_text = split_text.nil? ? '/' : split_text[0]
full_authors_names = get_member(writing_conference).collect(&:name)
if authors_text.present?
authors_names = authors_text.split(split_text).select{|a| !(full_authors_names.include?(a.strip()))}
full_authors_names += authors_names
end
full_authors_names.join(split_text)
end
def get_authors_show(writing_conference)
(writing_conference.authors.to_s.blank? ? get_member_show(writing_conference) : writing_conference.authors.to_s rescue '')
authors_text = Nokogiri::HTML(writing_conference.authors.to_s).text
split_text = authors_text.match(/[、,,\/]/)
split_text = split_text.nil? ? '/' : split_text[0]
full_authors_names = []
full_authors = get_member(writing_conference).collect{|member|
member_name = member.name
full_authors_names << member_name
"<a href='#{OrbitHelper.url_to_plugin_show(member.to_param,'member')}' title='#{member_name}'>#{member_name}</a>"
}
if authors_text.present?
authors_names = authors_text.split(split_text).select{|a| !(full_authors_names.include?(a.strip()))}
full_authors += authors_names
end
full_authors.join(split_text)
end
def get_member(writing_conference)
Array(MemberProfile.find(Array(writing_conference).collect(&:member_profile_id)))
Array(MemberProfile.where(:id.in=>Array(writing_conference).collect(&:member_profile_id).flatten))
end
def get_member_show(writing_conference)
get_member(writing_conference).collect{|member| "<a href='#{OrbitHelper.url_to_plugin_show(member.to_param,'member')}' title='#{member.name}'>#{member.name}</a>"}.join('/')

View File

@ -199,7 +199,7 @@ class WritingConference
when "url"
value = self.url.to_s.blank? ? "" : "<a href='#{self.url}'>#{self.url}</a>"
when "authors"
value = get_member_show(self) rescue ""
value = get_authors_show(self) rescue ""
else
value = self.send(field) rescue ""
end