http://docs.moodle.org/ja/%E3%82%B5%E3%82%A4%E3%83%88%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB
(1.6向けの記述)に沿った 1.9.5 の lib/filelib.php 用の修正パッチを置いておきます。
# たぶんみなさん各自対応済でしょうが,パッチとしては見当たらないようなので。
いやぁ,随分と久しぶりの話題ですね,探し出すのに随分と苦労しました.
http://moodle.org/mod/forum/discuss.php?d=73794
これですね,文字数を考慮するコードになっている理由は.
当方では,例のダウンロードファイル名をブラウザに合わせて修正する箇所を関数化していますね.
function convert_download_filename_encoding($filename) {
if (check_browser_version('MSIE')) {
if (strlen(rawurlencode($filename)) > 21 * 3 * 3) {
$filename = mb_convert_encoding($filename, "SJIS-WIN", "UTF-8");
$filename = str_replace('#', '%23', $filename);
} else {
// $filename = rawurlencode($filename);
$filename = fs_rawurlencode($filename);
}
} else if (check_browser_version('Safari')) {
$filename = "";
}
return $filename;
}
これをあちこちで使っています.いまgrepしています.
(1) admin/user/user_bulk_download.php
function user_download_csv($fields) {
global $CFG, $SESSION;
require_once($CFG->dirroot.'/user/profile/lib.php');
$filename = clean_filename(get_string('users').'.csv');
// (IE_Problem026): ここから追加
$filename = convert_download_filename_encoding($filename);
// (IE_Problem026): ここまで追加
header("Content-Type: application/download\n");
header("Content-Disposition: attachment; filename=$filename");
header("Expires: 0");
header("Cache-Control: must-revalidate,post-check=0,pre-check=0");
header("Pragma: public");
(2) lib/filelib.php
a) function send_temp_file()
//IE compatibiltiy HACK!
if (ini_get('zlib.output_compression')) {
ini_set('zlib.output_compression', 'Off');
}
// if user is using IE, urlencode the filename so that multibyte file name will show up correctly on popup
// (IE_Problem009): ここからコメントアウト
// if (check_browser_version('MSIE')) {
// $filename = urlencode($filename);
// }
// (IE_Problem009): ここまでコメントアウト
// (IE_Problem009): ここから追加
$filename = convert_download_filename_encoding($filename);
// (IE_Problem009): ここまで追加
b) function send_file()
//do not put '@' before the next header to detect incorrect moodle configurations,
//error should be better than "weird" empty lines for admins/users
//TODO: should we remove all those @ before the header()? Are all of the values supported on all servers?
header('Last-Modified: '. gmdate('D, d M Y H:i:s', $lastmodified) .' GMT');
// if user is using IE, urlencode the filename so that multibyte file name will show up correctly on popup
// (IE_Problem009): ここからコメントアウト
// if (check_browser_version('MSIE')) {
// $filename = rawurlencode($filename);
// }
// (IE_Problem009): ここまでコメントアウト
// (IE_Problem009): ここから追加
$filename = convert_download_filename_encoding($filename);
// (IE_Problem009): ここまで追加
他にもちょこちょこと使っていますが,当方の独自の改良箇所に関わっている部分ですね.とりあえずこの3箇所は明白に修正を行っても良さそうな箇所です.