1 | <?php |
---|
2 | /* vim: set expandtab tabstop=4 shiftwidth=4: */ |
---|
3 | // +----------------------------------------------------------------------+ |
---|
4 | // | PHP version 4 | |
---|
5 | // +----------------------------------------------------------------------+ |
---|
6 | // | Copyright (c) 1997-2004 The PHP Group | |
---|
7 | // +----------------------------------------------------------------------+ |
---|
8 | // | This source file is subject to version 3.0 of the PHP license, | |
---|
9 | // | that is bundled with this package in the file LICENSE, and is | |
---|
10 | // | available through the world-wide-web at the following url: | |
---|
11 | // | http://www.php.net/license/3_0.txt. | |
---|
12 | // | If you did not receive a copy of the PHP license and are unable to | |
---|
13 | // | obtain it through the world-wide-web, please send a note to | |
---|
14 | // | license@php.net so we can mail you a copy immediately. | |
---|
15 | // +----------------------------------------------------------------------+ |
---|
16 | // | Authors: KUBO Atsuhiro <iteman@users.sourceforge.net> | |
---|
17 | // +----------------------------------------------------------------------+ |
---|
18 | // |
---|
19 | // $Id: Display.php,v 1.9 2006/11/07 09:25:14 kuboa Exp $ |
---|
20 | // |
---|
21 | |
---|
22 | /** |
---|
23 | * Display information for Net_UserAgent_Mobile |
---|
24 | * |
---|
25 | * Net_UserAgent_Mobile_Display is a class for display information on |
---|
26 | * {@link Net_UserAgent_Mobile}. Handy for image resizing or dispatching. |
---|
27 | * |
---|
28 | * SYNOPSIS: |
---|
29 | * <code> |
---|
30 | * require_once('Net/UserAgent/Mobile.php'); |
---|
31 | * |
---|
32 | * $agent = &Net_UserAgent_Mobile::factory(); |
---|
33 | * $display = $agent->getDisplay(); |
---|
34 | * |
---|
35 | * $width = $display->getWidth(); |
---|
36 | * $height = $display->getHeight(); |
---|
37 | * list($width, $height) = $display->getSize(); |
---|
38 | * |
---|
39 | * if ($display->isColor()) { |
---|
40 | * $depth = $display->getDepth(); |
---|
41 | * } |
---|
42 | * |
---|
43 | * // only available in DoCoMo 505i |
---|
44 | * $width_bytes = $display->getWidthBytes(); |
---|
45 | * $height_bytes = $display->getHeightBytes(); |
---|
46 | * </code> |
---|
47 | * |
---|
48 | * USING EXTERNAL MAP FILE: |
---|
49 | * If the environment variable DOCOMO_MAP exists, the specified XML data will |
---|
50 | * be used for DoCoMo display information. |
---|
51 | * |
---|
52 | * ex) Please add the following code. |
---|
53 | * $_SERVER['DOCOMO_MAP'] = '/path/to/DoCoMoMap.xml'; |
---|
54 | * |
---|
55 | * @package Net_UserAgent_Mobile |
---|
56 | * @category Networking |
---|
57 | * @author KUBO Atsuhiro <iteman@users.sourceforge.net> |
---|
58 | * @access public |
---|
59 | * @version $Revision: 1.9 $ |
---|
60 | */ |
---|
61 | class Net_UserAgent_Mobile_Display |
---|
62 | { |
---|
63 | |
---|
64 | // {{{ properties |
---|
65 | |
---|
66 | /**#@+ |
---|
67 | * @access private |
---|
68 | */ |
---|
69 | |
---|
70 | /** |
---|
71 | * width of the display |
---|
72 | * @var integer |
---|
73 | */ |
---|
74 | var $_width; |
---|
75 | |
---|
76 | /** |
---|
77 | * height of the display |
---|
78 | * @var integer |
---|
79 | */ |
---|
80 | var $_height; |
---|
81 | |
---|
82 | /** |
---|
83 | * depth of the display |
---|
84 | * @var integer |
---|
85 | */ |
---|
86 | var $_depth; |
---|
87 | |
---|
88 | /** |
---|
89 | * color capability of the display |
---|
90 | * @var boolean |
---|
91 | */ |
---|
92 | var $_color; |
---|
93 | |
---|
94 | /** |
---|
95 | * width (bytes) of the display |
---|
96 | * @var integer |
---|
97 | */ |
---|
98 | var $_widthBytes; |
---|
99 | |
---|
100 | /** |
---|
101 | * height (bytes) of the display |
---|
102 | * @var integer |
---|
103 | */ |
---|
104 | var $_heightBytes; |
---|
105 | |
---|
106 | /**#@-*/ |
---|
107 | |
---|
108 | // }}} |
---|
109 | // {{{ constructor |
---|
110 | |
---|
111 | /** |
---|
112 | * constructor |
---|
113 | * |
---|
114 | * @param array $data display infomation |
---|
115 | */ |
---|
116 | function Net_UserAgent_Mobile_Display($data) |
---|
117 | { |
---|
118 | $this->_width = (integer)@$data['width']; |
---|
119 | $this->_height = (integer)@$data['height']; |
---|
120 | $this->_depth = (integer)@$data['depth']; |
---|
121 | $this->_color = (boolean)@$data['color']; |
---|
122 | |
---|
123 | $this->_widthBytes = (integer)@$data['width_bytes']; |
---|
124 | $this->_heightBytes = (integer)@$data['height_bytes']; |
---|
125 | } |
---|
126 | |
---|
127 | /**#@+ |
---|
128 | * @access public |
---|
129 | */ |
---|
130 | |
---|
131 | // }}} |
---|
132 | // {{{ calcSize() |
---|
133 | |
---|
134 | /** |
---|
135 | * returns width * height of the display |
---|
136 | * |
---|
137 | * @return integer |
---|
138 | */ |
---|
139 | function calcSize() |
---|
140 | { |
---|
141 | return $this->_width * $this->_height; |
---|
142 | } |
---|
143 | |
---|
144 | // }}} |
---|
145 | // {{{ getSize() |
---|
146 | |
---|
147 | /** |
---|
148 | * returns width with height of the display |
---|
149 | * |
---|
150 | * @return array |
---|
151 | */ |
---|
152 | function getSize() |
---|
153 | { |
---|
154 | return array($this->_width, $this->_height); |
---|
155 | } |
---|
156 | |
---|
157 | // }}} |
---|
158 | // {{{ getWidth() |
---|
159 | |
---|
160 | /** |
---|
161 | * returns width of the display |
---|
162 | * |
---|
163 | * @return integer |
---|
164 | */ |
---|
165 | function getWidth() |
---|
166 | { |
---|
167 | return $this->_width; |
---|
168 | } |
---|
169 | |
---|
170 | // }}} |
---|
171 | // {{{ getHeight() |
---|
172 | |
---|
173 | /** |
---|
174 | * returns height of the display |
---|
175 | * |
---|
176 | * @return integer |
---|
177 | */ |
---|
178 | function getHeight() |
---|
179 | { |
---|
180 | return $this->_height; |
---|
181 | } |
---|
182 | |
---|
183 | // }}} |
---|
184 | // {{{ getDepth() |
---|
185 | |
---|
186 | /** |
---|
187 | * returns depth of the display |
---|
188 | * |
---|
189 | * @return integer |
---|
190 | */ |
---|
191 | function getDepth() |
---|
192 | { |
---|
193 | return $this->_depth; |
---|
194 | } |
---|
195 | |
---|
196 | // }}} |
---|
197 | // {{{ isColor() |
---|
198 | |
---|
199 | /** |
---|
200 | * returns true if the display has color capability |
---|
201 | * |
---|
202 | * @return boolean |
---|
203 | */ |
---|
204 | function isColor() |
---|
205 | { |
---|
206 | return $this->_color; |
---|
207 | } |
---|
208 | |
---|
209 | // }}} |
---|
210 | // {{{ getWidthBytes() |
---|
211 | |
---|
212 | /** |
---|
213 | * returns width (bytes) of the display |
---|
214 | * |
---|
215 | * @return integer |
---|
216 | */ |
---|
217 | function getWidthBytes() |
---|
218 | { |
---|
219 | return $this->_widthBytes; |
---|
220 | } |
---|
221 | |
---|
222 | // }}} |
---|
223 | // {{{ getHeightBytes() |
---|
224 | |
---|
225 | /** |
---|
226 | * returns height (bytes) of the display |
---|
227 | * |
---|
228 | * @return integer |
---|
229 | */ |
---|
230 | function getHeightBytes() |
---|
231 | { |
---|
232 | return $this->_heightBytes; |
---|
233 | } |
---|
234 | |
---|
235 | /**#@-*/ |
---|
236 | } |
---|
237 | |
---|
238 | /* |
---|
239 | * Local Variables: |
---|
240 | * mode: php |
---|
241 | * coding: iso-8859-1 |
---|
242 | * tab-width: 4 |
---|
243 | * c-basic-offset: 4 |
---|
244 | * c-hanging-comment-ender-p: nil |
---|
245 | * indent-tabs-mode: nil |
---|
246 | * End: |
---|
247 | */ |
---|
248 | ?> |
---|