From 6743ee082d2284df84f08aff5d19f32af3ae64e7 Mon Sep 17 00:00:00 2001 From: nate Date: Sat, 24 Jun 2006 17:55:06 +0000 Subject: [PATCH] Adding WAP device detection to RequestHandler git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3176 3807eeeb-6ff5-0310-8944-8be069107fe0 --- .../controller/components/request_handler.php | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/cake/libs/controller/components/request_handler.php b/cake/libs/controller/components/request_handler.php index 1de6a30fa..7a064e1a4 100644 --- a/cake/libs/controller/components/request_handler.php +++ b/cake/libs/controller/components/request_handler.php @@ -57,7 +57,11 @@ class RequestHandlerComponent extends Object{ 'xhtml' => array('application/xhtml+xml', 'application/xhtml', 'text/xhtml'), 'xml' => array('application/xml', 'text/xml'), 'rss' => 'application/rss+xml', - 'atom' => 'application/atom+xml' + 'atom' => 'application/atom+xml', + 'wap' => array('text/vnd.wap.wml', 'text/vnd.wap.wmlscript', 'image/vnd.wap.wbmp'), + 'wml' => 'text/vnd.wap.wml', + 'wmlscript' => 'text/vnd.wap.wmlscript', + 'wbmp' => 'image/vnd.wap.wbmp' ); var $__acceptTypes = array(); @@ -152,6 +156,22 @@ class RequestHandlerComponent extends Object{ function isAtom() { return $this->accepts('atom'); } +/** + * Returns true if user agent string matches a mobile web browser, or if the client accepts WAP content + * + * @return bool True if user agent is a mobile web browser + */ + function isMobile() { + return (preg_match('/' . REQUEST_MOBILE_UA . '/i', env('HTTP_USER_AGENT')) > 0 || $this->accepts('wap')); + } +/** + * Returns true if the client accepts WAP content + * + * @return bool + */ + function isWap() { + return $this->accepts('wap'); + } /** * Returns true if the current call a POST request * @@ -253,14 +273,6 @@ class RequestHandlerComponent extends Object{ } return trim($ipaddr); } -/** - * Returns true if user agent string matches a mobile web browser - * - * @return bool True if user agent is a mobile web browser - */ - function isMobile() { - return (preg_match('/' . REQUEST_MOBILE_UA . '/i', env('HTTP_USER_AGENT')) > 0); - } /** * Strips extra whitespace from output *