/webapp/modules/ktai/Mobile/DoCoMoDisplayMap.php

https://github.com/usagi-project/mynets1 · PHP · 826 lines · 740 code · 21 blank · 65 comment · 9 complexity · c85a6c815d37c5501f4ee2f397ad1622 MD5 · raw file

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. /**
  4. * PHP versions 4 and 5
  5. *
  6. * LICENSE: This source file is subject to version 3.0 of the PHP license
  7. * that is available through the world-wide-web at the following URI:
  8. * http://www.php.net/license/3_0.txt. If you did not receive a copy of
  9. * the PHP License and are unable to obtain it through the web, please
  10. * send a note to license@php.net so we can mail you a copy immediately.
  11. *
  12. * @category Networking
  13. * @package Net_UserAgent_Mobile
  14. * @author KUBO Atsuhiro <iteman@users.sourceforge.net>
  15. * @copyright 2003-2006 KUBO Atsuhiro <iteman@users.sourceforge.net>
  16. * @license http://www.php.net/license/3_0.txt PHP License 3.0
  17. * @version CVS: $Id: DoCoMoDisplayMap.php,v 1.29 2006/11/07 09:25:14 kuboa Exp $
  18. * @link http://www.nttdocomo.co.jp/service/imode/make/content/spec/screen_area/index.html
  19. * @see Net_UserAgent_Mobile_Display
  20. * @since File available since Release 0.1
  21. */
  22. // {{{ Net_UserAgent_Mobile_DoCoMoDisplayMap
  23. /**
  24. * Display information mapping for DoCoMo.
  25. *
  26. * @category Networking
  27. * @package Net_UserAgent_Mobile
  28. * @author KUBO Atsuhiro <iteman@users.sourceforge.net>
  29. * @copyright 2003-2006 KUBO Atsuhiro <iteman@users.sourceforge.net>
  30. * @license http://www.php.net/license/3_0.txt PHP License 3.0
  31. * @version Release: @package_version@
  32. * @link http://www.nttdocomo.co.jp/service/imode/make/content/spec/screen_area/index.html
  33. * @see Net_UserAgent_Mobile_Display
  34. * @since Class available since Release 0.1
  35. */
  36. class Net_UserAgent_Mobile_DoCoMoDisplayMap
  37. {
  38. // {{{ properties
  39. /**#@+
  40. * @access public
  41. */
  42. /**#@-*/
  43. /**#@+
  44. * @access private
  45. */
  46. /**#@-*/
  47. /**#@+
  48. * @access public
  49. */
  50. // }}}
  51. // {{{ get()
  52. /**
  53. * Returns the display information of the model.
  54. *
  55. * @param string $model the name of the model
  56. * @return array
  57. * @static
  58. */
  59. function get($model)
  60. {
  61. static $displayMap;
  62. if (!isset($displayMap)) {
  63. if (isset($_SERVER['DOCOMO_MAP'])) {
  64. // using the specified XML data
  65. while (true) {
  66. if (!function_exists('xml_parser_create')
  67. || !is_readable($_SERVER['DOCOMO_MAP'])
  68. ) {
  69. break;
  70. }
  71. $xml = file_get_contents($_SERVER['DOCOMO_MAP']);
  72. $parser = xml_parser_create();
  73. if ($parser === false) {
  74. break;
  75. }
  76. xml_parse_into_struct($parser, $xml, $values, $indexes);
  77. if (!xml_parser_free($parser)) {
  78. break;
  79. }
  80. if (isset($indexes['OPT'])) {
  81. unset($indexes['OPT']);
  82. }
  83. foreach ($indexes as $modelName => $modelIndexes) {
  84. $displayMap[$modelName] = array();
  85. foreach ($values[ $modelIndexes[0] ]['attributes'] as $attributeName => $attributeValue) {
  86. $displayMap[$modelName][ strtolower($attributeName) ] = $attributeValue;
  87. }
  88. }
  89. break;
  90. }
  91. }
  92. if (!isset($displayMap)) {
  93. $displayMap = array(
  94. // i-mode compliant HTML 1.0
  95. 'D501I' => array(
  96. 'width' => 96,
  97. 'height' => 72,
  98. 'depth' => 2,
  99. 'color' => 0
  100. ),
  101. 'F501I' => array(
  102. 'width' => 112,
  103. 'height' => 84,
  104. 'depth' => 2,
  105. 'color' => 0
  106. ),
  107. 'N501I' => array(
  108. 'width' => 118,
  109. 'height' => 128,
  110. 'depth' => 2,
  111. 'color' => 0
  112. ),
  113. 'P501I' => array(
  114. 'width' => 96,
  115. 'height' => 120,
  116. 'depth' => 2,
  117. 'color' => 0
  118. ),
  119. // i-mode compliant HTML 2.0
  120. 'D502I' => array(
  121. 'width' => 96,
  122. 'height' => 90,
  123. 'depth' => 256,
  124. 'color' => 1
  125. ),
  126. 'F502I' => array(
  127. 'width' => 96,
  128. 'height' => 91,
  129. 'depth' => 256,
  130. 'color' => 1
  131. ),
  132. 'N502I' => array(
  133. 'width' => 118,
  134. 'height' => 128,
  135. 'depth' => 4,
  136. 'color' => 0
  137. ),
  138. 'P502I' => array(
  139. 'width' => 96,
  140. 'height' => 117,
  141. 'depth' => 4,
  142. 'color' => 0
  143. ),
  144. 'NM502I' => array(
  145. 'width' => 111,
  146. 'height' => 106,
  147. 'depth' => 2,
  148. 'color' => 0
  149. ),
  150. 'SO502I' => array(
  151. 'width' => 120,
  152. 'height' => 120,
  153. 'depth' => 4,
  154. 'color' => 0
  155. ),
  156. 'F502IT' => array(
  157. 'width' => 96,
  158. 'height' => 91,
  159. 'depth' => 256,
  160. 'color' => 1
  161. ),
  162. 'N502IT' => array(
  163. 'width' => 118,
  164. 'height' => 128,
  165. 'depth' => 256,
  166. 'color' => 1
  167. ),
  168. 'SO502IWM' => array(
  169. 'width' => 120,
  170. 'height' => 113,
  171. 'depth' => 256,
  172. 'color' => 1
  173. ),
  174. 'SH821I' => array(
  175. 'width' => 96,
  176. 'height' => 78,
  177. 'depth' => 256,
  178. 'color' => 1
  179. ),
  180. 'N821I' => array(
  181. 'width' => 118,
  182. 'height' => 128,
  183. 'depth' => 4,
  184. 'color' => 0
  185. ),
  186. 'P821I' => array(
  187. 'width' => 118,
  188. 'height' => 128,
  189. 'depth' => 4,
  190. 'color' => 0
  191. ),
  192. 'D209I' => array(
  193. 'width' => 96,
  194. 'height' => 90,
  195. 'depth' => 256,
  196. 'color' => 1
  197. ),
  198. 'ER209I' => array(
  199. 'width' => 120,
  200. 'height' => 72,
  201. 'depth' => 2,
  202. 'color' => 0
  203. ),
  204. 'F209I' => array(
  205. 'width' => 96,
  206. 'height' => 91,
  207. 'depth' => 256,
  208. 'color' => 1
  209. ),
  210. 'KO209I' => array(
  211. 'width' => 96,
  212. 'height' => 96,
  213. 'depth' => 256,
  214. 'color' => 1
  215. ),
  216. 'N209I' => array(
  217. 'width' => 108,
  218. 'height' => 82,
  219. 'depth' => 4,
  220. 'color' => 0
  221. ),
  222. 'P209I' => array(
  223. 'width' => 96,
  224. 'height' => 87,
  225. 'depth' => 4,
  226. 'color' => 0
  227. ),
  228. 'P209IS' => array(
  229. 'width' => 96,
  230. 'height' => 87,
  231. 'depth' => 256,
  232. 'color' => 1
  233. ),
  234. 'R209I' => array(
  235. 'width' => 96,
  236. 'height' => 72,
  237. 'depth' => 4,
  238. 'color' => 0
  239. ),
  240. 'P651PS' => array(
  241. 'width' => 96,
  242. 'height' => 87,
  243. 'depth' => 4,
  244. 'color' => 0
  245. ),
  246. 'R691I' => array(
  247. 'width' => 96,
  248. 'height' => 72,
  249. 'depth' => 4,
  250. 'color' => 0
  251. ),
  252. 'F671I' => array(
  253. 'width' => 120,
  254. 'height' => 126,
  255. 'depth' => 256,
  256. 'color' => 1
  257. ),
  258. 'F210I' => array(
  259. 'width' => 96,
  260. 'height' => 113,
  261. 'depth' => 256,
  262. 'color' => 1
  263. ),
  264. 'N210I' => array(
  265. 'width' => 118,
  266. 'height' => 113,
  267. 'depth' => 256,
  268. 'color' => 1
  269. ),
  270. 'P210I' => array(
  271. 'width' => 96,
  272. 'height' => 91,
  273. 'depth' => 256,
  274. 'color' => 1
  275. ),
  276. 'KO210I' => array(
  277. 'width' => 96,
  278. 'height' => 96,
  279. 'depth' => 256,
  280. 'color' => 1
  281. ),
  282. // i-mode compliant HTML 3.0
  283. 'F503I' => array(
  284. 'width' => 120,
  285. 'height' => 130,
  286. 'depth' => 256,
  287. 'color' => 1
  288. ),
  289. 'F503IS' => array(
  290. 'width' => 120,
  291. 'height' => 130,
  292. 'depth' => 4096,
  293. 'color' => 1
  294. ),
  295. 'P503I' => array(
  296. 'width' => 120,
  297. 'height' => 130,
  298. 'depth' => 256,
  299. 'color' => 1
  300. ),
  301. 'P503IS' => array(
  302. 'width' => 120,
  303. 'height' => 130,
  304. 'depth' => 256,
  305. 'color' => 1
  306. ),
  307. 'N503I' => array(
  308. 'width' => 118,
  309. 'height' => 128,
  310. 'depth' => 4096,
  311. 'color' => 1
  312. ),
  313. 'N503IS' => array(
  314. 'width' => 118,
  315. 'height' => 128,
  316. 'depth' => 4096,
  317. 'color' => 1
  318. ),
  319. 'SO503I' => array(
  320. 'width' => 120,
  321. 'height' => 113,
  322. 'depth' => 65536,
  323. 'color' => 1
  324. ),
  325. 'SO503IS' => array(
  326. 'width' => 120,
  327. 'height' => 113,
  328. 'depth' => 65536,
  329. 'color' => 1
  330. ),
  331. 'D503I' => array(
  332. 'width' => 132,
  333. 'height' => 126,
  334. 'depth' => 4096,
  335. 'color' => 1
  336. ),
  337. 'D503IS' => array(
  338. 'width' => 132,
  339. 'height' => 126,
  340. 'depth' => 4096,
  341. 'color' => 1
  342. ),
  343. 'D210I' => array(
  344. 'width' => 96,
  345. 'height' => 91,
  346. 'depth' => 256,
  347. 'color' => 1
  348. ),
  349. 'SO210I' => array(
  350. 'width' => 120,
  351. 'height' => 113,
  352. 'depth' => 256,
  353. 'color' => 1
  354. ),
  355. 'F211I' => array(
  356. 'width' => 96,
  357. 'height' => 113,
  358. 'depth' => 4096,
  359. 'color' => 1
  360. ),
  361. 'D211I' => array(
  362. 'width' => 100,
  363. 'height' => 91,
  364. 'depth' => 4096,
  365. 'color' => 1
  366. ),
  367. 'N211I' => array(
  368. 'width' => 118,
  369. 'height' => 128,
  370. 'depth' => 4096,
  371. 'color' => 1
  372. ),
  373. 'N211IS' => array(
  374. 'width' => 118,
  375. 'height' => 128,
  376. 'depth' => 4096,
  377. 'color' => 1
  378. ),
  379. 'P211I' => array(
  380. 'width' => 120,
  381. 'height' => 130,
  382. 'depth' => 65536,
  383. 'color' => 1
  384. ),
  385. 'P211IS' => array(
  386. 'width' => 120,
  387. 'height' => 130,
  388. 'depth' => 65536,
  389. 'color' => 1
  390. ),
  391. 'SO211I' => array(
  392. 'width' => 120,
  393. 'height' => 112,
  394. 'depth' => 4096,
  395. 'color' => 1
  396. ),
  397. 'R211I' => array(
  398. 'width' => 96,
  399. 'height' => 98,
  400. 'depth' => 4096,
  401. 'color' => 1
  402. ),
  403. 'SH251I' => array(
  404. 'width' => 120,
  405. 'height' => 130,
  406. 'depth' => 65536,
  407. 'color' => 1
  408. ),
  409. 'SH251IS' => array(
  410. 'width' => 176,
  411. 'height' => 187,
  412. 'depth' => 65536,
  413. 'color' => 1
  414. ),
  415. 'R692I' => array(
  416. 'width' => 96,
  417. 'height' => 98,
  418. 'depth' => 4096,
  419. 'color' => 1
  420. ),
  421. // i-mode compliant HTML 3.0
  422. // (FOMA 2001/2002/2101V)
  423. 'N2001' => array(
  424. 'width' => 118,
  425. 'height' => 128,
  426. 'depth' => 4096,
  427. 'color' => 1
  428. ),
  429. 'N2002' => array(
  430. 'width' => 118,
  431. 'height' => 128,
  432. 'depth' => 65536,
  433. 'color' => 1
  434. ),
  435. 'P2002' => array(
  436. 'width' => 118,
  437. 'height' => 128,
  438. 'depth' => 65536,
  439. 'color' => 1
  440. ),
  441. 'D2101V' => array(
  442. 'width' => 120,
  443. 'height' => 130,
  444. 'depth' => 262144,
  445. 'color' => 1
  446. ),
  447. 'P2101V' => array(
  448. 'width' => 163,
  449. 'height' => 182,
  450. 'depth' => 262144,
  451. 'color' => 1
  452. ),
  453. 'SH2101V' => array(
  454. 'width' => 800,
  455. 'height' => 600,
  456. 'depth' => 65536,
  457. 'color' => 1
  458. ),
  459. 'T2101V' => array(
  460. 'width' => 176,
  461. 'height' => 144,
  462. 'depth' => 262144,
  463. 'color' => 1
  464. ),
  465. // i-mode compliant HTML 4.0
  466. 'D504I' => array(
  467. 'width' => 132,
  468. 'height' => 144,
  469. 'depth' => 262144,
  470. 'color' => 1
  471. ),
  472. 'F504I' => array(
  473. 'width' => 132,
  474. 'height' => 136,
  475. 'depth' => 65536,
  476. 'color' => 1
  477. ),
  478. 'F504IS' => array(
  479. 'width' => 132,
  480. 'height' => 136,
  481. 'depth' => 65536,
  482. 'color' => 1
  483. ),
  484. 'N504I' => array(
  485. 'width' => 160,
  486. 'height' => 180,
  487. 'depth' => 65536,
  488. 'color' => 1
  489. ),
  490. 'N504IS' => array(
  491. 'width' => 160,
  492. 'height' => 180,
  493. 'depth' => 65536,
  494. 'color' => 1
  495. ),
  496. 'SO504I' => array(
  497. 'width' => 120,
  498. 'height' => 112,
  499. 'depth' => 65536,
  500. 'color' => 1
  501. ),
  502. 'P504I' => array(
  503. 'width' => 132,
  504. 'height' => 144,
  505. 'depth' => 65536,
  506. 'color' => 1
  507. ),
  508. 'P504IS' => array(
  509. 'width' => 132,
  510. 'height' => 144,
  511. 'depth' => 65536,
  512. 'color' => 1
  513. ),
  514. 'D251I' => array(
  515. 'width' => 132,
  516. 'height' => 144,
  517. 'depth' => 262144,
  518. 'color' => 1
  519. ),
  520. 'D251IS' => array(
  521. 'width' => 132,
  522. 'height' => 144,
  523. 'depth' => 262144,
  524. 'color' => 1
  525. ),
  526. 'F251I' => array(
  527. 'width' => 132,
  528. 'height' => 140,
  529. 'depth' => 65536,
  530. 'color' => 1
  531. ),
  532. 'N251I' => array(
  533. 'width' => 132,
  534. 'height' => 140,
  535. 'depth' => 65536,
  536. 'color' => 1
  537. ),
  538. 'N251IS' => array(
  539. 'width' => 132,
  540. 'height' => 140,
  541. 'depth' => 65536,
  542. 'color' => 1
  543. ),
  544. 'P251IS' => array(
  545. 'width' => 132,
  546. 'height' => 144,
  547. 'depth' => 65536,
  548. 'color' => 1
  549. ),
  550. 'F671IS' => array(
  551. 'width' => 160,
  552. 'height' => 120,
  553. 'depth' => 65536,
  554. 'color' => 1
  555. ),
  556. 'F212I' => array(
  557. 'width' => 132,
  558. 'height' => 136,
  559. 'depth' => 65536,
  560. 'color' => 1
  561. ),
  562. 'SO212I' => array(
  563. 'width' => 120,
  564. 'height' => 112,
  565. 'depth' => 65536,
  566. 'color' => 1
  567. ),
  568. 'F661I' => array(
  569. 'width' => 132,
  570. 'height' => 136,
  571. 'depth' => 65536,
  572. 'color' => 1
  573. ),
  574. 'F672I' => array(
  575. 'width' => 160,
  576. 'height' => 120,
  577. 'depth' => 65536,
  578. 'color' => 1
  579. ),
  580. 'SO213I' => array(
  581. 'width' => 120,
  582. 'height' => 112,
  583. 'depth' => 65536,
  584. 'color' => 1
  585. ),
  586. 'SO213IS' => array(
  587. 'width' => 120,
  588. 'height' => 112,
  589. 'depth' => 65536,
  590. 'color' => 1
  591. ),
  592. 'SO213IWR' => array(
  593. 'width' => 120,
  594. 'height' => 112,
  595. 'depth' => 65536,
  596. 'color' => 1
  597. ),
  598. // i-mode compliant HTML 4.0
  599. // (FOMA 2051/2102V/2701 etc.)
  600. 'F2051' => array(
  601. 'width' => 176,
  602. 'height' => 182,
  603. 'depth' => 65536,
  604. 'color' => 1
  605. ),
  606. 'N2051' => array(
  607. 'width' => 176,
  608. 'height' => 198,
  609. 'depth' => 65536,
  610. 'color' => 1
  611. ),
  612. 'P2102V' => array(
  613. 'width' => 176,
  614. 'height' => 198,
  615. 'depth' => 262144,
  616. 'color' => 1
  617. ),
  618. 'P2102V' => array(
  619. 'width' => 176,
  620. 'height' => 198,
  621. 'depth' => 262144,
  622. 'color' => 1
  623. ),
  624. 'F2102V' => array(
  625. 'width' => 176,
  626. 'height' => 182,
  627. 'depth' => 65536,
  628. 'color' => 1
  629. ),
  630. 'N2102V' => array(
  631. 'width' => 176,
  632. 'height' => 198,
  633. 'depth' => 65536,
  634. 'color' => 1
  635. ),
  636. 'N2701' => array(
  637. 'width' => 176,
  638. 'height' => 198,
  639. 'depth' => 65536,
  640. 'color' => 1
  641. ),
  642. 'NM850IG' => array(
  643. 'width' => 176,
  644. 'height' => 144,
  645. 'depth' => 65536,
  646. 'color' => 1
  647. ),
  648. // i-mode compliant HTML 5.0 (505i etc.)
  649. 'D505I' => array(
  650. 'width' => 240,
  651. 'height' => 270,
  652. 'depth' => 262144,
  653. 'color' => 1
  654. ),
  655. 'SO505I' => array(
  656. 'width' => 256,
  657. 'height' => 240,
  658. 'depth' => 262144,
  659. 'color' => 1
  660. ),
  661. 'SH505I' => array(
  662. 'width' => 240,
  663. 'height' => 252,
  664. 'depth' => 262144,
  665. 'color' => 1
  666. ),
  667. 'N505I' => array(
  668. 'width' => 240,
  669. 'height' => 270,
  670. 'depth' => 262144,
  671. 'color' => 1
  672. ),
  673. 'F505I' => array(
  674. 'width' => 240,
  675. 'height' => 268,
  676. 'depth' => 262144,
  677. 'color' => 1
  678. ),
  679. 'P505I' => array(
  680. 'width' => 240,
  681. 'height' => 266,
  682. 'depth' => 65536,
  683. 'color' => 1
  684. ),
  685. 'D505IS' => array(
  686. 'width' => 240,
  687. 'height' => 270,
  688. 'depth' => 262144,
  689. 'color' => 1
  690. ),
  691. 'P505IS' => array(
  692. 'width' => 240,
  693. 'height' => 266,
  694. 'depth' => 65536,
  695. 'color' => 1
  696. ),
  697. 'N505IS' => array(
  698. 'width' => 240,
  699. 'height' => 270,
  700. 'depth' => 262144,
  701. 'color' => 1
  702. ),
  703. 'SO505IS' => array(
  704. 'width' => 240,
  705. 'height' => 256,
  706. 'depth' => 262144,
  707. 'color' => 1
  708. ),
  709. 'SH505IS' => array(
  710. 'width' => 240,
  711. 'height' => 252,
  712. 'depth' => 262144,
  713. 'color' => 1
  714. ),
  715. 'F505IGPS' => array(
  716. 'width' => 240,
  717. 'height' => 268,
  718. 'depth' => 262144,
  719. 'color' => 1
  720. ),
  721. 'D252I' => array(
  722. 'width' => 176,
  723. 'height' => 198,
  724. 'depth' => 262144,
  725. 'color' => 1
  726. ),
  727. 'SH252I' => array(
  728. 'width' => 240,
  729. 'height' => 252,
  730. 'depth' => 262144,
  731. 'color' => 1
  732. ),
  733. 'P252I' => array(
  734. 'width' => 132,
  735. 'height' => 144,
  736. 'depth' => 65536,
  737. 'color' => 1
  738. ),
  739. 'N252I' => array(
  740. 'width' => 132,
  741. 'height' => 140,
  742. 'depth' => 65536,
  743. 'color' => 1
  744. ),
  745. 'P252IS' => array(
  746. 'width' => 132,
  747. 'height' => 144,
  748. 'depth' => 65536,
  749. 'color' => 1
  750. ),
  751. 'D506I' => array(
  752. 'width' => 240,
  753. 'height' => 270,
  754. 'depth' => 262144,
  755. 'color' => 1
  756. ),
  757. 'F506I' => array(
  758. 'width' => 240,
  759. 'height' => 268,
  760. 'depth' => 262144,
  761. 'color' => 1
  762. ),
  763. 'N506I' => array(
  764. 'width' => 240,
  765. 'height' => 295,
  766. 'depth' => 262144,
  767. 'color' => 1
  768. ),
  769. 'P506IC' => array(
  770. 'width' => 240,
  771. 'height' => 266,
  772. 'depth' => 65536,
  773. 'color' => 1
  774. ),
  775. 'SH506IC' => array(
  776. 'width' => 240,
  777. 'height' => 252,
  778. 'depth' => 262144,
  779. 'color' => 1
  780. ),
  781. 'SO506IC' => array(
  782. 'width' => 240,
  783. 'height' => 256,
  784. 'depth' => 262144,
  785. 'color' => 1
  786. ),
  787. 'N506IS' => array(
  788. 'width' => 240,
  789. 'height' => 295,
  790. 'depth' => 262144,
  791. 'color' => 1
  792. ),
  793. 'SO506I' => array(
  794. 'width' => 240,
  795. 'height' => 256,
  796. 'depth' => 262144,
  797. 'color' => 1
  798. ),
  799. 'SO506IS' => array(
  800. 'width' => 240,
  801. 'height' => 256,
  802. 'depth' => 262144,
  803. 'color' => 1
  804. ),
  805. 'N506ISII' => array(