1 class IframeController < ApplicationController
5 come_from = request.env[:HTTP_REFERER]
6 Rails.logger.warn " > > > request.env['HTTP_ACCEPT'] : #{request.env['HTTP_ACCEPT']}"
8 come_from = request.env['HTTP_REFERER']
9 Rails.logger.warn " > > > request.env['HTTP_REFERER'] : #{come_from}"
10 if come_from != nil || (request.env['HTTP_ACCEPT'].to_s.include? "application/msword")
11 redirect_to "#{Facebook_app}gallery?id=#{params['id']}"
13 if params[:locale] != nil
14 I18n.locale = params[:locale]
16 @gallery = Fbgallery.find(params['id'])
17 @gallery_flash_params = @gallery.flash_params
20 @gallery_flash_params = @gallery_flash_params.gsub("info_en.xml","info_de.xml")
21 @gallery_flash_params = @gallery_flash_params.gsub("lang=en","lang=de")
23 @gallery_flash_params = @gallery_flash_params.gsub("info_en.xml","info_ru.xml")
24 @gallery_flash_params = @gallery_flash_params.gsub("lang=en","lang=ru")
31 if params[:locale] != nil
32 I18n.locale = params[:locale]
34 @gallery = Fbgallery.find(params['id'])
35 @gallery_flash_params = @gallery.flash_params
38 @gallery_flash_params = @gallery_flash_params.gsub("info_en.xml","info_de.xml")
39 @gallery_flash_params = @gallery_flash_params.gsub("lang=en","lang=de")
41 @gallery_flash_params = @gallery_flash_params.gsub("info_en.xml","info_ru.xml")
42 @gallery_flash_params = @gallery_flash_params.gsub("lang=en","lang=ru")
48 case params[:fb_sig_locale]
56 debug_message "current I18n.locale =#{I18n.locale}"
59 #if there is a second request
60 if params['method'] != 'publisher_getInterface'
62 if params['fb_sig_profile_user'] != nil
63 action = "{*actor*} " + (I18n.t :likes_the_3d)
65 action = I18n.t :i_like_the
67 gallery = Fbgallery.find(params[:app_params][:gallery_id])
68 @json_code = "{'content':{'attachment':{'name' : '#{gallery.name}','href' : '#{Facebook_app}gallery?id=#{gallery.id}','caption' : '#{action}', 'description' : '#{I18n.t :press_on_the_play_button}', 'media' : [{'type' : 'video', 'video_src' : '#{gallery.swf_link}?#{gallery.flash_params}', 'preview_img' : '#{gallery.preview_link}', 'video_link' : '#{Facebook_app}gallery?id=#{gallery.id}', 'video_title' : '#{gallery.name}'}] } }, 'method':'publisher_getFeedStory'}"
69 @json_code = ActiveSupport::JSON.decode(@json_code)
71 #if there is a first request
73 @json_code_a = Hash.new
75 the_user = Fbuser.find_by_facebook_id (params["fb_sig_user"])
76 #here might be an error
77 user_galleries = the_user.fbgalleries
79 user_galleries_size = user_galleries.size
80 #if there is not enough, 10 - number of galleries to show
81 if user_galleries.size < Galleries_for_publications
82 #find additionally 10 most viewed galleries
83 fbgalleries = Fbgallery.find(:all,:order => "was_viewed DESC",:limit=> (Galleries_for_publications - user_galleries.size))
84 user_galleries += fbgalleries
86 the_string ="<span style='font-size:13px;'>
87 <div style=' width: 98%;'>
88 <div style=' width: 98%; float: left; text-align:center;'>
89 <span style='font-size:17px;'>
90 <b>#{I18n.t :select_gallery}</b>
93 #{ user_galleries_size > 0 ? "<div style=' width: 98%; float: left; text-align:center;margin: 10px 0 0 0;'><span style='font-size:20px;color:#2E9CCD;'> #{I18n.t :user_galleries}</span></div>": ""}"
95 #if div is need to be finished
97 finish_div_is_needed = false
98 #galleries publication
99 fbgalleries.each_with_index {|one,id|
101 #special div to align other divs
102 if div_counter % 3 == 0
103 if true == finish_div_is_needed
104 the_string += "</div>"
106 the_string += "<div style='width:100%;float:left'>"
107 finish_div_is_needed = true
111 #if user's gallereis has finished
112 if user_galleries_size == id
113 #close extra div for alignment
114 the_string += "</div>"
115 the_string += "<div style=' width: 98%; float: left; text-align:center;'><span style='font-size:20px;color:#2E9CCD;margin: 10px 0 0 0;'> #{I18n.t :most_viewed}</span></div>"
116 the_string += "<div style='width:100%;float:left'>"
117 finish_div_is_needed = true
122 <div style='width: 27%; float:left; vertical-align:middle;margin:5px;'> <input id=gallery_id_#{one.id} name=gallery_id type=radio value=#{one.id} />#{id+1}: <img height='60px' src=#{one.preview_link}><br><div style='margin:0 0 0 0px;'>#{one.name}</div></div>"
125 if finish_div_is_needed
126 the_string += "</div>"
128 the_string += "</div></span>"
131 temp ["fbml"]= the_string
132 temp ["publishEnabled"] = "true"
133 @json_code_a["content"] = temp
134 @json_code_a["method"] = "publisher_getInterface"
135 #@json_code = "{'content':{'fbml':'Select gallery to publish: <br>#{the_string}', 'publishEnabled':true},'method':'publisher_getInterface'}"
136 @json_code = @json_code_a
137 #end of if params['method'] != 'publisher_getInterface'