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.willcom-inc.com/ja/service/contents_service/club_air_edge/for_phone/homepage/index.html |
---|
20 | * @since File available since Release 0.5 |
---|
21 | */ |
---|
22 | |
---|
23 | require_once dirname(__FILE__) . '/Common.php'; |
---|
24 | require_once dirname(__FILE__) . '/Display.php'; |
---|
25 | |
---|
26 | // {{{ Net_UserAgent_Mobile_Willcom |
---|
27 | |
---|
28 | /** |
---|
29 | * AirH"PHONE implementation |
---|
30 | * |
---|
31 | * Net_UserAgent_Mobile_Willcom is a subclass of |
---|
32 | * {@link Net_UserAgent_Mobile_Common}, which implements Willcom's user |
---|
33 | * agents. |
---|
34 | * |
---|
35 | * SYNOPSIS: |
---|
36 | * <code> |
---|
37 | * require_once 'Net/UserAgent/Mobile.php'; |
---|
38 | * |
---|
39 | * $_SERVER['HTTP_USER_AGENT'] = |
---|
40 | * 'Mozilla/3.0(DDIPOCKET;JRC/AH-J3001V,AH-J3002V/1.0/0100/c50)CNF/2.0'; |
---|
41 | * $agent = &Net_UserAgent_Mobile::factory(); |
---|
42 | * |
---|
43 | * printf("Name: %s\n", $agent->getName()); // 'DDIPOCKET' |
---|
44 | * printf("Verdor: %s\n", $agent->getVendor()); // 'JRC' |
---|
45 | * printf("Model: %s\n", $agent->getModel()); // 'AH-J3001V,AH-J3002V' |
---|
46 | * printf("Model Version: %s\n", $agent->getModelVersion()); // '1.0' |
---|
47 | * printf("Browser Version: %s\n", $agent->getBrowserVersion()); // '0100' |
---|
48 | * printf("Cache Size: %s\n", $agent->getCacheSize()); // 50 |
---|
49 | * </code> |
---|
50 | * |
---|
51 | * @category Networking |
---|
52 | * @package Net_UserAgent_Mobile |
---|
53 | * @author KUBO Atsuhiro <iteman@users.sourceforge.net> |
---|
54 | * @copyright 2003-2008 KUBO Atsuhiro <iteman@users.sourceforge.net> |
---|
55 | * @license http://www.php.net/license/3_0.txt PHP License 3.0 |
---|
56 | * @version Release: 0.31.0 |
---|
57 | * @link http://www.willcom-inc.com/ja/service/contents_service/club_air_edge/for_phone/homepage/index.html |
---|
58 | * @see Net_UserAgent_Mobile_Common |
---|
59 | * @since Class available since Release 0.5 |
---|
60 | */ |
---|
61 | class Net_UserAgent_Mobile_Willcom extends Net_UserAgent_Mobile_Common |
---|
62 | { |
---|
63 | |
---|
64 | // {{{ properties |
---|
65 | |
---|
66 | /**#@+ |
---|
67 | * @access public |
---|
68 | */ |
---|
69 | |
---|
70 | /** |
---|
71 | * User-Agent name |
---|
72 | * @var string |
---|
73 | */ |
---|
74 | var $name = 'WILLCOM'; |
---|
75 | |
---|
76 | /**#@-*/ |
---|
77 | |
---|
78 | /**#@+ |
---|
79 | * @access private |
---|
80 | */ |
---|
81 | |
---|
82 | /** |
---|
83 | * vendor name |
---|
84 | * @var string |
---|
85 | */ |
---|
86 | var $_vendor; |
---|
87 | |
---|
88 | /** |
---|
89 | * version number of the model |
---|
90 | * @var string |
---|
91 | */ |
---|
92 | var $_modelVersion; |
---|
93 | |
---|
94 | /** |
---|
95 | * version number of the browser |
---|
96 | * @var string |
---|
97 | */ |
---|
98 | var $_browserVersion; |
---|
99 | |
---|
100 | /** |
---|
101 | * cache size as killobytes unit |
---|
102 | * @var integer |
---|
103 | */ |
---|
104 | var $_cacheSize; |
---|
105 | |
---|
106 | /**#@-*/ |
---|
107 | |
---|
108 | /**#@+ |
---|
109 | * @access public |
---|
110 | */ |
---|
111 | |
---|
112 | // }}} |
---|
113 | // {{{ isAirHPhone() |
---|
114 | |
---|
115 | /** |
---|
116 | * returns true |
---|
117 | * |
---|
118 | * @return boolean |
---|
119 | */ |
---|
120 | function isAirHPhone() |
---|
121 | { |
---|
122 | return $this->isWillcom(); |
---|
123 | } |
---|
124 | |
---|
125 | // }}} |
---|
126 | // {{{ parse() |
---|
127 | |
---|
128 | /** |
---|
129 | * Parses HTTP_USER_AGENT string. |
---|
130 | * |
---|
131 | * @param string $userAgent User-Agent string |
---|
132 | */ |
---|
133 | function parse($userAgent) |
---|
134 | { |
---|
135 | if (preg_match('!^Mozilla/3\.0\((?:DDIPOCKET|WILLCOM);(.*)\)!', |
---|
136 | $userAgent, $matches) |
---|
137 | ) { |
---|
138 | list($this->_vendor, $this->_rawModel, $this->_modelVersion, |
---|
139 | $this->_browserVersion, $cache) = |
---|
140 | explode('/', $matches[1]); |
---|
141 | if (!preg_match('/^[Cc](\d+)/', $cache, $matches)) { |
---|
142 | return $this->noMatch(); |
---|
143 | } |
---|
144 | $this->_cacheSize = (integer)$matches[1]; |
---|
145 | } else { |
---|
146 | $this->noMatch(); |
---|
147 | } |
---|
148 | } |
---|
149 | |
---|
150 | // }}} |
---|
151 | // {{{ makeDisplay() |
---|
152 | |
---|
153 | /** |
---|
154 | * create a new {@link Net_UserAgent_Mobile_Display} class instance |
---|
155 | * |
---|
156 | * @return object a newly created {@link Net_UserAgent_Mobile_Display} |
---|
157 | * object |
---|
158 | * @see Net_UserAgent_Mobile_Display |
---|
159 | */ |
---|
160 | function makeDisplay() |
---|
161 | { |
---|
162 | return new Net_UserAgent_Mobile_Display(null); |
---|
163 | } |
---|
164 | |
---|
165 | // }}} |
---|
166 | // {{{ getVendor() |
---|
167 | |
---|
168 | /** |
---|
169 | * returns vendor name |
---|
170 | * |
---|
171 | * @return string |
---|
172 | */ |
---|
173 | function getVendor() |
---|
174 | { |
---|
175 | return $this->_vendor; |
---|
176 | } |
---|
177 | |
---|
178 | // }}} |
---|
179 | // {{{ getModelVersion() |
---|
180 | |
---|
181 | /** |
---|
182 | * returns version number of the model |
---|
183 | * |
---|
184 | * @return string |
---|
185 | */ |
---|
186 | function getModelVersion() |
---|
187 | { |
---|
188 | return $this->_modelVersion; |
---|
189 | } |
---|
190 | |
---|
191 | // }}} |
---|
192 | // {{{ getBrowserVersion() |
---|
193 | |
---|
194 | /** |
---|
195 | * returns version number of the browser |
---|
196 | * |
---|
197 | * @return string |
---|
198 | */ |
---|
199 | function getBrowserVersion() |
---|
200 | { |
---|
201 | return $this->_browserVersion; |
---|
202 | } |
---|
203 | |
---|
204 | // }}} |
---|
205 | // {{{ getCacheSize() |
---|
206 | |
---|
207 | /** |
---|
208 | * returns cache size as killobytes unit |
---|
209 | * |
---|
210 | * @return integer |
---|
211 | */ |
---|
212 | function getCacheSize() |
---|
213 | { |
---|
214 | return $this->_cacheSize; |
---|
215 | } |
---|
216 | |
---|
217 | // }}} |
---|
218 | // {{{ getCarrierShortName() |
---|
219 | |
---|
220 | /** |
---|
221 | * returns the short name of the carrier |
---|
222 | * |
---|
223 | * @return string |
---|
224 | */ |
---|
225 | function getCarrierShortName() |
---|
226 | { |
---|
227 | return 'W'; |
---|
228 | } |
---|
229 | |
---|
230 | // }}} |
---|
231 | // {{{ getCarrierLongName() |
---|
232 | |
---|
233 | /** |
---|
234 | * returns the long name of the carrier |
---|
235 | * |
---|
236 | * @return string |
---|
237 | */ |
---|
238 | function getCarrierLongName() |
---|
239 | { |
---|
240 | return 'WILLCOM'; |
---|
241 | } |
---|
242 | |
---|
243 | // }}} |
---|
244 | // {{{ isWillcom() |
---|
245 | |
---|
246 | /** |
---|
247 | * Returns whether the agent is Willcom or not. |
---|
248 | * |
---|
249 | * @return boolean |
---|
250 | * @since Method available since Release 0.31.0 |
---|
251 | */ |
---|
252 | function isWillcom() |
---|
253 | { |
---|
254 | return true; |
---|
255 | } |
---|
256 | |
---|
257 | /**#@-*/ |
---|
258 | |
---|
259 | /**#@+ |
---|
260 | * @access private |
---|
261 | */ |
---|
262 | |
---|
263 | /**#@-*/ |
---|
264 | |
---|
265 | // }}} |
---|
266 | } |
---|
267 | |
---|
268 | // }}} |
---|
269 | |
---|
270 | /* |
---|
271 | * Local Variables: |
---|
272 | * mode: php |
---|
273 | * coding: iso-8859-1 |
---|
274 | * tab-width: 4 |
---|
275 | * c-basic-offset: 4 |
---|
276 | * c-hanging-comment-ender-p: nil |
---|
277 | * indent-tabs-mode: nil |
---|
278 | * End: |
---|
279 | */ |
---|