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