module Admin::SurveysHelper require 'iconv' unless String.method_defined?(:encode) def page_for_survey(survey=nil) ann_page = nil pages = Page.where(:module=>'survey') # pages.each do |page| # if page.categories.count ==1 # if page.categories.include?(bulletin.category.id.to_s) # ann_page = page # end # end # break if !ann_page.nil? # end # if ann_page.nil? # pages.each do |page| # if page.categories.include?(bulletin.category.id.to_s) # ann_page = page # end # break if !ann_page.nil? # end # end ann_page = pages.first if ann_page.nil? if !survey.blank? request.protocol+(request.host_with_port+ann_page.url+'/'+survey.to_param).gsub('//','/') rescue "/" else request.protocol+(request.host_with_port+'/'+I18n.locale.to_s+ann_page.url+'/').gsub('//','/') rescue "/" end end def remove_illegal_utf8(str) if String.method_defined?(:encode) str.encode!('UTF-8', 'UTF-8', :invalid => :replace) else ic = Iconv.new('UTF-8', 'UTF-8//IGNORE') str = ic.iconv(str) end str end end