diff --git a/app/controllers/ad_banners_controller.rb b/app/controllers/ad_banners_controller.rb index 2b206da..6b6123c 100644 --- a/app/controllers/ad_banners_controller.rb +++ b/app/controllers/ad_banners_controller.rb @@ -12,46 +12,52 @@ class AdBannersController < ApplicationController private def image_widget(adbanner) - images = adbanner.ad_images.can_display.collect.with_index do |b,i| - image_link = OrbitHelper.is_mobile_view ? b.file.mobile.url : b.file.url - klass = i == 0 ? "active" : "" - caption = i == 0 ? '
' : "" - { - "image_link" => image_link, - "title" => b.title, - "class" => klass, - "height" => adbanner.height, - "width" => adbanner.width, - "caption" => caption, - "context" => b.context, - "link" => b.out_link || "#" - } + images = [] + adbanner.ad_images.can_display.each_with_index do |b,i| + if b.language_enabled.include?(I18n.locale.to_s) + image_link = OrbitHelper.is_mobile_view ? b.file.mobile.url : b.file.url + klass = i == 0 ? "active" : "" + caption = i == 0 ? '
' : "" + images << { + "image_link" => image_link, + "title" => b.title, + "class" => klass, + "height" => adbanner.height, + "width" => adbanner.width, + "caption" => caption, + "context" => b.context, + "link" => b.out_link || "#" + } + end end - { - "extras" => { - "ad_fx" => adbanner.ad_fx, - "speed" => adbanner.speed, - "title" => adbanner.title, - "timeout" => adbanner.timeout, - "more" => "More" - }, - "images" => images - } + { + "extras" => { + "ad_fx" => adbanner.ad_fx, + "speed" => adbanner.speed, + "title" => adbanner.title, + "timeout" => adbanner.timeout, + "more" => "More" + }, + "images" => images + } end def video_widget(adbanner) - images = adbanner.ad_images.can_display.collect.with_index do |ad_b,i| - image_link = OrbitHelper.is_mobile_view ? ad_b.file.mobile.url : ad_b.file.url - caption = i == 0 ? '
' : "" - klass = i == 0 ? "active" : "" - if ad_b.exchange_item == "1" - image_html = "
#{ad_b.title}
" - else ad_b.exchange_item == "2" - image_html = "
#{ad_b.title}
#{ad_b.title}
" + images = [] + adbanner.ad_images.can_display.each_with_index do |ad_b,i| + if ad_b.language_enabled.include?(I18n.locale.to_s) + image_link = OrbitHelper.is_mobile_view ? ad_b.file.mobile.url : ad_b.file.url + caption = i == 0 ? '
' : "" + klass = i == 0 ? "active" : "" + if ad_b.exchange_item == "1" + image_html = "
#{ad_b.title}
" + else ad_b.exchange_item == "2" + image_html = "
#{ad_b.title}
#{ad_b.title}
" + end + images << { + "html" => image_html + } end - { - "html" => image_html - } end { "extras" => { diff --git a/app/models/ad_image.rb b/app/models/ad_image.rb index 0e17a16..dfbef35 100644 --- a/app/models/ad_image.rb +++ b/app/models/ad_image.rb @@ -14,6 +14,7 @@ class AdImage field :postdate , :type => DateTime, :default => Time.now field :deadline , :type => DateTime field :youtube , :type => String + field :language_enabled, :type => Array, :default => ["en","zh_tw"] field :exchange_item LINK_OPEN_TYPES = ["local", "new_window"] diff --git a/app/views/admin/ad_images/_form.html.erb b/app/views/admin/ad_images/_form.html.erb index 6e3e6da..3d34d49 100644 --- a/app/views/admin/ad_images/_form.html.erb +++ b/app/views/admin/ad_images/_form.html.erb @@ -62,7 +62,6 @@ -
@@ -88,7 +87,19 @@
- + +
+ +
+ <% @site_in_use_locales.each do |locale| %> + + <% end %> +
+
+