本文整理汇总了PHP中core_useragent::is_chrome方法的典型用法代码示例。如果您正苦于以下问题:PHP core_useragent::is_chrome方法的具体用法?PHP core_useragent::is_chrome怎么用?PHP core_useragent::is_chrome使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_useragent
的用法示例。
在下文中一共展示了core_useragent::is_chrome方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: embed
/**
* Generates code required to embed the player.
*
* @param moodle_url[] $urls
* @param string $name
* @param int $width
* @param int $height
* @param array $options
* @return string
*/
public function embed($urls, $name, $width, $height, $options)
{
global $CFG;
require_once $CFG->libdir . '/filelib.php';
$sources = array();
$mediamanager = core_media_manager::instance();
$datasetup = [];
$text = null;
$isaudio = null;
$hastracks = false;
$hasposter = false;
if (array_key_exists(core_media_manager::OPTION_ORIGINAL_TEXT, $options) && preg_match('/^<(video|audio)\\b/i', $options[core_media_manager::OPTION_ORIGINAL_TEXT], $matches)) {
// Original text already had media tag - get some data from it.
$text = $options[core_media_manager::OPTION_ORIGINAL_TEXT];
$isaudio = strtolower($matches[1]) === 'audio';
$hastracks = preg_match('/<track\\b/i', $text);
$hasposter = self::get_attribute($text, 'poster') !== null;
}
// Currently Flash in VideoJS does not support responsive layout. If Flash is enabled try to guess
// if HTML5 player will be engaged for the user and then set it to responsive.
$responsive = get_config('media_videojs', 'useflash') && !$this->youtube ? null : true;
// Build list of source tags.
foreach ($urls as $url) {
$extension = $mediamanager->get_extension($url);
$mimetype = $mediamanager->get_mimetype($url);
if ($mimetype === 'video/quicktime' && (core_useragent::is_chrome() || core_useragent::is_edge())) {
// Fix for VideoJS/Chrome bug https://github.com/videojs/video.js/issues/423 .
$mimetype = 'video/mp4';
}
$source = html_writer::empty_tag('source', array('src' => $url, 'type' => $mimetype));
$sources[] = $source;
if ($isaudio === null) {
$isaudio = in_array('.' . $extension, file_get_typegroup('extension', 'audio'));
}
if ($responsive === null) {
$responsive = core_useragent::supports_html5($extension);
}
}
$sources = implode("\n", $sources);
// Find the title, prevent double escaping.
$title = $this->get_name($name, $urls);
$title = preg_replace(['/&/', '/>/', '/</'], ['&', '>', '<'], $title);
// Ensure JS is loaded. This will also load language strings and populate $this->language with the current language.
$this->load_amd_module();
if ($this->youtube) {
$this->load_amd_module('Youtube');
$datasetup[] = '"techOrder": ["youtube"]';
$datasetup[] = '"sources": [{"type": "video/youtube", "src":"' . $urls[0] . '"}]';
$sources = '';
// Do not specify <source> tags - it may confuse browser.
$isaudio = false;
// Just in case.
}
// Add a language.
if ($this->language) {
$datasetup[] = '"language": "' . $this->language . '"';
}
// Set responsive option.
if ($responsive) {
$datasetup[] = '"fluid": true';
}
if ($isaudio && !$hastracks) {
// We don't need a full screen toggle for the audios (except when tracks are present).
$datasetup[] = '"controlBar": {"fullscreenToggle": false}';
}
if ($isaudio && !$height && !$hastracks && !$hasposter) {
// Hide poster area for audios without tracks or poster.
// See discussion on https://github.com/videojs/video.js/issues/2777 .
// Maybe TODO: if there are only chapter tracks we still don't need poster area.
$datasetup[] = '"aspectRatio": "1:0"';
}
// Attributes for the video/audio tag.
static $playercounter = 1;
$attributes = ['data-setup' => '{' . join(', ', $datasetup) . '}', 'id' => 'id_videojs_' . $playercounter++, 'class' => get_config('media_videojs', $isaudio ? 'audiocssclass' : 'videocssclass')];
if (!$responsive) {
// Note we ignore limitsize setting if not responsive.
parent::pick_video_size($width, $height);
$attributes += ['width' => $width] + ($height ? ['height' => $height] : []);
}
if ($text !== null) {
// Original text already had media tag - add necessary attributes and replace sources
// with the supported URLs only.
if (($class = self::get_attribute($text, 'class')) !== null) {
$attributes['class'] .= ' ' . $class;
}
$text = self::remove_attributes($text, ['id', 'width', 'height', 'class']);
if (self::get_attribute($text, 'title') === null) {
$attributes['title'] = $title;
}
$text = self::add_attributes($text, $attributes);
//.........这里部分代码省略.........
示例2: test_useragent_chrome
/**
* @dataProvider user_agents_providers
*/
public function test_useragent_chrome($useragent, $tests)
{
// Setup the core_useragent instance.
core_useragent::instance(true, $useragent);
if (isset($tests['is_chrome']) && $tests['is_chrome']) {
$this->assertTrue(core_useragent::is_chrome(), "Browser was not identified as a chrome browser");
$this->assertTrue(core_useragent::check_chrome_version());
} else {
$this->assertFalse(core_useragent::is_chrome(), "Browser was incorrectly identified as a chrome browser");
$this->assertFalse(core_useragent::check_chrome_version());
}
$versions = array('7' => false, '8' => false, '10' => false, '39' => false);
if (isset($tests['check_chrome_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_chrome_version'] + $versions;
}
foreach ($versions as $version => $result) {
$this->assertEquals($result, core_useragent::check_chrome_version($version), "Version incorrectly determined for Chrome version '{$version}'");
}
}
示例3: test_check_browser_version
/**
* Modifies $_SERVER['HTTP_USER_AGENT'] manually to check if check_browser_version
* works as expected.
*/
public function test_check_browser_version()
{
core_useragent::instance(true, $this->user_agents['Safari']['412']['Mac OS X']);
$this->assertTrue(core_useragent::is_safari());
$this->assertTrue(core_useragent::check_safari_version());
$this->assertTrue(core_useragent::is_webkit());
$this->assertTrue(core_useragent::check_webkit_version());
$this->assertTrue(core_useragent::check_safari_version('312'));
$this->assertFalse(core_useragent::check_safari_version('500'));
$this->assertFalse(core_useragent::is_chrome());
$this->assertFalse(core_useragent::check_chrome_version());
$this->assertFalse(core_useragent::is_safari_ios());
$this->assertFalse(core_useragent::check_safari_ios_version());
core_useragent::instance(true, $this->user_agents['Safari iOS']['528']['iPhone']);
$this->assertTrue(core_useragent::is_safari_ios());
$this->assertTrue(core_useragent::check_safari_ios_version());
$this->assertTrue(core_useragent::is_webkit());
$this->assertTrue(core_useragent::check_webkit_version());
$this->assertTrue(core_useragent::check_safari_ios_version('527'));
$this->assertFalse(core_useragent::check_safari_ios_version(590));
$this->assertFalse(core_useragent::check_safari_version('312'));
$this->assertFalse(core_useragent::check_safari_version('500'));
$this->assertFalse(core_useragent::is_chrome());
$this->assertFalse(core_useragent::check_chrome_version());
core_useragent::instance(true, $this->user_agents['WebKit Android']['530']['Nexus']);
$this->assertTrue(core_useragent::is_webkit());
$this->assertTrue(core_useragent::check_webkit_version());
$this->assertTrue(core_useragent::check_webkit_android_version('527'));
$this->assertFalse(core_useragent::check_webkit_android_version(590));
$this->assertFalse(core_useragent::is_safari());
$this->assertFalse(core_useragent::check_safari_version());
$this->assertFalse(core_useragent::is_chrome());
$this->assertFalse(core_useragent::check_chrome_version());
core_useragent::instance(true, $this->user_agents['WebKit Android']['537']['Samsung GT-9505']);
$this->assertTrue(core_useragent::is_webkit());
$this->assertTrue(core_useragent::check_webkit_version());
$this->assertTrue(core_useragent::check_webkit_android_version('527'));
$this->assertTrue(core_useragent::is_chrome());
$this->assertTrue(core_useragent::check_chrome_version());
$this->assertFalse(core_useragent::check_webkit_android_version(590));
$this->assertFalse(core_useragent::is_safari());
$this->assertFalse(core_useragent::check_safari_version());
core_useragent::instance(true, $this->user_agents['WebKit Android']['537']['Nexus 5']);
$this->assertTrue(core_useragent::is_webkit());
$this->assertTrue(core_useragent::check_webkit_version());
$this->assertTrue(core_useragent::check_webkit_android_version('527'));
$this->assertTrue(core_useragent::is_chrome());
$this->assertTrue(core_useragent::check_chrome_version());
$this->assertFalse(core_useragent::check_webkit_android_version(590));
$this->assertFalse(core_useragent::is_safari());
$this->assertFalse(core_useragent::check_safari_version());
core_useragent::instance(true, $this->user_agents['Chrome']['8']['Mac OS X']);
$this->assertTrue(core_useragent::is_chrome());
$this->assertTrue(core_useragent::check_chrome_version());
$this->assertTrue(core_useragent::is_webkit());
$this->assertTrue(core_useragent::check_webkit_version());
$this->assertTrue(core_useragent::check_chrome_version(8));
$this->assertFalse(core_useragent::check_chrome_version(10));
$this->assertFalse(core_useragent::check_safari_version('1'));
core_useragent::instance(true, $this->user_agents['Opera']['9.0']['Windows XP']);
$this->assertTrue(core_useragent::is_opera());
$this->assertTrue(core_useragent::check_opera_version());
$this->assertTrue(core_useragent::check_opera_version('8.0'));
$this->assertFalse(core_useragent::check_opera_version('10.0'));
core_useragent::instance(true, $this->user_agents['MSIE']['6.0']['Windows XP SP2']);
$this->assertTrue(core_useragent::is_ie());
$this->assertTrue(core_useragent::check_ie_version());
$this->assertTrue(core_useragent::check_ie_version('5.0'));
$this->assertFalse(core_useragent::check_ie_compatibility_view());
$this->assertFalse(core_useragent::check_ie_version('7.0'));
core_useragent::instance(true, $this->user_agents['MSIE']['5.0']['Windows 98']);
$this->assertFalse(core_useragent::is_ie());
$this->assertFalse(core_useragent::check_ie_version());
$this->assertTrue(core_useragent::check_ie_version(0));
$this->assertTrue(core_useragent::check_ie_version('5.0'));
$this->assertFalse(core_useragent::check_ie_compatibility_view());
$this->assertFalse(core_useragent::check_ie_version('7.0'));
core_useragent::instance(true, $this->user_agents['MSIE']['9.0']['Windows 7']);
$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->assertFalse(core_useragent::check_ie_compatibility_view());
$this->assertFalse(core_useragent::check_ie_version('10'));
core_useragent::instance(true, $this->user_agents['MSIE']['9.0i']['Windows 7']);
$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_compatibility_view());
$this->assertFalse(core_useragent::check_ie_version('10'));
core_useragent::instance(true, $this->user_agents['MSIE']['10.0']['Windows 8']);
$this->assertTrue(core_useragent::is_ie());
$this->assertTrue(core_useragent::check_ie_version());
//.........这里部分代码省略.........
示例4: test_check_browser_version
/**
* Modifies $_SERVER['HTTP_USER_AGENT'] manually to check if check_browser_version
* works as expected.
*/
public function test_check_browser_version()
{
core_useragent::instance(true, $this->user_agents['Safari']['412']['Mac OS X']);
$this->assertTrue(core_useragent::is_safari());
$this->assertTrue(core_useragent::check_safari_version());
$this->assertTrue(core_useragent::is_webkit());
$this->assertTrue(core_useragent::check_webkit_version());
$this->assertTrue(core_useragent::check_safari_version('312'));
$this->assertFalse(core_useragent::check_safari_version('500'));
$this->assertFalse(core_useragent::is_chrome());
$this->assertFalse(core_useragent::check_chrome_version());
$this->assertFalse(core_useragent::is_safari_ios());
$this->assertFalse(core_useragent::check_safari_ios_version());
$this->assertFalse(core_useragent::is_msword());
core_useragent::instance(true, $this->user_agents['Safari iOS']['528']['iPhone']);
$this->assertTrue(core_useragent::is_safari_ios());
$this->assertTrue(core_useragent::check_safari_ios_version());
$this->assertTrue(core_useragent::is_webkit());
$this->assertTrue(core_useragent::check_webkit_version());
$this->assertTrue(core_useragent::check_safari_ios_version('527'));
$this->assertFalse(core_useragent::check_safari_ios_version(590));
$this->assertFalse(core_useragent::check_safari_version('312'));
$this->assertFalse(core_useragent::check_safari_version('500'));
$this->assertFalse(core_useragent::is_chrome());
$this->assertFalse(core_useragent::check_chrome_version());
$this->assertFalse(core_useragent::is_msword());
core_useragent::instance(true, $this->user_agents['WebKit Android']['530']['Nexus']);
$this->assertTrue(core_useragent::is_webkit());
$this->assertTrue(core_useragent::check_webkit_version());
$this->assertTrue(core_useragent::check_webkit_android_version('527'));
$this->assertFalse(core_useragent::check_webkit_android_version(590));
$this->assertFalse(core_useragent::is_safari());
$this->assertFalse(core_useragent::check_safari_version());
$this->assertFalse(core_useragent::is_chrome());
$this->assertFalse(core_useragent::check_chrome_version());
$this->assertFalse(core_useragent::is_msword());
core_useragent::instance(true, $this->user_agents['WebKit Android']['537']['Samsung GT-9505']);
$this->assertTrue(core_useragent::is_webkit());
$this->assertTrue(core_useragent::check_webkit_version());
$this->assertTrue(core_useragent::check_webkit_android_version('527'));
$this->assertTrue(core_useragent::is_chrome());
$this->assertTrue(core_useragent::check_chrome_version());
$this->assertFalse(core_useragent::check_webkit_android_version(590));
$this->assertFalse(core_useragent::is_safari());
$this->assertFalse(core_useragent::check_safari_version());
core_useragent::instance(true, $this->user_agents['WebKit Android']['537']['Nexus 5']);
$this->assertTrue(core_useragent::is_webkit());
$this->assertTrue(core_useragent::check_webkit_version());
$this->assertTrue(core_useragent::check_webkit_android_version('527'));
$this->assertTrue(core_useragent::is_chrome());
$this->assertTrue(core_useragent::check_chrome_version());
$this->assertFalse(core_useragent::check_webkit_android_version(590));
$this->assertFalse(core_useragent::is_safari());
$this->assertFalse(core_useragent::check_safari_version());
core_useragent::instance(true, $this->user_agents['Chrome']['8']['Mac OS X']);
$this->assertTrue(core_useragent::is_chrome());
$this->assertTrue(core_useragent::check_chrome_version());
$this->assertTrue(core_useragent::is_webkit());
$this->assertTrue(core_useragent::check_webkit_version());
$this->assertTrue(core_useragent::check_chrome_version(8));
$this->assertFalse(core_useragent::check_chrome_version(10));
$this->assertFalse(core_useragent::check_safari_version('1'));
$this->assertFalse(core_useragent::is_msword());
core_useragent::instance(true, $this->user_agents['Opera']['9.0']['Windows XP']);
$this->assertTrue(core_useragent::is_opera());
$this->assertTrue(core_useragent::check_opera_version());
$this->assertTrue(core_useragent::check_opera_version('8.0'));
$this->assertFalse(core_useragent::check_opera_version('10.0'));
$this->assertFalse(core_useragent::is_msword());
core_useragent::instance(true, $this->user_agents['MSIE']['6.0']['Windows XP SP2']);
$this->assertTrue(core_useragent::is_ie());
$this->assertTrue(core_useragent::check_ie_version());
$this->assertTrue(core_useragent::check_ie_version('5.0'));
$this->assertFalse(core_useragent::check_ie_compatibility_view());
$this->assertFalse(core_useragent::check_ie_version('7.0'));
$this->assertFalse(core_useragent::is_msword());
core_useragent::instance(true, $this->user_agents['MSIE']['5.0']['Windows 98']);
$this->assertFalse(core_useragent::is_ie());
$this->assertFalse(core_useragent::check_ie_version());
$this->assertTrue(core_useragent::check_ie_version(0));
$this->assertTrue(core_useragent::check_ie_version('5.0'));
$this->assertFalse(core_useragent::check_ie_compatibility_view());
$this->assertFalse(core_useragent::check_ie_version('7.0'));
$this->assertFalse(core_useragent::is_msword());
core_useragent::instance(true, $this->user_agents['MSIE']['7.0']['Windows XP SP2']);
$this->assertTrue(core_useragent::is_ie());
$this->assertTrue(core_useragent::check_ie_version());
$this->assertTrue(core_useragent::check_ie_version('7.0'));
$this->assertFalse(core_useragent::check_ie_compatibility_view());
$this->assertFalse(core_useragent::check_ie_version('8.0'));
$this->assertFalse(core_useragent::is_msword());
core_useragent::instance(true, $this->user_agents['MSIE']['7.0b']['Windows XP']);
$this->assertTrue(core_useragent::is_ie());
$this->assertTrue(core_useragent::check_ie_version());
$this->assertTrue(core_useragent::check_ie_version('7.0'));
$this->assertFalse(core_useragent::check_ie_compatibility_view());
//.........这里部分代码省略.........