fix some error

This commit is contained in:
chiu 2020-04-25 12:35:30 +08:00
parent 8491ec8283
commit 69682e9b79
2 changed files with 36 additions and 26 deletions

View File

@ -9,17 +9,20 @@ module AnnouncementsHelper
subpart.select_options.each do |select_option| subpart.select_options.each do |select_option|
if !(@show_options.nil?) && select_option.field_name == @show_options.keys.first.to_s if !(@show_options.nil?) && select_option.field_name == @show_options.keys.first.to_s
value = YAML.load(select_option.value) value = YAML.load(select_option.value)
if value[I18n.locale] == t('announcement.small_size') tmp = value[:en]
I18n.with_locale(:en) do
if tmp == t('announcement.small_size')
@image_version = 'thumb' @image_version = 'thumb'
elsif value[I18n.locale] == t('announcement.medium_size') elsif tmp == t('announcement.medium_size')
@image_version = 'mobile' @image_version = 'mobile'
elsif value[I18n.locale] == t('announcement.orignal_size') elsif tmp == t('announcement.orignal_size')
@image_version = 'orignal' @image_version = 'orignal'
end end
end end
end end
end end
end end
end
def data_to_human_type(a) def data_to_human_type(a)
statuses = a.statuses_with_classname.collect do |status| statuses = a.statuses_with_classname.collect do |status|
{ {
@ -141,13 +144,13 @@ module AnnouncementsHelper
sorted sorted
end end
end end
def get_sorted_annc def get_sorted_annc(data_count=nil)
params = OrbitHelper.params params = OrbitHelper.params
locale = OrbitHelper.get_site_locale.to_s locale = OrbitHelper.get_site_locale.to_s
page = Page.where(url:params['url']).first page = Page.where(url:params['url']).first
page_number = OrbitHelper.page_number.to_i page_number = OrbitHelper.page_number.to_i
page_number = 1 if page_number == 0 page_number = 1 if page_number == 0
page_data_count = OrbitHelper.page_data_count.to_i page_data_count = data_count || OrbitHelper.page_data_count.to_i
feeds_anns = [] feeds_anns = []
tags = page.tags tags = page.tags
categories = params['category']=='all' ? (page.categories || []) : ([Category.find(params['category'])] rescue (page.categories || [])) categories = params['category']=='all' ? (page.categories || []) : ([Category.find(params['category'])] rescue (page.categories || []))

View File

@ -10,20 +10,24 @@
page.select_option_items.each do |select_option_item| page.select_option_items.each do |select_option_item|
if !(@show_option_items.nil?) && select_option_item.field_name == @show_option_items.keys.first.to_s if !(@show_option_items.nil?) && select_option_item.field_name == @show_option_items.keys.first.to_s
value = YAML.load(select_option_item.value) value = YAML.load(select_option_item.value)
if value[I18n.locale] == t('announcement.not_show') tmp = value[:en]
I18n.with_locale(:en) do
if tmp == t('announcement.not_show')
@show_back_and_next_flag = 0 @show_back_and_next_flag = 0
elsif value[I18n.locale] == t('announcement.show_top') elsif tmp == t('announcement.show_top')
@show_back_and_next_flag = 1 @show_back_and_next_flag = 1
elsif value[I18n.locale] == t('announcement.show_bottom') elsif tmp == t('announcement.show_bottom')
@show_back_and_next_flag = 2 @show_back_and_next_flag = 2
end end
end end
end end
end end
end
if @show_back_and_next_flag != 0 if @show_back_and_next_flag != 0
uid = params['uid'] uid = params['uid']
sorted,total_pages = get_sorted_annc sorted,total_pages = get_sorted_annc(0)
now_index = sorted.to_enum.with_index.select{|v| v[0].uid==uid}[0][1] now_index = sorted.to_enum.with_index.select{|v| v[0].uid==uid}[0][1] rescue nil
if !now_index.nil?
if now_index != 0 if now_index != 0
prev_result = sorted[now_index-1] prev_result = sorted[now_index-1]
prev_url = params['url'] + '/' + prev_result.to_param prev_url = params['url'] + '/' + prev_result.to_param
@ -35,6 +39,9 @@
next_content = "<a href='#{next_url}' title='#{t('announcement.next')}' class='next'><b>#{t('announcement.next')}</b><p>#{next_result['title'][I18n.locale]}</p></a>" next_content = "<a href='#{next_url}' title='#{t('announcement.next')}' class='next'><b>#{t('announcement.next')}</b><p>#{next_result['title'][I18n.locale]}</p></a>"
end end
content = "<div class='see_more_boxTitle'>#{prev_content}#{next_content}</div>".html_safe content = "<div class='see_more_boxTitle'>#{prev_content}#{next_content}</div>".html_safe
else
content = ''
end
end end
%> %>
<% if @show_back_and_next_flag!=0 %> <% if @show_back_and_next_flag!=0 %>