本文整理匯總了PHP中core_useragent::is_firefox方法的典型用法代碼示例。如果您正苦於以下問題:PHP core_useragent::is_firefox方法的具體用法?PHP core_useragent::is_firefox怎麽用?PHP core_useragent::is_firefox使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類core_useragent
的用法示例。
在下文中一共展示了core_useragent::is_firefox方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: send_stored_file
/**
* Handles the sending of file data to the user's browser, including support for
* byteranges etc.
*
* The $options parameter supports the following keys:
* (string|null) preview - send the preview of the file (e.g. "thumb" for a thumbnail)
* (string|null) filename - overrides the implicit filename
* (bool) dontdie - return control to caller afterwards. this is not recommended and only used for cleanup tasks.
* if this is passed as true, ignore_user_abort is called. if you don't want your processing to continue on cancel,
* you must detect this case when control is returned using connection_aborted. Please not that session is closed
* and should not be reopened.
*
* @category files
* @param stored_file $stored_file local file object
* @param int $lifetime Number of seconds before the file should expire from caches (null means $CFG->filelifetime)
* @param int $filter 0 (default)=no filtering, 1=all files, 2=html files only
* @param bool $forcedownload If true (default false), forces download of file rather than view in browser/plugin
* @param array $options additional options affecting the file serving
* @return null script execution stopped unless $options['dontdie'] is true
*/
function send_stored_file($stored_file, $lifetime = null, $filter = 0, $forcedownload = false, array $options = array())
{
global $CFG, $COURSE;
if (empty($options['filename'])) {
$filename = null;
} else {
$filename = $options['filename'];
}
if (empty($options['dontdie'])) {
$dontdie = false;
} else {
$dontdie = true;
}
if ($lifetime === 'default' or is_null($lifetime)) {
$lifetime = $CFG->filelifetime;
}
if (!empty($options['preview'])) {
// replace the file with its preview
$fs = get_file_storage();
$preview_file = $fs->get_file_preview($stored_file, $options['preview']);
if (!$preview_file) {
// unable to create a preview of the file, send its default mime icon instead
if ($options['preview'] === 'tinyicon') {
$size = 24;
} else {
if ($options['preview'] === 'thumb') {
$size = 90;
} else {
$size = 256;
}
}
$fileicon = file_file_icon($stored_file, $size);
send_file($CFG->dirroot . '/pix/' . $fileicon . '.png', basename($fileicon) . '.png');
} else {
// preview images have fixed cache lifetime and they ignore forced download
// (they are generated by GD and therefore they are considered reasonably safe).
$stored_file = $preview_file;
$lifetime = DAYSECS;
$filter = 0;
$forcedownload = false;
}
}
// handle external resource
if ($stored_file && $stored_file->is_external_file() && !isset($options['sendcachedexternalfile'])) {
$stored_file->send_file($lifetime, $filter, $forcedownload, $options);
die;
}
if (!$stored_file or $stored_file->is_directory()) {
// nothing to serve
if ($dontdie) {
return;
}
die;
}
if ($dontdie) {
ignore_user_abort(true);
}
\core\session\manager::write_close();
// Unlock session during file serving.
// 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
$filename = is_null($filename) ? $stored_file->get_filename() : $filename;
$isFF = core_useragent::is_firefox();
// only FF 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 (core_useragent::is_ie()) {
$filename = rawurlencode($filename);
}
if ($forcedownload) {
header('Content-Disposition: attachment; filename="' . $filename . '"');
} else {
if ($mimetype !== 'application/x-shockwave-flash') {
// If this is an swf don't pass content-disposition with filename as this makes the flash player treat the file
// as an upload and enforces security that may prevent the file from being loaded.
header('Content-Disposition: inline; filename="' . $filename . '"');
}
}
if ($lifetime > 0) {
//.........這裏部分代碼省略.........
示例2: list_supported_urls
public function list_supported_urls(array $urls, array $options = array())
{
$extensions = $this->get_supported_extensions();
$result = array();
foreach ($urls as $url) {
$ext = core_media::get_extension($url);
if (in_array($ext, $extensions)) {
if ($ext === 'ogg' || $ext === 'oga') {
// Formats .ogg and .oga are not supported in IE, Edge, or Safari.
if (core_useragent::is_ie() || core_useragent::is_edge() || core_useragent::is_safari()) {
continue;
}
} else {
// Formats .aac, .mp3, and .m4a are not supported in Opera.
if (core_useragent::is_opera()) {
continue;
}
// Formats .mp3 and .m4a were not reliably supported in Firefox before 27.
// https://developer.mozilla.org/en-US/docs/Web/HTML/Supported_media_formats
// has the details. .aac is still not supported.
if (core_useragent::is_firefox() && ($ext === 'aac' || !core_useragent::check_firefox_version(27))) {
continue;
}
}
// Old Android versions (pre 2.3.3) 'support' audio tag but no codecs.
if (core_useragent::is_webkit_android() && !core_useragent::is_webkit_android('533.1')) {
continue;
}
$result[] = $url;
}
}
return $result;
}
示例3: list_supported_urls
public function list_supported_urls(array $urls, array $options = array())
{
$extensions = $this->get_supported_extensions();
$result = array();
foreach ($urls as $url) {
$ext = core_media::get_extension($url);
if (in_array($ext, $extensions)) {
if ($ext === 'ogg' || $ext === 'oga') {
// Formats .ogg and .oga are not supported in IE or Safari.
if (core_useragent::is_ie() || core_useragent::is_safari()) {
continue;
}
} else {
// Formats .aac, .mp3, and .m4a are not supported in Firefox or Opera.
if (core_useragent::is_firefox() || core_useragent::is_opera()) {
continue;
}
}
// Old Android versions (pre 2.3.3) 'support' audio tag but no codecs.
if (core_useragent::is_webkit_android() && !core_useragent::is_webkit_android('533.1')) {
continue;
}
$result[] = $url;
}
}
return $result;
}
示例4: test_check_browser_version
//.........這裏部分代碼省略.........
$this->assertTrue(core_useragent::check_ie_version('10'));
$this->assertFalse(core_useragent::check_ie_compatibility_view());
$this->assertFalse(core_useragent::check_ie_version('11'));
core_useragent::instance(true, $this->user_agents['MSIE']['10.0i']['Windows 8']);
$this->assertTrue(core_useragent::is_ie());
$this->assertTrue(core_useragent::check_ie_version());
$this->assertTrue(core_useragent::check_ie_version(0));
$this->assertTrue(core_useragent::check_ie_version('5.0'));
$this->assertTrue(core_useragent::check_ie_version('9.0'));
$this->assertTrue(core_useragent::check_ie_version('10'));
$this->assertTrue(core_useragent::check_ie_compatibility_view());
$this->assertFalse(core_useragent::check_ie_version('11'));
core_useragent::instance(true, $this->user_agents['MSIE']['11.0']['Windows 8.1']);
$this->assertTrue(core_useragent::is_ie());
$this->assertTrue(core_useragent::check_ie_version());
$this->assertTrue(core_useragent::check_ie_version(0));
$this->assertTrue(core_useragent::check_ie_version('5.0'));
$this->assertTrue(core_useragent::check_ie_version('9.0'));
$this->assertTrue(core_useragent::check_ie_version('10'));
$this->assertTrue(core_useragent::check_ie_version('11'));
$this->assertFalse(core_useragent::check_ie_compatibility_view());
$this->assertFalse(core_useragent::check_ie_version('12'));
core_useragent::instance(true, $this->user_agents['MSIE']['11.0i']['Windows 8.1']);
$this->assertTrue(core_useragent::is_ie());
$this->assertTrue(core_useragent::check_ie_version());
$this->assertTrue(core_useragent::check_ie_version(0));
$this->assertTrue(core_useragent::check_ie_version('5.0'));
$this->assertTrue(core_useragent::check_ie_version('9.0'));
$this->assertTrue(core_useragent::check_ie_version('10'));
$this->assertTrue(core_useragent::check_ie_version('11'));
$this->assertTrue(core_useragent::check_ie_compatibility_view());
$this->assertFalse(core_useragent::check_ie_version('12'));
core_useragent::instance(true, $this->user_agents['Firefox']['2.0']['Windows XP']);
$this->assertTrue(core_useragent::is_firefox());
$this->assertTrue(core_useragent::check_firefox_version());
$this->assertTrue(core_useragent::check_firefox_version('1.5'));
$this->assertFalse(core_useragent::check_firefox_version('3.0'));
$this->assertTrue(core_useragent::check_gecko_version('2'));
$this->assertTrue(core_useragent::check_gecko_version(20030516));
$this->assertTrue(core_useragent::check_gecko_version(20051106));
$this->assertTrue(core_useragent::check_gecko_version(2006010100));
core_useragent::instance(true, $this->user_agents['Firefox']['1.0.6']['Windows XP']);
$this->assertTrue(core_useragent::is_firefox());
$this->assertTrue(core_useragent::check_firefox_version());
$this->assertTrue(core_useragent::check_gecko_version('1'));
$this->assertFalse(core_useragent::check_gecko_version(20030516));
$this->assertFalse(core_useragent::check_gecko_version(20051106));
$this->assertFalse(core_useragent::check_gecko_version(2006010100));
$this->assertFalse(core_useragent::check_firefox_version('1.5'));
$this->assertFalse(core_useragent::check_firefox_version('3.0'));
$this->assertFalse(core_useragent::check_gecko_version('2'));
core_useragent::instance(true, $this->user_agents['Firefox']['2.0']['Windows XP']);
$this->assertTrue(core_useragent::is_firefox());
$this->assertTrue(core_useragent::check_firefox_version());
$this->assertTrue(core_useragent::check_firefox_version('1.5'));
$this->assertTrue(core_useragent::check_gecko_version('1'));
$this->assertTrue(core_useragent::check_gecko_version('2'));
$this->assertTrue(core_useragent::check_gecko_version(20030516));
$this->assertTrue(core_useragent::check_gecko_version(20051106));
$this->assertTrue(core_useragent::check_gecko_version(2006010100));
$this->assertFalse(core_useragent::check_firefox_version('3.0'));
core_useragent::instance(true, $this->user_agents['Firefox']['3.6']['Linux']);
$this->assertTrue(core_useragent::is_firefox());
$this->assertTrue(core_useragent::check_firefox_version());
$this->assertTrue(core_useragent::check_firefox_version('1.5'));
$this->assertTrue(core_useragent::check_firefox_version('3.0'));
示例5: test_useragent_firefox
/**
* @dataProvider user_agents_providers
*/
public function test_useragent_firefox($useragent, $tests)
{
// Setup the core_useragent instance.
core_useragent::instance(true, $useragent);
if (isset($tests['is_firefox']) && $tests['is_firefox']) {
$this->assertTrue(core_useragent::is_firefox(), "Browser was not identified as a firefox browser");
$this->assertTrue(core_useragent::check_firefox_version());
} else {
$this->assertFalse(core_useragent::is_firefox(), "Browser was incorrectly identified as a firefox browser");
$this->assertFalse(core_useragent::check_firefox_version());
}
$versions = array('1.5' => false, '3.0' => false, '4' => false, '10' => false, '15' => false, '18' => false, '19' => false, '33' => false);
if (isset($tests['check_firefox_version'])) {
// The test provider has overwritten some of the above checks.
// Must use the '+' operator, because array_merge will incorrectly rewrite the array keys for integer-based indexes.
$versions = $tests['check_firefox_version'] + $versions;
}
foreach ($versions as $version => $result) {
$this->assertEquals($result, core_useragent::check_firefox_version($version), "Version incorrectly determined for Firefox version '{$version}'");
}
}
示例6: test_check_browser_version
//.........這裏部分代碼省略.........
core_useragent::instance(true, $this->user_agents['MSIE']['10.0i']['Windows 8']);
$this->assertTrue(core_useragent::is_ie());
$this->assertTrue(core_useragent::check_ie_version());
$this->assertTrue(core_useragent::check_ie_version(0));
$this->assertTrue(core_useragent::check_ie_version('5.0'));
$this->assertTrue(core_useragent::check_ie_version('9.0'));
$this->assertTrue(core_useragent::check_ie_version('10'));
$this->assertTrue(core_useragent::check_ie_compatibility_view());
$this->assertFalse(core_useragent::check_ie_version('11'));
$this->assertFalse(core_useragent::is_msword());
core_useragent::instance(true, $this->user_agents['MSIE']['11.0']['Windows 8.1']);
$this->assertTrue(core_useragent::is_ie());
$this->assertTrue(core_useragent::check_ie_version());
$this->assertTrue(core_useragent::check_ie_version(0));
$this->assertTrue(core_useragent::check_ie_version('5.0'));
$this->assertTrue(core_useragent::check_ie_version('9.0'));
$this->assertTrue(core_useragent::check_ie_version('10'));
$this->assertTrue(core_useragent::check_ie_version('11'));
$this->assertFalse(core_useragent::check_ie_compatibility_view());
$this->assertFalse(core_useragent::check_ie_version('12'));
$this->assertFalse(core_useragent::is_msword());
core_useragent::instance(true, $this->user_agents['MSIE']['11.0i']['Windows 8.1']);
$this->assertTrue(core_useragent::is_ie());
$this->assertTrue(core_useragent::check_ie_version());
$this->assertTrue(core_useragent::check_ie_version(0));
$this->assertTrue(core_useragent::check_ie_version('5.0'));
$this->assertTrue(core_useragent::check_ie_version('9.0'));
$this->assertTrue(core_useragent::check_ie_version('10'));
$this->assertTrue(core_useragent::check_ie_version('11'));
$this->assertTrue(core_useragent::check_ie_compatibility_view());
$this->assertFalse(core_useragent::check_ie_version('12'));
$this->assertFalse(core_useragent::is_msword());
core_useragent::instance(true, $this->user_agents['Firefox']['2.0']['Windows XP']);
$this->assertTrue(core_useragent::is_firefox());
$this->assertTrue(core_useragent::check_firefox_version());
$this->assertTrue(core_useragent::check_firefox_version('1.5'));
$this->assertFalse(core_useragent::check_firefox_version('3.0'));
$this->assertTrue(core_useragent::check_gecko_version('2'));
$this->assertTrue(core_useragent::check_gecko_version(20030516));
$this->assertTrue(core_useragent::check_gecko_version(20051106));
$this->assertTrue(core_useragent::check_gecko_version(2006010100));
$this->assertFalse(core_useragent::is_msword());
core_useragent::instance(true, $this->user_agents['Firefox']['1.0.6']['Windows XP']);
$this->assertTrue(core_useragent::is_firefox());
$this->assertTrue(core_useragent::check_firefox_version());
$this->assertTrue(core_useragent::check_gecko_version('1'));
$this->assertFalse(core_useragent::check_gecko_version(20030516));
$this->assertFalse(core_useragent::check_gecko_version(20051106));
$this->assertFalse(core_useragent::check_gecko_version(2006010100));
$this->assertFalse(core_useragent::check_firefox_version('1.5'));
$this->assertFalse(core_useragent::check_firefox_version('3.0'));
$this->assertFalse(core_useragent::check_gecko_version('2'));
$this->assertFalse(core_useragent::is_msword());
core_useragent::instance(true, $this->user_agents['Firefox']['2.0']['Windows XP']);
$this->assertTrue(core_useragent::is_firefox());
$this->assertTrue(core_useragent::check_firefox_version());
$this->assertTrue(core_useragent::check_firefox_version('1.5'));
$this->assertTrue(core_useragent::check_gecko_version('1'));
$this->assertTrue(core_useragent::check_gecko_version('2'));
$this->assertTrue(core_useragent::check_gecko_version(20030516));
$this->assertTrue(core_useragent::check_gecko_version(20051106));
$this->assertTrue(core_useragent::check_gecko_version(2006010100));
$this->assertFalse(core_useragent::check_firefox_version('3.0'));
$this->assertFalse(core_useragent::is_msword());
core_useragent::instance(true, $this->user_agents['Firefox']['3.6']['Linux']);
$this->assertTrue(core_useragent::is_firefox());