Guest User

Untitled

a guest
Apr 26th, 2012
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. def gallery_options(options)
  2. gallery = {}
  3.  
  4. if not options[:item_id].nil? or not options[:publication_id].nil?
  5. conditions = {}
  6. conditions[:item_id] = options[:item_id] unless options[:item_id].nil?
  7. conditions[:publication_id] = options[:publication_id] unless options[:publication_id].nil?
  8.  
  9. images = Gallery.find(:first, :conditions => conditions)
  10.  
  11. unless images.nil?
  12. images = images.gallery_image
  13. images = images.paginate( :page => params[:page], :per_page => options[:paginate] ) unless options[:paginate].nil?
  14. if params[:image_id]
  15. img = GalleryImage.find(params[:image_id])
  16. else
  17. img = images.first
  18. end
  19. gallery[:img] = img
  20. gallery[:images] = images
  21. end
  22. end
  23. gallery
  24. end
Advertisement
Add Comment
Please, Sign In to add comment