Add UserUtil::isTablet() method
authorjoshuaruesweg <ruesweg@woltlab.com>
Thu, 29 Oct 2020 12:55:47 +0000 (13:55 +0100)
committerjoshuaruesweg <ruesweg@woltlab.com>
Mon, 2 Nov 2020 14:43:05 +0000 (15:43 +0100)
wcfsetup/install/files/lib/util/UserUtil.class.php

index f2d96ca1b056be1e24bcba6f2174264aa8214485..39970a3cb642beb8febb00650989f44c4f2fa2de 100644 (file)
@@ -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.
         *