Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Static Public Member Functions | Data Fields | Protected Member Functions | Static Protected Attributes
Zend_Http_UserAgent_Mobile Class Reference
Inheritance diagram for Zend_Http_UserAgent_Mobile:
Zend_Http_UserAgent_AbstractDevice Zend_Http_UserAgent_Device

Public Member Functions

 __construct ($userAgent=null, array $server=array(), array $config=array())
 
 getType ()
 
 getMarkupLanguage ($preferredMarkup=null)
 
 getImageFormatSupport ()
 
 getMaxImageHeight ()
 
 getMaxImageWidth ()
 
 getPhysicalScreenHeight ()
 
 getPhysicalScreenWidth ()
 
 getPreferredMarkup ()
 
 getXhtmlSupportLevel ()
 
 hasFlashSupport ()
 
 hasPdfSupport ()
 
 hasPhoneNumber ()
 
 httpsSupport ()
 
- Public Member Functions inherited from Zend_Http_UserAgent_AbstractDevice
 __construct ($userAgent=null, array $server=array(), array $config=array())
 
 serialize ()
 
 unserialize ($serialized)
 
 getType ()
 
 hasFeature ($feature)
 
 getFeature ($feature)
 
 setFeature ($feature, $value=false, $group='')
 
 setGroup ($group, $feature)
 
 getGroup ($group)
 
 getAllFeatures ()
 
 getAllGroups ()
 
 getImageFormatSupport ()
 
 getMaxImageHeight ()
 
 getMaxImageWidth ()
 
 getPhysicalScreenHeight ()
 
 getPhysicalScreenWidth ()
 
 getPreferredMarkup ()
 
 getXhtmlSupportLevel ()
 
 hasFlashSupport ()
 
 hasPdfSupport ()
 
 hasPhoneNumber ()
 
 httpsSupport ()
 
 getBrowser ()
 
 getBrowserVersion ()
 
 getUserAgent ()
 
 getImages ()
 
 setBrowser ($browser)
 
 setBrowserVersion ($browserVersion)
 
 setUserAgent ($userAgent)
 
 setImages ($_images)
 

Static Public Member Functions

static match ($userAgent, $server)
 
static userAgentStart ($userAgent)
 
- Static Public Member Functions inherited from Zend_Http_UserAgent_AbstractDevice
static extractFromUserAgent ($userAgent)
 

Data Fields

const DEFAULT_FEATURES_ADAPTER_CLASSNAME = 'Zend_Http_UserAgent_Features_Adapter_Browscap'
 
const DEFAULT_FEATURES_ADAPTER_PATH = 'Zend/Http/UserAgent/Features/Adapter/Browscap.php'
 

Protected Member Functions

 _defineFeatures ()
 
- Protected Member Functions inherited from Zend_Http_UserAgent_AbstractDevice
 _restoreFromArray (array $spec)
 
 _defineFeatures ()
 
 _getDefaultFeatures ()
 
 _loadFeaturesAdapter ()
 

Static Protected Attributes

static $_uaSignatures
 
static $_haTerms
 
static $_uaBegin
 

Additional Inherited Members

- Static Protected Member Functions inherited from Zend_Http_UserAgent_AbstractDevice
static _matchAgentAgainstSignatures ($userAgent, $signatures)
 
- Protected Attributes inherited from Zend_Http_UserAgent_AbstractDevice
 $_browser = ''
 
 $_browserVersion = ''
 
 $_config
 
 $_userAgent
 
 $_server
 
 $_images
 
 $_aFeatures = array()
 
 $_aGroup = array()
 

Detailed Description

Definition at line 33 of file Mobile.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $userAgent = null,
array  $server = array(),
array  $config = array() 
)

Constructor

Returns
void

Implements Zend_Http_UserAgent_Device.

Definition at line 328 of file Mobile.php.

329  {
330  // For mobile detection, an adapter must be defined
331  if (empty($config['mobile']['features'])) {
332  $config['mobile']['features']['path'] = self::DEFAULT_FEATURES_ADAPTER_PATH;
333  $config['mobile']['features']['classname'] = self::DEFAULT_FEATURES_ADAPTER_CLASSNAME;
334  }
335  parent::__construct($userAgent, $server, $config);
336  }
$config
Definition: fraud_order.php:17
const DEFAULT_FEATURES_ADAPTER_PATH
Definition: Mobile.php:38
const DEFAULT_FEATURES_ADAPTER_CLASSNAME
Definition: Mobile.php:36

Member Function Documentation

◆ _defineFeatures()

_defineFeatures ( )
protected

Look for features

Returns
string

Definition at line 353 of file Mobile.php.

354  {
355  $this->setFeature('is_wireless_device', false, 'product_info');
356 
357  parent::_defineFeatures();
358 
359  if (isset($this->_aFeatures["mobile_browser"])) {
360  $this->setFeature("browser_name", $this->_aFeatures["mobile_browser"]);
361  $this->_browser = $this->_aFeatures["mobile_browser"];
362  }
363  if (isset($this->_aFeatures["mobile_browser_version"])) {
364  $this->setFeature("browser_version", $this->_aFeatures["mobile_browser_version"]);
365  $this->_browserVersion = $this->_aFeatures["mobile_browser_version"];
366  }
367 
368  // markup
369  if ($this->getFeature('device_os') == 'iPhone OS'
370  || $this->getFeature('device_os_token') == 'iPhone OS'
371  ) {
372  $this->setFeature('markup', 'iphone');
373  } else {
374  $this->setFeature('markup', $this->getMarkupLanguage($this->getFeature('preferred_markup')));
375  }
376 
377  // image format
378  $this->_images = array();
379 
380  if ($this->getFeature('png')) {
381  $this->_images[] = 'png';
382  }
383  if ($this->getFeature('jpg')) {
384  $this->_images[] = 'jpg';
385  }
386  if ($this->getFeature('gif')) {
387  $this->_images[] = 'gif';
388  }
389  if ($this->getFeature('wbmp')) {
390  $this->_images[] = 'wbmp';
391  }
392 
393  return $this->_aFeatures;
394  }
getMarkupLanguage($preferredMarkup=null)
Definition: Mobile.php:402
setFeature($feature, $value=false, $group='')

◆ getImageFormatSupport()

getImageFormatSupport ( )

Determine image format support

Returns
array

Implements Zend_Http_UserAgent_Device.

Definition at line 432 of file Mobile.php.

433  {
434  return $this->_images;
435  }

◆ getMarkupLanguage()

getMarkupLanguage (   $preferredMarkup = null)

Determine markup language expected

@access public

Returns
TYPE

Definition at line 402 of file Mobile.php.

403  {
404  $return = '';
405  switch ($preferredMarkup) {
406  case 'wml_1_1':
407  case 'wml_1_2':
408  case 'wml_1_3':
409  $return = 'wml'; //text/vnd.wap.wml encoding="ISO-8859-15"
410  case 'html_wi_imode_compact_generic':
411  case 'html_wi_imode_html_1':
412  case 'html_wi_imode_html_2':
413  case 'html_wi_imode_html_3':
414  case 'html_wi_imode_html_4':
415  case 'html_wi_imode_html_5':
416  $return = 'chtml'; //text/html
417  case 'html_wi_oma_xhtmlmp_1_0': //application/vnd.wap.xhtml+xml
418  case 'html_wi_w3_xhtmlbasic': //application/xhtml+xml DTD XHTML Basic 1.0
419  $return = 'xhtml';
420  case 'html_web_3_2': //text/html DTD Html 3.2 Final
421  case 'html_web_4_0': //text/html DTD Html 4.01 Transitional
422  $return = '';
423  }
424  return $return;
425  }

◆ getMaxImageHeight()

getMaxImageHeight ( )

Determine maximum image height supported

Returns
int

Implements Zend_Http_UserAgent_Device.

Definition at line 442 of file Mobile.php.

443  {
444  return $this->getFeature('max_image_height');
445  }

◆ getMaxImageWidth()

getMaxImageWidth ( )

Determine maximum image width supported

Returns
int

Implements Zend_Http_UserAgent_Device.

Definition at line 452 of file Mobile.php.

453  {
454  return $this->getFeature('max_image_width');
455  }

◆ getPhysicalScreenHeight()

getPhysicalScreenHeight ( )

Determine physical screen height

Returns
int

Implements Zend_Http_UserAgent_Device.

Definition at line 462 of file Mobile.php.

463  {
464  return $this->getFeature('physical_screen_height');
465  }

◆ getPhysicalScreenWidth()

getPhysicalScreenWidth ( )

Determine physical screen width

Returns
int

Implements Zend_Http_UserAgent_Device.

Definition at line 472 of file Mobile.php.

473  {
474  return $this->getFeature('physical_screen_width');
475  }

◆ getPreferredMarkup()

getPreferredMarkup ( )

Determine preferred markup

Returns
string

Implements Zend_Http_UserAgent_Device.

Definition at line 482 of file Mobile.php.

483  {
484  return $this->getFeature("markup");
485  }

◆ getType()

getType ( )

Gives the current browser type

Returns
string

Definition at line 343 of file Mobile.php.

344  {
345  return 'mobile';
346  }

◆ getXhtmlSupportLevel()

getXhtmlSupportLevel ( )

Determine X/HTML support level

Returns
int

Implements Zend_Http_UserAgent_Device.

Definition at line 492 of file Mobile.php.

493  {
494  return $this->getFeature('xhtml_support_level');
495  }

◆ hasFlashSupport()

hasFlashSupport ( )

Does the device support Flash?

Returns
bool

Implements Zend_Http_UserAgent_Device.

Definition at line 502 of file Mobile.php.

503  {
504  return $this->getFeature('fl_browser');
505  }

◆ hasPdfSupport()

hasPdfSupport ( )

Does the device support PDF?

Returns
bool

Implements Zend_Http_UserAgent_Device.

Definition at line 512 of file Mobile.php.

513  {
514  return $this->getFeature('pdf_support');
515  }

◆ hasPhoneNumber()

hasPhoneNumber ( )

Does the device have an associated phone number?

Returns
bool

Implements Zend_Http_UserAgent_Device.

Definition at line 522 of file Mobile.php.

523  {
524  return $this->getFeature('can_assign_phone_number');
525  }

◆ httpsSupport()

httpsSupport ( )

Does the device support HTTPS?

Returns
bool

Implements Zend_Http_UserAgent_Device.

Definition at line 532 of file Mobile.php.

533  {
534  return ($this->getFeature('https_support') == 'supported');
535  }

◆ match()

static match (   $userAgent,
  $server 
)
static

Comparison of the UserAgent chain and User Agent signatures

Parameters
string$userAgentUser Agent chain
array$server$_SERVER like param
Returns
bool

Implements Zend_Http_UserAgent_Device.

Definition at line 278 of file Mobile.php.

279  {
280  // To have a quick identification, try light-weight tests first
281  if (isset($server['all_http'])) {
282  if (strpos(strtolower(str_replace(' ', '', $server['all_http'])), 'operam') !== false) {
283  // Opera Mini or Opera Mobi
284  return true;
285  }
286  }
287 
288  if (isset($server['http_x_wap_profile']) || isset($server['http_profile'])) {
289  return true;
290  }
291 
292  if (isset($server['http_accept'])) {
293  if (self::_matchAgentAgainstSignatures($server['http_accept'], self::$_haTerms)) {
294  return true;
295  }
296  }
297 
298  if (self::userAgentStart($userAgent)) {
299  return true;
300  }
301 
302  if (self::_matchAgentAgainstSignatures($userAgent, self::$_uaSignatures)) {
303  return true;
304  }
305 
306  return false;
307  }

◆ userAgentStart()

static userAgentStart (   $userAgent)
static

Retrieve beginning clause of user agent

Parameters
string$userAgent
Returns
string

Definition at line 315 of file Mobile.php.

316  {
317 
318  $mobile_ua = strtolower(substr($userAgent, 0, 4));
319 
320  return (in_array($mobile_ua, self::$_uaBegin));
321  }

Field Documentation

◆ $_haTerms

$_haTerms
staticprotected
Initial value:
= array(
'midp',
'wml',
'vnd.rim',
'vnd.wap',
'j2me',
)

Definition at line 170 of file Mobile.php.

◆ $_uaBegin

$_uaBegin
staticprotected

Definition at line 183 of file Mobile.php.

◆ $_uaSignatures

$_uaSignatures
staticprotected

Definition at line 45 of file Mobile.php.

◆ DEFAULT_FEATURES_ADAPTER_CLASSNAME

const DEFAULT_FEATURES_ADAPTER_CLASSNAME = 'Zend_Http_UserAgent_Features_Adapter_Browscap'

Definition at line 36 of file Mobile.php.

◆ DEFAULT_FEATURES_ADAPTER_PATH

const DEFAULT_FEATURES_ADAPTER_PATH = 'Zend/Http/UserAgent/Features/Adapter/Browscap.php'

Definition at line 38 of file Mobile.php.


The documentation for this class was generated from the following file: