source: trunk/data/module/Net/UserAgent/Mobile/EZweb.php @ 18562

Revision 18562, 7.5 KB checked in by kajiwara, 14 years ago (diff)

EC-CUBE Ver2.4.3 分コミット。詳細はこちら( http://www.ec-cube.net/release/detail.php?release_id=210

  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/* vim: set expandtab tabstop=4 shiftwidth=4: */
3
4/**
5 * PHP versions 4 and 5
6 *
7 * LICENSE: This source file is subject to version 3.0 of the PHP license
8 * that is available through the world-wide-web at the following URI:
9 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
10 * the PHP License and are unable to obtain it through the web, please
11 * send a note to license@php.net so we can mail you a copy immediately.
12 *
13 * @category   Networking
14 * @package    Net_UserAgent_Mobile
15 * @author     KUBO Atsuhiro <iteman@users.sourceforge.net>
16 * @copyright  2003-2008 KUBO Atsuhiro <iteman@users.sourceforge.net>
17 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
18 * @version    CVS: $Id$
19 * @link       http://www.au.kddi.com/ezfactory/tec/spec/4_4.html
20 * @link       http://www.au.kddi.com/ezfactory/tec/spec/new_win/ezkishu.html
21 * @see        Net_UserAgent_Mobile_Common
22 * @since      File available since Release 0.1.0
23 */
24
25require_once dirname(__FILE__) . '/Common.php';
26require_once dirname(__FILE__) . '/Display.php';
27
28// {{{ Net_UserAgent_Mobile_EZweb
29
30/**
31 * EZweb implementation
32 *
33 * Net_UserAgent_Mobile_EZweb is a subclass of
34 * {@link Net_UserAgent_Mobile_Common}, which implements EZweb (WAP1.0/2.0)
35 * user agents.
36 *
37 * SYNOPSIS:
38 * <code>
39 * require_once 'Net/UserAgent/Mobile.php';
40 *
41 * $_SERVER['HTTP_USER_AGENT'] = 'UP.Browser/3.01-HI02 UP.Link/3.2.1.2';
42 * $agent = &Net_UserAgent_Mobile::factory();
43 *
44 * printf("Name: %s\n", $agent->getName()); // 'UP.Browser'
45 * printf("Version: %s\n", $agent->getVersion()); // 3.01
46 * printf("DeviceID: %s\n", $agent->getDeviceID()); // 'HI02'
47 * printf("Server: %s\n", $agent->getServer()); // 'UP.Link/3.2.1.2'
48 *
49 * e.g.) 'UP.Browser/3.01-HI02 UP.Link/3.2.1.2 (Google WAP Proxy/1.0)'
50 * printf("Comment: %s\n", $agent->getComment()); // 'Google WAP Proxy/1.0'
51 *
52 * e.g.) 'KDDI-TS21 UP.Browser/6.0.2.276 (GUI) MMP/1.1'
53 * if ($agent->isXHTMLCompliant()) {
54 *     print "XHTML compliant!\n"; // true
55 * }
56 * </code>
57 *
58 * @category   Networking
59 * @package    Net_UserAgent_Mobile
60 * @author     KUBO Atsuhiro <iteman@users.sourceforge.net>
61 * @copyright  2003-2008 KUBO Atsuhiro <iteman@users.sourceforge.net>
62 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
63 * @version    Release: 0.31.0
64 * @link       http://www.au.kddi.com/ezfactory/tec/spec/4_4.html
65 * @link       http://www.au.kddi.com/ezfactory/tec/spec/new_win/ezkishu.html
66 * @see        Net_UserAgent_Mobile_Common
67 * @since      Class available since Release 0.1.0
68 */
69class Net_UserAgent_Mobile_EZweb extends Net_UserAgent_Mobile_Common
70{
71
72    // {{{ properties
73
74    /**#@+
75     * @access public
76     */
77
78    /**#@-*/
79
80    /**#@+
81     * @access private
82     */
83
84    /**
85     * server string like 'UP.Link/3.2.1.2'
86     * @var string
87     */
88    var $_serverName = '';
89
90    /**
91     * comment like 'Google WAP Proxy/1.0'
92     * @var string
93     */
94    var $_comment = null;
95
96    /**
97     * whether it's XHTML compliant or not
98     * @var boolean
99     */
100    var $_xhtmlCompliant = false;
101
102    /**#@-*/
103
104    /**#@+
105     * @access public
106     */
107
108    // }}}
109    // {{{ isEZweb()
110
111    /**
112     * returns true
113     *
114     * @return boolean
115     */
116    function isEZweb()
117    {
118        return true;
119    }
120
121    // }}}
122    // {{{ isTUKa()
123
124    /**
125     * returns true if the agent is TU-Ka
126     *
127     * @return boolean
128     */
129    function isTUKa()
130    {
131        $tuka = substr($this->_rawModel, 2, 1);
132        if ($this->isWAP2()) {
133            if ($tuka == 'U') {
134                return true;
135            }
136        } else {
137            if ($tuka == 'T') {
138                return true;
139            }
140        }
141       
142        return false;
143    }
144
145    // }}}
146    // {{{ parse()
147
148    /**
149     * Parses HTTP_USER_AGENT string.
150     *
151     * @param string $userAgent User-Agent string
152     */
153    function parse($userAgent)
154    {
155        if (preg_match('/^KDDI-(.*)/', $userAgent, $matches)) {
156
157            // KDDI-TS21 UP.Browser/6.0.2.276 (GUI) MMP/1.1
158            $this->_xhtmlCompliant = true;
159            list($this->_rawModel, $browser, $opt, $this->_serverName) =
160                explode(' ', $matches[1], 4);
161            list($this->name, $version) = explode('/', $browser);
162            $this->version = "$version $opt";
163        } else {
164
165            // UP.Browser/3.01-HI01 UP.Link/3.4.5.2
166            @list($browser, $this->_serverName, $comment) =
167                explode(' ', $userAgent, 3);
168            list($this->name, $software) = explode('/', $browser);
169            list($this->version, $this->_rawModel) =
170                explode('-', $software);
171            if ($comment) {
172                $this->_comment =
173                    preg_replace('/^\((.*)\)$/', '$1', $comment);
174            }
175        }
176    }
177
178    // }}}
179    // {{{ makeDisplay()
180
181    /**
182     * create a new {@link Net_UserAgent_Mobile_Display} class instance
183     *
184     * @return object a newly created {@link Net_UserAgent_Mobile_Display}
185     *     object
186     * @see Net_UserAgent_Mobile_Display
187     */
188    function makeDisplay()
189    {
190        @list($width, $height) =
191            explode(',', $this->getHeader('X-UP-DEVCAP-SCREENPIXELS'));
192        $screenDepth =
193            explode(',', $this->getHeader('X-UP-DEVCAP-SCREENDEPTH'));
194        $depth = $screenDepth[0] ? pow(2, (integer)$screenDepth[0]) : 0;
195        $color =
196            $this->getHeader('X-UP-DEVCAP-ISCOLOR') === '1' ? true : false;
197        return new Net_UserAgent_Mobile_Display(array(
198                                                      'width'  => $width,
199                                                      'height' => $height,
200                                                      'color'  => $color,
201                                                      'depth'  => $depth
202                                                      )
203                                                );
204    }
205
206    // }}}
207    // {{{ getDeviceID()
208
209    /**
210     * Returns the device ID of the user agent.
211     *
212     * @return string
213     */
214    function getDeviceID()
215    {
216        return $this->_rawModel;
217    }
218
219    // }}}
220    // {{{ getServer()
221
222    /**
223     * returns server string like 'UP.Link/3.2.1.2'
224     *
225     * @return string
226     */
227    function getServer()
228    {
229        return $this->_serverName;
230    }
231
232    // }}}
233    // {{{ getComment()
234
235    /**
236     * returns comment like 'Google WAP Proxy/1.0'. returns null if nothinng.
237     *
238     * @return boolean
239     */
240    function getComment()
241    {
242        return $this->_comment;
243    }
244
245    // }}}
246    // {{{ isXHTMLCompliant()
247
248    /**
249     * returns whether it's XHTML compliant or not
250     *
251     * @return boolean
252     */
253    function isXHTMLCompliant()
254    {
255        return $this->_xhtmlCompliant;
256    }
257
258    // }}}
259    // {{{ getCarrierShortName()
260
261    /**
262     * returns the short name of the carrier
263     *
264     * @return string
265     */
266    function getCarrierShortName()
267    {
268        return 'E';
269    }
270
271    // }}}
272    // {{{ getCarrierLongName()
273
274    /**
275     * returns the long name of the carrier
276     *
277     * @return string
278     */
279    function getCarrierLongName()
280    {
281        return 'EZweb';
282    }
283
284    // }}}
285    // {{{ isWIN()
286
287    /**
288     * Returns whether the agent is CDMA 1X WIN or not.
289     *
290     * @return boolean
291     */
292    function isWIN()
293    {
294        return substr($this->_rawModel, 2, 1) == 3 ? true : false;
295    }
296
297    /**#@-*/
298
299    /**#@+
300     * @access private
301     */
302
303    /**#@-*/
304
305    // }}}
306}
307
308// }}}
309
310/*
311 * Local Variables:
312 * mode: php
313 * coding: iso-8859-1
314 * tab-width: 4
315 * c-basic-offset: 4
316 * c-hanging-comment-ender-p: nil
317 * indent-tabs-mode: nil
318 * End:
319 */
Note: See TracBrowser for help on using the repository browser.