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

Source for file Willcom.php

Documentation is available at Willcom.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3.  
  4. /**
  5.  * PHP versions 4 and 5
  6.  *
  7.  * Copyright (c) 2003-2009 KUBO Atsuhiro <kubo@iteman.jp>,
  8.  * All rights reserved.
  9.  *
  10.  * Redistribution and use in source and binary forms, with or without
  11.  * modification, are permitted provided that the following conditions are met:
  12.  *
  13.  *     * Redistributions of source code must retain the above copyright
  14.  *       notice, this list of conditions and the following disclaimer.
  15.  *     * Redistributions in binary form must reproduce the above copyright
  16.  *       notice, this list of conditions and the following disclaimer in the
  17.  *       documentation and/or other materials provided with the distribution.
  18.  *
  19.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  20.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22.  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  23.  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  24.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  25.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  26.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  27.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  28.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  29.  * POSSIBILITY OF SUCH DAMAGE.
  30.  *
  31.  * @category   Networking
  32.  * @package    Net_UserAgent_Mobile
  33.  * @author     KUBO Atsuhiro <kubo@iteman.jp>
  34.  * @copyright  2003-2009 KUBO Atsuhiro <kubo@iteman.jp>
  35.  * @license    http://www.opensource.org/licenses/bsd-license.php  New BSD License
  36.  * @version    CVS: $Id: Willcom.php,v 1.1 2009/05/26 08:48:16 kuboa Exp $
  37.  * @link       http://www.willcom-inc.com/ja/service/contents_service/club_air_edge/for_phone/homepage/index.html
  38.  * @since      File available since Release 0.5
  39.  */
  40.  
  41. require_once 'Net/UserAgent/Mobile/Common.php';
  42. require_once 'Net/UserAgent/Mobile/Display.php';
  43.  
  44. // {{{ Net_UserAgent_Mobile_Willcom
  45.  
  46. /**
  47.  * AirH"PHONE implementation
  48.  *
  49.  * Net_UserAgent_Mobile_Willcom is a subclass of {@link Net_UserAgent_Mobile_Common},
  50.  * which implements Willcom's user agents.
  51.  *
  52.  * SYNOPSIS:
  53.  * <code>
  54.  * require_once 'Net/UserAgent/Mobile.php';
  55.  *
  56.  * $_SERVER['HTTP_USER_AGENT'] =
  57.  *     'Mozilla/3.0(DDIPOCKET;JRC/AH-J3001V,AH-J3002V/1.0/0100/c50)CNF/2.0';
  58.  * $agent = &Net_UserAgent_Mobile::factory();
  59.  *
  60.  * printf("Name: %s\n", $agent->getName()); // 'DDIPOCKET'
  61.  * printf("Verdor: %s\n", $agent->getVendor()); // 'JRC'
  62.  * printf("Model: %s\n", $agent->getModel()); // 'AH-J3001V,AH-J3002V'
  63.  * printf("Model Version: %s\n", $agent->getModelVersion()); // '1.0'
  64.  * printf("Browser Version: %s\n", $agent->getBrowserVersion()); // '0100'
  65.  * printf("Cache Size: %s\n", $agent->getCacheSize()); // 50
  66.  * </code>
  67.  *
  68.  * @category   Networking
  69.  * @package    Net_UserAgent_Mobile
  70.  * @author     KUBO Atsuhiro <kubo@iteman.jp>
  71.  * @copyright  2003-2009 KUBO Atsuhiro <kubo@iteman.jp>
  72.  * @license    http://www.opensource.org/licenses/bsd-license.php  New BSD License
  73.  * @version    Release: 1.0.0
  74.  * @link       http://www.willcom-inc.com/ja/service/contents_service/club_air_edge/for_phone/homepage/index.html
  75.  * @since      Class available since Release 0.5
  76.  */
  77. {
  78.  
  79.     // {{{ properties
  80.  
  81.     /**#@+
  82.      * @access public
  83.      */
  84.  
  85.     /**
  86.      * User-Agent name
  87.      * @var string 
  88.      */
  89.     var $name = 'WILLCOM';
  90.  
  91.     /**#@-*/
  92.  
  93.     /**#@+
  94.      * @access private
  95.      */
  96.  
  97.     /**
  98.      * vendor name
  99.      * @var string 
  100.      */
  101.     var $_vendor;
  102.  
  103.     /**
  104.      * version number of the model
  105.      * @var string 
  106.      */
  107.     var $_modelVersion;
  108.  
  109.     /**
  110.      * version number of the browser
  111.      * @var string 
  112.      */
  113.     var $_browserVersion;
  114.  
  115.     /**
  116.      * cache size as killobytes unit
  117.      * @var integer 
  118.      */
  119.     var $_cacheSize;
  120.  
  121.     /**#@-*/
  122.  
  123.     /**#@+
  124.      * @access public
  125.      */
  126.  
  127.     // }}}
  128.     // {{{ isAirHPhone()
  129.  
  130.     /**
  131.      * returns true
  132.      *
  133.      * @return boolean 
  134.      */
  135.     function isAirHPhone()
  136.     {
  137.         return $this->isWillcom();
  138.     }
  139.  
  140.     // }}}
  141.     // {{{ parse()
  142.  
  143.     /**
  144.      * Parses HTTP_USER_AGENT string.
  145.      *
  146.      * @param string $userAgent User-Agent string
  147.      */
  148.     function parse($userAgent)
  149.     {
  150.         if (preg_match('!^Mozilla/3\.0\((?:DDIPOCKET|WILLCOM);(.*)\)!',
  151.                        $userAgent$matches)
  152.             {
  153.             list($this->_vendor$this->_rawModel$this->_modelVersion,
  154.                  $this->_browserVersion$cache=
  155.                 explode('/'$matches[1]);
  156.             if (!preg_match('/^[Cc](\d+)/'$cache$matches)) {
  157.                 return $this->noMatch();
  158.             }
  159.             $this->_cacheSize = (integer)$matches[1];
  160.         else {
  161.             $this->noMatch();
  162.         }
  163.     }
  164.  
  165.     // }}}
  166.     // {{{ makeDisplay()
  167.  
  168.     /**
  169.      * create a new {@link Net_UserAgent_Mobile_Display} class instance
  170.      *
  171.      * @return Net_UserAgent_Mobile_Display 
  172.      */
  173.     function makeDisplay()
  174.     {
  175.         return new Net_UserAgent_Mobile_Display(null);
  176.     }
  177.  
  178.     // }}}
  179.     // {{{ getVendor()
  180.  
  181.     /**
  182.      * returns vendor name
  183.      *
  184.      * @return string 
  185.      */
  186.     function getVendor()
  187.     {
  188.         return $this->_vendor;
  189.     }
  190.  
  191.     // }}}
  192.     // {{{ getModelVersion()
  193.  
  194.     /**
  195.      * returns version number of the model
  196.      *
  197.      * @return string 
  198.      */
  199.     function getModelVersion()
  200.     {
  201.         return $this->_modelVersion;
  202.     }
  203.  
  204.     // }}}
  205.     // {{{ getBrowserVersion()
  206.  
  207.     /**
  208.      * returns version number of the browser
  209.      *
  210.      * @return string 
  211.      */
  212.     function getBrowserVersion()
  213.     {
  214.         return $this->_browserVersion;
  215.     }
  216.  
  217.     // }}}
  218.     // {{{ getCacheSize()
  219.  
  220.     /**
  221.      * returns cache size as killobytes unit
  222.      *
  223.      * @return integer 
  224.      */
  225.     function getCacheSize()
  226.     {
  227.         return $this->_cacheSize;
  228.     }
  229.  
  230.     // }}}
  231.     // {{{ getCarrierShortName()
  232.  
  233.     /**
  234.      * returns the short name of the carrier
  235.      *
  236.      * @return string 
  237.      */
  238.     function getCarrierShortName()
  239.     {
  240.         return 'W';
  241.     }
  242.  
  243.     // }}}
  244.     // {{{ getCarrierLongName()
  245.  
  246.     /**
  247.      * returns the long name of the carrier
  248.      *
  249.      * @return string 
  250.      */
  251.     function getCarrierLongName()
  252.     {
  253.         return 'WILLCOM';
  254.     }
  255.  
  256.     // }}}
  257.     // {{{ isWillcom()
  258.  
  259.     /**
  260.      * Returns whether the agent is Willcom or not.
  261.      *
  262.      * @return boolean 
  263.      * @since Method available since Release 0.31.0
  264.      */
  265.     function isWillcom()
  266.     {
  267.         return true;
  268.     }
  269.  
  270.     /**#@-*/
  271.  
  272.     /**#@+
  273.      * @access private
  274.      */
  275.  
  276.     /**#@-*/
  277.  
  278.     // }}}
  279. }
  280.  
  281. // }}}
  282.  
  283. /*
  284.  * Local Variables:
  285.  * mode: php
  286.  * coding: iso-8859-1
  287.  * tab-width: 4
  288.  * c-basic-offset: 4
  289.  * c-hanging-comment-ender-p: nil
  290.  * indent-tabs-mode: nil
  291.  * End:
  292.  */

Documentation generated on Tue, 23 Jun 2009 10:00:06 +0000 by phpDocumentor 1.4.2. PEAR Logo Copyright © PHP Group 2004.