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 | * @since File available since Release 0.1 |
---|
38 | */ |
---|
39 | |
---|
40 | // {{{ Net_UserAgent_Mobile_Display |
---|
41 | |
---|
42 | /** |
---|
43 | * Display information for Net_UserAgent_Mobile |
---|
44 | * |
---|
45 | * Net_UserAgent_Mobile_Display is a class for display information on |
---|
46 | * {@link Net_UserAgent_Mobile}. Handy for image resizing or dispatching. |
---|
47 | * |
---|
48 | * SYNOPSIS: |
---|
49 | * <code> |
---|
50 | * require_once 'Net/UserAgent/Mobile.php'; |
---|
51 | * |
---|
52 | * $agent = &Net_UserAgent_Mobile::factory(); |
---|
53 | * $display = $agent->getDisplay(); |
---|
54 | * |
---|
55 | * $width = $display->getWidth(); |
---|
56 | * $height = $display->getHeight(); |
---|
57 | * list($width, $height) = $display->getSize(); |
---|
58 | * |
---|
59 | * if ($display->isColor()) { |
---|
60 | * $depth = $display->getDepth(); |
---|
61 | * } |
---|
62 | * |
---|
63 | * // only available in DoCoMo 505i |
---|
64 | * $width_bytes = $display->getWidthBytes(); |
---|
65 | * $height_bytes = $display->getHeightBytes(); |
---|
66 | * </code> |
---|
67 | * |
---|
68 | * USING EXTERNAL MAP FILE: |
---|
69 | * If the environment variable DOCOMO_MAP exists, the specified XML data will be used |
---|
70 | * for DoCoMo display information. |
---|
71 | * |
---|
72 | * ex) Please add the following code. |
---|
73 | * $_SERVER['DOCOMO_MAP'] = '/path/to/DoCoMoMap.xml'; |
---|
74 | * |
---|
75 | * @category Networking |
---|
76 | * @package Net_UserAgent_Mobile |
---|
77 | * @author KUBO Atsuhiro <kubo@iteman.jp> |
---|
78 | * @copyright 2003-2009 KUBO Atsuhiro <kubo@iteman.jp> |
---|
79 | * @license http://www.opensource.org/licenses/bsd-license.php New BSD License |
---|
80 | * @version Release: 1.0.0 |
---|
81 | * @since Class available since Release 0.1 |
---|
82 | */ |
---|
83 | class Net_UserAgent_Mobile_Display |
---|
84 | { |
---|
85 | |
---|
86 | // {{{ properties |
---|
87 | |
---|
88 | /**#@+ |
---|
89 | * @access public |
---|
90 | */ |
---|
91 | |
---|
92 | /**#@-*/ |
---|
93 | |
---|
94 | /**#@+ |
---|
95 | * @access private |
---|
96 | */ |
---|
97 | |
---|
98 | /** |
---|
99 | * width of the display |
---|
100 | * @var integer |
---|
101 | */ |
---|
102 | var $_width; |
---|
103 | |
---|
104 | /** |
---|
105 | * height of the display |
---|
106 | * @var integer |
---|
107 | */ |
---|
108 | var $_height; |
---|
109 | |
---|
110 | /** |
---|
111 | * depth of the display |
---|
112 | * @var integer |
---|
113 | */ |
---|
114 | var $_depth; |
---|
115 | |
---|
116 | /** |
---|
117 | * color capability of the display |
---|
118 | * @var boolean |
---|
119 | */ |
---|
120 | var $_color; |
---|
121 | |
---|
122 | /** |
---|
123 | * width (bytes) of the display |
---|
124 | * @var integer |
---|
125 | */ |
---|
126 | var $_widthBytes; |
---|
127 | |
---|
128 | /** |
---|
129 | * height (bytes) of the display |
---|
130 | * @var integer |
---|
131 | */ |
---|
132 | var $_heightBytes; |
---|
133 | |
---|
134 | /**#@-*/ |
---|
135 | |
---|
136 | /**#@+ |
---|
137 | * @access public |
---|
138 | */ |
---|
139 | |
---|
140 | // }}} |
---|
141 | // {{{ constructor |
---|
142 | |
---|
143 | /** |
---|
144 | * constructor |
---|
145 | * |
---|
146 | * @param array $data display infomation |
---|
147 | */ |
---|
148 | function Net_UserAgent_Mobile_Display($data) |
---|
149 | { |
---|
150 | $this->_width = (integer)@$data['width']; |
---|
151 | $this->_height = (integer)@$data['height']; |
---|
152 | $this->_depth = (integer)@$data['depth']; |
---|
153 | $this->_color = (boolean)@$data['color']; |
---|
154 | |
---|
155 | $this->_widthBytes = (integer)@$data['width_bytes']; |
---|
156 | $this->_heightBytes = (integer)@$data['height_bytes']; |
---|
157 | } |
---|
158 | |
---|
159 | // }}} |
---|
160 | // {{{ calcSize() |
---|
161 | |
---|
162 | /** |
---|
163 | * returns width * height of the display |
---|
164 | * |
---|
165 | * @return integer |
---|
166 | */ |
---|
167 | function calcSize() |
---|
168 | { |
---|
169 | return $this->_width * $this->_height; |
---|
170 | } |
---|
171 | |
---|
172 | // }}} |
---|
173 | // {{{ getSize() |
---|
174 | |
---|
175 | /** |
---|
176 | * returns width with height of the display |
---|
177 | * |
---|
178 | * @return array |
---|
179 | */ |
---|
180 | function getSize() |
---|
181 | { |
---|
182 | return array($this->_width, $this->_height); |
---|
183 | } |
---|
184 | |
---|
185 | // }}} |
---|
186 | // {{{ getWidth() |
---|
187 | |
---|
188 | /** |
---|
189 | * returns width of the display |
---|
190 | * |
---|
191 | * @return integer |
---|
192 | */ |
---|
193 | function getWidth() |
---|
194 | { |
---|
195 | return $this->_width; |
---|
196 | } |
---|
197 | |
---|
198 | // }}} |
---|
199 | // {{{ getHeight() |
---|
200 | |
---|
201 | /** |
---|
202 | * returns height of the display |
---|
203 | * |
---|
204 | * @return integer |
---|
205 | */ |
---|
206 | function getHeight() |
---|
207 | { |
---|
208 | return $this->_height; |
---|
209 | } |
---|
210 | |
---|
211 | // }}} |
---|
212 | // {{{ getDepth() |
---|
213 | |
---|
214 | /** |
---|
215 | * returns depth of the display |
---|
216 | * |
---|
217 | * @return integer |
---|
218 | */ |
---|
219 | function getDepth() |
---|
220 | { |
---|
221 | return $this->_depth; |
---|
222 | } |
---|
223 | |
---|
224 | // }}} |
---|
225 | // {{{ isColor() |
---|
226 | |
---|
227 | /** |
---|
228 | * returns true if the display has color capability |
---|
229 | * |
---|
230 | * @return boolean |
---|
231 | */ |
---|
232 | function isColor() |
---|
233 | { |
---|
234 | return $this->_color; |
---|
235 | } |
---|
236 | |
---|
237 | // }}} |
---|
238 | // {{{ getWidthBytes() |
---|
239 | |
---|
240 | /** |
---|
241 | * returns width (bytes) of the display |
---|
242 | * |
---|
243 | * @return integer |
---|
244 | */ |
---|
245 | function getWidthBytes() |
---|
246 | { |
---|
247 | return $this->_widthBytes; |
---|
248 | } |
---|
249 | |
---|
250 | // }}} |
---|
251 | // {{{ getHeightBytes() |
---|
252 | |
---|
253 | /** |
---|
254 | * returns height (bytes) of the display |
---|
255 | * |
---|
256 | * @return integer |
---|
257 | */ |
---|
258 | function getHeightBytes() |
---|
259 | { |
---|
260 | return $this->_heightBytes; |
---|
261 | } |
---|
262 | |
---|
263 | /**#@-*/ |
---|
264 | |
---|
265 | /**#@+ |
---|
266 | * @access private |
---|
267 | */ |
---|
268 | |
---|
269 | /**#@-*/ |
---|
270 | |
---|
271 | // }}} |
---|
272 | } |
---|
273 | |
---|
274 | // }}} |
---|
275 | |
---|
276 | /* |
---|
277 | * Local Variables: |
---|
278 | * mode: php |
---|
279 | * coding: iso-8859-1 |
---|
280 | * tab-width: 4 |
---|
281 | * c-basic-offset: 4 |
---|
282 | * c-hanging-comment-ender-p: nil |
---|
283 | * indent-tabs-mode: nil |
---|
284 | * End: |
---|
285 | */ |
---|