MDL-40931 useragent: separated user agent functionality into a lib

This commit moves user agent related functionality out of several
core libraries and combines it into a more manageable class.
All core uses are converted and functions deprecated in favor
of the new class.
This commit is contained in:
Sam Hemelryk
2013-08-26 13:59:19 +12:00
parent d2aa53be1b
commit c3d2fbf9cd
30 changed files with 1460 additions and 1045 deletions
+6 -6
View File
@@ -2101,7 +2101,7 @@ function readstring_accel($string, $mimetype, $accelerate) {
function send_temp_file($path, $filename, $pathisstring=false) {
global $CFG;
if (check_browser_version('Firefox', '1.5')) {
if (core_useragent::check_firefox_version('1.5')) {
// only FF is known to correctly save to disk before opening...
$mimetype = mimeinfo('type', $filename);
} else {
@@ -2121,7 +2121,7 @@ function send_temp_file($path, $filename, $pathisstring=false) {
}
// if user is using IE, urlencode the filename so that multibyte file name will show up correctly on popup
if (check_browser_version('MSIE')) {
if (core_useragent::check_ie_version()) {
$filename = urlencode($filename);
}
@@ -2197,12 +2197,12 @@ function send_file($path, $filename, $lifetime = 'default' , $filter=0, $pathiss
// Use given MIME type if specified, otherwise guess it using mimeinfo.
// IE, Konqueror and Opera open html file directly in browser from web even when directed to save it to disk :-O
// only Firefox saves all files locally before opening when content-disposition: attachment stated
$isFF = check_browser_version('Firefox', '1.5'); // only FF > 1.5 properly tested
$isFF = core_useragent::check_firefox_version('1.5'); // only FF > 1.5 properly tested
$mimetype = ($forcedownload and !$isFF) ? 'application/x-forcedownload' :
($mimetype ? $mimetype : mimeinfo('type', $filename));
// if user is using IE, urlencode the filename so that multibyte file name will show up correctly on popup
if (check_browser_version('MSIE')) {
if (core_useragent::check_ie_version()) {
$filename = rawurlencode($filename);
}
@@ -2361,12 +2361,12 @@ function send_stored_file($stored_file, $lifetime=86400 , $filter=0, $forcedownl
// IE, Konqueror and Opera open html file directly in browser from web even when directed to save it to disk :-O
// only Firefox saves all files locally before opening when content-disposition: attachment stated
$filename = is_null($filename) ? $stored_file->get_filename() : $filename;
$isFF = check_browser_version('Firefox', '1.5'); // only FF > 1.5 properly tested
$isFF = core_useragent::check_firefox_version('1.5'); // only FF > 1.5 properly tested
$mimetype = ($forcedownload and !$isFF) ? 'application/x-forcedownload' :
($stored_file->get_mimetype() ? $stored_file->get_mimetype() : mimeinfo('type', $filename));
// if user is using IE, urlencode the filename so that multibyte file name will show up correctly on popup
if (check_browser_version('MSIE')) {
if (core_useragent::check_ie_version()) {
$filename = rawurlencode($filename);
}