本文整理匯總了PHP中core_useragent::check_webkit_android_version方法的典型用法代碼示例。如果您正苦於以下問題:PHP core_useragent::check_webkit_android_version方法的具體用法?PHP core_useragent::check_webkit_android_version怎麽用?PHP core_useragent::check_webkit_android_version使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類core_useragent
的用法示例。
在下文中一共展示了core_useragent::check_webkit_android_version方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: embed
public function embed($urls, $name, $width, $height, $options)
{
// Special handling to make videos play on Android devices pre 2.3.
// Note: I tested and 2.3.3 (in emulator) works without, is 533.1 webkit.
$oldandroid = core_useragent::is_webkit_android() && !core_useragent::check_webkit_android_version('533.1');
// Build array of source tags.
$sources = array();
foreach ($urls as $url) {
$mimetype = core_media::get_mimetype($url);
$source = html_writer::tag('source', '', array('src' => $url, 'type' => $mimetype));
if ($mimetype === 'video/mp4') {
if ($oldandroid) {
// Old Android fails if you specify the type param.
$source = html_writer::tag('source', '', array('src' => $url));
}
// Better add m4v as first source, it might be a bit more
// compatible with problematic browsers.
array_unshift($sources, $source);
} else {
$sources[] = $source;
}
}
$sources = implode("\n", $sources);
$title = s($this->get_name($name, $urls));
if (!$width) {
// No width specified, use system default.
$width = CORE_MEDIA_VIDEO_WIDTH;
}
if (!$height) {
// Let browser choose height automatically.
$size = "width=\"{$width}\"";
} else {
$size = "width=\"{$width}\" height=\"{$height}\"";
}
$sillyscript = '';
$idtag = '';
if ($oldandroid) {
// Old Android does not support 'controls' option.
$id = 'core_media_html5v_' . md5(time() . '_' . rand());
$idtag = 'id="' . $id . '"';
$sillyscript = <<<OET
<script type="text/javascript">
document.getElementById('{$id}').addEventListener('click', function() {
this.play();
}, false);
</script>
OET;
}
$fallback = core_media_player::PLACEHOLDER;
return <<<OET
<span class="mediaplugin mediaplugin_html5video">
<video {$idtag} controls="true" {$size} preload="metadata" title="{$title}">
{$sources}
{$fallback}
</video>
{$sillyscript}
</span>
OET;
}
示例2: embed
public function embed($urls, $name, $width, $height, $options)
{
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)) {
// We already had media tag, do nothing here.
return $options[core_media_manager::OPTION_ORIGINAL_TEXT];
}
// Special handling to make videos play on Android devices pre 2.3.
// Note: I tested and 2.3.3 (in emulator) works without, is 533.1 webkit.
$oldandroid = core_useragent::is_webkit_android() && !core_useragent::check_webkit_android_version('533.1');
// Build array of source tags.
$sources = array();
foreach ($urls as $url) {
$mimetype = core_media_manager::instance()->get_mimetype($url);
$source = html_writer::empty_tag('source', array('src' => $url, 'type' => $mimetype));
if ($mimetype === 'video/mp4') {
if ($oldandroid) {
// Old Android fails if you specify the type param.
$source = html_writer::empty_tag('source', array('src' => $url));
}
// Better add m4v as first source, it might be a bit more
// compatible with problematic browsers.
array_unshift($sources, $source);
} else {
$sources[] = $source;
}
}
$sources = implode("\n", $sources);
$title = $this->get_name($name, $urls);
// Escape title but prevent double escaping.
$title = s(preg_replace(['/&/', '/>/', '/</'], ['&', '>', '<'], $title));
self::pick_video_size($width, $height);
if (!$height) {
// Let browser choose height automatically.
$size = "width=\"{$width}\"";
} else {
$size = "width=\"{$width}\" height=\"{$height}\"";
}
$sillyscript = '';
$idtag = '';
if ($oldandroid) {
// Old Android does not support 'controls' option.
$id = 'core_media_html5v_' . md5(time() . '_' . rand());
$idtag = 'id="' . $id . '"';
$sillyscript = <<<OET
<script type="text/javascript">
document.getElementById('{$id}').addEventListener('click', function() {
this.play();
}, false);
</script>
OET;
}
// We don't want fallback to another player because list_supported_urls() is already smart.
// Otherwise we could end up with nested <video> tags. Fallback to link only.
$fallback = self::LINKPLACEHOLDER;
return <<<OET
<span class="mediaplugin mediaplugin_html5video">
<video {$idtag} controls="true" {$size} preload="metadata" title="{$title}">
{$sources}
{$fallback}
</video>
{$sillyscript}
</span>
OET;
}
示例3: test_useragent_webkit_android
/**
* @dataProvider user_agents_providers
*/
public function test_useragent_webkit_android($useragent, $tests)
{
// Setup the core_useragent instance.
core_useragent::instance(true, $useragent);
if (isset($tests['is_webkit_android']) && $tests['is_webkit_android']) {
$this->assertTrue(core_useragent::is_webkit_android(), "Browser was not identified as an Android webkit browser");
$this->assertTrue(core_useragent::check_webkit_android_version());
} else {
$this->assertFalse(core_useragent::is_webkit_android(), "Browser was incorrectly identified as an Android webkit browser");
$this->assertFalse(core_useragent::check_webkit_android_version());
}
$versions = array('525' => false, '527' => false, '590' => false);
if (isset($tests['check_webkit_android_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_webkit_android_version'] + $versions;
}
foreach ($versions as $version => $result) {
$this->assertEquals($result, core_useragent::check_webkit_android_version($version), "Version incorrectly determined for Android webkit version '{$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());
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());
//.........這裏部分代碼省略.........
示例5: 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());
//.........這裏部分代碼省略.........