added language option for adbanner pro

This commit is contained in:
Harry Bomrah 2016-05-18 16:29:39 +08:00
parent 7cf9796abc
commit ac93c3de49
3 changed files with 40 additions and 23 deletions

View File

@ -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 ? '<div class="cycle-overlay"></div><div class="cycle-pager"></div>' : ""
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 ? '<div class="cycle-overlay"></div><div class="cycle-pager"></div>' : ""
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
{

View File

@ -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"]

View File

@ -105,6 +105,19 @@
</div>
</div>
<!-- language-selection -->
<div class="control-group">
<label class="control-label muted"><%= t(:select_language) %></label>
<div class="controls">
<% @site_in_use_locales.each do |locale| %>
<label class="checkbox">
<%= check_box_tag "ad_image[language_enabled][]", locale, (@ad_image.language_enabled.include?(locale.to_s) rescue false) %>
<%= t(locale.to_s) %>
</label>
<% end %>
</div>
</div>
</div>
</div>