class Panel::Gallery::Widget::AlbumsController < OrbitWidgetController def widget1 @part = PagePart.find(params[:part_id]) @title = @part.title_translations[I18n.locale.to_s] vertical = @part.widget_options['vertical'].to_i rescue 0 horizontal = @part.widget_options['horizontal'].to_i rescue 0 @album = Album.find(@part.widget_options['album_id']) rescue nil @album_images = @album.album_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 = [] if !@album_images.nil? if @album_images.count > @total @randoms = [] until @randoms.count == @total do r = @rnd.rand(0...@album_images.count) if !@randoms.include?r @randoms << r image = @album_images[r] values = {"show_link"=>theater_panel_gallery_front_end_album_path(@album,:image_id=>image),"thumb"=>image.file.thumb.url} @images << values end end elsif @album_images.count == @total @album_images.each do |image| values = {"show_link"=>theater_panel_gallery_front_end_album_path(@album,:image_id=>image),"thumb"=>image.file.thumb.url} @images << values end else @album_images.each do |image| values = {"show_link"=>theater_panel_gallery_front_end_album_path(@album,:image_id=>image),"thumb"=>image.file.thumb.url} @images << values end until @images.count == @total do values = {"show_link"=>"javascript:void(0);","thumb"=>"assets/gallery/nodata.jpg"} @images << values end end else until @images.count == @total do values = {"show_link"=>"javascript:void(0);","thumb"=>"assets/gallery/nodata.jpg"} @images << values end end end def widget2 end end