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,12 +9,15 @@ 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]
@image_version = 'thumb' I18n.with_locale(:en) do
elsif value[I18n.locale] == t('announcement.medium_size') if tmp == t('announcement.small_size')
@image_version = 'mobile' @image_version = 'thumb'
elsif value[I18n.locale] == t('announcement.orignal_size') elsif tmp == t('announcement.medium_size')
@image_version = 'orignal' @image_version = 'mobile'
elsif tmp == t('announcement.orignal_size')
@image_version = 'orignal'
end
end end
end end
end end
@ -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,31 +10,38 @@
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]
@show_back_and_next_flag = 0 I18n.with_locale(:en) do
elsif value[I18n.locale] == t('announcement.show_top') if tmp == t('announcement.not_show')
@show_back_and_next_flag = 1 @show_back_and_next_flag = 0
elsif value[I18n.locale] == t('announcement.show_bottom') elsif tmp == t('announcement.show_top')
@show_back_and_next_flag = 2 @show_back_and_next_flag = 1
elsif tmp == t('announcement.show_bottom')
@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 != 0 if !now_index.nil?
prev_result = sorted[now_index-1] if now_index != 0
prev_url = params['url'] + '/' + prev_result.to_param prev_result = sorted[now_index-1]
prev_content = "<a href='#{prev_url}' title='#{t('announcement.prev')}' class='prev'><b>#{t('announcement.prev')}</b><p>#{prev_result['title'][I18n.locale]}</p></a>" prev_url = params['url'] + '/' + prev_result.to_param
prev_content = "<a href='#{prev_url}' title='#{t('announcement.prev')}' class='prev'><b>#{t('announcement.prev')}</b><p>#{prev_result['title'][I18n.locale]}</p></a>"
end
if now_index != sorted.length-1
next_result = sorted[now_index+1]
next_url = params['url'] + '/' + next_result.to_param
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
content = "<div class='see_more_boxTitle'>#{prev_content}#{next_content}</div>".html_safe
else
content = ''
end end
if now_index != sorted.length-1
next_result = sorted[now_index+1]
next_url = params['url'] + '/' + next_result.to_param
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
content = "<div class='see_more_boxTitle'>#{prev_content}#{next_content}</div>".html_safe
end end
%> %>
<% if @show_back_and_next_flag!=0 %> <% if @show_back_and_next_flag!=0 %>