- Timestamp:
- 2008/03/12 16:43:11 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2/data/module/Net/UserAgent/Mobile/DoCoMo.php
r15532 r17127 14 14 * @package Net_UserAgent_Mobile 15 15 * @author KUBO Atsuhiro <[email protected]> 16 * @copyright 2003-200 7KUBO Atsuhiro <[email protected]>16 * @copyright 2003-2008 KUBO Atsuhiro <[email protected]> 17 17 * @license http://www.php.net/license/3_0.txt PHP License 3.0 18 18 * @version CVS: $Id$ … … 22 22 */ 23 23 24 require_once dirname(__FILE__) . '/Common.php';25 require_once dirname(__FILE__) . '/Display.php';26 require_once dirname(__FILE__) . '/DoCoMoDisplayMap.php';24 require_once 'Net/UserAgent/Mobile/Common.php'; 25 require_once 'Net/UserAgent/Mobile/Display.php'; 26 require_once 'Net/UserAgent/Mobile/DoCoMoDisplayMap.php'; 27 27 28 28 // {{{ Net_UserAgent_Mobile_DoCoMo … … 75 75 * @package Net_UserAgent_Mobile 76 76 * @author KUBO Atsuhiro <[email protected]> 77 * @copyright 2003-200 7KUBO Atsuhiro <[email protected]>77 * @copyright 2003-2008 KUBO Atsuhiro <[email protected]> 78 78 * @license http://www.php.net/license/3_0.txt PHP License 3.0 79 * @version Release: 0.3 0.079 * @version Release: 0.31.0 80 80 * @link http://www.nttdocomo.co.jp/service/imode/make/content/spec/useragent/index.html 81 81 * @see Net_UserAgent_Mobile_Common … … 98 98 99 99 /** 100 * name of the model like 'P502i'101 * @var string102 */103 var $_model = '';104 105 /**106 100 * status of the cache (TC, TB, TD, TJ) 107 101 * @var string 108 102 */ 109 var $_status = '';103 var $_status; 110 104 111 105 /** … … 113 107 * @var integer 114 108 */ 115 var $_bandwidth = null;109 var $_bandwidth; 116 110 117 111 /** … … 119 113 * @var string 120 114 */ 121 var $_serialNumber = null;115 var $_serialNumber; 122 116 123 117 /** … … 131 125 * @var string 132 126 */ 133 var $_cardID = null;127 var $_cardID; 134 128 135 129 /** … … 137 131 * @var string 138 132 */ 139 var $_comment = null;133 var $_comment; 140 134 141 135 /** … … 149 143 * @var string 150 144 */ 151 var $_displayBytes = '';145 var $_displayBytes; 152 146 153 147 /**#@-*/ … … 174 168 175 169 /** 176 * parse HTTP_USER_AGENT string 177 * 170 * Parses HTTP_USER_AGENT string. 171 * 172 * @param string $userAgent User-Agent string 178 173 * @return mixed void, or a PEAR error object on error 179 174 */ 180 function parse() 181 { 182 @list($main, $foma_or_comment) = 183 explode(' ', $this->getUserAgent(), 2); 175 function parse($userAgent) 176 { 177 @list($main, $foma_or_comment) = explode(' ', $userAgent, 2); 184 178 185 179 if ($foma_or_comment … … 220 214 function makeDisplay() 221 215 { 222 $display = Net_UserAgent_Mobile_DoCoMoDisplayMap::get($this-> _model);223 if ( $this->_displayBytes !== '') {216 $display = Net_UserAgent_Mobile_DoCoMoDisplayMap::get($this->getModel()); 217 if (!is_null($this->_displayBytes)) { 224 218 list($widthBytes, $heightBytes) = 225 219 explode('*', $this->_displayBytes); … … 248 242 '504i|251i|^F671iS$|212i|2051|2102V|661i|2701|672i|SO213i|850i' => '4.0', 249 243 'eggy|P751v' => '3.2', 250 '505i|252i|900i|506i|880i|253i|P213i|901i|700i|851i|701i|881i|^SA800i$|600i|^L601i$|^M702i(S|G)$' => '5.0', 251 '902i|702i|851i|882i|^N601i$|^D800iDS$|^P703imyu$' => '6.0', 252 '903i|703i' => '7.0' 244 '505i|252i|900i|506i|880i|253i|P213i|901i|700i|^(SH|P)851i|701i|881i|^SA800i$|600i|^L601i$|^M702i(S|G)$|^L602i$' => '5.0', 245 '902i|702i|851i|882i|^N601i$|^D800iDS$|^P703imyu$|^P704imyu$|^L70[45]i$|^F883i$' => '6.0', 246 '903i|703i|904i|704i|883i|801i|^[FD]705i' => '7.0', 247 '905i|705i' => '7.1' 253 248 ); 254 249 } 255 250 256 251 foreach ($htmlVersionMap as $key => $value) { 257 if (preg_match("/$key/", $this->_ model)) {252 if (preg_match("/$key/", $this->_rawModel)) { 258 253 return $value; 259 254 } … … 293 288 function getSeries() 294 289 { 295 if ($this->isFOMA() && preg_match('/(\d{4})/', $this->_ model)) {290 if ($this->isFOMA() && preg_match('/(\d{4})/', $this->_rawModel)) { 296 291 return 'FOMA'; 297 292 } 298 293 299 if (preg_match('/(\d{3}i)/', $this->_ model, $matches)) {294 if (preg_match('/(\d{3}i)/', $this->_rawModel, $matches)) { 300 295 return $matches[1]; 301 296 } 302 297 303 if ($this->_ model == 'P651ps') {298 if ($this->_rawModel == 'P651ps') { 304 299 return '651'; 305 300 } … … 318 313 function getVendor() 319 314 { 320 if (preg_match('/([A-Z]+)\d/', $this->_ model, $matches)) {315 if (preg_match('/([A-Z]+)\d/', $this->_rawModel, $matches)) { 321 316 return $matches[1]; 322 317 } 318 323 319 return null; 324 }325 326 // }}}327 // {{{ getModel()328 329 /**330 * returns name of the model like 'P502i'331 *332 * @return string333 */334 function getModel()335 {336 return $this->_model;337 320 } 338 321 … … 437 420 $gpsModels = array('F661i', 'F505iGPS'); 438 421 } 439 return in_array($this->_ model, $gpsModels);422 return in_array($this->_rawModel, $gpsModels); 440 423 } 441 424 … … 483 466 function _parseMain($main) 484 467 { 485 @list($this->name, $this->version, $this->_ model, $cache, $rest) =468 @list($this->name, $this->version, $this->_rawModel, $cache, $rest) = 486 469 explode('/', $main, 5); 487 if ($this->_ model === 'SH505i2') {470 if ($this->_rawModel == 'SH505i2') { 488 471 $this->_model = 'SH505i'; 489 472 } 490 473 491 474 if ($cache) { 492 if (!preg_match('/^c(\d+) /', $cache, $matches)) {475 if (!preg_match('/^c(\d+)$/', $cache, $matches)) { 493 476 return $this->noMatch(); 494 477 } … … 530 513 function _parseFOMA($foma) 531 514 { 532 if (!preg_match('/^([^( ]+)/', $foma, $matches)) {515 if (!preg_match('/^([^(\s]+)/', $foma, $matches)) { 533 516 return $this->noMatch(); 534 517 } 535 $this->_model = $matches[1]; 536 if ($matches[1] === 'MST_v_SH2101V') { 518 519 $this->_rawModel = $matches[1]; 520 if ($this->_rawModel == 'MST_v_SH2101V') { 537 521 $this->_model = 'SH2101V'; 538 522 } 539 523 540 if (preg_match('/^[^(]+\((.*?)\)$/', $foma, $matches)) { 524 if (preg_match('/^[^(\s]+\s?\((.*?)\)$/', $foma, $matches)) { 525 if (preg_match('/^compatible/', $matches[1])) { // The user-agent is DoCoMo compatible. 526 $this->_comment = $matches[1]; 527 return; 528 } 529 541 530 $rest = explode(';', $matches[1]); 542 531 foreach ($rest as $value) { 543 if (preg_match('/^c(\d+) /', $value, $matches)) {532 if (preg_match('/^c(\d+)$/', $value, $matches)) { 544 533 $this->_cacheSize = (integer)$matches[1]; 545 534 continue; … … 585 574 * End: 586 575 */ 587 ?>
Note: See TracChangeset
for help on using the changeset viewer.
