source: branches/comu-ver2/data/module/Net/UserAgent/Mobile/Willcom.php @ 18188

Revision 18188, 6.7 KB checked in by AMUAMU, 15 years ago (diff)

#403 関連 Net_UserAgent_Mobileを1.0.0(stable)にアップデート

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php
Line 
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$
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
41require_once dirname(__FILE__) . '/Common.php';
42require_once dirname(__FILE__) . '/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 */
77class Net_UserAgent_Mobile_Willcom extends Net_UserAgent_Mobile_Common
78{
79
80    // {{{ properties
81
82    /**#@+
83     * @access public
84     */
85
86    /**
87     * User-Agent name
88     * @var string
89     */
90    var $name = 'WILLCOM';
91
92    /**#@-*/
93
94    /**#@+
95     * @access private
96     */
97
98    /**
99     * vendor name
100     * @var string
101     */
102    var $_vendor;
103
104    /**
105     * version number of the model
106     * @var string
107     */
108    var $_modelVersion;
109
110    /**
111     * version number of the browser
112     * @var string
113     */
114    var $_browserVersion;
115
116    /**
117     * cache size as killobytes unit
118     * @var integer
119     */
120    var $_cacheSize;
121
122    /**#@-*/
123
124    /**#@+
125     * @access public
126     */
127
128    // }}}
129    // {{{ isAirHPhone()
130
131    /**
132     * returns true
133     *
134     * @return boolean
135     */
136    function isAirHPhone()
137    {
138        return $this->isWillcom();
139    }
140
141    // }}}
142    // {{{ parse()
143
144    /**
145     * Parses HTTP_USER_AGENT string.
146     *
147     * @param string $userAgent User-Agent string
148     */
149    function parse($userAgent)
150    {
151        if (preg_match('!^Mozilla/3\.0\((?:DDIPOCKET|WILLCOM);(.*)\)!',
152                       $userAgent, $matches)
153            ) {
154            list($this->_vendor, $this->_rawModel, $this->_modelVersion,
155                 $this->_browserVersion, $cache) =
156                explode('/', $matches[1]);
157            if (!preg_match('/^[Cc](\d+)/', $cache, $matches)) {
158                return $this->noMatch();
159            }
160            $this->_cacheSize = (integer)$matches[1];
161        } else {
162            $this->noMatch();
163        }
164    }
165
166    // }}}
167    // {{{ makeDisplay()
168
169    /**
170     * create a new {@link Net_UserAgent_Mobile_Display} class instance
171     *
172     * @return Net_UserAgent_Mobile_Display
173     */
174    function makeDisplay()
175    {
176        return new Net_UserAgent_Mobile_Display(null);
177    }
178
179    // }}}
180    // {{{ getVendor()
181
182    /**
183     * returns vendor name
184     *
185     * @return string
186     */
187    function getVendor()
188    {
189        return $this->_vendor;
190    }
191
192    // }}}
193    // {{{ getModelVersion()
194
195    /**
196     * returns version number of the model
197     *
198     * @return string
199     */
200    function getModelVersion()
201    {
202        return $this->_modelVersion;
203    }
204
205    // }}}
206    // {{{ getBrowserVersion()
207
208    /**
209     * returns version number of the browser
210     *
211     * @return string
212     */
213    function getBrowserVersion()
214    {
215        return $this->_browserVersion;
216    }
217
218    // }}}
219    // {{{ getCacheSize()
220
221    /**
222     * returns cache size as killobytes unit
223     *
224     * @return integer
225     */
226    function getCacheSize()
227    {
228        return $this->_cacheSize;
229    }
230
231    // }}}
232    // {{{ getCarrierShortName()
233
234    /**
235     * returns the short name of the carrier
236     *
237     * @return string
238     */
239    function getCarrierShortName()
240    {
241        return 'W';
242    }
243
244    // }}}
245    // {{{ getCarrierLongName()
246
247    /**
248     * returns the long name of the carrier
249     *
250     * @return string
251     */
252    function getCarrierLongName()
253    {
254        return 'WILLCOM';
255    }
256
257    // }}}
258    // {{{ isWillcom()
259
260    /**
261     * Returns whether the agent is Willcom or not.
262     *
263     * @return boolean
264     * @since Method available since Release 0.31.0
265     */
266    function isWillcom()
267    {
268        return true;
269    }
270
271    /**#@-*/
272
273    /**#@+
274     * @access private
275     */
276
277    /**#@-*/
278
279    // }}}
280}
281
282// }}}
283
284/*
285 * Local Variables:
286 * mode: php
287 * coding: iso-8859-1
288 * tab-width: 4
289 * c-basic-offset: 4
290 * c-hanging-comment-ender-p: nil
291 * indent-tabs-mode: nil
292 * End:
293 */
Note: See TracBrowser for help on using the repository browser.