%
require 'event_news_helper'
data = action_data
params = OrbitHelper.params
page = Page.where(url:params['url']).first
@ad_banner_location = 2
@show_back_and_next_flag = 0
if Page.instance_methods.include?(:select_option_items) && ModuleApp.instance_methods.include?(:show_option_items)
@show_option_items = nil
ModuleApp.all.select{|tmp| tmp.key.to_s=='event_news_mod'}.each do |module_app|
@show_option_items = module_app.show_option_items
end
page.select_option_items.each do |select_option_item|
unless @show_option_items.nil?
if select_option_item.field_name == @show_option_items.keys.first.to_s
value = YAML.load(select_option_item.value)
tmp = value[:en]
I18n.with_locale(:en) do
if tmp == t('event_news.not_show')
@show_back_and_next_flag = 0
elsif tmp == t('event_news.show_top')
@show_back_and_next_flag = 1
elsif tmp == t('event_news.show_bottom')
@show_back_and_next_flag = 2
end
end
elsif select_option_item.field_name == @show_option_items.keys[2].to_s
value = YAML.load(select_option_item.value)
tmp = value[:en]
I18n.with_locale(:en) do
if tmp == t('event_news.show_top')
@ad_banner_location = 1
elsif tmp == t('event_news.show_bottom')
@ad_banner_location = 2
end
end
end
end
end
end
if @show_back_and_next_flag != 0
uid = params['uid']
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 = "#{t('event_news.prev')} #{prev_result['title'][I18n.locale]} #{next_result['title'][I18n.locale]}