Revision 15080,
1.2 KB
checked in by nanasess, 17 years ago
(diff) |
svn properties 設定
- svn:mime-type - application/x-httpd-php; charset=UTF-8
- svn:keywords - Id
|
-
Property svn:keywords set to
Id
-
Property svn:mime-type set to
application/x-httpd-php; charset=UTF-8
|
Line | |
---|
1 | <?php
|
---|
2 | /** |
---|
3 | * 表示できない絵文字を置き換える文字列 (Shift JIS) |
---|
4 | * デフォルトは空文字列。 |
---|
5 | */ |
---|
6 | define('MOBILE_EMOJI_SUBSTITUTE', ''); |
---|
7 | |
---|
8 | /** |
---|
9 | * 携帯端末の絵文字を扱うクラス |
---|
10 | */ |
---|
11 | class GC_MobileEmoji { |
---|
12 | /** |
---|
13 | * 絵文字タグを各キャリア用の文字コードに変換する |
---|
14 | * output buffering 用コールバック関数 |
---|
15 | * |
---|
16 | * @param string 入力 |
---|
17 | * @return string 出力 |
---|
18 | */ |
---|
19 | function handler($buffer) { |
---|
20 | $replace_callback = create_function('$matches', 'return GC_MobileEmoji::indexToCode($matches[1]);'); |
---|
21 | return preg_replace_callback('/\[emoji:(e?\d+)\]/', $replace_callback, $buffer); |
---|
22 | } |
---|
23 | |
---|
24 | /** |
---|
25 | * 絵文字番号を絵文字を表す Shift JIS の文字列に変換する。 |
---|
26 | * |
---|
27 | * @param string $index 絵文字番号 |
---|
28 | * @return string 絵文字を表す Shift JIS の文字列を返す。 |
---|
29 | */ |
---|
30 | function indexToCode($index) { |
---|
31 | $carrier = GC_MobileUserAgent::getCarrier(); |
---|
32 | if ($carrier === false) { |
---|
33 | return MOBILE_EMOJI_SUBSTITUTE; |
---|
34 | } |
---|
35 | |
---|
36 | static $arrMap; |
---|
37 | if (!isset($arrMap)) { |
---|
38 | $arrMap = @include_once(dirname(__FILE__) . "/../include/mobile_emoji_map_$carrier.inc"); |
---|
39 | } |
---|
40 | |
---|
41 | return isset($arrMap[$index]) ? $arrMap[$index] : MOBILE_EMOJI_SUBSTITUTE; |
---|
42 | } |
---|
43 | } |
---|
44 | ?>
|
---|
Note: See
TracBrowser
for help on using the repository browser.