You woke up in your bed, with your cat, Mimi, curled contently on your feet. you squirm, and she lifts her head and looks up at you."Mornin' mimi." She yawned in responce, and you crawl out of bed. You hear towards your closet, on the other side of your 50x50 bedroom, complete with A walk in closet, a bathroom, and a mini fridge. Your dad and mom are famous actors, but you are not very happy. They hardly pay any attention to you, and thats why you get in trouble so much. You look for a cute oufit to match your 4-inch high heels,(Avoiding brown or yellow.) You choose out a blue shirt with buttons on the sleeves and a matching belt. you wear a mini skirt,completely black.You trot downstairs with your hair curled and your nails done.(You dont like to wear makeup.) Your nanny, Mindi, Look up, and sneers"Oh if it isnt the demon child. Hope you have a good day, Devil-child!" She throws a paper bag lunch at you and you walk out the door, Flicked her off behind your back. You walk to the limo outside your mantion. The chauffer node and opens the door."madame, Your going to be late." You look at him."So?" He jsut sighes and closes the door. You lean back, careful not to muss up your hair, and 5 minutes later, you arrive at school. You walk into the school and enter the office."(Your name), Your late........again." You rool your eyes. You walk out and stop. Because there, standing in front of you, was the boy and girl from your dreams."Sora, There!" The girl points. The boy turns around. "There you are." He walks over to you, his key chains jingling."time to go."
if use_new_lookup_system == false
sites = Array.new
if controller.controller_name == "site"
#sites = Site_slave.find_by_sql(["SELECT * FROM sites, (SELECT id FROM sites WHERE (category_id = ? AND ext_type IN (5,6,7) AND id <= ?) ORDER BY id DESC LIMIT #{mobile_page_size}) as x WHERE sites.id = x.id", @site.category_id, @site.id])
if @permalink_site.ext_type == 4
if false # this loads same type of content after the permalink
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type = 4 AND id <= ?", @permalink_site.category_id, @permalink_site.id], :order=>"datecreated DESC, id DESC", :limit=>numshowing, :offset=>array_start)
if sites.length == 0
offset_count = Site_slave.count(:all, :conditions=>["category_id = ? AND ext_type = 4 AND id <= ?", @permalink_site.category_id, @permalink_site.id])
new_current_page = current_page - ((offset_count+numshowing-1) / numshowing) # page number starting from 0 is going to be the current page minus the number of pages it took to show from permalink to end
array_start = numshowing * (new_current_page - 1)
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type = 4 AND id > ?", @permalink_site.category_id, @permalink_site.id], :order=>"datecreated DESC, id DESC", :limit=>numshowing, :offset=>array_start)
end
else
# sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (1,5,6,7,9,10) and id <= ?", @category.id, @permalink_site.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
sites = Site_slave.find_by_sql(["SELECT sites.* FROM sites, (SELECT id FROM sites WHERE category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id <= ? ORDER BY datecreated DESC LIMIT ?, ?) AS x WHERE x.id = sites.id", @permalink_site.category_id, @permalink_site.id, array_start, numshowing])
if sites.length == 0
offset_count = Site_slave.count(:all, :conditions=>["category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id <= ?", @permalink_site.category_id, @permalink_site.id])
new_current_page = current_page - ((offset_count+numshowing-1) / numshowing) # page number starting from 0 is going to be the current page minus the number of pages it took to show from permalink to end
array_start = numshowing * (new_current_page - 1)
# sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id > ?", @permalink_site.category_id, @permalink_site.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
sites = Site_slave.find_by_sql(["SELECT sites.* FROM sites, (SELECT id FROM sites WHERE category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id > ? ORDER BY datecreated DESC LIMIT ?, ?) AS x WHERE x.id = sites.id", @permalink_site.category_id, @permalink_site.id, array_start, numshowing])
end
end
elsif @permalink_site.is_image?
if false # this loads same type of content after the permalink
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (5,6,7) AND id <= ?", @permalink_site.category_id, @permalink_site.id], :order=>"datecreated DESC, id DESC", :limit=>numshowing, :offset=>array_start)
if sites.length == 0 # wrap to newest if no results were found going back in time
offset_count = Site_slave.count(:all, :conditions=>["category_id = ? AND ext_type IN (5,6,7) AND id <= ?", @permalink_site.category_id, @permalink_site.id])
new_current_page = current_page - ((offset_count+numshowing-1) / numshowing) # page number starting from 0 is going to be the current page minus the number of pages it took to show from permalink to end
array_start = numshowing * (new_current_page - 1)
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (5,6,7) AND id > ?", @permalink_site.category_id, @permalink_site.id], :order=>"datecreated DESC, id DESC", :limit=>numshowing, :offset=>array_start)
end
else # this loads any type of content after the permalink
# sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (1,5,6,7,9,10) and id <= ?", @category.id, @permalink_site.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
sites = Site_slave.find_by_sql(["SELECT sites.* FROM sites, (SELECT id FROM sites WHERE category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id <= ? ORDER BY datecreated DESC LIMIT ?, ?) AS x WHERE x.id = sites.id", @permalink_site.category_id, @permalink_site.id, array_start, numshowing])
if sites.length == 0
offset_count = Site_slave.count(:all, :conditions=>["category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id <= ?", @permalink_site.category_id, @permalink_site.id])
new_current_page = current_page - ((offset_count+numshowing-1) / numshowing) # page number starting from 0 is going to be the current page minus the number of pages it took to show from permalink to end
array_start = numshowing * (new_current_page - 1)
# sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id > ?", @permalink_site.category_id, @permalink_site.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
sites = Site_slave.find_by_sql(["SELECT sites.* FROM sites, (SELECT id FROM sites WHERE category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id > ? ORDER BY datecreated DESC LIMIT ?, ?) AS x WHERE x.id = sites.id", @permalink_site.category_id, @permalink_site.id, array_start, numshowing])
end
end
elsif @permalink_site.is_video?
if false # this loads same type of content after the permalink
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (9,10) AND id <= ?", @permalink_site.category_id, @permalink_site.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
if sites.length == 0
offset_count = Site_slave.count(:all, :conditions=>["category_id = ? AND ext_type IN (9,10) AND id <= ?", @permalink_site.category_id, @permalink_site.id])
new_current_page = current_page - ((offset_count+numshowing-1) / numshowing) # page number starting from 0 is going to be the current page minus the number of pages it took to show from permalink to end
array_start = numshowing * (new_current_page - 1)
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (9,10) AND id > ?", @permalink_site.category_id, @permalink_site.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
end
else # this loads any type of content after the permalink
# sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (1,5,6,7,9,10) and id <= ?", @category.id, @permalink_site.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
sites = Site_slave.find_by_sql(["SELECT sites.* FROM sites, (SELECT id FROM sites WHERE category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id <= ? ORDER BY datecreated DESC LIMIT ?, ?) AS x WHERE x.id = sites.id", @permalink_site.category_id, @permalink_site.id, array_start, numshowing])
if sites.length == 0
offset_count = Site_slave.count(:all, :conditions=>["category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id <= ?", @permalink_site.category_id, @permalink_site.id])
new_current_page = current_page - ((offset_count+numshowing-1) / numshowing) # page number starting from 0 is going to be the current page minus the number of pages it took to show from permalink to end
array_start = numshowing * (new_current_page - 1)
# sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id > ?", @permalink_site.category_id, @permalink_site.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
sites = Site_slave.find_by_sql(["SELECT sites.* FROM sites, (SELECT id FROM sites WHERE category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id > ? ORDER BY datecreated DESC LIMIT ?, ?) AS x WHERE x.id = sites.id", @permalink_site.category_id, @permalink_site.id, array_start, numshowing])
end
end
end
elsif controller.controller_name == "search"
sites = @site_results #@site_results is the array of site objects returned by sphinx
elsif controller.controller_name == "collection"
sites = @sites_collections2D##.collect {|site| site[0]} Special case below to bundle site and collection_site together for display later
elsif controller.controller_name == "welcome"
sites = Popculture_slave.find(:all, :order=>"publish_date desc", :limit=>numshowing, :offset=>array_start)
elsif controller.controller_name == "soapbox" && controller.action_name == "show"
if false # this loads same type of content after the permalink
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type = 1 AND id <= ?", @permalink_site.category_id, @permalink_site.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
if sites.length == 0
offset_count = Site_slave.count(:all, :conditions=>["category_id = ? AND ext_type = 1 AND id <= ?", @permalink_site.category_id, @permalink_site.id])
new_current_page = current_page - ((offset_count+numshowing-1) / numshowing) # page number starting from 0 is going to be the current page minus the number of pages it took to show from permalink to end
array_start = numshowing * (new_current_page - 1)
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type = 1 AND id > ?", @permalink_site.category_id, @permalink_site.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
end
else # this loads any type of content after the permalink
# sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (1,5,6,7,9,10) and id <= ?", @category.id, @permalink_site.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
sites = Site_slave.find_by_sql(["SELECT sites.* FROM sites, (SELECT id FROM sites WHERE category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id <= ? ORDER BY datecreated DESC LIMIT ?, ?) AS x WHERE x.id = sites.id", @permalink_site.category_id, @permalink_site.id, array_start, numshowing])
if sites.length == 0
offset_count = Site_slave.count(:all, :conditions=>["category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id <= ?", @permalink_site.category_id, @permalink_site.id])
new_current_page = current_page - ((offset_count+numshowing-1) / numshowing) # page number starting from 0 is going to be the current page minus the number of pages it took to show from permalink to end
array_start = numshowing * (new_current_page - 1)
# sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id > ?", @permalink_site.category_id, @permalink_site.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
sites = Site_slave.find_by_sql(["SELECT sites.* FROM sites, (SELECT id FROM sites WHERE category_id = ? AND ext_type IN (1,5,6,7,9,10) AND id > ? ORDER BY datecreated DESC LIMIT ?, ?) AS x WHERE x.id = sites.id", @permalink_site.category_id, @permalink_site.id, array_start, numshowing])
end
end
elsif controller.controller_name == "soapbox" && controller.action_name == "list"
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type = 1", @category.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
elsif controller.controller_name == "category" && controller.action_name == "home"
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (1,5,6,7,9,10)", @category.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
if false && @luser && @luser.id < 10
if sites.length > 0
if current_page.to_i == 1
wall_entries = Wall_entry_slave.find(:all, :conditions=>["category_id = ? AND timestamp > ? AND deleted_by = 0", @category.id, sites[sites.length - 1].datecreated], :order=>"timestamp DESC")
else
wall_entries = Wall_entry_slave.find(:all, :conditions=>["category_id = ? AND timestamp < ? and timestamp > ? AND deleted_by = 0", @category.id, sites[0].datecreated, sites[sites.length - 1].datecreated], :order=>"timestamp DESC")
end
begin
wall_entries.each do |wall_entry|
wall_site_hash = {:card_type=>"chatter", :datecreated=>wall_entry.timestamp, :chatter_data=>wall_entry}
site_counter = 0
sites.each do |site_object|
if site_object.is_a? Site_slave
if site_counter == 0 && wall_site_hash[:datecreated] > site_object.datecreated #wall post is newer than the newest site in the array
sites.insert(0, wall_site_hash)
break
end
if site_counter > 0 && site_object.datecreated < wall_site_hash[:datecreated]
sites.insert(site_counter, wall_site_hash)
break
end
end
site_counter = site_counter + 1
end
end
rescue StandardError => kaboom
Notifier::deliver_email_alert_request("Cliff Szu", "theclifbar@gmail.com", "Error: chatter card error", "#{kaboom.inspect}")
puts "################################### _viewer_main_viewer_body_cardcontainer Error: #{__LINE__} #{kaboom.inspect} :::: #{session.inspect.to_s}, #{params.to_s}, #{request.env.to_s}"
end
end
end
site = sites[0]
# commented following line out - there should not be a @permalink_site on club home; the first card should not be treated differently on club home
# @permalink_site = sites[0]
else
#I also need to change pagination to pull from a different set... maybe we should just pass in a parameter or object like @site or site_id, and if that is not nil, then use similar queries to pull the subsequent pages for sites
if params[:show_only].to_s != ""
show_only = params[:show_only].to_s
case show_only
when "images"
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (5,6,7)", @category.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
when "videos"
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type IN (9,10)", @category.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
when "trivia"
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type = 3", @category.id], :order=>"datecreated DESC", :limit=>numshowing, :offset=>array_start)
when "polls"
sites = Site_slave.find(:all, :conditions=>["category_id = ? AND ext_type = 2", @category.id], :order=>"datecreated DESC", :limit=>numshowing, :off