Fix album widget options

This commit is contained in:
chris committed 2013-01-07 00:40:43 +08:00
1 parent be00cec4d7
commit c6111460f5
7 files changed
+18 -28

No files matched your search

@@ -1,27 +1,26 @@
class Panel::Gallery::Widget::AlbumsController < OrbitWidgetController
def widget1
vertical = 2
horizontal = 6
@part = PagePart.find(params[:part_id])
vertical = @wiget_options[:vertical] if (@wiget_options.has_key?(:vertical) && @wiget_options[:vertical] < vertical)
horizontal = @wiget_options[:horizontal] if (@wiget_options.has_key?(:horizontal) && @wiget_options[:horizontal] < horizontal)
vertical = @part.widget_options['vertical'].to_i rescue 0
horizontal = @part.widget_options['horizontal'].to_i rescue 0
@album = GalleryAlbum.find(@part.widget_options['album_id']) rescue nil
@album_images = @album.gallery_images if @album
@settings = {"vertical"=>vertical,"horizontal"=>horizontal} #[note] horizontal has it's limitation from 2 to 6
@class = "c" + @settings["horizontal"].to_s
@total = @settings["vertical"] * @settings["horizontal"]
@rnd = Random.new
@images = []
for i in 0..@total-1
@sn = @rnd.rand(0...GalleryImage.count)
if @sn < 0
@sn = @sn * -1
end
image = GalleryImage.skip(@sn).limit(1).first
image = @album_images[@rnd.rand(0...@album_images.count)]
values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url}
@images << values
end
end
def widget2
end