diff --git a/app/helpers/announcements_helper.rb b/app/helpers/announcements_helper.rb index ed6f777..fe9f0a6 100644 --- a/app/helpers/announcements_helper.rb +++ b/app/helpers/announcements_helper.rb @@ -9,12 +9,15 @@ module AnnouncementsHelper subpart.select_options.each do |select_option| if !(@show_options.nil?) && select_option.field_name == @show_options.keys.first.to_s value = YAML.load(select_option.value) - if value[I18n.locale] == t('announcement.small_size') - @image_version = 'thumb' - elsif value[I18n.locale] == t('announcement.medium_size') - @image_version = 'mobile' - elsif value[I18n.locale] == t('announcement.orignal_size') - @image_version = 'orignal' + tmp = value[:en] + I18n.with_locale(:en) do + if tmp == t('announcement.small_size') + @image_version = 'thumb' + elsif tmp == t('announcement.medium_size') + @image_version = 'mobile' + elsif tmp == t('announcement.orignal_size') + @image_version = 'orignal' + end end end end @@ -141,13 +144,13 @@ module AnnouncementsHelper sorted end end - def get_sorted_annc + def get_sorted_annc(data_count=nil) params = OrbitHelper.params locale = OrbitHelper.get_site_locale.to_s page = Page.where(url:params['url']).first page_number = OrbitHelper.page_number.to_i 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 = [] tags = page.tags categories = params['category']=='all' ? (page.categories || []) : ([Category.find(params['category'])] rescue (page.categories || [])) diff --git a/app/views/announcements/show.html.erb b/app/views/announcements/show.html.erb index df74886..6d7c32f 100644 --- a/app/views/announcements/show.html.erb +++ b/app/views/announcements/show.html.erb @@ -10,31 +10,38 @@ 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 value = YAML.load(select_option_item.value) - if value[I18n.locale] == t('announcement.not_show') - @show_back_and_next_flag = 0 - elsif value[I18n.locale] == t('announcement.show_top') - @show_back_and_next_flag = 1 - elsif value[I18n.locale] == t('announcement.show_bottom') - @show_back_and_next_flag = 2 + tmp = value[:en] + I18n.with_locale(:en) do + if tmp == t('announcement.not_show') + @show_back_and_next_flag = 0 + elsif tmp == t('announcement.show_top') + @show_back_and_next_flag = 1 + elsif tmp == t('announcement.show_bottom') + @show_back_and_next_flag = 2 + end end end end end if @show_back_and_next_flag != 0 uid = params['uid'] - sorted,total_pages = get_sorted_annc - now_index = sorted.to_enum.with_index.select{|v| v[0].uid==uid}[0][1] - if now_index != 0 - prev_result = sorted[now_index-1] - prev_url = params['url'] + '/' + prev_result.to_param - prev_content = "" + sorted,total_pages = get_sorted_annc(0) + 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 + prev_result = sorted[now_index-1] + prev_url = params['url'] + '/' + prev_result.to_param + prev_content = "" + end + if now_index != sorted.length-1 + next_result = sorted[now_index+1] + next_url = params['url'] + '/' + next_result.to_param + next_content = "" + end + content = "
#{prev_content}#{next_content}
".html_safe + else + content = '' end - if now_index != sorted.length-1 - next_result = sorted[now_index+1] - next_url = params['url'] + '/' + next_result.to_param - next_content = "" - end - content = "
#{prev_content}#{next_content}
".html_safe end %> <% if @show_back_and_next_flag!=0 %>