2 require_once 'common.php';
\r
4 // {{{ class MPC_EZweb
\r
6 * EZweb
\8aG
\95¶
\8e\9a\95Ï
\8a·
\83x
\81[
\83X
\83N
\83\89\83X
\r
8 * @author ryster <ryster@php-develop.org>
\r
9 * @license http://www.opensource.org/licenses/mit-license.php The MIT License
\r
10 * @link http://php-develop.org/MobilePictogramConverter/
\r
12 class MPC_EZweb extends MPC_Common
\r
15 *
\8aG
\95¶
\8e\9a\92\8a\8fo
\90³
\8bK
\95\
\8c»
\r
19 'WEB' => '/<img\s+(icon|localsrc)="?([0-9]+)"?\s*>/ie',
\r
20 'IMG' => '/(<img src="{PATH}\/(\d{1,3})\.gif" alt="" border="0" \/>)/ie',
\r
24 *
\95¶
\8e\9a\97ñ
\82©
\82çEZweb
\8aG
\95¶
\8e\9a\82ð
\8c\9f\8fo
\82µ
\81A
\8ew
\92è
\82³
\82ê
\82½
\83t
\83H
\81[
\83}
\83b
\83g
\82É
\95Ï
\8a·
\r
25 *
\8aî
\96{
\81E
\8ag
\92£
\81E
\89B
\82µ
\8aG
\95¶
\8e\9a\91Î
\89\9e\r
27 * @param string $to (MPC_TO_FOMA, MPC_TO_EZWEB, MPC_TO_SOFTBANK)
\r
28 * @param integer $option (MPC_TO_OPTION_RAW, MPC_TO_OPTION_WEB, MPC_TO_OPTION_IMG)
\r
31 function Convert($to, $option = MPC_TO_OPTION_RAW)
\r
33 if (isset($toCharset)) {
\r
34 $this->setToCharset($toCharset);
\r
37 $this->setOption($option);
\r
38 $str = $this->getString();
\r
39 $type = $this->getStringType();
\r
40 $fromCharset = $this->getFromCharset();
\r
43 if ($type != MPC_FROM_OPTION_RAW) {
\r
44 if (empty($this->e2icon_table)) {
\r
45 require 'map/e2icon_table.php';
\r
47 $regex = str_replace('{PATH}', preg_quote(rtrim($this->getEZwebImagePath(), '/'), '/'), $this->getRegex($type));
\r
48 $eval = ($fromCharset == MPC_FROM_CHARSET_UTF8) ? 'mb_convert_encoding(pack("H*", dechex(\$this->e2icon_table[$2] - 1792)), "UTF-8", "unicode")' : 'pack("H*", dechex(\$this->e2icon_table[$2]))';
\r
49 $str = preg_replace($regex, $eval, $str);
\r
52 $this->setDS(unpack('C*', $str));
\r
53 $c = count($this->decstring);
\r
54 for ($this->i = 1;$this->i <= $c;$this->i++) {
\r
55 $result = $this->Inspection();
\r
56 if (is_null($result)) {
\r
60 //
\8aG
\95¶
\8e\9a\95Ï
\8a·
\8f\88\97\9d\r
61 if ($this->isPictogram($result)) {
\r
62 $hex = ($fromCharset == MPC_FROM_CHARSET_UTF8) ? strtoupper(dechex(hexdec(bin2hex(mb_convert_encoding(pack('H*', $this->decs2hex($result)), 'unicode', 'utf-8'))) + 1792)) : $this->decs2hex($result);
\r
63 if (empty($this->e2icon_table)) {
\r
64 require 'map/e2icon_table.php';
\r
66 list($iconno) = array_keys($this->e2icon_table, hexdec($hex));
\r
67 $this->setPictogram($this->encoder($iconno));
\r
69 $this->setUnPictogram(pack('H*', $this->decs2hex($result)));
\r
72 //
\82±
\82±
\82Å
\95¶
\8e\9a\83R
\81[
\83h
\82Ì
\95Ï
\8a·
\82Æ
\82©
\82â
\82é
\97\
\92è
\r
73 $buf = $this->getUnPictograms() + $this->getPictograms();
\r
74 $this->ReleaseUnPictograms();
\r
75 $this->ReleasePictograms();
\r
76 if (is_array($buf)) {
\r
78 return implode('', $buf);
\r
85 *
\95¶
\8e\9a\97ñ
\82©
\82çEZweb
\8aG
\95¶
\8e\9a\82ð
\8f\9c\8aO
\82·
\82é
\r
91 $str = $this->getString();
\r
92 $type = $this->getStringType();
\r
93 $charset = $this->getFromCharset();
\r
95 if ($type != MPC_FROM_OPTION_RAW) {
\r
96 if (empty($this->e2icon_table)) {
\r
97 require 'map/e2icon_table.php';
\r
99 $regex = str_replace('{PATH}', preg_quote(rtrim($this->getEZwebImagePath(), '/'), '/'), $this->getRegex($type));
\r
100 return preg_replace($regex, '', $str);
\r
103 $this->setDS(unpack('C*', $str));
\r
104 $c = count($this->decstring);
\r
105 for ($this->i = 1;$this->i <= $c;$this->i++) {
\r
106 $result = $this->Inspection();
\r
107 if (is_null($result)) {
\r
110 if ($this->isPictogram($result) == false) {
\r
111 $this->setUnPictogram(pack('H*', $this->decs2hex($result)));
\r
114 $buf = $this->getUnPictograms();
\r
115 $this->ReleaseUnPictograms();
\r
116 if (is_array($buf)) {
\r
117 return implode('', $buf);
\r
124 *
\95¶
\8e\9a\97ñ
\82ÉEZweb
\8aG
\95¶
\8e\9a\82ª
\89½
\8cÂ
\8aÜ
\82Ü
\82ê
\82Ä
\82¢
\82é
\82©
\83`
\83F
\83b
\83N
\r
131 $str = $this->getString();
\r
132 $type = $this->getStringType();
\r
133 $charset = $this->getFromCharset();
\r
135 if ($type != MPC_FROM_OPTION_RAW) {
\r
136 if (empty($this->e2icon_table)) {
\r
137 require 'map/e2icon_table.php';
\r
139 $regex = str_replace('{PATH}', preg_quote(rtrim($this->getEZwebImagePath(), '/'), '/'), $this->getRegex($type));
\r
140 return preg_replace($regex, '', $str);
\r
143 $this->setDS(unpack('C*', $str));
\r
144 $c = count($this->decstring);
\r
145 for ($this->i = 1;$this->i <= $c;$this->i++) {
\r
146 $result = $this->Inspection();
\r
147 if (is_null($result)) {
\r
150 if ($this->isPictogram($result) == true) {
\r
154 $this->ReleaseUnPictograms();
\r
159 *
\83o
\83C
\83i
\83\8a\82ªEZweb
\8aG
\95¶
\8e\9a\82©
\82Ç
\82¤
\82©
\81A
\83`
\83F
\83b
\83N
\r
161 * @param array $chars
\r
164 function isPictogram($chars)
\r
166 if ($this->getFromCharset() == MPC_FROM_CHARSET_UTF8) {
\r
167 list($char1, $char2, $char3) = $chars;
\r
171 ($char2 == 0xB1 && ($char3 >= 0x80 && $char3 <= 0xBE)) ||
\r
172 ($char2 == 0xB2 && ($char3 >= 0x80 && $char3 <= 0xBF)) ||
\r
173 ($char2 == 0xB3 && ($char3 >= 0x80 && $char3 <= 0xBC)) ||
\r
174 ($char2 == 0xB5 && ($char3 >= 0x80 && $char3 <= 0xBE)) ||
\r
175 ($char2 == 0xB6 && ($char3 >= 0x80 && $char3 <= 0x8D)) ||
\r
176 ($char2 == 0xBD && ($char3 >= 0x80 && $char3 <= 0xBE)) ||
\r
177 ($char2 == 0xBE && ($char3 >= 0x80 && $char3 <= 0xBF)) ||
\r
178 ($char2 == 0xBF && ($char3 >= 0x80 && $char3 <= 0xBC))
\r
183 ($char2 == 0x81 && ($char3 >= 0x80 && $char3 <= 0xBE)) ||
\r
184 ($char2 == 0x82 && ($char3 >= 0x80 && $char3 <= 0xBF)) ||
\r
185 ($char2 == 0x83 && ($char3 >= 0x80 && $char3 <= 0xBC))
\r
194 list($char1, $char2) = $chars;
\r
195 if ((($char1 == 0xF3 || $char1 == 0xF6 || $char1 == 0xF7) && (($char2 >= 0x40 && $char2 <= 0x7E) || ($char2 >= 0x80 && $char2 <= 0xFC))) || ($char1 == 0xF4 && (($char2 >= 0x40 && $char2 <= 0x7E) || ($char2 >= 0x80 && $char2 <= 0x8D)))) {
\r