From 8342a0779f96495a43380a33fcc4cb2f72736af6 Mon Sep 17 00:00:00 2001 From: joshuaruesweg Date: Thu, 29 Oct 2020 13:55:47 +0100 Subject: [PATCH] Add UserUtil::isTablet() method --- wcfsetup/install/files/lib/util/UserUtil.class.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/wcfsetup/install/files/lib/util/UserUtil.class.php b/wcfsetup/install/files/lib/util/UserUtil.class.php index f2d96ca1b0..39970a3cb6 100644 --- a/wcfsetup/install/files/lib/util/UserUtil.class.php +++ b/wcfsetup/install/files/lib/util/UserUtil.class.php @@ -140,6 +140,20 @@ final class UserUtil { return false; } + /** + * Checks if the User Agent gives an indicator about a tablet device. + * Heads up: This is only a basic test and can easily be falsified by the user. + * + * @since 5.4 + */ + public static function isTablet(string $userAgent): bool { + if (preg_match('/tab(let)|ipad/i', $userAgent)) { + return true; + } + + return false; + } + /** * Returns the readable browser for a given user agent. * -- 2.20.1