source: branches/dev/data/class/GC_MobileEmoji.php @ 11460

Revision 11460, 1.2 KB checked in by inoue, 17 years ago (diff)

モバイル版EC-CUBE

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