diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index a49126a6c..9d22f207a 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -290,14 +290,11 @@ class CoursesController < ApplicationController def export_course_member_excel @all_members = student_homework_score(0,0,0,"desc") filename="#{@course.teacher.lastname.to_s + @course.teacher.firstname.to_s }_#{@course.name}_#{@course.time.to_s + @course.term}#{l(:excel_member_list)}"; - # 如果是ie 需要转码 - if(/trident/.match(request.env["HTTP_USER_AGENT"]) != nil) - filename= URI::encode(filename) - end + respond_to do |format| format.xls { send_data(member_to_xls(@all_members,@course.course_groups), :type => "text/excel;charset=utf-8; header=present", - :filename => "#{filename}.xls") + :filename => filename_for_content_disposition("#{filename}.xls")) } end end diff --git a/app/controllers/gantts_controller.rb b/app/controllers/gantts_controller.rb index ee132ac29..710bb2f47 100644 --- a/app/controllers/gantts_controller.rb +++ b/app/controllers/gantts_controller.rb @@ -42,8 +42,8 @@ class GanttsController < ApplicationController respond_to do |format| format.html { render :action => "show", :layout => 'base_projects' }#by young - format.png { send_data(@gantt.to_image, :disposition => 'inline', :type => 'image/png', :filename => "#{basename}.png") } if @gantt.respond_to?('to_image') - format.pdf { send_data(@gantt.to_pdf, :type => 'application/pdf', :filename => "#{basename}.pdf") } + format.png { send_data(@gantt.to_image, :disposition => 'inline', :type => 'image/png', :filename => filename_for_content_disposition("#{basename}.png")) } if @gantt.respond_to?('to_image') + format.pdf { send_data(@gantt.to_pdf, :type => 'application/pdf', :filename => filename_for_content_disposition("#{basename}.pdf") ) } end end end diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 5dd5363b9..93459578c 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -33,7 +33,7 @@ class HomeworkAttachController < ApplicationController format.js format.xls { send_data(homework_to_xls(@all_homework_list), :type => "text/excel;charset=utf-8; header=present", - :filename => "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}(#{l(:excel_not_rated)}).xls") + :filename => filename_for_content_disposition("#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}(#{l(:excel_not_rated)}).xls") ) } end end @@ -66,7 +66,7 @@ class HomeworkAttachController < ApplicationController format.js format.xls { send_data(homework_to_xls(all_homework_list), :type => "text/excel;charset=utf-8; header=present", - :filename => "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}(#{l(:excel_been_rated)}).xls") + :filename => filename_for_content_disposition("#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}(#{l(:excel_been_rated)}).xls") ) } end end @@ -101,7 +101,7 @@ class HomeworkAttachController < ApplicationController format.js format.xls { send_data(homework_to_xls(all_homework_list), :type => "text/excel;charset=utf-8; header=present", - :filename => "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}.xls") + :filename => filename_for_content_disposition("#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}.xls") ) } end end diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 923414583..e529dd3b9 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -151,7 +151,7 @@ class IssuesController < ApplicationController format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' } format.pdf { pdf = issue_to_pdf(@issue, :journals => @journals) - send_data(pdf, :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") + send_data(pdf, :type => 'application/pdf', :filename => filename_for_content_disposition("#{@project.identifier}-#{@issue.id}.pdf") ) } end end diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index a8f2a11f1..ec54ae8a4 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -413,7 +413,7 @@ class PollController < ApplicationController respond_to do |format| format.xls { send_data(poll_to_xls(poll_questions), :type => "text/excel;charset=utf-8; header=present", - :filename => "#{@poll.polls_name}.xls") + :filename => filename_for_content_disposition("#{@poll.polls_name}.xls") ) } end end diff --git a/app/controllers/stores_controller.rb b/app/controllers/stores_controller.rb index 85ea85241..0d1755294 100644 --- a/app/controllers/stores_controller.rb +++ b/app/controllers/stores_controller.rb @@ -84,7 +84,7 @@ class StoresController < ApplicationController respond_to do |format| format.xls { send_data(homework_to_xls(attachments), :type => "text/excel;charset=utf-8; header=present", - :filename => "#{l(:label_file_lost_list)}.xls") + :filename => filename_for_content_disposition("#{l(:label_file_lost_list)}.xls") ) } end end diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index da6d48b8d..c0351c6da 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -82,14 +82,14 @@ class WikiController < ApplicationController @content = @page.content_for_version(params[:version]) if User.current.allowed_to?(:export_wiki_pages, @project) if params[:format] == 'pdf' - send_data(wiki_page_to_pdf(@page, @project), :type => 'application/pdf', :filename => "#{@page.title}.pdf") + send_data(wiki_page_to_pdf(@page, @project), :type => 'application/pdf', :filename => filename_for_content_disposition("#{@page.title}.pdf") ) return elsif params[:format] == 'html' export = render_to_string :action => 'export', :layout => false - send_data(export, :type => 'text/html', :filename => "#{@page.title}.html") + send_data(export, :type => 'text/html', :filename => filename_for_content_disposition("#{@page.title}.html")) return elsif params[:format] == 'txt' - send_data(@content.text, :type => 'text/plain', :filename => "#{@page.title}.txt") + send_data(@content.text, :type => 'text/plain', :filename => filename_for_content_disposition("#{@page.title}.txt") ) return end end @@ -286,7 +286,7 @@ class WikiController < ApplicationController send_data(export, :type => 'text/html', :filename => "wiki.html") } format.pdf { - send_data(wiki_pages_to_pdf(@pages, @project), :type => 'application/pdf', :filename => "#{@project.identifier}.pdf") + send_data(wiki_pages_to_pdf(@pages, @project), :type => 'application/pdf', :filename => filename_for_content_disposition("#{@project.identifier}.pdf") ) } end end