mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
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
This commit is contained in:
parent
e941e48a07
commit
6743ee082d
1 changed files with 21 additions and 9 deletions
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue