Net_UserAgent_Mobile
[ class tree: Net_UserAgent_Mobile ] [ index: Net_UserAgent_Mobile ] [ all elements ]

Source for file AirHPhone.php

Documentation is available at AirHPhone.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2004 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 3.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available through the world-wide-web at the following url:           |
  11. // | http://www.php.net/license/3_0.txt.                                  |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: KUBO Atsuhiro <kubo@isite.co.jp>                            |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: AirHPhone.php,v 1.7 2004/09/25 12:35:38 kuboa Exp $
  20. //
  21.  
  22. require_once(dirname(__FILE__'/Common.php');
  23. require_once(dirname(__FILE__'/Display.php');
  24.  
  25. /**
  26.  * AirH"PHONE implementation
  27.  *
  28.  * Net_UserAgent_Mobile_AirHPhone is a subclass of
  29.  * {@link Net_UserAgent_Mobile_Common}, which implements DDI POCKET's
  30.  * AirH"PHONE user agents.
  31.  *
  32.  * SYNOPSIS:
  33.  * <code>
  34.  * require_once('Net/UserAgent/Mobile.php');
  35.  *
  36.  * $_SERVER['HTTP_USER_AGENT'] =
  37.  *     'Mozilla/3.0(DDIPOCKET;JRC/AH-J3001V,AH-J3002V/1.0/0100/c50)CNF/2.0';
  38.  * $agent = &Net_UserAgent_Mobile::factory();
  39.  *
  40.  * printf("Name: %s\n", $agent->getName()); // 'DDIPOCKET'
  41.  * printf("Verdor: %s\n", $agent->getVendor()); // 'JRC'
  42.  * printf("Model: %s\n", $agent->getModel()); // 'AH-J3001V,AH-J3002V'
  43.  * printf("Model Version: %s\n", $agent->getModelVersion()); // '1.0'
  44.  * printf("Browser Version: %s\n", $agent->getBrowserVersion()); // '0100'
  45.  * printf("Cache Size: %s\n", $agent->getCacheSize()); // 50
  46.  * </code>
  47.  *
  48.  * @package  Net_UserAgent_Mobile
  49.  * @category Networking
  50.  * @author   KUBO Atsuhiro <kubo@isite.co.jp>
  51.  * @access   public
  52.  * @version  $Revision: 1.7 $
  53.  * @see      Net_UserAgent_Mobile_Common
  54.  * @link     http://www.ddipocket.co.jp/airh_phone/i_hp.html
  55.  */
  56. {
  57.  
  58.     // {{{ properties
  59.  
  60.     /**
  61.      * User-Agent name
  62.      * @var string 
  63.      * @access public
  64.      */
  65.     var $name = 'DDIPOCKET';
  66.  
  67.     /**#@+
  68.      * @access private
  69.      */
  70.  
  71.     /**
  72.      * vendor name
  73.      * @var string 
  74.      */
  75.     var $_vendor;
  76.  
  77.     /**
  78.      * model name
  79.      * @var string 
  80.      */
  81.     var $_model;
  82.  
  83.     /**
  84.      * version number of the model
  85.      * @var string 
  86.      */
  87.     var $_modelVersion;
  88.  
  89.     /**
  90.      * version number of the browser
  91.      * @var string 
  92.      */
  93.     var $_browserVersion;
  94.  
  95.     /**
  96.      * cache size as killobytes unit
  97.      * @var integer 
  98.      */
  99.     var $_cacheSize;
  100.  
  101.     /**#@-*/
  102.  
  103.     /**#@+
  104.      * @access public
  105.      */
  106.  
  107.     // }}}
  108.     // {{{ isAirHPhone()
  109.  
  110.     /**
  111.      * returns true
  112.      *
  113.      * @return boolean 
  114.      */
  115.     function isAirHPhone()
  116.     {
  117.         return true;
  118.     }
  119.  
  120.     // }}}
  121.     // {{{ parse()
  122.  
  123.     /**
  124.      * parse HTTP_USER_AGENT string
  125.      */
  126.     function parse()
  127.     {
  128.         $agent $this->getUserAgent();
  129.         if (preg_match('!^Mozilla/3\.0\(DDIPOCKET;(.*)\)CNF/2\.0$!',
  130.                        $agent$matches)
  131.             {
  132.             list($this->_vendor$this->_model$this->_modelVersion,
  133.                  $this->_browserVersion$cache=
  134.                 explode('/'$matches[1]);
  135.             if (!preg_match('/^c(\d+)/'$cache$matches)) {
  136.                 return $this->noMatch();
  137.             }
  138.             $this->_cacheSize = (integer)$matches[1];
  139.         else {
  140.             $this->noMatch();
  141.         }
  142.     }
  143.  
  144.     // }}}
  145.     // {{{ makeDisplay()
  146.  
  147.     /**
  148.      * create a new {@link Net_UserAgent_Mobile_Display} class instance
  149.      *
  150.      * @return object newly created {@link Net_UserAgent_Mobile_Display}
  151.      *      object
  152.      * @see Net_UserAgent_Mobile_Display
  153.      */
  154.     function makeDisplay()
  155.     {
  156.         return new Net_UserAgent_Mobile_Display(null);
  157.     }
  158.  
  159.     // }}}
  160.     // {{{ getVendor()
  161.  
  162.     /**
  163.      * returns vendor name
  164.      *
  165.      * @return string 
  166.      */
  167.     function getVendor()
  168.     {
  169.         return $this->_vendor;
  170.     }
  171.  
  172.     // }}}
  173.     // {{{ getModel()
  174.  
  175.     /**
  176.      * returns model name. Note that model names are separated with ','.
  177.      *
  178.      * @return string 
  179.      */
  180.     function getModel()
  181.     {
  182.         return $this->_model;
  183.     }
  184.  
  185.     // }}}
  186.     // {{{ getModelVersion()
  187.  
  188.     /**
  189.      * returns version number of the model
  190.      *
  191.      * @return string 
  192.      */
  193.     function getModelVersion()
  194.     {
  195.         return $this->_modelVersion;
  196.     }
  197.  
  198.     // }}}
  199.     // {{{ getBrowserVersion()
  200.  
  201.     /**
  202.      * returns version number of the browser
  203.      *
  204.      * @return string 
  205.      */
  206.     function getBrowserVersion()
  207.     {
  208.         return $this->_browserVersion;
  209.     }
  210.  
  211.     // }}}
  212.     // {{{ getCacheSize()
  213.  
  214.     /**
  215.      * returns cache size as killobytes unit
  216.      *
  217.      * @return integer 
  218.      */
  219.     function getCacheSize()
  220.     {
  221.         return $this->_cacheSize;
  222.     }
  223.  
  224.     // }}}
  225.     // {{{ getCarrierShortName()
  226.  
  227.     /**
  228.      * returns the short name of the carrier
  229.      *
  230.      * @return string 
  231.      */
  232.     function getCarrierShortName()
  233.     {
  234.         return 'H';
  235.     }
  236.  
  237.     // }}}
  238.     // {{{ getCarrierLongName()
  239.  
  240.     /**
  241.      * returns the long name of the carrier
  242.      *
  243.      * @return string 
  244.      */
  245.     function getCarrierLongName()
  246.     {
  247.         return 'AirH';
  248.     }
  249.  
  250.     /**#@-*/
  251. }
  252.  
  253. /*
  254.  * Local Variables:
  255.  * mode: php
  256.  * coding: iso-8859-1
  257.  * tab-width: 4
  258.  * c-basic-offset: 4
  259.  * c-hanging-comment-ender-p: nil
  260.  * indent-tabs-mode: nil
  261.  * End:
  262.  */
  263. ?>

Documentation generated on Mon, 11 Mar 2019 14:16:45 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.