diff --git a/app/controllers/ad_banners_controller.rb b/app/controllers/ad_banners_controller.rb index 7727c17..11e9061 100644 --- a/app/controllers/ad_banners_controller.rb +++ b/app/controllers/ad_banners_controller.rb @@ -1,31 +1,34 @@ class AdBannersController < ApplicationController def widget adbanner = Banner.find(OrbitHelper.widget_custom_value) - images = adbanner.ad_images.can_display.asc(:sort_number,:created_at).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 ? '
' : "" - alt_title = (b.title.nil? || b.title == "" ? "ad-banner image" : b.title) + images = [] + adbanner.ad_images.can_display.asc(:sort_number,:created_at).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 ? '
' : "" + alt_title = (b.title.nil? || b.title == "" ? "ad-banner image" : b.title) - if b.link_open == "new_window" - target = "_blank" - else - target = "" - end + if b.link_open == "new_window" + target = "_blank" + else + target = "" + end - { - "image_link" => image_link, - "image_alt" => "ad banner image", - "title" => b.title, - "alt_title" => alt_title, - "class" => klass, - "height" => adbanner.height, - "width" => adbanner.width, - "caption" => caption, - "context" => (b.context.tr('"',"'") rescue ""), - "link" => b.out_link || "#", - "target" => target - } + images << { + "image_link" => image_link, + "image_alt" => "ad banner image", + "title" => b.title, + "alt_title" => alt_title, + "class" => klass, + "height" => adbanner.height, + "width" => adbanner.width, + "caption" => caption, + "context" => (b.context.tr('"',"'") rescue ""), + "link" => b.out_link || "#", + "target" => target + } + end end base_image = adbanner.base_image.nil? ? 1 : adbanner.base_image { diff --git a/app/models/ad_image.rb b/app/models/ad_image.rb index 92e8dee..a57465d 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 :sort_number, :type => Integer + field :language_enabled, :type => Array, :default => ["en","zh_tw"] 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 b13b345..4e7db59 100644 --- a/app/views/admin/ad_images/_form.html.erb +++ b/app/views/admin/ad_images/_form.html.erb @@ -105,6 +105,19 @@ + +
+ +
+ <% @site_in_use_locales.each do |locale| %> + + <% end %> +
+
+